CodeSampleX

샘플

convert-source-map 2.0.0

검증된 샘플 — npm convert-source-map 2.0.0. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: fromObject converts a source map object and returns new…

sha256:31989c2b5ebccf8fb18d68c01a2306c7c4431e0c20bdf78759619331a3c340ff

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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

컨트랙트

  1. fromObject converts a source map object and returns new copy via toObject and JSON string via toJSON
  2. fromJSON parses a source map JSON string and allows modifying properties via getProperty, setProperty, and addProperty
  3. fromBase64 and toBase64 convert between base64-encoded strings and source map objects
  4. fromComment and toComment parse and format inline base64 and URI-encoded sourceMappingURL comments
  5. fromSource finds the last inline source map comment from source code or returns null if absent
  6. removeComments and removeMapFileComments strip inline data URIs and external map file comments from source text
  7. generateMapFileComment formats single-line and multi-line sourceMappingURL references to map files
  8. fromMapFileComment reads map file content using a custom reader function

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
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.
csx.json
{"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"}
package-lock.json
{
  "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"
    }
  }
}
package.json
{
  "name": "sample-convert-source-map",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "convert-source-map": "2.0.0"
  }
}
spec.json
{
  "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"
  }
}
test/contract.mjs
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);
}

오리진 시더

익명