CodeSampleX

샘플

@jridgewell/gen-mapping 0.3.13

검증된 샘플 — npm @jridgewell/gen-mapping 0.3.13. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: GenMapping constructor initializes a source map…

sha256:68d72d35fab28d6e8939bc2e71688369f35ca601ce45691af4ec70e4939bbe16

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

케이스

HOW
목표
verify pkg:npm/%40jridgewell/gen-mapping@0.3.13
패키지
환경
node 22.23.2
생성일
2026-08-24T20:26:01Z

컨트랙트

  1. GenMapping constructor initializes a source map instance with optional file and sourceRoot
  2. addMapping associates 1-based generated positions with original source positions and optional symbol names
  3. addSegment associates 0-based generated coordinates directly with original source coordinates
  4. maybeAddMapping skips redundant consecutive mappings with identical original positions
  5. setSourceContent embeds original file content into sourcesContent
  6. setIgnore marks source file indices in ignoreList for debugger filtering
  7. toDecodedMap exports source map with decoded segment coordinate arrays
  8. toEncodedMap exports source map with VLQ encoded mappings string
  9. allMappings returns array of high-level mapping objects for all recorded segments
  10. fromMap initializes a new GenMapping instance pre-populated from an existing source map

파일

  • 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/%40jridgewell/gen-mapping@0.3.13
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40jridgewell/gen-mapping@0.3.13
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:7bf65b0081c919194e5c784e8c30d9ae87e5b0524dde78689584f57b79f8f219","constraints":{"executionContext":"node"},"contract":["GenMapping constructor initializes a source map instance with optional file and sourceRoot","addMapping associates 1-based generated positions with original source positions and optional symbol names","addSegment associates 0-based generated coordinates directly with original source coordinates","maybeAddMapping skips redundant consecutive mappings with identical original positions","setSourceContent embeds original file content into sourcesContent","setIgnore marks source file indices in ignoreList for debugger filtering","toDecodedMap exports source map with decoded segment coordinate arrays","toEncodedMap exports source map with VLQ encoded mappings string","allMappings returns array of high-level mapping objects for all recorded segments","fromMap initializes a new GenMapping instance pre-populated from an existing source map"],"goal":"verify pkg:npm/%40jridgewell/gen-mapping@0.3.13","kind":"HOW","packages":["pkg:npm/%40jridgewell/gen-mapping@0.3.13"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","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/gen-mapping@0.3.13"],"schemaVersion":1,"subject":"pkg:npm/%40jridgewell/gen-mapping@0.3.13","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-gen-mapping",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-gen-mapping",
      "version": "1.0.0",
      "dependencies": {
        "@jridgewell/gen-mapping": "0.3.13"
      }
    },
    "node_modules/@jridgewell/gen-mapping": {
      "version": "0.3.13",
      "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
      "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
      "license": "MIT",
      "dependencies": {
        "@jridgewell/sourcemap-codec": "^1.5.0",
        "@jridgewell/trace-mapping": "^0.3.24"
      }
    },
    "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"
      }
    }
  }
}
package.json
{
  "name": "sample-gen-mapping",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "@jridgewell/gen-mapping": "0.3.13"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40jridgewell/gen-mapping@0.3.13",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40jridgewell/gen-mapping@0.3.13"
  ],
  "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 {
  GenMapping,
  addMapping,
  addSegment,
  maybeAddMapping,
  maybeAddSegment,
  setSourceContent,
  setIgnore,
  toDecodedMap,
  toEncodedMap,
  fromMap,
  allMappings,
} from '@jridgewell/gen-mapping';

// 1. GenMapping constructor initializes a source map instance with optional file and sourceRoot
{
  const map = new GenMapping({ file: 'output.js', sourceRoot: 'https://example.com/src' });
  assert.equal(map.file, 'output.js');
  assert.equal(map.sourceRoot, 'https://example.com/src');
  const decoded = toDecodedMap(map);
  assert.equal(decoded.version, 3);
  assert.equal(decoded.file, 'output.js');
  assert.equal(decoded.sourceRoot, 'https://example.com/src');
  assert.deepEqual(decoded.sources, []);
  assert.deepEqual(decoded.names, []);
  assert.deepEqual(decoded.mappings, []);
}

// 2. addMapping associates 1-based generated positions with original source positions and optional symbol names
{
  const map = new GenMapping({ file: 'bundle.js' });
  addMapping(map, {
    generated: { line: 1, column: 0 },
    source: 'foo.js',
    original: { line: 1, column: 0 },
  });
  addMapping(map, {
    generated: { line: 1, column: 10 },
    source: 'foo.js',
    original: { line: 1, column: 5 },
    name: 'bar',
  });

  const decoded = toDecodedMap(map);
  assert.deepEqual(decoded.sources, ['foo.js']);
  assert.deepEqual(decoded.names, ['bar']);
  assert.deepEqual(decoded.mappings, [
    [
      [0, 0, 0, 0],
      [10, 0, 0, 5, 0],
    ],
  ]);
}

