CodeSampleX

Sample

@jridgewell/gen-mapping 0.3.13: toEncodedMap

Verified sample for npm @jridgewell/gen-mapping 0.3.13: toEncodedMap. The contract ran on node 22 · linux debian/x64 · docker and passed.

sha256:5fd65a553a8d2f8bf579fc93f336209380a64ad0ef0443ccd66d8ebf1b69991e

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
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

Case

HOW
Goal
verify @jridgewell/gen-mapping.toEncodedMap in pkg:npm/%40jridgewell/gen-mapping@0.3.13
Packages
Symbols
  • @jridgewell/gen-mapping.toEncodedMap
Environment
node 22.23.2
Created
2026-09-05T15:36:52Z

Contract

  1. toEncodedMap returns an EncodedSourceMap object with version 3 and VLQ encoded mappings
  2. toEncodedMap serializes source mappings and symbol names correctly into VLQ encoded format
  3. toEncodedMap includes optional file, sourceRoot, sourcesContent, and ignoreList metadata
  4. toEncodedMap produces an empty mappings string when no mappings are added to GenMapping

Files

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

Download the source artifact (tar.gz)

Source

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.toEncodedMap 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.toEncodedMap

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:d63b9baf94d7c8c7335b908747d1949c8c5e0b82cf5e746d1c4c56bdeb027646","constraints":{"executionContext":"node"},"contract":["toEncodedMap returns an EncodedSourceMap object with version 3 and VLQ encoded mappings","toEncodedMap serializes source mappings and symbol names correctly into VLQ encoded format","toEncodedMap includes optional file, sourceRoot, sourcesContent, and ignoreList metadata","toEncodedMap produces an empty mappings string when no mappings are added to GenMapping"],"goal":"verify @jridgewell/gen-mapping.toEncodedMap 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.toEncodedMap"]},"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.toEncodedMap"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-gen-mapping-to-encoded-map",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-gen-mapping-to-encoded-map",
      "version": "1.0.0",
      "license": "MIT-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": "sample-gen-mapping-to-encoded-map",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "@jridgewell/gen-mapping": "0.3.13"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @jridgewell/gen-mapping.toEncodedMap in pkg:npm/%40jridgewell/gen-mapping@0.3.13",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40jridgewell/gen-mapping@0.3.13"
  ],
  "symbols": [
    "@jridgewell/gen-mapping.toEncodedMap"
  ]
}
src/index.mjs
import {
  GenMapping,
  addMapping,
  addSegment,
  setSourceContent,
  setIgnore,
  toEncodedMap
} from "@jridgewell/gen-mapping";

export function createGenMapping(options = {}) {
  return new GenMapping(options);
}

export function encodeMapping(map) {
  return toEncodedMap(map);
}

export {
  GenMapping,
  addMapping,
  addSegment,
  setSourceContent,
  setIgnore,
  toEncodedMap
};
test/contract.mjs
import assert from "node:assert/strict";
import {
  GenMapping,
  addMapping,
  setSourceContent,
  setIgnore,
  toEncodedMap,
  createGenMapping,
  encodeMapping
} from "../src/index.mjs";

// Test 1: toEncodedMap returns an EncodedSourceMap object with version 3 and VLQ encoded mappings
{
  const map = createGenMapping({
    file: "output.js",
    sourceRoot: "https://example.com/src"
  });
  addMapping(map, {
    generated: { line: 1, column: 0 },
    source: "input.js",
    original: { line: 1, column: 0 }
  });

  const encoded = encodeMapping(map);
  assert.equal(encoded.version, 3);
  assert.equal(encoded.file, "output.js");
  assert.equal(encoded.sourceRoot, "https://example.com/src");
  assert.equal(typeof encoded.mappings, "string");
  assert.equal(encoded.mappings, "AAAA");
  assert.deepEqual(encoded.sources, ["input.js"]);
}

// Test 2: toEncodedMap serializes source mappings and symbol names correctly into VLQ encoded format
{
  const map = new GenMapping();
  addMapping(map, {
    generated: { line: 1, column: 0 },
    source: "index.js",
    original: { line: 1, column: 0 },
    name: "init"
  });
  addMapping(map, {
    generated: { line: 2, column: 4 },
    source: "index.js",
    original: { line: 2, column: 2 },
    name: "start"
  });

  const encoded = toEncodedMap(map);
  assert.deepEqual(encoded.names, ["init", "start"]);
  assert.equal(encoded.mappings, "AAAAA;IACEC");
  assert.deepEqual(encoded.sources, ["index.js"]);
}

// Test 3: toEncodedMap includes optional file, sourceRoot, sourcesContent, and ignoreList metadata
{
  const map = new GenMapping({
    file: "minified.js",
    sourceRoot: "https://example.com/dist"
  });
  setSourceContent(map, "lib.js", "export function run() {}");
  setIgnore(map, "lib.js", true);
  addMapping(map, {
    generated: { line: 1, column: 0 },
    source: "lib.js",
    original: { line: 1, column: 0 }
  });

  const encoded = toEncodedMap(map);
  assert.equal(encoded.file, "minified.js");
  assert.equal(encoded.sourceRoot, "https://example.com/dist");
  assert.deepEqual(encoded.sourcesContent, ["export function run() {}"]);
  assert.deepEqual(encoded.ignoreList, [0]);
}

// Test 4: toEncodedMap produces an empty mappings string when no mappings are added to GenMapping
{
  const map = new GenMapping();
  const encoded = toEncodedMap(map);

  assert.equal(encoded.version, 3);
  assert.equal(encoded.mappings, "");
  assert.deepEqual(encoded.names, []);
  assert.deepEqual(encoded.sources, []);
  assert.deepEqual(encoded.sourcesContent, []);
}

console.log("All @jridgewell/gen-mapping.toEncodedMap contract tests passed successfully.");

Origin Seeder

anonymous