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

@responsivejs/contract

v1.0.0-alpha.0

Published

The design-contract DSL of r$ — declarative, serializable responsive/layout/a11y/aesthetic expectations for authoring, CI regression, and AI agents.

Downloads

105

Readme

@responsivejs/contract

The design-contract DSL of r$: declare what a responsive layout must guarantee — then verify it in CI, record baselines, and hand the same contract to AI agents.

npm install --save-dev @responsivejs/contract

This package is the spec: types, the 27-constraint registry, the fluent builder, a zero-dependency validator with did-you-mean errors, and the published JSON Schema. Execution (verifyContract) lives in @responsivejs/design.

A contract

{
    "version": 1,
    "name": "home",
    "viewport": { "widths": [320, 768, 1280] },
    "selectors": { "sidebar": ".app-sidebar" },
    "designSystem": { "profile": "material-design-3" },
    "rules": [
        { "id": "no-bleed", "assert": "noOverflow", "description": "nothing may bleed out of the viewport" },
        { "id": "sidebar-mobile", "assert": "hidden", "args": { "selector": "$sidebar" }, "when": { "max": 767 } },
        { "id": "sidebar-desktop", "assert": "visible", "args": { "selector": "$sidebar" }, "when": { "min": 768 } }
    ],
    "score": [{ "min": 0.6 }],
    "baselines": [{ "selector": "$sidebar", "prop": "width", "tolerance": { "px": 4 } }]
}

Or the builder, which validates on build() and round-trips through JSON:

import { contract } from '@responsivejs/contract';

const home = contract('home')
    .viewport({ widths: [320, 768, 1280] })
    .select('sidebar', '.app-sidebar')
    .assert('noOverflow', undefined, { id: 'no-bleed' })
    .below(768)
    .assert('hidden', { selector: '$sidebar' }, { id: 'sidebar-mobile' })
    .from(768)
    .assert('visible', { selector: '$sidebar' }, { id: 'sidebar-desktop' })
    .build();

Verify in CI (5 lines)

import { test, expect } from '@playwright/test';
import { verifyContract, formatContractConsole } from '@responsivejs/design';
import home from './contracts/home.contract.json' with { type: 'json' };

test('home keeps its design contract', async ({ page }) => {
    await page.goto('/');
    const report = await verifyContract(home, page); // sweep derived from the contract itself
    expect(report.pass, formatContractConsole(report)).toBe(true);
});

The contract is self-contained: selectors and widths for the sweep come from the contract (including bp±1 samples for breakpointSafe rules).

The agent loop

Every violation carries its ruleId → the agent looks the rule up in the contract, reads the authored description (the intent) and the violation's fix suggestion, patches, re-verifies. recordBaseline(contract, store) fills baselines[].curve from real measurements — record once, assert forever.

Versioning

version: 1 + published schema ($id on raw.githubusercontent.com). Additive optional fields don't bump the version; changed semantics do. The loader rejects unknown fields and newer versions with an upgrade hint.

Deferred by design (v1): YAML, a11y/axe block, container scope, baseline interpolation, contract composition/extends, DTCG export.

Documentation

Full API reference: docs/api/contract.md · guide: CI regression

Licensed under MPL-2.0.