示例
source-map-support 0.5.21: sourceMapSupport.install
已验证示例 — npm source-map-support 0.5.21: sourceMapSupport.install. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: sourceMapSupport.install configures…
sha256:538be996e4848ae80667e27ec77f4129821af67b64457af004c41cfb4c596ce3
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux 24 · ubuntu · glibc 2.39 x64 npm
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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-01 |
案例
HOW- 目标
- verify sourceMapSupport.install in pkg:npm/source-map-support@0.5.21
- 符号
-
- sourceMapSupport.install
- 创建时间
- 2026-09-01T11:51:22Z
契约
- sourceMapSupport.install configures Error.prepareStackTrace for stack trace remapping
- sourceMapSupport.install rewrites stack traces to map generated positions back to original source files
- sourceMapSupport.install supports custom retrieveSourceMap hook to resolve in-memory source maps
- sourceMapSupport.install preserves standard stack trace structure when no source map is found
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- 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 sourceMapSupport.install in pkg:npm/source-map-support@0.5.21
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/source-map-support@0.5.21
Demonstrate these symbols/APIs:
- sourceMapSupport.install
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:5046590449b2dfd1c98ea3da01e34f5959b466640c9ac3098f2d932ae84d8491","contract":["sourceMapSupport.install configures Error.prepareStackTrace for stack trace remapping","sourceMapSupport.install rewrites stack traces to map generated positions back to original source files","sourceMapSupport.install supports custom retrieveSourceMap hook to resolve in-memory source maps","sourceMapSupport.install preserves standard stack trace structure when no source map is found"],"goal":"verify sourceMapSupport.install in pkg:npm/source-map-support@0.5.21","kind":"HOW","packages":["pkg:npm/source-map-support@0.5.21"],"schemaVersion":1,"symbols":["sourceMapSupport.install"]},"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-support@0.5.21"],"schemaVersion":1,"subject":"pkg:npm/source-map-support@0.5.21","symbols":["sourceMapSupport.install"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-source-map-support-install",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-source-map-support-install",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"source-map-support": "0.5.21"
}
},
"node_modules/buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
"license": "MIT"
},
"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"
}
},
"node_modules/source-map-support": {
"version": "0.5.21",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
"license": "MIT",
"dependencies": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
}
}
}
}
{
"name": "sample-source-map-support-install",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of sourceMapSupport.install in source-map-support",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"license": "MIT-0",
"dependencies": {
"source-map-support": "0.5.21"
}
}
{
"schemaVersion": 1,
"goal": "verify sourceMapSupport.install in pkg:npm/source-map-support@0.5.21",
"kind": "HOW",
"packages": [
"pkg:npm/source-map-support@0.5.21"
],
"symbols": [
"sourceMapSupport.install"
]
}
const sourceMapSupport = require("source-map-support");
/**
* Installs source map support into Node.js stack trace handling.
* @param {object} [options]
* @returns {void}
*/
function install(options) {
return sourceMapSupport.install(options);
}
/**
* Resets custom retrieve handlers to defaults if available.
* @returns {void}
*/
function resetRetrieveHandlers() {
if (typeof sourceMapSupport.resetRetrieveHandlers === "function") {
sourceMapSupport.resetRetrieveHandlers();
}
}
module.exports = {
sourceMapSupport,
install,
resetRetrieveHandlers,
};
import assert from "node:assert";
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
const { sourceMapSupport, install, resetRetrieveHandlers } = require("../src/index.js");
async function runContract() {
// 1. sourceMapSupport.install configures Error.prepareStackTrace for stack trace remapping
assert.strictEqual(typeof sourceMapSupport.install, "function", "sourceMapSupport.install must be a function");
assert.strictEqual(typeof install, "function", "install wrapper must be a function");
let hookInvocations = 0;
const sampleSourceMap = {
version: 3,
file: "compiled-bundle.js",
sources: ["src/original-module.ts"],
sourcesContent: [
"export function executeTask(value: number): number {\n if (value < 0) throw new Error(\"negative value\");\n return value * 2;\n}\n"
],
names: ["executeTask", "value"],
mappings: "AAAA,gBAAsBA,YAAY,CAACC,KAAa;IAC9C,IAAIA,KAAK,GAAG,CAAC;MAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACjD,OAAOA,KAAK,GAAG,CAAC,CAAC;AACnB,CAAC"
};
install({
emptyCacheBetweenOperations: true,
handleUncaughtExceptions: false,
environment: "node",
retrieveSourceMap(source) {
if (source === "compiled-bundle.js" || source.endsWith("/compiled-bundle.js")) {
hookInvocations++;
return {
url: "compiled-bundle.js",
map: sampleSourceMap,
};
}
return null;
},
});
assert.strictEqual(typeof Error.prepareStackTrace, "function", "Error.prepareStackTrace must be a function after install()");
// 2. sourceMapSupport.install rewrites stack traces to map generated positions back to original source files
const fnWithSourceURL = new Function(
"//# sourceURL=compiled-bundle.js\nthrow new Error(\"error inside compiled bundle\");"
);
let caughtError = null;
try {
fnWithSourceURL();
} catch (err) {
caughtError = err;
}
assert.ok(caughtError instanceof Error, "Expected error to be thrown");
assert.ok(
caughtError.stack.includes("src/original-module.ts"),
`Expected stack trace to contain mapped original file "src/original-module.ts", got:\n${caughtError.stack}`
);
// 3. sourceMapSupport.install supports custom retrieveSourceMap hook to resolve in-memory source maps
assert.ok(hookInvocations > 0, "Expected custom retrieveSourceMap hook to be invoked when formatting stack trace");
// 4. sourceMapSupport.install preserves standard stack trace structure when no source map is found
const fnUnmapped = new Function(
"//# sourceURL=unmapped-file.js\nthrow new Error(\"unmapped error message\");"
);
let unmappedErr = null;
try {
fnUnmapped();
} catch (err) {
unmappedErr = err;
}
assert.ok(unmappedErr instanceof Error, "Expected unmapped error");
assert.ok(typeof unmappedErr.stack === "string", "Stack trace must be a string");
assert.ok(unmappedErr.stack.includes("unmapped error message"), "Stack trace must contain original error message");
assert.ok(unmappedErr.stack.includes("unmapped-file.js"), "Stack trace must contain unmapped source URL");
resetRetrieveHandlers();
console.log("Contract assertions passed successfully.");
}
runContract().catch((err) => {
console.error("Contract test failed:", err);
process.exit(1);
});
原始种子者
匿名