示例
@jridgewell/trace-mapping 0.3.31: sourceContentFor
已验证示例 — npm @jridgewell/trace-mapping 0.3.31: sourceContentFor. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: sourceContentFor returns the embedded…
sha256:216fec617f1f2888b99b8085d43febeee3a7a8dc43be50394199ae5632fb0f20
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
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-27 |
案例
HOW- 目标
- verify @jridgewell/trace-mapping.sourceContentFor in pkg:npm/%40jridgewell/trace-mapping@0.3.31
- 符号
-
- @jridgewell/trace-mapping.sourceContentFor
- 环境
- node 22.23.2
- 创建时间
- 2026-08-27T11:50:49Z
契约
- sourceContentFor returns the embedded source content for a source file present in sourcesContent
- sourceContentFor returns null for a source file without content or when sourcesContent is not provided
- sourceContentFor returns null for an unknown or unmapped source file path
- sourceContentFor resolves sources correctly when sourceRoot is configured in the source map
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- 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.sourceContentFor 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.sourceContentFor
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:5237a04d316955944c34148c3fef8e3da3f402c81153920709e659199306ffd6","contract":["sourceContentFor returns the embedded source content for a source file present in sourcesContent","sourceContentFor returns null for a source file without content or when sourcesContent is not provided","sourceContentFor returns null for an unknown or unmapped source file path","sourceContentFor resolves sources correctly when sourceRoot is configured in the source map"],"goal":"verify @jridgewell/trace-mapping.sourceContentFor 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.sourceContentFor"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","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.sourceContentFor"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-trace-mapping-source-content-for",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-trace-mapping-source-content-for",
"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-source-content-for",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"@jridgewell/trace-mapping": "0.3.31"
}
}
{
"schemaVersion": 1,
"goal": "verify @jridgewell/trace-mapping.sourceContentFor in pkg:npm/%40jridgewell/trace-mapping@0.3.31",
"kind": "HOW",
"packages": [
"pkg:npm/%40jridgewell/trace-mapping@0.3.31"
],
"symbols": [
"@jridgewell/trace-mapping.sourceContentFor"
]
}
import { TraceMap, sourceContentFor } from "@jridgewell/trace-mapping";
export function createTraceMap(map) {
return new TraceMap(map);
}
export function getSourceContent(tracer, source) {
return sourceContentFor(tracer, source);
}
import assert from "node:assert/strict";
import { TraceMap, sourceContentFor } from "@jridgewell/trace-mapping";
import { createTraceMap, getSourceContent } from "../src/index.mjs";
// Test 1: sourceContentFor returns the embedded source content for a source file present in sourcesContent
{
const map = {
version: 3,
sources: ["input.js", "utils.js"],
sourcesContent: ["export const x = 42;", "export function add(a, b) { return a + b; }"],
mappings: "AAAA;"
};
const tracer = createTraceMap(map);
assert.equal(getSourceContent(tracer, "input.js"), "export const x = 42;");
assert.equal(getSourceContent(tracer, "utils.js"), "export function add(a, b) { return a + b; }");
assert.equal(sourceContentFor(tracer, "input.js"), "export const x = 42;");
}
// Test 2: sourceContentFor returns null for a source file without content or when sourcesContent is not provided
{
const mapWithNull = {
version: 3,
sources: ["has-content.js", "no-content.js"],
sourcesContent: ["const a = 1;", null],
mappings: "AAAA;"
};
const tracer1 = createTraceMap(mapWithNull);
assert.equal(getSourceContent(tracer1, "has-content.js"), "const a = 1;");
assert.equal(getSourceContent(tracer1, "no-content.js"), null);
const mapWithoutSourcesContent = {
version: 3,
sources: ["input.js"],
mappings: "AAAA;"
};
const tracer2 = createTraceMap(mapWithoutSourcesContent);
assert.equal(getSourceContent(tracer2, "input.js"), null);
}
// Test 3: sourceContentFor returns null for an unknown or unmapped source file path
{
const map = {
version: 3,
sources: ["file1.js"],
sourcesContent: ["const ok = true;"],
mappings: "AAAA;"
};
const tracer = createTraceMap(map);
assert.equal(getSourceContent(tracer, "unknown.js"), null);
assert.equal(getSourceContent(tracer, ""), null);
assert.equal(getSourceContent(tracer, null), null);
assert.equal(getSourceContent(tracer, undefined), null);
}
// Test 4: sourceContentFor resolves sources correctly when sourceRoot is configured in the source map
{
const mapWithRoot = {
version: 3,
sourceRoot: "https://example.com/src/",
sources: ["app.js"],
sourcesContent: ["console.log('root app');"],
mappings: "AAAA;"
};
const tracer = createTraceMap(mapWithRoot);
assert.equal(getSourceContent(tracer, "https://example.com/src/app.js"), "console.log('root app');");
assert.equal(getSourceContent(tracer, "app.js"), "console.log('root app');");
}
console.log("All @jridgewell/trace-mapping.sourceContentFor contract tests passed successfully.");
原始种子者
匿名