CodeSampleX

Exemplo

@img/sharp-webcontainers-wasm32 0.35.5: cache

Amostra verificada para npm @img/sharp-webcontainers-wasm32 0.35.5: cache. O contrato rodou em node 22 · linux debian/x64 · docker e passou.

sha256:bf933e4a853d6c9158fdc89f3db720f8663d4249b484bd068f75fb468f039ebe

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 npm 10

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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-29

Caso

HOW
Objetivo
verify @img/sharp-webcontainers-wasm32.cache in pkg:npm/%40img/sharp-webcontainers-wasm32@0.35.5
Pacotes
Símbolos
  • @img/sharp-webcontainers-wasm32.cache
Ambiente
node 22.23
Criado
2026-11-29T05:51:22Z

Contrato

  1. importing the bare package '@img/sharp-webcontainers-wasm32' rejects with ERR_PACKAGE_PATH_NOT_EXPORTED; the wasm binding is exported at '@img/sharp-webcontainers-wasm32/sharp.node'
  2. cache() with no arguments returns { memory: { current: 0, high: 0, max: 100 }, files: { current: 0, max: 100 }, items: { current: 0, max: 100 } } initially
  3. cache(memory, files, items) accepts positional numeric limits and updates memory.max, files.max, and items.max
  4. partial positional calls (1 or 2 arguments) and non-numeric arguments (null, undefined, options objects) leave omitted or non-numeric slots unchanged rather than throwing or accepting an options object
  5. floating-point numeric limits passed to cache() are truncated toward zero
  6. cache(0, 0, 0) sets memory.max, files.max, and items.max to 0 and persists across subsequent cache() queries

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

