CodeSampleX

Beispiel

@jridgewell/gen-mapping 0.3.13: addMapping

Verifiziertes Beispiel für npm @jridgewell/gen-mapping 0.3.13: addMapping. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:b419ea90c3deab7e58a370513461840ddd0181f479965dbc92c1298347c960c8

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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

Fall

HOW
Ziel
verify @jridgewell/gen-mapping.addMapping in pkg:npm/%40jridgewell/gen-mapping@0.3.13
Pakete
Symbole
  • @jridgewell/gen-mapping.addMapping
Umgebung
node 22.23.2
Erstellt
2026-09-05T13:58:50Z

Contract

  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

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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');

Ursprungs-Seeder

anonym