CodeSampleX

Beispiel

@img/sharp-wasm32 0.35.5

Verifiziertes Beispiel für npm @img/sharp-wasm32 0.35.5. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:37be7902f1d5146741e98b84d9bd610b172070d12c7ddd51ecf983cd25057608

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-11-23

Fall

HOW
Ziel
verify pkg:npm/%40img/sharp-wasm32@0.35.5
Pakete
Umgebung
node 22.23.2
Erstellt
2026-11-23T17:22:52Z

Contract

  1. require('@img/sharp-wasm32') throws ERR_PACKAGE_PATH_NOT_EXPORTED because the package exposes subpath exports ./sharp.node, ./versions, and ./package
  2. require('@img/sharp-wasm32/sharp.node').libvipsVersion() returns { semver: '8.18.7', isGlobal: false, isWasm: true } matching require('@img/sharp-wasm32/versions').vips
  3. sharpWasm.format() reports buffer input and output support for png, jpeg, and webp
  4. sharpWasm.cache(50, 20, 100), sharpWasm.concurrency(2), sharpWasm.simd(false), and sharpWasm.counters() configure and query the WebAssembly libvips runtime
  5. sharpWasm.metadata(options, cb) decodes an in-memory 1x1 RGB PNG buffer to { format: 'png', width: 1, height: 1, space: 'srgb', channels: 3, depth: 'uchar', hasAlpha: false }
  6. sharpWasm.stats(options, cb) reports isOpaque: true, 3 channels, and red-dominant RGB on a 1x1 red PNG buffer
  7. sharpWasm.metadata(options, cb) passes an Error to the callback for non-image bytes

Dateien

  • PROMPT.md
  • csx.json
  • index.js
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.cjs

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/%40img/sharp-wasm32@0.35.5
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40img/sharp-wasm32@0.35.5
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:9844379ef21152156398e16a3ceb9aa670106bd675a6b6664dc8766d314c9c4c","constraints":{"executionContext":"node"},"contract":["require('@img/sharp-wasm32') throws ERR_PACKAGE_PATH_NOT_EXPORTED because the package exposes subpath exports ./sharp.node, ./versions, and ./package","require('@img/sharp-wasm32/sharp.node').libvipsVersion() returns { semver: '8.18.7', isGlobal: false, isWasm: true } matching require('@img/sharp-wasm32/versions').vips","sharpWasm.format() reports buffer input and output support for png, jpeg, and webp","sharpWasm.cache(50, 20, 100), sharpWasm.concurrency(2), sharpWasm.simd(false), and sharpWasm.counters() configure and query the WebAssembly libvips runtime","sharpWasm.metadata(options, cb) decodes an in-memory 1x1 RGB PNG buffer to { format: 'png', width: 1, height: 1, space: 'srgb', channels: 3, depth: 'uchar', hasAlpha: false }","sharpWasm.stats(options, cb) reports isOpaque: true, 3 channels, and red-dominant RGB on a 1x1 red PNG buffer","sharpWasm.metadata(options, cb) passes an Error to the callback for non-image bytes"],"goal":"verify pkg:npm/%40img/sharp-wasm32@0.35.5","kind":"HOW","packages":["pkg:npm/%40img/sharp-wasm32@0.35.5"],"schemaVersion":1},"contractCommand":["node","test/contract.cjs"],"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/%40img/sharp-wasm32@0.35.5"],"schemaVersion":1,"subject":"pkg:npm/%40img/sharp-wasm32@0.35.5","verifierAdapter":"node-typescript@1"}
index.js
'use strict';

const sharpWasm = require('@img/sharp-wasm32/sharp.node');
const versions = require('@img/sharp-wasm32/versions');

function createInputOptions(buffer) {
  return {
    input: {
      buffer,
      failOn: 'warning',
      limitInputPixels: 268402689,
      limitInputChannels: 4,
      unlimited: false,
      autoOrient: false
    },
    debuglog: () => {}
  };
}

function readMetadata(buffer) {
  return new Promise((resolve, reject) => {
    sharpWasm.metadata(createInputOptions(buffer), (err, info) => {
      if (err) {
        reject(err);
        return;
      }
      resolve(info);
    });
  });
}

function readStats(buffer) {
  return new Promise((resolve, reject) => {
    sharpWasm.stats(createInputOptions(buffer), (err, stats) => {
      if (err) {
        reject(err);
        return;
      }
      resolve(stats);
    });
  });
}

