サンプル
postcss-value-parser 4.2.0: ValueParser
検証済みサンプル — npm postcss-value-parser 4.2.0: ValueParser. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: postcss-value-parser package.json…
sha256:eb5ba6d579605ec7eb7fcc98cd4fb1f9577046eede927f794be06c08dd2f5d08
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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 |
ケース
HOW- ゴール
- verify ValueParser in pkg:npm/postcss-value-parser@4.2.0
- シンボル
-
- ValueParser
- 環境
- node 22.23.2
- 作成日
- 2026-09-01T19:57:52Z
コントラクト
- postcss-value-parser package.json declares export mappings and version 4.2.0
- postcss-value-parser exports ValueParser constructor and factory function
- ValueParser parses CSS declaration values into word, space, and literal nodes with source index offsets
- ValueParser parses nested function invocations into function nodes with nested argument nodes
- ValueParser parses quoted string literals preserving quote delimiters and unescaped values
- ValueParser walk traverses the AST recursively and supports early branch termination
- ValueParser toString serializes the AST back into equivalent CSS string
- ValueParser.unit parses CSS numeric values and dimension units
- ValueParser.stringify serializes an array of AST nodes into CSS string
ファイル
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
ソース
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 ValueParser in pkg:npm/postcss-value-parser@4.2.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/postcss-value-parser@4.2.0
Demonstrate these symbols/APIs:
- ValueParser
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:f50a82768bae3087ee9ccdc884509e4c21095f09b0df9f8a63c85e1d311702cc","contract":["postcss-value-parser package.json declares export mappings and version 4.2.0","postcss-value-parser exports ValueParser constructor and factory function","ValueParser parses CSS declaration values into word, space, and literal nodes with source index offsets","ValueParser parses nested function invocations into function nodes with nested argument nodes","ValueParser parses quoted string literals preserving quote delimiters and unescaped values","ValueParser walk traverses the AST recursively and supports early branch termination","ValueParser toString serializes the AST back into equivalent CSS string","ValueParser.unit parses CSS numeric values and dimension units","ValueParser.stringify serializes an array of AST nodes into CSS string"],"goal":"verify ValueParser in pkg:npm/postcss-value-parser@4.2.0","kind":"HOW","packages":["pkg:npm/postcss-value-parser@4.2.0"],"schemaVersion":1,"symbols":["ValueParser"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/postcss-value-parser@4.2.0"],"schemaVersion":1,"subject":"pkg:npm/postcss-value-parser@4.2.0","symbols":["ValueParser"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-postcss-value-parser-value-parser",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-postcss-value-parser-value-parser",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"postcss-value-parser": "4.2.0"
}
},
"node_modules/postcss-value-parser": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz",
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==",
"license": "MIT"
}
}
}
{
"name": "sample-postcss-value-parser-value-parser",
"version": "1.0.0",
"type": "module",
"private": true,
"license": "MIT-0",
"dependencies": {
"postcss-value-parser": "4.2.0"
}
}
{
"schemaVersion": 1,
"goal": "verify ValueParser in pkg:npm/postcss-value-parser@4.2.0",
"kind": "HOW",
"packages": [
"pkg:npm/postcss-value-parser@4.2.0"
],
"symbols": [
"ValueParser"
]
}
import assert from 'node:assert/strict';
import fs from 'node:fs';
import { createRequire } from 'node:module';
import ValueParser from 'postcss-value-parser';
const require = createRequire(import.meta.url);
// Contract 1: postcss-value-parser package.json declares export mappings and version 4.2.0
{
const pkgJsonPath = require.resolve('postcss-value-parser/package.json');
assert.ok(fs.existsSync(pkgJsonPath));
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
assert.strictEqual(pkgJson.name, 'postcss-value-parser');
assert.strictEqual(pkgJson.version, '4.2.0');
assert.ok(pkgJson.main);
}
// Contract 2: postcss-value-parser exports ValueParser constructor and factory function
{
assert.strictEqual(typeof ValueParser, 'function');
const instance = new ValueParser('10px');
assert.ok(instance instanceof ValueParser);
const called = ValueParser('10px');
assert.ok(called instanceof ValueParser);
}
// Contract 3: ValueParser parses CSS declaration values into word, space, and literal nodes with source index offsets
{
const parsed = ValueParser('10px solid #333');
assert.ok(Array.isArray(parsed.nodes));
assert.strictEqual(parsed.nodes.length, 5);
assert.deepStrictEqual(parsed.nodes[0], {
type: 'word',
sourceIndex: 0,
sourceEndIndex: 4,
value: '10px'
});
assert.deepStrictEqual(parsed.nodes[1], {
type: 'space',
sourceIndex: 4,
sourceEndIndex: 5,
value: ' '
});
assert.deepStrictEqual(parsed.nodes[2], {
type: 'word',
sourceIndex: 5,
sourceEndIndex: 10,
value: 'solid'
});
assert.deepStrictEqual(parsed.nodes[3], {
type: 'space',
sourceIndex: 10,
sourceEndIndex: 11,
value: ' '
});
assert.deepStrictEqual(parsed.nodes[4], {
type: 'word',
sourceIndex: 11,
sourceEndIndex: 15,
value: '#333'
});
}
// Contract 4: ValueParser parses nested function invocations into function nodes with nested argument nodes
{
const parsed = ValueParser('calc(100% - 20px)');
assert.strictEqual(parsed.nodes.length, 1);
const fnNode = parsed.nodes[0];
assert.strictEqual(fnNode.type, 'function');
assert.strictEqual(fnNode.value, 'calc');
assert.strictEqual(fnNode.sourceIndex, 0);
assert.strictEqual(fnNode.sourceEndIndex, 17);
assert.strictEqual(fnNode.before, '');
assert.strictEqual(fnNode.after, '');
assert.ok(Array.isArray(fnNode.nodes));
assert.strictEqual(fnNode.nodes.length, 5);
assert.strictEqual(fnNode.nodes[0].type, 'word');
assert.strictEqual(fnNode.nodes[0].value, '100%');
assert.strictEqual(fnNode.nodes[0].sourceIndex, 5);
assert.strictEqual(fnNode.nodes[0].sourceEndIndex, 9);
assert.strictEqual(fnNode.nodes[2].type, 'word');
assert.strictEqual(fnNode.nodes[2].value, '-');
assert.strictEqual(fnNode.nodes[4].type, 'word');
assert.strictEqual(fnNode.nodes[4].value, '20px');
}
// Contract 5: ValueParser parses quoted string literals preserving quote delimiters and unescaped values
{
const parsed = ValueParser('url("image.png") \'Helvetica Neue\'');
const urlFn = parsed.nodes[0];
assert.strictEqual(urlFn.type, 'function');
assert.strictEqual(urlFn.value, 'url');
assert.strictEqual(urlFn.nodes[0].type, 'string');
assert.strictEqual(urlFn.nodes[0].value, 'image.png');
assert.strictEqual(urlFn.nodes[0].quote, '"');
assert.strictEqual(urlFn.nodes[0].sourceIndex, 4);
assert.strictEqual(urlFn.nodes[0].sourceEndIndex, 15);
const quotedFont = parsed.nodes[2];
assert.strictEqual(quotedFont.type, 'string');
assert.strictEqual(quotedFont.value, 'Helvetica Neue');
assert.strictEqual(quotedFont.quote, "'");
assert.strictEqual(quotedFont.sourceIndex, 17);
assert.strictEqual(quotedFont.sourceEndIndex, 33);
}
// Contract 6: ValueParser walk traverses the AST recursively and supports early branch termination
{
const parsed = ValueParser('rgba(255, 0, 0, 0.5) 10px');
const visited = [];
parsed.walk((node) => {
visited.push(node.value);
});
assert.ok(visited.includes('rgba'));
assert.ok(visited.includes('255'));
assert.ok(visited.includes('10px'));
const stopped = [];
parsed.walk((node) => {
stopped.push(node.value);
if (node.type === 'function') {
return false; // Skip walking inside the function
}
});
assert.ok(stopped.includes('rgba'));
assert.ok(!stopped.includes('255'));
assert.ok(stopped.includes('10px'));
}
// Contract 7: ValueParser toString serializes the AST back into equivalent CSS string
{
const input = 'linear-gradient(to right, red, blue)';
const parsed = ValueParser(input);
assert.strictEqual(parsed.toString(), input);
parsed.nodes[0].nodes[2].value = 'bottom';
assert.strictEqual(parsed.toString(), 'linear-gradient(to bottom, red, blue)');
}
// Contract 8: ValueParser.unit parses CSS numeric values and dimension units
{
assert.strictEqual(typeof ValueParser.unit, 'function');
assert.deepStrictEqual(ValueParser.unit('12.5px'), {
number: '12.5',
unit: 'px'
});
assert.deepStrictEqual(ValueParser.unit('-4rem'), {
number: '-4',
unit: 'rem'
});
assert.deepStrictEqual(ValueParser.unit('100%'), {
number: '100',
unit: '%'
});
assert.deepStrictEqual(ValueParser.unit('42'), {
number: '42',
unit: ''
});
assert.strictEqual(ValueParser.unit('auto'), false);
assert.strictEqual(ValueParser.unit(''), false);
}
// Contract 9: ValueParser.stringify serializes an array of AST nodes into CSS string
{
assert.strictEqual(typeof ValueParser.stringify, 'function');
const nodes = [
{ type: 'word', value: '1px' },
{ type: 'space', value: ' ' },
{ type: 'word', value: 'solid' },
{ type: 'space', value: ' ' },
{ type: 'word', value: 'black' }
];
assert.strictEqual(ValueParser.stringify(nodes), '1px solid black');
}
console.log('All postcss-value-parser ValueParser contract tests passed.');
オリジンシーダー
匿名