CodeSampleX

Beispiel

convert-source-map 1.9.0

Verifiziertes Beispiel für npm convert-source-map 1.9.0. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.

sha256:3da0b0fb6d3493e7b5d2ecd2dcc0487399af4afe00f358d3189502ab22103033

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 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-25

Fall

HOW
Ziel
verify pkg:npm/convert-source-map@1.9.0
Pakete
Umgebung
node 22.23.2
Erstellt
2026-08-25T02:37:43Z

Contract

  1. fromObject converts a source map object to a Converter with toComment and toJSON methods
  2. fromComment parses inline line and block sourceMappingURL comments into source map objects
  3. fromJSON and fromBase64 reconstruct source map converters from serialized formats
  4. fromSource extracts embedded inline source map from source code string
  5. removeComments strips inline source map comment annotations from source code
  6. setProperty and getProperty modify and inspect source map metadata properties

Dateien

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • 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 pkg:npm/convert-source-map@1.9.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/convert-source-map@1.9.0

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:d928a57238232f7f02686681914c9f0c7007076e6c2718c8c8718183192e4741","contract":["fromObject converts a source map object to a Converter with toComment and toJSON methods","fromComment parses inline line and block sourceMappingURL comments into source map objects","fromJSON and fromBase64 reconstruct source map converters from serialized formats","fromSource extracts embedded inline source map from source code string","removeComments strips inline source map comment annotations from source code","setProperty and getProperty modify and inspect source map metadata properties"],"goal":"verify pkg:npm/convert-source-map@1.9.0","kind":"HOW","packages":["pkg:npm/convert-source-map@1.9.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","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/convert-source-map@1.9.0"],"schemaVersion":1,"subject":"pkg:npm/convert-source-map@1.9.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-convert-source-map",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-convert-source-map",
      "version": "1.0.0",
      "dependencies": {
        "convert-source-map": "1.9.0"
      }
    },
    "node_modules/convert-source-map": {
      "version": "1.9.0",
      "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz",
      "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-convert-source-map",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of convert-source-map",
  "main": "src/index.js",
  "dependencies": {
    "convert-source-map": "1.9.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/convert-source-map@1.9.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/convert-source-map@1.9.0"
  ]
}
src/index.js
const convertSourceMap = require('convert-source-map');

/**
 * Generate an inline sourceMappingURL comment from a source map object.
 * @param {object} mapObject - Source map object.
 * @param {object} [options] - Generation options.
 * @param {boolean} [options.multiline=false] - Whether to generate a block comment.
 * @returns {string} Inline comment string.
 */
function createSourceMapComment(mapObject, options = {}) {
  const converter = convertSourceMap.fromObject(mapObject);
  return converter.toComment(options);
}

/**
 * Parse a source map object from an inline comment string.
 * @param {string} comment - Inline comment containing source map.
 * @returns {object|null} Parsed source map object, or null if invalid.
 */
function parseSourceMapFromComment(comment) {
  const converter = convertSourceMap.fromComment(comment);
  return converter ? converter.toObject() : null;
}

/**
 * Extract and parse an inline source map from a source code string.
 * @param {string} sourceCode - Source code containing inline source map.
 * @returns {object|null} Parsed source map object, or null if not found.
 */
function parseSourceMapFromSource(sourceCode) {
  const converter = convertSourceMap.fromSource(sourceCode);
  return converter ? converter.toObject() : null;
}

/**
 * Strip inline source map comments from source code.
 * @param {string} sourceCode - Source code containing inline source maps.
 * @returns {string} Source code without inline source map comments.
 */
function stripSourceMapComments(sourceCode) {
  return convertSourceMap.removeComments(sourceCode);
}

/**
 * Set a metadata property on a source map object.
 * @param {object} mapObject - Source map object.
 * @param {string} key - Property name.
 * @param {any} value - Property value.
 * @returns {object} Updated source map object.
 */
function modifySourceMapProperty(mapObject, key, value) {
  const converter = convertSourceMap.fromObject(mapObject);
  converter.setProperty(key, value);
  return converter.toObject();
}

