Пример
source-map 0.6.1: SourceMapConsumer
Проверенный пример — npm source-map 0.6.1: SourceMapConsumer. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден.
sha256:6e34f2d9dd46d525a4d8a8c458a7c0addf85cf2e4d302dfbc5ccb524f5263256
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 2
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 24 · ubuntu · glibc 2.39 x64 npm
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| 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-23 |
| 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-07 |
Кейс
HOW- Цель
- verify source-map.SourceMapConsumer in pkg:npm/source-map@0.6.1
- Пакеты
- Символы
-
- source-map.SourceMapConsumer
- Создан
- 2026-08-23T13:37:59Z
Контракт
- SourceMapConsumer parses raw source map and resolves original position for a generated coordinate
- SourceMapConsumer resolves original position with GREATEST_LOWER_BOUND and LEAST_UPPER_BOUND bias options
- SourceMapConsumer resolves generated position for an original source line and column
- SourceMapConsumer returns all generated positions matching an original source line
- SourceMapConsumer retrieves embedded source content by file name
- SourceMapConsumer iterates over mappings in GENERATED_ORDER and ORIGINAL_ORDER
- SourceMapConsumer checks whether contents are embedded for all source files
Файлы
- 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 source-map.SourceMapConsumer in pkg:npm/source-map@0.6.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/source-map@0.6.1
Demonstrate these symbols/APIs:
- source-map.SourceMapConsumer
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:f6f7a4f31aee60da6579456ccac44df06465bcb249b1fa5e17fe3f23a971c08d","contract":["SourceMapConsumer parses raw source map and resolves original position for a generated coordinate","SourceMapConsumer resolves original position with GREATEST_LOWER_BOUND and LEAST_UPPER_BOUND bias options","SourceMapConsumer resolves generated position for an original source line and column","SourceMapConsumer returns all generated positions matching an original source line","SourceMapConsumer retrieves embedded source content by file name","SourceMapConsumer iterates over mappings in GENERATED_ORDER and ORIGINAL_ORDER","SourceMapConsumer checks whether contents are embedded for all source files"],"goal":"verify source-map.SourceMapConsumer in pkg:npm/source-map@0.6.1","kind":"HOW","packages":["pkg:npm/source-map@0.6.1"],"schemaVersion":1,"symbols":["source-map.SourceMapConsumer"]},"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/source-map@0.6.1"],"schemaVersion":1,"subject":"pkg:npm/source-map@0.6.1","symbols":["source-map.SourceMapConsumer"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-source-map-consumer",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-source-map-consumer",
"version": "1.0.0",
"dependencies": {
"source-map": "0.6.1"
}
},
"node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
}
}
}
}
{
"name": "sample-source-map-consumer",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"source-map": "0.6.1"
}
}
{
"schemaVersion": 1,
"goal": "verify source-map.SourceMapConsumer in pkg:npm/source-map@0.6.1",
"kind": "HOW",
"packages": [
"pkg:npm/source-map@0.6.1"
],
"symbols": [
"source-map.SourceMapConsumer"
]
}
import assert from 'node:assert/strict';
import { SourceMapConsumer, SourceMapGenerator } from 'source-map';
function createFixtureSourceMap() {
const generator = new SourceMapGenerator({
file: 'bundle.min.js'
});
generator.setSourceContent('util.js', 'export function add(a, b) {\n return a + b;\n}\n');
generator.setSourceContent('main.js', 'import { add } from "./util";\nconst sum = add(1, 2);\n');
// Mapping 1: util.js add function definition
generator.addMapping({
generated: { line: 1, column: 0 },
original: { line: 1, column: 0 },
source: 'util.js',
name: 'add'
});
// Mapping 2: util.js return statement
generator.addMapping({
generated: { line: 1, column: 20 },
original: { line: 2, column: 2 },
source: 'util.js'
});
// Mapping 3: main.js import
generator.addMapping({
generated: { line: 2, column: 0 },
original: { line: 1, column: 0 },
source: 'main.js'
});
// Mapping 4: main.js sum assignment
generator.addMapping({
generated: { line: 2, column: 15 },
original: { line: 2, column: 6 },
source: 'main.js',
name: 'sum'
});
// Mapping 5: main.js call to add on same line
generator.addMapping({
generated: { line: 2, column: 25 },
original: { line: 2, column: 12 },
source: 'main.js',
name: 'add'
});
return generator.toJSON();
}
const rawMap = createFixtureSourceMap();
// 1. SourceMapConsumer parses raw source map and resolves original position for a generated coordinate
{
const consumer = new SourceMapConsumer(rawMap);
const pos = consumer.originalPositionFor({ line: 2, column: 15 });
assert.equal(pos.source, 'main.js');
assert.equal(pos.line, 2);
assert.equal(pos.column, 6);
assert.equal(pos.name, 'sum');
}
// 2. SourceMapConsumer resolves original position with GREATEST_LOWER_BOUND and LEAST_UPPER_BOUND bias options
{
const consumer = new SourceMapConsumer(rawMap);
// Column 18 is between mapping at col 15 and col 25 on line 2
const lowerPos = consumer.originalPositionFor({
line: 2,
column: 18,
bias: SourceMapConsumer.GREATEST_LOWER_BOUND
});
assert.equal(lowerPos.line, 2);
assert.equal(lowerPos.column, 6);
assert.equal(lowerPos.name, 'sum');
const upperPos = consumer.originalPositionFor({
line: 2,
column: 18,
bias: SourceMapConsumer.LEAST_UPPER_BOUND
});
assert.equal(upperPos.line, 2);
assert.equal(upperPos.column, 12);
assert.equal(upperPos.name, 'add');
}
// 3. SourceMapConsumer resolves generated position for an original source line and column
{
const consumer = new SourceMapConsumer(rawMap);
const genPos = consumer.generatedPositionFor({
source: 'util.js',
line: 2,
column: 2
});
assert.equal(genPos.line, 1);
assert.equal(genPos.column, 20);
}
// 4. SourceMapConsumer returns all generated positions matching an original source line
{
const consumer = new SourceMapConsumer(rawMap);
const allPositions = consumer.allGeneratedPositionsFor({
source: 'main.js',
line: 2
});
assert.ok(Array.isArray(allPositions));
assert.equal(allPositions.length, 2);
assert.equal(allPositions[0].line, 2);
assert.equal(allPositions[0].column, 15);
assert.equal(allPositions[1].line, 2);
assert.equal(allPositions[1].column, 25);
}
// 5. SourceMapConsumer retrieves embedded source content by file name
{
const consumer = new SourceMapConsumer(rawMap);
const utilContent = consumer.sourceContentFor('util.js');
assert.equal(utilContent, 'export function add(a, b) {\n return a + b;\n}\n');
const mainContent = consumer.sourceContentFor('main.js');
assert.equal(mainContent, 'import { add } from "./util";\nconst sum = add(1, 2);\n');
const missingContent = consumer.sourceContentFor('nonexistent.js', true);
assert.equal(missingContent, null);
}
// 6. SourceMapConsumer iterates over mappings in GENERATED_ORDER and ORIGINAL_ORDER
{
const consumer = new SourceMapConsumer(rawMap);
const genOrderMappings = [];
consumer.eachMapping((m) => {
genOrderMappings.push({ genLine: m.generatedLine, genCol: m.generatedColumn });
}, null, SourceMapConsumer.GENERATED_ORDER);
assert.equal(genOrderMappings.length, 5);
assert.deepEqual(genOrderMappings[0], { genLine: 1, genCol: 0 });
assert.deepEqual(genOrderMappings[1], { genLine: 1, genCol: 20 });
assert.deepEqual(genOrderMappings[2], { genLine: 2, genCol: 0 });
const origOrderMappings = [];
consumer.eachMapping((m) => {
origOrderMappings.push({ source: m.source, origLine: m.originalLine, origCol: m.originalColumn });
}, null, SourceMapConsumer.ORIGINAL_ORDER);
assert.equal(origOrderMappings.length, 5);
assert.equal(origOrderMappings[0].source, 'util.js');
assert.equal(origOrderMappings[0].origLine, 1);
assert.equal(origOrderMappings[0].origCol, 0);
}
// 7. SourceMapConsumer checks whether contents are embedded for all source files
{
const consumer = new SourceMapConsumer(rawMap);
assert.equal(consumer.hasContentsOfAllSources(), true);
const partialMap = {
version: 3,
file: 'out.js',
sources: ['a.js', 'b.js'],
sourcesContent: ['content a', null],
names: [],
mappings: 'AAAA;'
};
const partialConsumer = new SourceMapConsumer(partialMap);
assert.equal(partialConsumer.hasContentsOfAllSources(), false);
}
Исходный сидер
аноним