CodeSampleX

Sample

rrweb-cssom 0.7.1: CSSImportRule

Verified sample for npm rrweb-cssom 0.7.1: CSSImportRule. The contract ran on node 22 · linux debian/x64 · docker and passed: CSSImportRule initializes with…

sha256:2b4b680e0d15509c83159f977b3b2bed6dfe71b7d162dfef350e2096a7db9fdb

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 npm

Verification-run environments

Environment Contract Stages Run
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-04

Case

HOW
Goal
verify rrweb-cssom.CSSImportRule in pkg:npm/rrweb-cssom@0.7.1
Packages
Symbols
  • rrweb-cssom.CSSImportRule
Created
2026-09-04T02:27:16Z

Contract

  1. CSSImportRule initializes with type 3 (IMPORT_RULE), empty href, and MediaList and CSSStyleSheet instances
  2. CSSImportRule serializes href and optional media query to cssText format
  3. CSSImportRule parses url, quotes, and media condition when assigning cssText
  4. parse extracts CSSImportRule from CSS @import rules with href, media, and parent style sheet references

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

Download the source artifact (tar.gz)

Source

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify rrweb-cssom.CSSImportRule in pkg:npm/rrweb-cssom@0.7.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/rrweb-cssom@0.7.1
Demonstrate these symbols/APIs:
  - rrweb-cssom.CSSImportRule

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:979f382d16cd9fc4b07dc3c591cd67bc371385c19f1dde1aae6091e0439f6477","contract":["CSSImportRule initializes with type 3 (IMPORT_RULE), empty href, and MediaList and CSSStyleSheet instances","CSSImportRule serializes href and optional media query to cssText format","CSSImportRule parses url, quotes, and media condition when assigning cssText","parse extracts CSSImportRule from CSS @import rules with href, media, and parent style sheet references"],"goal":"verify rrweb-cssom.CSSImportRule in pkg:npm/rrweb-cssom@0.7.1","kind":"HOW","packages":["pkg:npm/rrweb-cssom@0.7.1"],"schemaVersion":1,"symbols":["rrweb-cssom.CSSImportRule"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/rrweb-cssom@0.7.1"],"schemaVersion":1,"subject":"pkg:npm/rrweb-cssom@0.7.1","symbols":["rrweb-cssom.CSSImportRule"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-rrweb-cssom-cssimportrule",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-rrweb-cssom-cssimportrule",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "rrweb-cssom": "0.7.1"
      }
    },
    "node_modules/rrweb-cssom": {
      "version": "0.7.1",
      "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.7.1.tgz",
      "integrity": "sha512-TrEMa7JGdVm0UThDJSx7ddw5nVm3UJS9o9CCIZ72B1vSyEZoziDqBYP3XIoi/12lKrJR8rE3jeFHMok2F/Mnsg==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-rrweb-cssom-cssimportrule",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for rrweb-cssom CSSImportRule",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "rrweb-cssom": "0.7.1"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify rrweb-cssom.CSSImportRule in pkg:npm/rrweb-cssom@0.7.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/rrweb-cssom@0.7.1"
  ],
  "symbols": [
    "rrweb-cssom.CSSImportRule"
  ]
}
src/index.js
'use strict';

const {
  parse,
  CSSImportRule,
  CSSRule,
  CSSStyleSheet,
  MediaList,
} = require('rrweb-cssom');

function parseImportRules(cssText) {
  const stylesheet = parse(cssText);
  return Array.from(stylesheet.cssRules).filter(
    (rule) => rule instanceof CSSImportRule
  );
}

function createImportRule(href, mediaQuery) {
  const rule = new CSSImportRule();
  if (href !== undefined) {
    rule.href = href;
  }
  if (mediaQuery) {
    rule.media.mediaText = mediaQuery;
  }
  return rule;
}

function setImportRuleCssText(rule, cssText) {
  rule.cssText = cssText;
  return {
    href: rule.href,
    mediaText: rule.media.mediaText,
  };
}

module.exports = {
  parse,
  CSSImportRule,
  CSSRule,
  CSSStyleSheet,
  MediaList,
  parseImportRules,
  createImportRule,
  setImportRuleCssText,
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  CSSImportRule,
  CSSRule,
  CSSStyleSheet,
  MediaList,
  parseImportRules,
  createImportRule,
  setImportRuleCssText,
} = require('../src/index.js');

