示例
source-map 0.6.1
已验证示例 — npm source-map 0.6.1. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: SourceMapGenerator generates a v3 source map with mappings between…
sha256:1c4f42ef2f518c2bc287edd13722a08be9d3b56d615d7c085477bce00eaf8180
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
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 pkg:npm/source-map@0.6.1
- 创建时间
- 2026-08-23T13:34:46Z
契约
- SourceMapGenerator generates a v3 source map with mappings between generated and original positions
- SourceMapGenerator sets and embeds original source file content in sourcesContent
- SourceMapConsumer resolves original source, line, column, and symbol name from generated coordinates
- SourceMapConsumer resolves generated line and column coordinates from original positions
- SourceMapConsumer returns all generated positions corresponding to an original line
- SourceMapConsumer retrieves embedded original source content for a source identifier
- SourceMapConsumer iterates over all mappings in generated order
- SourceNode constructs composite source trees and produces generated code with an accurate source map
文件
- 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 pkg:npm/source-map@0.6.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/source-map@0.6.1
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:0330299caadb4577e9648fe47b9603a178a65241de9250b9544ca8ae8cacab60","contract":["SourceMapGenerator generates a v3 source map with mappings between generated and original positions","SourceMapGenerator sets and embeds original source file content in sourcesContent","SourceMapConsumer resolves original source, line, column, and symbol name from generated coordinates","SourceMapConsumer resolves generated line and column coordinates from original positions","SourceMapConsumer returns all generated positions corresponding to an original line","SourceMapConsumer retrieves embedded original source content for a source identifier","SourceMapConsumer iterates over all mappings in generated order","SourceNode constructs composite source trees and produces generated code with an accurate source map"],"goal":"verify pkg:npm/source-map@0.6.1","kind":"HOW","packages":["pkg:npm/source-map@0.6.1"],"schemaVersion":1},"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","verifierAdapter":"node-typescript@1"}
{
"name": "sample-source-map",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-source-map",
"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",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"source-map": "0.6.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/source-map@0.6.1",
"kind": "HOW",
"packages": [
"pkg:npm/source-map@0.6.1"
]
}
import assert from 'node:assert/strict';
import { SourceMapGenerator, SourceMapConsumer, SourceNode } from 'source-map';
// 1. SourceMapGenerator generates a v3 source map with mappings between generated and original positions
{
const generator = new SourceMapGenerator({
file: 'bundle.js',
sourceRoot: 'http://example.com/src/'
});
generator.addMapping({
generated: { line: 1, column: 0 },
original: { line: 10, column: 4 },
source: 'input.js',
name: 'calculateTotal'
});
const rawMap = generator.toJSON();
assert.equal(rawMap.version, 3);
assert.equal(rawMap.file, 'bundle.js');
assert.equal(rawMap.sourceRoot, 'http://example.com/src/');
assert.deepEqual(rawMap.sources, ['input.js']);
assert.deepEqual(rawMap.names, ['calculateTotal']);
assert.equal(typeof rawMap.mappings, 'string');
assert.ok(rawMap.mappings.length > 0);
}
// 2. SourceMapGenerator sets and embeds original source file content in sourcesContent
{
const generator = new SourceMapGenerator({ file: 'out.js' });
const sourceCode = 'function hello() { return "world"; }';
generator.setSourceContent('hello.js', sourceCode);
generator.addMapping({
generated: { line: 1, column: 0 },
original: { line: 1, column: 0 },
source: 'hello.js'
});
const rawMap = generator.toJSON();
assert.deepEqual(rawMap.sources, ['hello.js']);
assert.deepEqual(rawMap.sourcesContent, [sourceCode]);
}
// 3. SourceMapConsumer resolves original source, line, column, and symbol name from generated coordinates
{
const generator = new SourceMapGenerator({ file: 'min.js' });
generator.addMapping({
generated: { line: 1, column: 5 },
original: { line: 2, column: 10 },
source: 'orig.js',
name: 'myFunction'
});
const consumer = new SourceMapConsumer(generator.toJSON());
const pos = consumer.originalPositionFor({ line: 1, column: 5 });
assert.equal(pos.source, 'orig.js');
assert.equal(pos.line, 2);
assert.equal(pos.column, 10);
assert.equal(pos.name, 'myFunction');
}
// 4. SourceMapConsumer resolves generated line and column coordinates from original positions
{
const generator = new SourceMapGenerator({ file: 'min.js' });
generator.addMapping({
generated: { line: 1, column: 20 },
original: { line: 5, column: 8 },
source: 'orig.js'
});
const consumer = new SourceMapConsumer(generator.toJSON());
const genPos = consumer.generatedPositionFor({
source: 'orig.js',
line: 5,
column: 8
});
assert.equal(genPos.line, 1);
assert.equal(genPos.column, 20);
}
// 5. SourceMapConsumer returns all generated positions corresponding to an original line
{
const generator = new SourceMapGenerator({ file: 'bundle.js' });
generator.addMapping({
generated: { line: 1, column: 0 },
original: { line: 3, column: 0 },
source: 'source.js'
});
generator.addMapping({
generated: { line: 1, column: 15 },
original: { line: 3, column: 5 },
source: 'source.js'
});
const consumer = new SourceMapConsumer(generator.toJSON());
const allPositions = consumer.allGeneratedPositionsFor({
source: 'source.js',
line: 3
});
assert.ok(Array.isArray(allPositions));
assert.equal(allPositions.length, 2);
assert.equal(allPositions[0].line, 1);
assert.equal(allPositions[0].column, 0);
assert.equal(allPositions[1].line, 1);
assert.equal(allPositions[1].column, 15);
}
// 6. SourceMapConsumer retrieves embedded original source content for a source identifier
{
const generator = new SourceMapGenerator({ file: 'out.js' });
generator.setSourceContent('math.js', 'export const pi = 3.14159;');
generator.addMapping({
generated: { line: 1, column: 0 },
original: { line: 1, column: 0 },
source: 'math.js'
});
const consumer = new SourceMapConsumer(generator.toJSON());
const retrievedContent = consumer.sourceContentFor('math.js');
assert.equal(retrievedContent, 'export const pi = 3.14159;');
}
// 7. SourceMapConsumer iterates over all mappings in generated order
{
const generator = new SourceMapGenerator({ file: 'out.js' });
generator.addMapping({
generated: { line: 1, column: 0 },
original: { line: 1, column: 0 },
source: 'a.js'
});
generator.addMapping({
generated: { line: 2, column: 4 },
original: { line: 10, column: 2 },
source: 'b.js',
name: 'ident'
});
const consumer = new SourceMapConsumer(generator.toJSON());
const collected = [];
consumer.eachMapping((m) => {
collected.push({
generatedLine: m.generatedLine,
generatedColumn: m.generatedColumn,
originalLine: m.originalLine,
originalColumn: m.originalColumn,
source: m.source,
name: m.name
});
});
assert.equal(collected.length, 2);
assert.deepEqual(collected[0], {
generatedLine: 1,
generatedColumn: 0,
originalLine: 1,
originalColumn: 0,
source: 'a.js',
name: null
});
assert.deepEqual(collected[1], {
generatedLine: 2,
generatedColumn: 4,
originalLine: 10,
originalColumn: 2,
source: 'b.js',
name: 'ident'
});
}
// 8. SourceNode constructs composite source trees and produces generated code with an accurate source map
{
const node = new SourceNode(null, null, null, [
new SourceNode(1, 0, 'part1.js', 'const a = 10;\n'),
new SourceNode(1, 0, 'part2.js', 'const b = 20;\n'),
'console.log(a + b);\n'
]);
const output = node.toStringWithSourceMap({ file: 'output.js' });
assert.equal(output.code, 'const a = 10;\nconst b = 20;\nconsole.log(a + b);\n');
const consumer = new SourceMapConsumer(output.map.toJSON());
const posA = consumer.originalPositionFor({ line: 1, column: 0 });
assert.equal(posA.source, 'part1.js');
assert.equal(posA.line, 1);
const posB = consumer.originalPositionFor({ line: 2, column: 0 });
assert.equal(posB.source, 'part2.js');
assert.equal(posB.line, 1);
}
原始种子者
匿名