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

@corralimited/snapdiff-stabilize

v0.1.0

Published

Capture-stability primitives for SnapDiff: pre-navigation init scripts, anti-animation CSS, deterministic clock, and post-load image stabilization. Used by the SnapDiff backend and the @corralimited/snapdiff-playwright reporter; usable standalone with any

Downloads

82

Readme

@corralimited/snapdiff-stabilize

Capture-stability primitives shared by SnapDiff and the @corralimited/snapdiff-playwright reporter. Usable standalone with any Playwright project that wants Percy/Chromatic-grade capture stability.

What it does

  • Anti-animation CSS — cancels CSS animations and transitions, hides the text caret, hides scrollbars. Eliminates frame-timing flake and OS-specific scrollbar widths.
  • Deterministic clock — pins Date.now(), new Date(), and Math.random() to fixed values. Eliminates "X minutes ago" and randomized-content false positives.
  • Image-set stability poll — waits for <img> count and complete state to stabilize across two consecutive ticks, with a configurable total budget. Far more reliable on slow networks and progressive UIs than a fixed per-image timeout.
  • Lazy-load triggering — step-scrolls through full-page captures to wake IntersectionObserver-based lazy loaders along the way, not just at the final position.
  • Hover and focus reset — moves the pointer off the page and blurs document.activeElement so :hover and :focus styles drop before the screenshot.

Usage

Two paths depending on whether the caller owns the Playwright BrowserContext.

A. You own the context (recommended — server-side captures)

import { chromium } from 'playwright';
import { buildInitScript, stabilizePostLoad } from '@corralimited/snapdiff-stabilize';

const browser = await chromium.launch();
const context = await browser.newContext({ deviceScaleFactor: 2 });

// Pre-navigation: install the CSS injector and clock freeze before any
// author script runs. Animations can't fire, timestamps render frozen.
await context.addInitScript({ content: buildInitScript({ freezeClock: true }) });

const page = await context.newPage();
await page.goto('https://example.com', { waitUntil: 'load' });

// Post-load: settle fonts, lazy images, and reset hover/focus. CSS and
// clock effects are already applied via the init script — leave the post-
// load CSS/clock flags off.
await stabilizePostLoad(page, { fullPage: false });

const png = await page.screenshot({ type: 'png' });

B. You don't own the context (client-side captures inside a test)

When the user's Playwright test owns the context, addInitScript is unavailable to you. Apply the effects post-load on a best-effort basis:

import { test } from '@playwright/test';
import { stabilizePostLoad } from '@corralimited/snapdiff-stabilize';

test('account page', async ({ page }) => {
  await page.goto('/account');

  await stabilizePostLoad(page, {
    fullPage: false,
    injectStabilizeCss: true,  // CSS not in place yet — inject now
    freezeClock: true,         // optional; off by default
  });

  await page.screenshot({ path: 'account.png' });
});

The trade-off: animations that already fired during page load can't be undone. Anything still in flight is neutralized before the screenshot.

API

Constants

  • FIXED_TIMEDate.UTC(2024, 0, 1, 0, 0, 0). Bumping this is a baseline-breaking change.
  • RANDOM_SEED1337. LCG seed for the deterministic Math.random().
  • LAZY_IMAGE_STABILIZE_MS5000. Total budget for the image stability poll.
  • PER_IMAGE_TIMEOUT_MS3000. Per-image fallback inside the poll.
  • STABILIZE_CSS — the raw CSS string injected by the stabilizer.

Script builders

Return strings suitable for BrowserContext.addInitScript({ content }) or page.evaluate.

  • buildStabilizeCssScript() — CSS-injection script with MutationObserver fallback for pre-documentElement execution.
  • buildClockFreezeScript({ fixedTime?, randomSeed? })Date / Math.random shim.
  • buildInitScript({ freezeClock?, fixedTime?, randomSeed? }) — combined script for addInitScript.

Post-load helper

  • stabilizePostLoad(page, opts) — runs the post-load settle sequence.
    • fullPage?: boolean — step-scroll for lazy-load triggering.
    • injectStabilizeCss?: boolean — inject CSS post-load (when no init script ran).
    • freezeClock?: boolean — apply the clock shim post-load.
    • lazyImageStabilizeMs?: number — override total poll budget.
    • perImageTimeoutMs?: number — override per-image fallback.

License

MIT — see LICENSE.