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

@lenout/render

v0.7.0

Published

Lenout Renderer (night) — DPI-aware tile-based WebGPU renderer with WebNN refinement and WebGL2/Canvas fallbacks.

Readme

Lenout Renderer (night)

Lenout Renderer is the project-owned, tile-based 2D renderer. It selects native WebGPU first and falls back to WebGL 2 or Canvas 2D when the browser cannot create a WebGPU device.

Runtime tiers

| Tier | Drawing backend | Neural backend | Notes | |---|---|---|---| | webgpu+webnn | Native WebGPU | WebNN | WebNN context and graph are available | | webgpu | Native WebGPU | CPU fallback | WebGPU drawing without WebNN | | webgl2 | WebGL 2 | None | Compatibility renderer | | cpu | Canvas 2D | None | Last-resort renderer |

webgpu+webnn does not mean the browser guarantees a physical NPU. The current WebNN standard accepts an accelerated-execution preference, but the user agent chooses between available CPU, GPU, and dedicated ML accelerators. capabilities.neuralBackend reports webnn-accelerated, webnn, cpu, or none; the legacy npuInference field remains false because WebNN does not expose the selected physical device.

WebGPU path

The Tier 3 renderer includes:

  • persistent tile accumulation with dirty-tile clearing;
  • premultiplied-alpha geometry, image, text, and brush pipelines;
  • correct line-width geometry and tessellated vector fills/strokes;
  • procedural anti-aliased brush edges using WGSL derivatives;
  • instanced brush dabs with growable GPU buffers;
  • cached image and text textures with bounded text-cache eviction;
  • automatic fallback when WebGPU adapter/device creation fails.

The renderer is currently 2D. supports3D is deliberately false until a real 3D command and depth pipeline exist.

DPI-aware rendering

Lenout keeps world coordinates in logical CSS pixels and sizes the canvas backing store independently. The default pixelRatio: "auto" follows window.devicePixelRatio, capped at 2 to control GPU memory. WebGPU, WebGL 2, Canvas 2D, text bitmaps, tile scissors, and brush rendering all use the same display metrics.

Call renderer.resize(width, height) with logical dimensions when the layout changes. The render pipeline also performs this synchronization from the logical viewport passed to render(). A DPI or size change resets the retained tile surface so the next frame is redrawn at the new resolution.

WebNN brush refinement

Long brush strokes are prepared asynchronously so pointer rendering is never blocked. A fixed WebNN matrix graph smooths adjacent position, size, and opacity samples in batches. Short strokes use the equivalent CPU operation because dispatch overhead would be larger than the work. Pending pointer updates are coalesced so only the newest node command is refined.

WebNN requires a secure context. For embedded deployments, allow the webnn Permissions Policy for the application origin. If context creation, graph compilation, or dispatch fails, refinement falls back to the matching CPU implementation.

Usage

import { createLenoutRenderer } from "@lenout/render";
import { createRenderPipeline } from "@lenout/render/pipeline";

const canvas = document.querySelector("canvas")!;
const renderer = await createLenoutRenderer(canvas, {
  neuralBrushSmoothing: 0.18,
  powerPreference: "high-performance",
  pixelRatio: "auto",
  maxPixelRatio: 2,
});
renderer.initialize();

const pipeline = createRenderPipeline(sceneGraph, tileManager, renderer);
const bounds = canvas.parentElement!.getBoundingClientRect();
pipeline.render(bounds.width, bounds.height);

console.log(renderer.display);
// { logicalWidth, logicalHeight, physicalWidth, physicalHeight, pixelRatio, revision }

renderer.destroy();

Set neuralBrushSmoothing to 0 to preserve raw dab values, or use a value from 0 to 1 to blend toward neural/CPU-refined values.

Set pixelRatio to a fixed number for deterministic screenshots or exports. maxPixelRatio accepts values up to 4; higher ratios increase backing-store memory quadratically. Set manageCssSize: false only when the host application owns the canvas CSS size completely.

Source layout

src/
├── dpi.ts                      logical/physical display sizing
├── renderer.ts                 capability detection and tier factory
├── pipeline.ts                 dirty-tile orchestration and async preparation
├── neural/
│   ├── webnnTypes.ts           narrow WebNN runtime types
│   └── webnnBrushRefiner.ts    accelerated graph and CPU fallback
└── tier3/
    ├── webgpuRenderer.ts       frame and tile orchestration
    ├── webgpuResources.ts      pipelines, buffers, and texture cache
    ├── webgpuGeometry.ts       command tessellation
    ├── webgpuShaders.ts        WGSL programs
    └── textBitmapCache.ts      bounded text raster cache

The package has no runtime dependencies. TypeScript, Vite, Vitest, and WebGPU declarations are development-only dependencies.