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

@preply/ds-visual-coverage-core

v14.3.1

Published

Readme

@preply/ds-visual-coverage-core

All the DS visual coverage utilities the platform-specific packages share.

Also, it includes the simplest implementation of the countPixels function, the core of the DS visual coverage, that transforms the log containing the UI tree data into a bitmap.

See @preply/ds-visual-coverage-web and @preply/ds-visual-coverage-rn for platform-specific tools.

tl;dr:

Provide all the utils to count the Design System visual coverage.

As a reminder, the general idea is to

  1. Collect DOM elements coordinates and size (not part of this package).
  2. Convert the coordinates and size into a virtual representation of the DOM tree, and count the DS component pixels with a bitmap (see countPixels).
  3. Count the pixels and calculate a coverage % (not part of this package).
  4. All the above can be done "per page" or the page can be split into different coverage containers (think of micro frontends where the same page can contain areas that belong to different teams).

Fictional but visual example

A page made up of the following elements:

  1. A non-DS header
  2. A non-DS container that contains
    1. A DS heading
    2. Two DS buttons
  3. A DS box

Could be represented by the following list of children data

[
  {
    "rect": [
      0, // <-- top
      0, // <-- left
      20, // <-- width
      16 // <-- height
    ],
    "dsComponentName": null,
    "weight": 1 // <-- component weight, used for the border size in the bitmap
  }
  [
  { "rect": [0, 0, 20, 3], "dsComponentName": "Heading", "weight": 1 },
  { "rect": [8, 0, 20, 4], "dsComponentName": "Text", "weight": 1 },
  { "rect": [16, 3, 8, 4], "dsComponentName": "null", "weight": 1 }
  { "rect": [16, 12, 8, 4], "dsComponentName": "Button", "weight": 2, "weight": 1 },
]
]

is transformed by countPixels to a bitmap like the following

[
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  -,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,
  0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,
  0,-,1,-,-,-,-,-,-,-,-,-,-,-,-,-,-,1,-,0,
  0,-,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-,0,
  0,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,0,
  0,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,0,
  0,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,0,
  0,-,-,-,-,-,-,2,2,2,2,2,-,2,2,2,2,2,-,0,
  0,-,-,-,-,-,-,2,-,-,-,2,-,2,-,-,-,2,-,0,
  0,-,-,-,-,-,-,2,2,2,2,2,-,2,2,2,2,2,-,0,
  0,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  3,3,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,3,3,
  3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  1,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,1,
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  0,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,0,
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
  2,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,2,
  2,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,2,
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
  0,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,0,
  0,-,-,-,0,0,0,0,0,0,0,-,3,3,3,3,3,3,3,3,
  0,-,-,-,0,-,-,-,-,-,0,-,3,3,3,3,3,3,3,3,
  0,-,-,-,0,-,-,-,-,-,0,-,3,3,-,-,-,-,3,3,
  0,-,-,-,0,-,-,-,-,-,0,-,3,3,3,3,3,3,3,3,
  0,-,-,-,0,0,0,0,0,0,0,-,3,3,3,3,3,3,3,3,
  0,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
]

which, for the sake of understanding it, can be visualized this way

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩
🟩⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️🟩
🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩
🟥⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️🟥
🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩
🟩⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️🟩
🟩⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️🟩
🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩
🟥⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️🟥
🟥⬛️⬛️⬛️🟥🟥🟥🟥🟥🟥🟥⬛️🟩🟩🟩🟩🟩🟩🟩🟩
🟥⬛️⬛️⬛️🟥⬛️⬛️⬛️⬛️⬛️🟥⬛️🟩🟩🟩🟩🟩🟩🟩🟩
🟥⬛️⬛️⬛️🟥⬛️⬛️⬛️⬛️⬛️🟥⬛️🟩🟩⬛️⬛️⬛️⬛️🟩🟩
🟥⬛️⬛️⬛️🟥⬛️⬛️⬛️⬛️⬛️🟥⬛️🟩🟩🟩🟩🟩🟩🟩🟩
🟥⬛️⬛️⬛️🟥🟥🟥🟥🟥🟥🟥⬛️🟩🟩🟩🟩🟩🟩🟩🟩
🟥⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️🟥
🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥

CSS Stacking contexts

The Visual Coverage algorithm cares of the DOM elements' overlapping when converting the DOM structure to a bitmap, but replicating the CSS stacking context is hard. When implementing the Visual Coverage perspective, we chose a tradeoffs: from a Visual Coverage perspective, the subsequent DOM elements are closer to the user.

We explain in the platform-specific libraries, how to deal with floating elements (like dialogs).