CodeSampleX

Beispiel

@jridgewell/source-map 0.3.11: generate and consume source maps with SourceMapGenerator and SourceMapConsumer

Verifiziertes Beispiel für npm @jridgewell/source-map 0.3.11: generate and consume source maps with SourceMapGenerator and SourceMapConsumer. Der Vertrag…

sha256:cd955a15d9d14491fcf327dc93d2cf371536158c5ee4c3392cab4b18e4c4d544

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 linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

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

Fall

HOW
Ziel
generate and consume source maps with SourceMapGenerator and SourceMapConsumer
Pakete
Symbole
  • SourceMapConsumer
  • SourceMapGenerator
Erstellt
2026-08-27T23:46:02Z

Contract

  1. SourceMapGenerator generates v3 source map with mappings and embedded sourcesContent
  2. SourceMapConsumer resolves originalPositionFor with mapped line column and symbol name
  3. SourceMapConsumer resolves generatedPositionFor matching original line and column
  4. SourceMapConsumer retrieves original source code via sourceContentFor

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: generate and consume source maps with SourceMapGenerator and SourceMapConsumer
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40jridgewell/source-map@0.3.11
Demonstrate these symbols/APIs:
  - SourceMapConsumer
  - SourceMapGenerator

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:cbd03d708bf1f1fcfb6144c4ef3b5578df3f1dec78c10b972a9ba977d05dd5aa","contract":["SourceMapGenerator generates v3 source map with mappings and embedded sourcesContent","SourceMapConsumer resolves originalPositionFor with mapped line column and symbol name","SourceMapConsumer resolves generatedPositionFor matching original line and column","SourceMapConsumer retrieves original source code via sourceContentFor"],"goal":"generate and consume source maps with SourceMapGenerator and SourceMapConsumer","kind":"HOW","packages":["pkg:npm/%40jridgewell/source-map@0.3.11"],"schemaVersion":1,"symbols":["SourceMapConsumer","SourceMapGenerator"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40jridgewell/source-map@0.3.11"],"schemaVersion":1,"subject":"pkg:npm/%40jridgewell/source-map@0.3.11","symbols":["SourceMapConsumer","SourceMapGenerator"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-source-map",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-source-map",
      "version": "1.0.0",
      "dependencies": {
        "@jridgewell/source-map": "0.3.11"
      }
    },
    "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/source-map": {
      "version": "0.3.11",
      "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz",
      "integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==",
      "license": "MIT",
      "dependencies": {
        "@jridgewell/gen-mapping": "^0.3.5",
        "@jridgewell/trace-mapping": "^0.3.25"
      }
    },
    "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-source-map",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "@jridgewell/source-map": "0.3.11"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "generate and consume source maps with SourceMapGenerator and SourceMapConsumer",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40jridgewell/source-map@0.3.11"
  ],
  "symbols": [
    "SourceMapConsumer",
    "SourceMapGenerator"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { SourceMapGenerator, SourceMapConsumer } from '@jridgewell/source-map';

// 1. Generate source map with SourceMapGenerator
const generator = new SourceMapGenerator({
  file: 'bundle.js',
  sourceRoot: 'https://example.com/src/'
});

const originalCode = 'function hello() {\n  console.log("world");\n}\n';
generator.setSourceContent('hello.js', originalCode);

generator.addMapping({
  source: 'hello.js',
  original: { line: 2, column: 2 },
  generated: { line: 1, column: 18 },
  name: 'console'
});

const rawMap = generator.toJSON();

assert.equal(rawMap.version, 3);
assert.equal(rawMap.file, 'bundle.js');
assert.equal(rawMap.sourceRoot, 'https://example.com/src/');
assert.deepEqual(rawMap.sources, ['hello.js']);
assert.deepEqual(rawMap.sourcesContent, [originalCode]);
assert.ok(typeof rawMap.mappings === 'string');

// 2. Query original position with SourceMapConsumer
const consumer = new SourceMapConsumer(rawMap);

const origPos = consumer.originalPositionFor({ line: 1, column: 18 });
assert.equal(origPos.source, 'https://example.com/src/hello.js');
assert.equal(origPos.line, 2);
assert.equal(origPos.column, 2);
assert.equal(origPos.name, 'console');

// 3. Query generated position with SourceMapConsumer
const genPos = consumer.generatedPositionFor({
  source: 'hello.js',
  line: 2,
  column: 2
});
assert.equal(genPos.line, 1);
assert.equal(genPos.column, 18);

// 4. Retrieve source content with SourceMapConsumer
const retrievedSource = consumer.sourceContentFor('hello.js');
assert.equal(retrievedSource, originalCode);

consumer.destroy();
console.log('Contract passed');

Ursprungs-Seeder

anonym