// 3. addSegment associates 0-based generated coordinates directly with original source coordinates
{
  const map = new GenMapping();
  addSegment(map, 0, 0, 'input.js', 0, 0);
  addSegment(map, 0, 5, 'input.js', 0, 5, 'greet');
  addSegment(map, 1, 0, 'input.js', 1, 0);

  const decoded = toDecodedMap(map);
  assert.equal(decoded.mappings.length, 2);
  assert.deepEqual(decoded.mappings[0], [
    [0, 0, 0, 0],
    [5, 0, 0, 5, 0],
  ]);
  assert.deepEqual(decoded.mappings[1], [
    [0, 0, 1, 0],
  ]);
}

// 4. maybeAddMapping skips redundant consecutive mappings with identical original positions
{
  const map = new GenMapping();
  maybeAddMapping(map, {
    generated: { line: 1, column: 0 },
    source: 'a.js',
    original: { line: 1, column: 0 },
  });
  maybeAddMapping(map, {
    generated: { line: 1, column: 4 },
    source: 'a.js',
    original: { line: 1, column: 0 },
  });
  const decoded = toDecodedMap(map);
  assert.equal(decoded.mappings[0].length, 1);
}

// 5. setSourceContent embeds original file content into sourcesContent
{
  const map = new GenMapping();
  addSegment(map, 0, 0, 'a.js', 0, 0);
  setSourceContent(map, 'a.js', 'const x = 1;');

  const decoded = toDecodedMap(map);
  assert.deepEqual(decoded.sourcesContent, ['const x = 1;']);

  const encoded = toEncodedMap(map);
  assert.deepEqual(encoded.sourcesContent, ['const x = 1;']);
}

// 6. setIgnore marks source file indices in ignoreList for debugger filtering
{
  const map = new GenMapping();
  addSegment(map, 0, 0, 'node_modules/dep/index.js', 0, 0);
  addSegment(map, 0, 10, 'src/index.js', 0, 0);
  setIgnore(map, 'node_modules/dep/index.js', true);

  const decoded = toDecodedMap(map);
  assert.deepEqual(decoded.ignoreList, [0]);

  const encoded = toEncodedMap(map);
  assert.deepEqual(encoded.ignoreList, [0]);
}

// 7. toDecodedMap exports source map with decoded segment coordinate arrays
{
  const map = new GenMapping({ file: 'min.js' });
  addSegment(map, 0, 0, 'src.js', 0, 0);
  const decoded = toDecodedMap(map);
  assert.equal(decoded.file, 'min.js');
  assert.ok(Array.isArray(decoded.mappings));
  assert.ok(Array.isArray(decoded.mappings[0]));
  assert.deepEqual(decoded.mappings[0][0], [0, 0, 0, 0]);
}

// 8. toEncodedMap exports source map with VLQ encoded mappings string
{
  const map = new GenMapping({ file: 'min.js' });
  addSegment(map, 0, 0, 'src.js', 0, 0);
  const encoded = toEncodedMap(map);
  assert.equal(encoded.file, 'min.js');
  assert.equal(typeof encoded.mappings, 'string');
  assert.ok(encoded.mappings.length > 0);
}

// 9. allMappings returns array of high-level mapping objects for all recorded segments
{
  const map = new GenMapping();
  addMapping(map, {
    generated: { line: 1, column: 0 },
    source: 'foo.js',
    original: { line: 2, column: 4 },
    name: 'testVar',
  });

  const mappings = allMappings(map);
  assert.equal(mappings.length, 1);
  assert.deepEqual(mappings[0], {
    generated: { line: 1, column: 0 },
    source: 'foo.js',
    original: { line: 2, column: 4 },
    name: 'testVar',
  });
}

// 10. fromMap initializes a new GenMapping instance pre-populated from an existing source map
{
  const original = new GenMapping({ file: 'out.js' });
  addMapping(original, {
    generated: { line: 1, column: 0 },
    source: 'src.js',
    original: { line: 1, column: 0 },
  });
  const encoded = toEncodedMap(original);

  const cloned = fromMap(encoded);
  addMapping(cloned, {
    generated: { line: 2, column: 0 },
    source: 'src.js',
    original: { line: 2, column: 0 },
  });

  const decoded = toDecodedMap(cloned);
  assert.equal(decoded.file, 'out.js');
  assert.equal(decoded.mappings.length, 2);
}

오리진 시더

익명