サンプル
@img/sharp-webcontainers-wasm32 0.35.5: cache
検証済みサンプル — npm @img/sharp-webcontainers-wasm32 0.35.5: cache. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: importing the bare package…
sha256:bf933e4a853d6c9158fdc89f3db720f8663d4249b484bd068f75fb468f039ebe
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 npm 10
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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 |
ケース
HOW- ゴール
- verify @img/sharp-webcontainers-wasm32.cache in pkg:npm/%40img/sharp-webcontainers-wasm32@0.35.5
- シンボル
-
- @img/sharp-webcontainers-wasm32.cache
- 環境
- node 22.23
- 作成日
- 2026-11-29T05:51:22Z
コントラクト
- 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
ファイル
- .npmrc
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
ソース
force=true
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.
{"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"}
{
"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"
}
}
}
{
"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"
}
}
{
"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"
]
}
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);
}
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');
オリジンシーダー
匿名