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

@ginexys/layout-engine

v0.1.0

Published

Deterministic, browser-native document layout reconstruction: PDF geometry to the GxDoc structure, plus document forensics.

Readme

Ginexys Layout Engine

Deterministic layout reconstruction for messy documents. It reads PDF geometry (text operators, vector paths, the struct tree) and rebuilds columns, tables, figures, math and reading order into GxDoc, a typed intermediate structure that apps edit and export. It runs in the browser or a worker: no upload, no required model weights, same input gives the same output.

This is the engine behind Document Workbench. The Workbench app consumes it as a package and contains no extraction code.

Install

npm install @ginexys/layout-engine pdfjs-dist@4

pdfjs-dist 4.x is a peer dependency. onnxruntime-web is an optional peer, needed only for the layout-model worker.

Quick start

Tell the engine where the pdf.js worker is served from, once, at startup. With Vite:

import pdfWorkerUrl from 'pdfjs-dist/build/pdf.worker.mjs?url';
import { setPdfWorkerSrc } from '@ginexys/layout-engine/extraction/util/assetBase';

setPdfWorkerSrc(pdfWorkerUrl);

Reconstruct a PDF in the geometry worker. Results stream back one page at a time:

import GeometryWorker from '@ginexys/layout-engine/workers/geometryWorker?worker';
import { pdfWorkerSrc } from '@ginexys/layout-engine/extraction/util/assetBase';

const worker = new GeometryWorker();
worker.onmessage = ({ data }) => {
  if (data.type === 'page') console.log(data.page, data.regions, data.html);
  if (data.type === 'complete') console.log(`${data.pageCount} pages`);
  if (data.type === 'error') console.error(data.error);
};
const bytes = new Uint8Array(await file.arrayBuffer());
worker.postMessage({ type: 'process', bytes, pdfWorkerSrc: pdfWorkerSrc() });

Work with the result as GxDoc:

import { validateDoc } from '@ginexys/layout-engine/gxdoc';
import { htmlToGxDoc } from '@ginexys/layout-engine/ir/htmlToGxDoc';
import { gxDocToHtml } from '@ginexys/layout-engine/ir/gxDocToHtml';

With other bundlers, create the worker from @ginexys/layout-engine/workers/geometryWorker the way that bundler handles module workers.

From a CDN

The modules are plain ES modules, but they import pdfjs-dist, katex and @canwork/boxwood by name, so load them through a CDN that rewrites those imports, such as esm.sh:

<script type="module">
  import { validateDoc } from 'https://esm.sh/@ginexys/[email protected]/gxdoc';
  import { gxDocToHtml } from 'https://esm.sh/@ginexys/[email protected]/ir/gxDocToHtml';
</script>

Browsers only start workers from the page's own origin, so for the geometry worker, install the package or serve its files yourself.

What is in here

| Path | Role | |---|---| | src/extraction/vector/ | Path reconciler, column detection, table reconstruction, page assembly, math | | src/extraction/forensics/ | Document forensics: altered regions, duplicate pages, OCR confidence, reading order | | src/extraction/util/ | Engine utilities (asset base, image store, math render, OCR grid and scale) | | src/ir/ | GxDoc, the output contract, plus importers and renderers | | src/workers/ | Geometry and layout workers |

Boundary rule

The engine never imports from an app. Apps import the engine only through the entry points in package.json exports:

import { validateDoc } from '@ginexys/layout-engine/gxdoc';
import { gxDocToHtml } from '@ginexys/layout-engine/ir/gxDocToHtml';
import { analyseDocument } from '@ginexys/layout-engine/forensics';

GxDoc is versioned (gx-doc/1). A breaking schema change is a major version.

Benchmark

Vector layer, scored on the 4,073 born-digital pages of the DocLayNet v1.2 test split (CDLA-Permissive-1.0, human-labelled, never used for tuning): 0 crashes, identical output on repeat runs, about 22 ms per page (median). Scanned and image-backed pages (926) are reported separately once the DocForensics path is complete. Accuracy, the method and the known gaps it exposed are in bench/README.md.

Development

npm install
npm test

License

AGPL-3.0-or-later, with a commercial license available from Canwork LLC ([email protected]). Code from v0.1.0-mit and earlier remains MIT. See NOTICE. Outside contributions require a contributor license agreement so the dual license stays possible.