module.exports = {
  convertSourceMap,
  createSourceMapComment,
  parseSourceMapFromComment,
  parseSourceMapFromSource,
  stripSourceMapComments,
  modifySourceMapProperty
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  convertSourceMap,
  createSourceMapComment,
  parseSourceMapFromComment,
  parseSourceMapFromSource,
  stripSourceMapComments,
  modifySourceMapProperty
} = require('../src/index.js');

// 1. Export verification
assert.strictEqual(typeof convertSourceMap, 'object', 'convertSourceMap should be exported');
assert.strictEqual(typeof convertSourceMap.fromObject, 'function', 'fromObject should be a function');
assert.strictEqual(typeof convertSourceMap.fromJSON, 'function', 'fromJSON should be a function');
assert.strictEqual(typeof convertSourceMap.fromBase64, 'function', 'fromBase64 should be a function');
assert.strictEqual(typeof convertSourceMap.fromComment, 'function', 'fromComment should be a function');
assert.strictEqual(typeof convertSourceMap.fromSource, 'function', 'fromSource should be a function');
assert.strictEqual(typeof convertSourceMap.removeComments, 'function', 'removeComments should be a function');
assert.strictEqual(typeof createSourceMapComment, 'function', 'createSourceMapComment should be a function');
assert.strictEqual(typeof parseSourceMapFromComment, 'function', 'parseSourceMapFromComment should be a function');
assert.strictEqual(typeof parseSourceMapFromSource, 'function', 'parseSourceMapFromSource should be a function');
assert.strictEqual(typeof stripSourceMapComments, 'function', 'stripSourceMapComments should be a function');
assert.strictEqual(typeof modifySourceMapProperty, 'function', 'modifySourceMapProperty should be a function');

// 2. fromObject converts a source map object to a Converter with toComment and toJSON methods
const sampleMap = {
  version: 3,
  file: 'output.js',
  sources: ['input.js'],
  mappings: 'AAAA;'
};
const conv = convertSourceMap.fromObject(sampleMap);
assert.deepStrictEqual(conv.toObject(), sampleMap);
assert.strictEqual(typeof conv.toJSON(), 'string');
assert.strictEqual(typeof conv.toBase64(), 'string');

const lineComment = conv.toComment();
assert.ok(lineComment.startsWith('//# sourceMappingURL=data:application/json;charset=utf-8;base64,'));
const blockComment = conv.toComment({ multiline: true });
assert.ok(blockComment.startsWith('/*# sourceMappingURL=data:application/json;charset=utf-8;base64,'));
assert.ok(blockComment.endsWith('*/'));

// 3. fromComment parses inline line and block sourceMappingURL comments into source map objects
const parsedLine = parseSourceMapFromComment(lineComment);
assert.deepStrictEqual(parsedLine, sampleMap);

const parsedBlock = parseSourceMapFromComment(blockComment);
assert.deepStrictEqual(parsedBlock, sampleMap);

// 4. fromJSON and fromBase64 reconstruct source map converters from serialized formats
const jsonString = JSON.stringify(sampleMap);
const fromJsonConv = convertSourceMap.fromJSON(jsonString);
assert.deepStrictEqual(fromJsonConv.toObject(), sampleMap);

const base64String = Buffer.from(jsonString).toString('base64');
const fromBase64Conv = convertSourceMap.fromBase64(base64String);
assert.deepStrictEqual(fromBase64Conv.toObject(), sampleMap);

// 5. fromSource extracts embedded inline source map from source code string
const sampleCode = 'function hello() { return 1; }\n' + lineComment;
const parsedFromCode = parseSourceMapFromSource(sampleCode);
assert.deepStrictEqual(parsedFromCode, sampleMap);

// 6. removeComments strips inline source map comment annotations from source code
const stripped = stripSourceMapComments(sampleCode);
assert.strictEqual(stripped, 'function hello() { return 1; }\n');
assert.strictEqual(convertSourceMap.fromSource(stripped), null);

// 7. setProperty and getProperty modify and inspect source map metadata properties
const updatedMap = modifySourceMapProperty(sampleMap, 'sourcesContent', ['function hello() {}']);
assert.deepStrictEqual(updatedMap.sourcesContent, ['function hello() {}']);
assert.strictEqual(updatedMap.version, 3);
assert.strictEqual(updatedMap.file, 'output.js');

console.log('Contract tests passed successfully.');

Ursprungs-Seeder

anonym