Пример
@jridgewell/trace-mapping 0.3.31: decodedMap
Проверенный пример — npm @jridgewell/trace-mapping 0.3.31: decodedMap. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден.
sha256:d24ea39a65b2315651fc3e187b1ff301a0ac9e8e242bc32d1fa3458985db81f3
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 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-27 |
Кейс
HOW- Цель
- verify @jridgewell/trace-mapping.decodedMap in pkg:npm/%40jridgewell/trace-mapping@0.3.31
- Символы
-
- @jridgewell/trace-mapping.decodedMap
- Окружение
- node 22.23.2
- Создан
- 2026-08-27T11:38:34Z
Контракт
- decodedMap returns a DecodedSourceMap object with decoded 2D mappings array from a TraceMap initialized with encoded VLQ string
- decodedMap preserves source map metadata including version, file, sources, sourcesContent, names, and sourceRoot
- decodedMap correctly decodes 1-segment, 4-segment, and 5-segment mapping tokens
- decodedMap works with TraceMap initialized from a JSON string or an already-decoded source map
- decodedMap output is a plain object serializable with JSON.stringify and compatible with standard source map consumers
- decodedMap preserves ignoreList when present in the source map
Файлы
- PROMPT.md
- csx.json
- index.js
- 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 @jridgewell/trace-mapping.decodedMap in pkg:npm/%40jridgewell/trace-mapping@0.3.31
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40jridgewell/trace-mapping@0.3.31
Demonstrate these symbols/APIs:
- @jridgewell/trace-mapping.decodedMap
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:96adf6c0e519ae28ead3ea5e6b838d712e267a7d41a12e84eafba5b6cde31782","contract":["decodedMap returns a DecodedSourceMap object with decoded 2D mappings array from a TraceMap initialized with encoded VLQ string","decodedMap preserves source map metadata including version, file, sources, sourcesContent, names, and sourceRoot","decodedMap correctly decodes 1-segment, 4-segment, and 5-segment mapping tokens","decodedMap works with TraceMap initialized from a JSON string or an already-decoded source map","decodedMap output is a plain object serializable with JSON.stringify and compatible with standard source map consumers","decodedMap preserves ignoreList when present in the source map"],"goal":"verify @jridgewell/trace-mapping.decodedMap in pkg:npm/%40jridgewell/trace-mapping@0.3.31","kind":"HOW","packages":["pkg:npm/%40jridgewell/trace-mapping@0.3.31"],"schemaVersion":1,"symbols":["@jridgewell/trace-mapping.decodedMap"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","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/trace-mapping@0.3.31"],"schemaVersion":1,"subject":"pkg:npm/%40jridgewell/trace-mapping@0.3.31","symbols":["@jridgewell/trace-mapping.decodedMap"],"verifierAdapter":"node-typescript@1"}
import { TraceMap, decodedMap } from '@jridgewell/trace-mapping';
/**
* Returns a decoded source map object from a source map input (object, JSON string, or TraceMap instance).
* @param {import('@jridgewell/trace-mapping').SourceMapInput | TraceMap} input
* @returns {import('@jridgewell/trace-mapping').DecodedSourceMap}
*/
export function getDecodedMap(input) {
const tracer = input instanceof TraceMap ? input : new TraceMap(input);
return decodedMap(tracer);
}
export { TraceMap, decodedMap };
export default getDecodedMap;
{
"name": "sample-trace-mapping-decoded-map",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-trace-mapping-decoded-map",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@jridgewell/trace-mapping": "0.3.31"
}
},
"node_modules/@jridgewell/resolve-uri": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
"license": "MIT",
"engines": {
"node": ">=6.0.0"
}
},
"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"
},
"node_modules/@jridgewell/trace-mapping": {
"version": "0.3.31",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
"license": "MIT",
"dependencies": {
"@jridgewell/resolve-uri": "^3.1.0",
"@jridgewell/sourcemap-codec": "^1.4.14"
}
}
}
}
{
"name": "sample-trace-mapping-decoded-map",
"version": "1.0.0",
"type": "module",
"main": "index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"@jridgewell/trace-mapping": "0.3.31"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify @jridgewell/trace-mapping.decodedMap in pkg:npm/%40jridgewell/trace-mapping@0.3.31",
"kind": "HOW",
"packages": [
"pkg:npm/%40jridgewell/trace-mapping@0.3.31"
],
"symbols": [
"@jridgewell/trace-mapping.decodedMap"
]
}
import assert from 'node:assert/strict';
import { TraceMap, decodedMap, getDecodedMap } from '../index.js';
// 1. decodedMap returns a DecodedSourceMap object with decoded 2D mappings array from a TraceMap initialized with encoded VLQ string
{
const encodedMap = {
version: 3,
file: 'bundle.js',
sources: ['src/app.js'],
sourcesContent: ['console.log("hello");'],
names: ['console', 'log'],
mappings: 'AAAA,SAASA,GAAG',
sourceRoot: 'http://example.com/'
};
const tracer = new TraceMap(encodedMap);
const result = decodedMap(tracer);
assert.equal(typeof result, 'object');
assert.ok(Array.isArray(result.mappings));
assert.equal(result.mappings.length, 1);
assert.ok(result.mappings[0].length >= 1);
assert.ok(Array.isArray(result.mappings[0][0]));
}
// 2. decodedMap preserves source map metadata including version, file, sources, sourcesContent, names, and sourceRoot
{
const mapData = {
version: 3,
file: 'output.min.js',
sources: ['module.js', 'helper.js'],
sourcesContent: ['const a = 1;', 'const b = 2;'],
names: ['a', 'b'],
mappings: 'AAAA;ACAA',
sourceRoot: 'http://example.com/project/'
};
const tracer = new TraceMap(mapData);
const result = decodedMap(tracer);
assert.equal(result.version, 3);
assert.equal(result.file, 'output.min.js');
assert.deepEqual(result.sources, ['module.js', 'helper.js']);
assert.deepEqual(result.sourcesContent, ['const a = 1;', 'const b = 2;']);
assert.deepEqual(result.names, ['a', 'b']);
assert.equal(result.sourceRoot, 'http://example.com/project/');
}
// 3. decodedMap correctly decodes 1-segment, 4-segment, and 5-segment mapping tokens
{
const mapData = {
version: 3,
sources: ['orig.js'],
names: ['myVar'],
mappings: 'A;AAAA;AAAAA'
};
const tracer = new TraceMap(mapData);
const result = decodedMap(tracer);
assert.equal(result.mappings.length, 3);
assert.deepEqual(result.mappings[0][0], [0]);
assert.deepEqual(result.mappings[1][0], [0, 0, 0, 0]);
assert.deepEqual(result.mappings[2][0], [0, 0, 0, 0, 0]);
}
// 4. decodedMap works with TraceMap initialized from a JSON string or an already-decoded source map
{
const rawDecoded = {
version: 3,
file: 'test.js',
sources: ['test.ts'],
names: [],
mappings: [
[[0, 0, 0, 0]],
[[4, 0, 1, 2]]
]
};
const tracerFromDecoded = new TraceMap(rawDecoded);
const result1 = decodedMap(tracerFromDecoded);
assert.deepEqual(result1.mappings, [
[[0, 0, 0, 0]],
[[4, 0, 1, 2]]
]);
const jsonStr = JSON.stringify(rawDecoded);
const tracerFromJson = new TraceMap(jsonStr);
const result2 = decodedMap(tracerFromJson);
assert.deepEqual(result2.mappings, [
[[0, 0, 0, 0]],
[[4, 0, 1, 2]]
]);
const wrapperResult = getDecodedMap(rawDecoded);
assert.deepEqual(wrapperResult.mappings, result1.mappings);
}
// 5. decodedMap output is a plain object serializable with JSON.stringify and compatible with standard source map consumers
{
const mapData = {
version: 3,
file: 'lib.js',
sources: ['lib.ts'],
names: ['func'],
mappings: 'AAAAA'
};
const tracer = new TraceMap(mapData);
const result = decodedMap(tracer);
const json = JSON.stringify(result);
const parsed = JSON.parse(json);
assert.equal(parsed.version, 3);
assert.equal(parsed.file, 'lib.js');
assert.deepEqual(parsed.mappings, [[[0, 0, 0, 0, 0]]]);
}
// 6. decodedMap preserves ignoreList when present in the source map
{
const mapDataWithIgnore = {
version: 3,
sources: ['node_modules/lib.js', 'src/index.js'],
mappings: 'AAAA;AAAA',
ignoreList: [0]
};
const tracer = new TraceMap(mapDataWithIgnore);
const result = decodedMap(tracer);
assert.deepEqual(result.ignoreList, [0]);
}
console.log('Contract tests passed successfully.');
Исходный сидер
аноним