// 1. CSSImportRule initializes with type 3 (IMPORT_RULE), empty href, and MediaList and CSSStyleSheet instances
{
  const rule = createImportRule();
  assert(rule instanceof CSSImportRule, 'rule must be instance of CSSImportRule');
  assert(rule instanceof CSSRule, 'rule must be instance of CSSRule');
  assert.strictEqual(rule.type, 3, 'rule.type must be numeric 3');
  assert.strictEqual(rule.type, CSSRule.IMPORT_RULE, 'rule.type must equal CSSRule.IMPORT_RULE');
  assert.strictEqual(rule.href, '', 'initial href must be empty string');
  assert(rule.media instanceof MediaList, 'rule.media must be instance of MediaList');
  assert(rule.styleSheet instanceof CSSStyleSheet, 'rule.styleSheet must be instance of CSSStyleSheet');
  assert.strictEqual(rule.parentRule, null, 'parentRule must be null initially');
  assert.strictEqual(rule.parentStyleSheet, null, 'parentStyleSheet must be null initially');
}

// 2. CSSImportRule serializes href and optional media query to cssText format
{
  const ruleWithoutMedia = createImportRule('reset.css');
  assert.strictEqual(ruleWithoutMedia.cssText, '@import url(reset.css);', 'cssText without media query must match');

  const ruleWithMedia = createImportRule('responsive.css', 'screen and (max-width: 768px)');
  assert.strictEqual(
    ruleWithMedia.cssText,
    '@import url(responsive.css) screen and (max-width: 768px);',
    'cssText with media query must match'
  );
}

// 3. CSSImportRule parses url, quotes, and media condition when assigning cssText
{
  const rule1 = createImportRule();
  const parsed1 = setImportRuleCssText(rule1, "@import url('theme.css') print, projection;");
  assert.strictEqual(parsed1.href, 'theme.css', 'href extracted from url() with quotes');
  assert.strictEqual(parsed1.mediaText, 'print, projection', 'media query extracted');

  const rule2 = createImportRule();
  const parsed2 = setImportRuleCssText(rule2, '@import "mobile.css";');
  assert.strictEqual(parsed2.href, 'mobile.css', 'href extracted from double quotes');
  assert.strictEqual(parsed2.mediaText, '', 'media query is empty when omitted');

  const rule3 = createImportRule();
  const parsed3 = setImportRuleCssText(rule3, '@import url(bundle.css);');
  assert.strictEqual(parsed3.href, 'bundle.css', 'href extracted from unquoted url()');
  assert.strictEqual(parsed3.mediaText, '', 'media query is empty when omitted');
}

// 4. parse extracts CSSImportRule from CSS @import rules with href, media, and parent style sheet references
{
  const css = '@import url("base.css") all;\n@import "print.css" print;\nbody { margin: 0; }';
  const importRules = parseImportRules(css);
  assert.strictEqual(importRules.length, 2, 'Should parse exactly two CSSImportRules');

  const firstRule = importRules[0];
  assert(firstRule instanceof CSSImportRule, 'first rule must be CSSImportRule');
  assert.strictEqual(firstRule.type, 3, 'first rule type must be 3');
  assert.strictEqual(firstRule.href, 'base.css', 'first rule href must match');
  assert.strictEqual(firstRule.media.mediaText, 'all', 'first rule mediaText must match');
  assert(firstRule.parentStyleSheet !== null, 'first rule parentStyleSheet must be set');
  assert.strictEqual(firstRule.styleSheet.parentStyleSheet, firstRule.parentStyleSheet, 'nested styleSheet parent must link back');

  const secondRule = importRules[1];
  assert(secondRule instanceof CSSImportRule, 'second rule must be CSSImportRule');
  assert.strictEqual(secondRule.type, 3, 'second rule type must be 3');
  assert.strictEqual(secondRule.href, 'print.css', 'second rule href must match');
  assert.strictEqual(secondRule.media.mediaText, 'print', 'second rule mediaText must match');
}

console.log('Contract tests passed successfully.');

Origin Seeder

anonymous