Exemplo
rrweb-cssom 0.7.1: CSSStyleDeclaration
Amostra verificada para npm rrweb-cssom 0.7.1: CSSStyleDeclaration. O contrato rodou em node 22 · linux debian/x64 · docker e passou.
sha256:6670ab2beb2af77c1439da179e2e5a9b244f50f43c29c386c8e8002bb38aca09
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-01 |
Caso
HOW- Objetivo
- verify CSSStyleDeclaration in pkg:npm/rrweb-cssom@0.7.1
- Pacotes
- Símbolos
-
- CSSStyleDeclaration
- Criado
- 2026-09-01T22:03:58Z
Contrato
- CSSStyleDeclaration parses cssText declarations into indexed properties, values, and priority
- CSSStyleDeclaration.getPropertyValue retrieves property values and returns empty string for missing properties
- CSSStyleDeclaration.getPropertyPriority returns important for important declarations and empty string otherwise
- CSSStyleDeclaration.setProperty adds or updates CSS properties with optional priority
- CSSStyleDeclaration.removeProperty removes existing property, returns old value, and updates declaration length
- CSSStyleDeclaration.cssText getter serializes declaration list to CSS format
- CSSStyleDeclaration is attached as style property on parsed CSSStyleRule instances
- Helper functions createStyleDeclaration and parseStyleRule provide convenient access to style declarations
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
Código-fonte
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 CSSStyleDeclaration 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:
- CSSStyleDeclaration
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.
{"case":{"caseId":"case:sha256:014903b4aaa1bb055753e1025fba9adeb6dca0bc14745e599cae221be24c8983","contract":["CSSStyleDeclaration parses cssText declarations into indexed properties, values, and priority","CSSStyleDeclaration.getPropertyValue retrieves property values and returns empty string for missing properties","CSSStyleDeclaration.getPropertyPriority returns important for important declarations and empty string otherwise","CSSStyleDeclaration.setProperty adds or updates CSS properties with optional priority","CSSStyleDeclaration.removeProperty removes existing property, returns old value, and updates declaration length","CSSStyleDeclaration.cssText getter serializes declaration list to CSS format","CSSStyleDeclaration is attached as style property on parsed CSSStyleRule instances","Helper functions createStyleDeclaration and parseStyleRule provide convenient access to style declarations"],"goal":"verify CSSStyleDeclaration in pkg:npm/rrweb-cssom@0.7.1","kind":"HOW","packages":["pkg:npm/rrweb-cssom@0.7.1"],"schemaVersion":1,"symbols":["CSSStyleDeclaration"]},"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":["CSSStyleDeclaration"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-3399760597",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-3399760597",
"version": "1.0.0",
"license": "ISC",
"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"
}
}
}
{
"name": "sample-rrweb-cssom",
"version": "1.0.0",
"type": "module",
"private": true,
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"rrweb-cssom": "0.7.1"
}
}
{
"schemaVersion": 1,
"goal": "verify CSSStyleDeclaration in pkg:npm/rrweb-cssom@0.7.1",
"kind": "HOW",
"packages": [
"pkg:npm/rrweb-cssom@0.7.1"
],
"symbols": [
"CSSStyleDeclaration"
]
}
import { CSSStyleDeclaration, parse } from 'rrweb-cssom';
/**
* Creates a CSSStyleDeclaration instance optionally initialized with cssText.
* @param {string} [cssText=''] Optional CSS declaration string.
* @returns {CSSStyleDeclaration} Initialized style declaration instance.
*/
export function createStyleDeclaration(cssText = '') {
const style = new CSSStyleDeclaration();
if (cssText) {
style.cssText = cssText;
}
return style;
}
/**
* Parses a CSS text rule and returns the CSSStyleDeclaration of the first rule.
* @param {string} css CSS style rule string.
* @returns {CSSStyleDeclaration|null} CSSStyleDeclaration of the rule, or null if no rule exists.
*/
export function parseStyleRule(css) {
const sheet = parse(css);
if (sheet && sheet.cssRules && sheet.cssRules.length > 0) {
return sheet.cssRules[0].style;
}
return null;
}
export { CSSStyleDeclaration, parse };
export default CSSStyleDeclaration;
import assert from 'node:assert/strict';
import { CSSStyleDeclaration, parse } from 'rrweb-cssom';
import { createStyleDeclaration, parseStyleRule } from '../src/index.mjs';
// 1. CSSStyleDeclaration parses cssText declarations into indexed properties, values, and priority
{
const style = new CSSStyleDeclaration();
style.cssText = 'color: red; background-color: blue !important; font-size: 14px;';
assert.equal(style.length, 3);
assert.equal(style[0], 'color');
assert.equal(style[1], 'background-color');
assert.equal(style[2], 'font-size');
assert.equal(style.getPropertyValue('color'), 'red');
assert.equal(style.getPropertyValue('background-color'), 'blue');
assert.equal(style.getPropertyPriority('background-color'), 'important');
assert.equal(style.getPropertyPriority('color'), '');
}
// 2. CSSStyleDeclaration.getPropertyValue retrieves property values and returns empty string for missing properties
{
const style = new CSSStyleDeclaration();
style.cssText = 'display: flex; margin-top: 10px;';
assert.equal(style.getPropertyValue('display'), 'flex');
assert.equal(style.getPropertyValue('margin-top'), '10px');
assert.equal(style.getPropertyValue('non-existent-prop'), '');
}
// 3. CSSStyleDeclaration.getPropertyPriority returns important for important declarations and empty string otherwise
{
const style = new CSSStyleDeclaration();
style.cssText = 'color: red !important; width: 100px;';
assert.equal(style.getPropertyPriority('color'), 'important');
assert.equal(style.getPropertyPriority('width'), '');
}
// 4. CSSStyleDeclaration.setProperty adds or updates CSS properties with optional priority
{
const style = new CSSStyleDeclaration();
style.setProperty('margin', '10px');
assert.equal(style.getPropertyValue('margin'), '10px');
assert.equal(style.length, 1);
assert.equal(style[0], 'margin');
style.setProperty('opacity', '0.5', 'important');
assert.equal(style.getPropertyValue('opacity'), '0.5');
assert.equal(style.getPropertyPriority('opacity'), 'important');
assert.equal(style.length, 2);
style.setProperty('margin', '20px');
assert.equal(style.getPropertyValue('margin'), '20px');
}
// 5. CSSStyleDeclaration.removeProperty removes existing property, returns old value, and updates declaration length
{
const style = new CSSStyleDeclaration();
style.cssText = 'color: red; padding: 5px;';
assert.equal(style.length, 2);
const removed = style.removeProperty('color');
assert.equal(removed, 'red');
assert.equal(style.getPropertyValue('color'), '');
assert.equal(style.length, 1);
assert.equal(style[0], 'padding');
const missing = style.removeProperty('non-existent');
assert.equal(missing, '');
assert.equal(style.length, 1);
}
// 6. CSSStyleDeclaration.cssText getter serializes declaration list to CSS format
{
const style = new CSSStyleDeclaration();
style.setProperty('color', 'red');
style.setProperty('font-weight', 'bold', 'important');
assert.equal(style.cssText, 'color: red; font-weight: bold !important;');
}
// 7. CSSStyleDeclaration is attached as style property on parsed CSSStyleRule instances
{
const stylesheet = parse('.card { color: #fff; padding: 8px !important; }');
assert.equal(stylesheet.cssRules.length, 1);
const rule = stylesheet.cssRules[0];
assert.equal(rule.style instanceof CSSStyleDeclaration, true);
assert.equal(rule.style.getPropertyValue('color'), '#fff');
assert.equal(rule.style.getPropertyPriority('padding'), 'important');
assert.equal(rule.style.length, 2);
}
// 8. Helper functions createStyleDeclaration and parseStyleRule provide convenient access to style declarations
{
const emptyStyle = createStyleDeclaration();
assert.equal(emptyStyle instanceof CSSStyleDeclaration, true);
assert.equal(emptyStyle.length, 0);
const initialStyle = createStyleDeclaration('border: 1px solid black;');
assert.equal(initialStyle.getPropertyValue('border'), '1px solid black');
const parsedStyle = parseStyleRule('h1 { font-size: 24px; }');
assert.equal(parsedStyle instanceof CSSStyleDeclaration, true);
assert.equal(parsedStyle.getPropertyValue('font-size'), '24px');
const emptyRule = parseStyleRule('');
assert.equal(emptyRule, null);
}
console.log('Contract tests passed successfully.');
Seeder de origem
anônimo