Пример
@jridgewell/sourcemap-codec 1.5.5: decode
Проверенный пример — npm @jridgewell/sourcemap-codec 1.5.5: decode. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден.
sha256:b7c8c55ba3c2eebedef0c8fa092f2f637c89d2aab348946c527d38c9243bc2d6
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-26 |
Кейс
HOW- Цель
- verify decode in pkg:npm/%40jridgewell/sourcemap-codec@1.5.5
- Символы
-
- decode
- Окружение
- node 22.23.2
- Создан
- 2026-08-26T05:12:28Z
Контракт
- decode parses empty mappings string to a single empty line array
- decode parses 1-element segment containing generated column offset
- decode parses 4-element segment containing generated column, source index, original line, and original column
- decode parses 5-element segment containing generated column, source index, original line, original column, and name index
- decode parses comma-separated segments within the same line
- decode parses semicolon-separated lines and preserves empty lines
Файлы
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Исходный код
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 decode in pkg:npm/%40jridgewell/sourcemap-codec@1.5.5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40jridgewell/sourcemap-codec@1.5.5
Demonstrate these symbols/APIs:
- decode
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:81f0faf1b464181eeaefbbdcf4792f96fec9065b0a3a762464e573b86734aad8","constraints":{"executionContext":"node"},"contract":["decode parses empty mappings string to a single empty line array","decode parses 1-element segment containing generated column offset","decode parses 4-element segment containing generated column, source index, original line, and original column","decode parses 5-element segment containing generated column, source index, original line, original column, and name index","decode parses comma-separated segments within the same line","decode parses semicolon-separated lines and preserves empty lines"],"goal":"verify decode in pkg:npm/%40jridgewell/sourcemap-codec@1.5.5","kind":"HOW","packages":["pkg:npm/%40jridgewell/sourcemap-codec@1.5.5"],"schemaVersion":1,"symbols":["decode"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40jridgewell/sourcemap-codec@1.5.5"],"schemaVersion":1,"subject":"pkg:npm/%40jridgewell/sourcemap-codec@1.5.5","symbols":["decode"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-sourcemap-codec",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-sourcemap-codec",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@jridgewell/sourcemap-codec": "1.5.5"
}
},
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
"license": "MIT"
}
}
}
{
"name": "sample-sourcemap-codec",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for @jridgewell/sourcemap-codec",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"@jridgewell/sourcemap-codec": "1.5.5"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify decode in pkg:npm/%40jridgewell/sourcemap-codec@1.5.5",
"kind": "HOW",
"packages": [
"pkg:npm/%40jridgewell/sourcemap-codec@1.5.5"
],
"symbols": [
"decode"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const { decode } = require('@jridgewell/sourcemap-codec');
/**
* Decode a source map mappings string into an array of lines containing segments.
*
* @param {string} mappings
* @returns {number[][][]}
*/
function decodeMappings(mappings) {
return decode(mappings);
}
/**
* Decode mappings and convert raw segment tuples into structured objects.
*
* @param {string} mappings
* @returns {Array<Array<{ generatedColumn: number, sourceIndex?: number, originalLine?: number, originalColumn?: number, nameIndex?: number }>>}
*/
function decodeToStructured(mappings) {
const decoded = decode(mappings);
return decoded.map((line) =>
line.map((segment) => {
const obj = { generatedColumn: segment[0] };
if (segment.length >= 4) {
obj.sourceIndex = segment[1];
obj.originalLine = segment[2];
obj.originalColumn = segment[3];
}
if (segment.length >= 5) {
obj.nameIndex = segment[4];
}
return obj;
})
);
}
/**
* Count total number of mapping segments across all lines.
*
* @param {string} mappings
* @returns {number}
*/
function countSegments(mappings) {
const decoded = decode(mappings);
return decoded.reduce((acc, line) => acc + line.length, 0);
}
module.exports = {
decodeMappings,
decodeToStructured,
countSegments
};
const assert = require('node:assert');
const { decode } = require('@jridgewell/sourcemap-codec');
const {
decodeMappings,
decodeToStructured,
countSegments
} = require('../src/index.js');
// 1. Empty mappings string
const emptyResult = decode('');
assert.deepStrictEqual(emptyResult, [[]], 'empty mappings should return single empty line array');
assert.deepStrictEqual(decodeMappings(''), [[]], 'decodeMappings helper handles empty mappings');
assert.strictEqual(countSegments(''), 0, 'countSegments on empty mappings returns 0');
// 2. Single 1-element segment (generated column only: [generatedColumn])
// "K" in VLQ is 5
const singleCol = decode('K');
assert.deepStrictEqual(singleCol, [[[5]]], 'decode single 1-element segment');
// 3. Single 4-element segment: [genCol, sourceIndex, origLine, origCol]
// "AAAA" decodes to [0, 0, 0, 0]
const single4Tuple = decode('AAAA');
assert.deepStrictEqual(single4Tuple, [[[0, 0, 0, 0]]], 'decode single 4-element segment');
// 4. Single 5-element segment: [genCol, sourceIndex, origLine, origCol, nameIndex]
// "AAAAA" decodes to [0, 0, 0, 0, 0]
const single5Tuple = decode('AAAAA');
assert.deepStrictEqual(single5Tuple, [[[0, 0, 0, 0, 0]]], 'decode single 5-element segment');
// 5. Multiple segments on the same line (comma separated)
// "AAAA,CAAC" -> [0,0,0,0], [1,0,0,1]
const multiSegments = decode('AAAA,CAAC');
assert.deepStrictEqual(multiSegments, [
[
[0, 0, 0, 0],
[1, 0, 0, 1]
]
], 'decode multiple segments on one line');
// 6. Multiple lines separated by semicolons and empty lines
// "AAAA;;EAAA" -> line 0 has [0,0,0,0], line 1 is empty [], line 2 has [2,0,0,0]
const multiLines = decode('AAAA;;EAAA');
assert.deepStrictEqual(multiLines, [
[[0, 0, 0, 0]],
[],
[[2, 0, 0, 0]]
], 'decode multiple lines with empty lines');
// 7. Structured helper verification
const structured = decodeToStructured('AAAAA,CAAC;EAAA');
assert.strictEqual(structured.length, 2, 'structured representation has 2 lines');
assert.deepStrictEqual(structured[0][0], {
generatedColumn: 0,
sourceIndex: 0,
originalLine: 0,
originalColumn: 0,
nameIndex: 0
}, 'structured segment with 5 fields');
assert.deepStrictEqual(structured[0][1], {
generatedColumn: 1,
sourceIndex: 0,
originalLine: 0,
originalColumn: 1
}, 'structured segment with 4 fields');
assert.deepStrictEqual(structured[1][0], {
generatedColumn: 2,
sourceIndex: 0,
originalLine: 0,
originalColumn: 1
}, 'structured segment on second line');
// 8. Count segments helper verification
assert.strictEqual(countSegments('AAAAA,CAAC;EAAA'), 3, 'countSegments correctly counts 3 segments');
console.log('Contract tests passed successfully.');
Исходный сидер
аноним