.npmrc
force=true
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 @img/sharp-webcontainers-wasm32.cache in pkg:npm/%40img/sharp-webcontainers-wasm32@0.35.5
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40img/sharp-webcontainers-wasm32@0.35.5
Demonstrate these symbols/APIs:
  - @img/sharp-webcontainers-wasm32.cache

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:275cc16f92188dcfde4a0e2a2a312f4f7d0d2f30cc39b8e157867f5dcf95d637","contract":["importing the bare package '@img/sharp-webcontainers-wasm32' rejects with ERR_PACKAGE_PATH_NOT_EXPORTED; the wasm binding is exported at '@img/sharp-webcontainers-wasm32/sharp.node'","cache() with no arguments returns { memory: { current: 0, high: 0, max: 100 }, files: { current: 0, max: 100 }, items: { current: 0, max: 100 } } initially","cache(memory, files, items) accepts positional numeric limits and updates memory.max, files.max, and items.max","partial positional calls (1 or 2 arguments) and non-numeric arguments (null, undefined, options objects) leave omitted or non-numeric slots unchanged rather than throwing or accepting an options object","floating-point numeric limits passed to cache() are truncated toward zero","cache(0, 0, 0) sets memory.max, files.max, and items.max to 0 and persists across subsequent cache() queries"],"goal":"verify @img/sharp-webcontainers-wasm32.cache in pkg:npm/%40img/sharp-webcontainers-wasm32@0.35.5","kind":"HOW","packages":["pkg:npm/%40img/sharp-webcontainers-wasm32@0.35.5"],"schemaVersion":1,"symbols":["@img/sharp-webcontainers-wasm32.cache"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9","runtime":"node","runtimeVersion":"22.23","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40img/sharp-webcontainers-wasm32@0.35.5"],"schemaVersion":1,"subject":"pkg:npm/%40img/sharp-webcontainers-wasm32@0.35.5","symbols":["@img/sharp-webcontainers-wasm32.cache"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sharp-webcontainers-wasm32-cache-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sharp-webcontainers-wasm32-cache-sample",
      "version": "1.0.0",
      "dependencies": {
        "@img/sharp-webcontainers-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/@img/sharp-webcontainers-wasm32": {
      "version": "0.35.5",
      "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.5.tgz",
      "integrity": "sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==",
      "cpu": [
        "wasm32"
      ],
      "license": "Apache-2.0",
      "dependencies": {
        "@img/sharp-wasm32": "0.35.5"
      },
      "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-webcontainers-wasm32-cache-sample",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "@img/sharp-webcontainers-wasm32": "0.35.5"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @img/sharp-webcontainers-wasm32.cache in pkg:npm/%40img/sharp-webcontainers-wasm32@0.35.5",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40img/sharp-webcontainers-wasm32@0.35.5"
  ],
  "symbols": [
    "@img/sharp-webcontainers-wasm32.cache"
  ]
}
src/index.mjs
import sharpNode from '@img/sharp-webcontainers-wasm32/sharp.node';

export function getCacheStats() {
  return sharpNode.cache();
}

export function setCacheLimits(memory, files, items) {
  return sharpNode.cache(memory, files, items);
}

export function disableCache() {
  return sharpNode.cache(0, 0, 0);
}
test/contract.mjs
import assert from 'node:assert/strict';
import sharpNode from '@img/sharp-webcontainers-wasm32/sharp.node';
import { getCacheStats, setCacheLimits, disableCache } from '../src/index.mjs';

// 1. Bare package import is rejected; the binding is exported at ./sharp.node.
await assert.rejects(
  () => import('@img/sharp-webcontainers-wasm32'),
  (err) => err?.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED',
);

// 2. Default cache() returns memory, files, and items counters with initial max 100.
assert.equal(typeof sharpNode.cache, 'function');
const initial = getCacheStats();
assert.deepEqual(initial, {
  memory: { current: 0, high: 0, max: 100 },
  files: { current: 0, max: 100 },
  items: { current: 0, max: 100 },
});

// 3. Positional numeric arguments (memory, files, items) update all three limits.
const updated = setCacheLimits(25, 10, 50);
assert.equal(updated.memory.max, 25);
assert.equal(updated.files.max, 10);
assert.equal(updated.items.max, 50);

// 4. Partial positional calls update only supplied slots and keep the rest unchanged.
const memOnly = sharpNode.cache(40);
assert.equal(memOnly.memory.max, 40);
assert.equal(memOnly.files.max, 10);
assert.equal(memOnly.items.max, 50);

const memAndFiles = sharpNode.cache(30, 15);
assert.equal(memAndFiles.memory.max, 30);
assert.equal(memAndFiles.files.max, 15);
assert.equal(memAndFiles.items.max, 50);

// 5. Options objects and non-numeric arguments are ignored per slot (unlike high-level sharp.cache(opts)).
const ignoredObj = sharpNode.cache({ memory: 5, files: 5, items: 5 });
assert.equal(ignoredObj.memory.max, 30);
assert.equal(ignoredObj.files.max, 15);
assert.equal(ignoredObj.items.max, 50);

const itemsOnly = sharpNode.cache(null, undefined, 75);
assert.equal(itemsOnly.memory.max, 30);
assert.equal(itemsOnly.files.max, 15);
assert.equal(itemsOnly.items.max, 75);

// 6. Floating-point numeric limits are truncated toward zero.
const truncated = sharpNode.cache(12.9, 5.7, 20.4);
assert.equal(truncated.memory.max, 12);
assert.equal(truncated.files.max, 5);
assert.equal(truncated.items.max, 20);

// 7. Passing (0, 0, 0) disables cache limits and persists across subsequent cache() reads.
const disabled = disableCache();
assert.equal(disabled.memory.max, 0);
assert.equal(disabled.files.max, 0);
assert.equal(disabled.items.max, 0);

const afterDisable = getCacheStats();
assert.equal(afterDisable.memory.max, 0);
assert.equal(afterDisable.files.max, 0);
assert.equal(afterDisable.items.max, 0);

console.log('contract passed');

Seeder de origem

anônimo