CodeSampleX

샘플

@jridgewell/gen-mapping 0.3.13: addMapping

검증된 샘플 — npm @jridgewell/gen-mapping 0.3.13: addMapping. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: addMapping associates generated 1-based…

sha256:b419ea90c3deab7e58a370513461840ddd0181f479965dbc92c1298347c960c8

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

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
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-05

케이스

HOW
목표
verify @jridgewell/gen-mapping.addMapping in pkg:npm/%40jridgewell/gen-mapping@0.3.13
패키지
심벌
  • @jridgewell/gen-mapping.addMapping
환경
node 22.23.2
생성일
2026-09-05T13:58:50Z

컨트랙트

  1. addMapping associates generated 1-based line and 0-based column with original positions
  2. addMapping creates sourceless 1-field segments when source is omitted
  3. addMapping associates identifier names creating 5-field segments and registers symbol names
  4. addMapping optionally populates inline source content for mapped source files
  5. addMapping maintains column sort order when inserting mappings out of order on the same line
  6. addMapping supports multi-line generated positions producing segmented decoded mappings

파일

  • 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 @jridgewell/gen-mapping.addMapping in 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
Demonstrate these symbols/APIs:
  - @jridgewell/gen-mapping.addMapping
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:2bf81508d0896a51bab08398c45547c817b0154ab24d6c0c246f5c1396370541","constraints":{"executionContext":"node"},"contract":["addMapping associates generated 1-based line and 0-based column with original positions","addMapping creates sourceless 1-field segments when source is omitted","addMapping associates identifier names creating 5-field segments and registers symbol names","addMapping optionally populates inline source content for mapped source files","addMapping maintains column sort order when inserting mappings out of order on the same line","addMapping supports multi-line generated positions producing segmented decoded mappings"],"goal":"verify @jridgewell/gen-mapping.addMapping in pkg:npm/%40jridgewell/gen-mapping@0.3.13","kind":"HOW","packages":["pkg:npm/%40jridgewell/gen-mapping@0.3.13"],"schemaVersion":1,"symbols":["@jridgewell/gen-mapping.addMapping"]},"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/%40jridgewell/gen-mapping@0.3.13"],"schemaVersion":1,"subject":"pkg:npm/%40jridgewell/gen-mapping@0.3.13","symbols":["@jridgewell/gen-mapping.addMapping"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "gen-mapping-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "gen-mapping-sample",
      "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.6.0",
      "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz",
      "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==",
      "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": "gen-mapping-sample",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for @jridgewell/gen-mapping",
  "dependencies": {
    "@jridgewell/gen-mapping": "0.3.13"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @jridgewell/gen-mapping.addMapping in pkg:npm/%40jridgewell/gen-mapping@0.3.13",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40jridgewell/gen-mapping@0.3.13"
  ],
  "symbols": [
    "@jridgewell/gen-mapping.addMapping"
  ],
  "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';
import {
  GenMapping,
  addMapping,
  toDecodedMap,
  toEncodedMap,
  allMappings,
} from '@jridgewell/gen-mapping';

// 1. addMapping associates generated 1-based line and 0-based column with original positions
{
  const map = new GenMapping();
  addMapping(map, {
    generated: { line: 1, column: 0 },
    source: 'foo.js',
    original: { line: 1, column: 0 },
  });
  const decoded = toDecodedMap(map);
  assert.deepStrictEqual(decoded.sources, ['foo.js']);
  // Line index 0 in decoded.mappings corresponds to generated line 1.
  // Segment: [genColumn, sourceIndex, originalLine (0-based), originalColumn (0-based)]
  assert.deepStrictEqual(decoded.mappings[0], [[0, 0, 0, 0]]);
  const mappings = allMappings(map);
  assert.strictEqual(mappings.length, 1);
  assert.deepStrictEqual(mappings[0], {
    generated: { line: 1, column: 0 },
    source: 'foo.js',
    original: { line: 1, column: 0 },
    name: undefined,
  });
}

// 2. addMapping creates sourceless 1-field segments when source is omitted
{
  const map = new GenMapping();
  addMapping(map, {
    generated: { line: 1, column: 4 },
  });
  const decoded = toDecodedMap(map);
  // Sourceless segment only contains generated column: [4]
  assert.deepStrictEqual(decoded.mappings[0], [[4]]);
  const mappings = allMappings(map);
  assert.strictEqual(mappings.length, 1);
  assert.deepStrictEqual(mappings[0], {
    generated: { line: 1, column: 4 },
    source: undefined,
    original: undefined,
    name: undefined,
  });
}

// 3. addMapping associates identifier names creating 5-field segments and registers symbol names
{
  const map = new GenMapping();
  addMapping(map, {
    generated: { line: 1, column: 10 },
    source: 'bar.js',
    original: { line: 5, column: 2 },
    name: 'calculateTotal',
  });
  const decoded = toDecodedMap(map);
  assert.deepStrictEqual(decoded.names, ['calculateTotal']);
  // Segment: [genCol, sourceIdx, origLine(0-based=4), origCol(0-based=2), nameIdx(0)]
  assert.deepStrictEqual(decoded.mappings[0], [[10, 0, 4, 2, 0]]);
  const mappings = allMappings(map);
  assert.strictEqual(mappings.length, 1);
  assert.deepStrictEqual(mappings[0], {
    generated: { line: 1, column: 10 },
    source: 'bar.js',
    original: { line: 5, column: 2 },
    name: 'calculateTotal',
  });
}

// 4. addMapping optionally populates inline source content for mapped source files
{
  const map = new GenMapping();
  const sourceCode = 'const x = 42;';
  addMapping(map, {
    generated: { line: 1, column: 0 },
    source: 'inline.js',
    original: { line: 1, column: 0 },
    content: sourceCode,
  });
  const decoded = toDecodedMap(map);
  assert.deepStrictEqual(decoded.sources, ['inline.js']);
  assert.deepStrictEqual(decoded.sourcesContent, [sourceCode]);
}

// 5. addMapping maintains column sort order when inserting mappings out of order on the same line
{
  const map = new GenMapping();
  // Insert column 20 first, then column 5
  addMapping(map, {
    generated: { line: 1, column: 20 },
    source: 'order.js',
    original: { line: 1, column: 20 },
  });
  addMapping(map, {
    generated: { line: 1, column: 5 },
    source: 'order.js',
    original: { line: 1, column: 5 },
  });
  const decoded = toDecodedMap(map);
  // Column 5 should be sorted before column 20
  assert.strictEqual(decoded.mappings[0].length, 2);
  assert.strictEqual(decoded.mappings[0][0][0], 5);
  assert.strictEqual(decoded.mappings[0][1][0], 20);
}

// 6. addMapping supports multi-line generated positions producing segmented decoded mappings
{
  const map = new GenMapping({ file: 'output.js' });
  addMapping(map, {
    generated: { line: 1, column: 0 },
    source: 'src.js',
    original: { line: 10, column: 0 },
  });
  addMapping(map, {
    generated: { line: 2, column: 4 },
    source: 'src.js',
    original: { line: 20, column: 2 },
  });
  const decoded = toDecodedMap(map);
  assert.strictEqual(decoded.mappings.length, 2);
  assert.deepStrictEqual(decoded.mappings[0], [[0, 0, 9, 0]]);
  assert.deepStrictEqual(decoded.mappings[1], [[4, 0, 19, 2]]);

  const encoded = toEncodedMap(map);
  assert.strictEqual(encoded.version, 3);
  assert.strictEqual(encoded.file, 'output.js');
  assert.strictEqual(typeof encoded.mappings, 'string');
}

console.log('Contract passed');

오리진 시더

익명