module.exports = {
  sharpWasm,
  versions,
  readMetadata,
  readStats
};
package-lock.json
{
  "name": "sharp-wasm32-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sharp-wasm32-sample",
      "version": "1.0.0",
      "dependencies": {
        "@img/sharp-wasm32": "0.35.5"
      }
    },
    "node_modules/@emnapi/runtime": {
      "version": "1.11.3",
      "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz",
      "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==",
      "license": "MIT",
      "dependencies": {
        "tslib": "^2.4.0"
      }
    },
    "node_modules/@img/sharp-wasm32": {
      "version": "0.35.5",
      "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.5.tgz",
      "integrity": "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==",
      "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
      "dependencies": {
        "@emnapi/runtime": "^1.11.3"
      },
      "engines": {
        "node": ">=20.9.0"
      },
      "funding": {
        "url": "https://opencollective.com/libvips"
      }
    },
    "node_modules/tslib": {
      "version": "2.9.1",
      "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz",
      "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==",
      "license": "0BSD"
    }
  }
}
package.json
{
  "name": "sharp-wasm32-sample",
  "version": "1.0.0",
  "private": true,
  "type": "commonjs",
  "scripts": {
    "test": "node test/contract.cjs"
  },
  "dependencies": {
    "@img/sharp-wasm32": "0.35.5"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40img/sharp-wasm32@0.35.5",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40img/sharp-wasm32@0.35.5"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.cjs
'use strict';

const assert = require('node:assert/strict');
const { sharpWasm, versions, readMetadata, readStats } = require('../index.js');

// Valid 1x1 red RGB PNG encoded offline
const PNG_1X1_RED = Buffer.from(
  '89504e470d0a1a0a0000000d4948445200000001000000010802000000907753de' +
  '0000000c4944415408d763f8cfc000000301010018dd8db00000000049454e44ae426082',
  'hex'
);

async function main() {
  // 1. Bare package import is rejected by package exports map
  assert.throws(
    () => require('@img/sharp-wasm32'),
    { code: 'ERR_PACKAGE_PATH_NOT_EXPORTED' }
  );

  // 2. Subpath export ./versions matches libvipsVersion() and reports WebAssembly build
  assert.equal(versions.vips, '8.18.7');
  assert.equal(typeof versions.emscripten, 'string');
  assert.ok(versions.emscripten.length > 0);

  const libvips = sharpWasm.libvipsVersion();
  assert.deepEqual(libvips, {
    semver: versions.vips,
    isGlobal: false,
    isWasm: true
  });

  // 3. Supported formats report buffer input/output for png, jpeg, and webp
  const formats = sharpWasm.format();
  for (const id of ['png', 'jpeg', 'webp']) {
    assert.equal(formats[id].id, id);
    assert.equal(formats[id].input.buffer, true);
    assert.equal(formats[id].output.buffer, true);
  }

  // 4. Cache, concurrency, SIMD, and counters APIs operate on the WASM libvips runtime
  const updatedCache = sharpWasm.cache(50, 20, 100);
  assert.equal(updatedCache.memory.max, 50);
  assert.equal(updatedCache.files.max, 20);
  assert.equal(updatedCache.items.max, 100);

  assert.equal(sharpWasm.concurrency(2), 2);
  assert.equal(sharpWasm.concurrency(), 2);

  const initialSimd = sharpWasm.simd();
  assert.equal(typeof initialSimd, 'boolean');
  assert.equal(sharpWasm.simd(false), false);
  assert.equal(sharpWasm.simd(initialSimd), initialSimd);

  const counters = sharpWasm.counters();
  assert.equal(Number.isInteger(counters.queue) && counters.queue >= 0, true);
  assert.equal(Number.isInteger(counters.process) && counters.process >= 0, true);

  // 5. metadata() decodes an in-memory PNG buffer asynchronously in WASM
  const meta = await readMetadata(PNG_1X1_RED);
  assert.equal(meta.format, 'png');
  assert.equal(meta.width, 1);
  assert.equal(meta.height, 1);
  assert.equal(meta.space, 'srgb');
  assert.equal(meta.channels, 3);
  assert.equal(meta.depth, 'uchar');
  assert.equal(meta.hasAlpha, false);

  // 6. stats() computes image channel statistics and dominant RGB colour in WASM
  const stats = await readStats(PNG_1X1_RED);
  assert.equal(stats.isOpaque, true);
  assert.equal(stats.channels.length, 3);
  assert.ok(stats.dominant.r > stats.dominant.g);
  assert.ok(stats.dominant.r > stats.dominant.b);

  // 7. Invalid image bytes reject cleanly through the error callback
  await assert.rejects(
    () => readMetadata(Buffer.from('not-a-valid-image')),
    Error
  );

  console.log('contract passed');
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});

Ursprungs-Seeder

anonym