示例
convert-source-map 2.0.0
已验证示例 — npm convert-source-map 2.0.0. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: fromObject converts a source map object and returns new copy via…
sha256:31989c2b5ebccf8fb18d68c01a2306c7c4431e0c20bdf78759619331a3c340ff
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 2
- 构建过它的签名密钥
- 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-25 |
| 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/convert-source-map@2.0.0
- 环境
- node 22.23.2
- 创建时间
- 2026-08-25T02:34:41Z
契约
- fromObject converts a source map object and returns new copy via toObject and JSON string via toJSON
- fromJSON parses a source map JSON string and allows modifying properties via getProperty, setProperty, and addProperty
- fromBase64 and toBase64 convert between base64-encoded strings and source map objects
- fromComment and toComment parse and format inline base64 and URI-encoded sourceMappingURL comments
- fromSource finds the last inline source map comment from source code or returns null if absent
- removeComments and removeMapFileComments strip inline data URIs and external map file comments from source text
- generateMapFileComment formats single-line and multi-line sourceMappingURL references to map files
- fromMapFileComment reads map file content using a custom reader function
文件
- 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/convert-source-map@2.0.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/convert-source-map@2.0.0
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:ea77ca5ba5a7f7298fe4423f887787d9b1d65aa5a5dbe0bb6661db739e3d06e2","constraints":{"executionContext":"node"},"contract":["fromObject converts a source map object and returns new copy via toObject and JSON string via toJSON","fromJSON parses a source map JSON string and allows modifying properties via getProperty, setProperty, and addProperty","fromBase64 and toBase64 convert between base64-encoded strings and source map objects","fromComment and toComment parse and format inline base64 and URI-encoded sourceMappingURL comments","fromSource finds the last inline source map comment from source code or returns null if absent","removeComments and removeMapFileComments strip inline data URIs and external map file comments from source text","generateMapFileComment formats single-line and multi-line sourceMappingURL references to map files","fromMapFileComment reads map file content using a custom reader function"],"goal":"verify pkg:npm/convert-source-map@2.0.0","kind":"HOW","packages":["pkg:npm/convert-source-map@2.0.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/convert-source-map@2.0.0"],"schemaVersion":1,"subject":"pkg:npm/convert-source-map@2.0.0","verifierAdapter":"node-typescript@1"}
{
"name": "sample-convert-source-map",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-convert-source-map",
"version": "1.0.0",
"dependencies": {
"convert-source-map": "2.0.0"
}
},
"node_modules/convert-source-map": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",
"integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",
"license": "MIT"
}
}
}
{
"name": "sample-convert-source-map",
"version": "1.0.0",
"private": true,
"dependencies": {
"convert-source-map": "2.0.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/convert-source-map@2.0.0",
"kind": "HOW",
"packages": [
"pkg:npm/convert-source-map@2.0.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import convert from 'convert-source-map';
const rawMap = {
version: 3,
file: 'min.js',
names: ['bar', 'baz'],
sources: ['one.js', 'two.js'],
sourceRoot: 'http://example.com/www/js/',
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,OAAU,GACrB',
};
// 1. fromObject converts a source map object and returns new copy via toObject and JSON string via toJSON
{
const conv = convert.fromObject(rawMap);
const obj = conv.toObject();
assert.deepEqual(obj, rawMap);
assert.notEqual(obj, rawMap);
const jsonStr = conv.toJSON();
assert.equal(typeof jsonStr, 'string');
assert.deepEqual(JSON.parse(jsonStr), rawMap);
}
// 2. fromJSON parses a source map JSON string and allows modifying properties via getProperty, setProperty, and addProperty
{
const json = JSON.stringify(rawMap);
const conv = convert.fromJSON(json);
assert.equal(conv.getProperty('file'), 'min.js');
conv.setProperty('file', 'bundle.min.js');
assert.equal(conv.getProperty('file'), 'bundle.min.js');
conv.addProperty('x_custom', 'custom-value');
assert.equal(conv.getProperty('x_custom'), 'custom-value');
assert.throws(
() => {
conv.addProperty('file', 'other.js');
},
{
name: 'Error',
message: 'property "file" already exists on the sourcemap, use set property instead',
}
);
}
// 3. fromBase64 and toBase64 convert between base64-encoded strings and source map objects
{
const conv = convert.fromObject(rawMap);
const base64 = conv.toBase64();
assert.equal(typeof base64, 'string');
const parsed = convert.fromBase64(base64);
assert.deepEqual(parsed.toObject(), rawMap);
}
// 4. fromComment and toComment parse and format inline base64 and URI-encoded sourceMappingURL comments
{
const conv = convert.fromObject(rawMap);
const singleLineComment = conv.toComment();
assert.ok(singleLineComment.startsWith('//# sourceMappingURL=data:application/json;charset=utf-8;base64,'));
const parsedFromSingle = convert.fromComment(singleLineComment);
assert.deepEqual(parsedFromSingle.toObject(), rawMap);
const multiLineComment = conv.toComment({ multiline: true });
assert.ok(multiLineComment.startsWith('/*# sourceMappingURL=data:application/json;charset=utf-8;base64,'));
assert.ok(multiLineComment.endsWith(' */'));
const parsedFromMulti = convert.fromComment(multiLineComment);
assert.deepEqual(parsedFromMulti.toObject(), rawMap);
const uriComment = conv.toComment({ encoding: 'uri' });
assert.ok(uriComment.startsWith('//# sourceMappingURL=data:application/json;charset=utf-8,'));
const parsedFromUri = convert.fromComment(uriComment);
assert.deepEqual(parsedFromUri.toObject(), rawMap);
}
// 5. fromSource finds the last inline source map comment from source code or returns null if absent
{
const conv = convert.fromObject(rawMap);
const comment = conv.toComment();
const sourceCode = `function foo() { return 42; }\n${comment}`;
const extracted = convert.fromSource(sourceCode);
assert.ok(extracted);
assert.deepEqual(extracted.toObject(), rawMap);
const noCommentCode = 'function bar() { return 1; }';
assert.equal(convert.fromSource(noCommentCode), null);
}
// 6. removeComments and removeMapFileComments strip inline data URIs and external map file comments from source text
{
const inlineComment = convert.fromObject(rawMap).toComment();
const codeWithInline = `console.log("hello");\n${inlineComment}\n`;
const codeWithoutInline = convert.removeComments(codeWithInline);
assert.equal(codeWithoutInline.trim(), 'console.log("hello");');
const mapFileComment = convert.generateMapFileComment('bundle.js.map');
const codeWithMapFile = `console.log("world");\n${mapFileComment}\n`;
const codeWithoutMapFile = convert.removeMapFileComments(codeWithMapFile);
assert.equal(codeWithoutMapFile.trim(), 'console.log("world");');
}
// 7. generateMapFileComment formats single-line and multi-line sourceMappingURL references to map files
{
const single = convert.generateMapFileComment('app.min.js.map');
assert.equal(single, '//# sourceMappingURL=app.min.js.map');
const multi = convert.generateMapFileComment('app.min.js.map', { multiline: true });
assert.equal(multi, '/*# sourceMappingURL=app.min.js.map */');
}
// 8. fromMapFileComment reads map file content using a custom reader function
{
const comment = '//# sourceMappingURL=mapfile.json';
const readFn = (filename) => {
assert.equal(filename, 'mapfile.json');
return JSON.stringify(rawMap);
};
const conv = convert.fromMapFileComment(comment, readFn);
assert.deepEqual(conv.toObject(), rawMap);
}
原始种子者
匿名