CodeSampleX

サンプル

caniuse-lite 1.0.30001809

検証済みサンプル — npm caniuse-lite 1.0.30001809. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: getAgent(browserName) returns browser metadata…

sha256:d48f542445447037d8db0fe373d0608532c32a60a8026b2f27b6b798f6644f8b

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
2
ビルドした署名鍵
1
宣言された環境 linux 24 · ubuntu · glibc 2.39 x64 npm

検証実行環境

環境 コントラクト ステージ 実行日
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-26
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-07

ケース

HOW
ゴール
verify pkg:npm/caniuse-lite@1.0.30001809
パッケージ
作成日
2026-08-26T06:52:09Z

コントラクト

  1. getAgent(browserName) returns browser metadata including name, prefix, and supported versions
  2. getFeature(featureName) unpacks and returns feature title, status, and browser support stats
  3. getFeatureSupport(featureName, browserName, version) returns support status string or null for invalid queries
  4. isFeatureSupported(featureName, browserName, version) returns true for supported browser versions and false otherwise
  5. getRegionStats(regionData) unpacks regional browser usage statistics

ファイル

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

ソースアーティファクトをダウンロード (tar.gz)

ソース

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/caniuse-lite@1.0.30001809
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/caniuse-lite@1.0.30001809

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:b665d2079a5acefe0c3887b7ebe0f23ca335f2a7ce8bfaf5d4c32012a256bbb4","contract":["getAgent(browserName) returns browser metadata including name, prefix, and supported versions","getFeature(featureName) unpacks and returns feature title, status, and browser support stats","getFeatureSupport(featureName, browserName, version) returns support status string or null for invalid queries","isFeatureSupported(featureName, browserName, version) returns true for supported browser versions and false otherwise","getRegionStats(regionData) unpacks regional browser usage statistics"],"goal":"verify pkg:npm/caniuse-lite@1.0.30001809","kind":"HOW","packages":["pkg:npm/caniuse-lite@1.0.30001809"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/caniuse-lite@1.0.30001809"],"schemaVersion":1,"subject":"pkg:npm/caniuse-lite@1.0.30001809","verifierAdapter":"node-typescript@1"}
index.mjs
import { agents, feature, features, region } from 'caniuse-lite';

export function getAgent(browserName) {
  return agents[browserName] ?? null;
}

export function getFeature(featureName) {
  const raw = features[featureName];
  if (!raw) return null;
  return feature(raw);
}

export function getFeatureSupport(featureName, browserName, version) {
  const feat = getFeature(featureName);
  if (!feat || !feat.stats || !feat.stats[browserName]) return null;
  return feat.stats[browserName][version] ?? null;
}

export function isFeatureSupported(featureName, browserName, version) {
  const support = getFeatureSupport(featureName, browserName, version);
  if (!support) return false;
  return support.startsWith('y');
}

export function getRegionStats(regionData) {
  return region(regionData);
}
package-lock.json
{
  "name": "sample-caniuse-lite",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-caniuse-lite",
      "version": "1.0.0",
      "dependencies": {
        "caniuse-lite": "1.0.30001809"
      }
    },
    "node_modules/caniuse-lite": {
      "version": "1.0.30001809",
      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001809.tgz",
      "integrity": "sha512-xxWVywk6a6Arlk+hymeycyn/VgqEfLDxupvhH/xiY5SJ/18kmi9o6MiO320DCUzypORHLtvh0I4i04tUhCNHNQ==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "CC-BY-4.0"
    }
  }
}
package.json
{
  "name": "sample-caniuse-lite",
  "version": "1.0.0",
  "description": "Clean-room verification sample for caniuse-lite",
  "type": "module",
  "private": true,
  "dependencies": {
    "caniuse-lite": "1.0.30001809"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/caniuse-lite@1.0.30001809",
  "kind": "HOW",
  "packages": [
    "pkg:npm/caniuse-lite@1.0.30001809"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import usRegion from 'caniuse-lite/data/regions/US.js';
import {
  getAgent,
  getFeature,
  getFeatureSupport,
  isFeatureSupported,
  getRegionStats
} from '../index.mjs';

// 1. getAgent(browserName) returns browser metadata including name, prefix, and supported versions
const chromeAgent = getAgent('chrome');
assert.ok(chromeAgent !== null, 'Chrome agent should exist');
assert.equal(chromeAgent.browser, 'Chrome');
assert.equal(chromeAgent.prefix, 'webkit');
assert.ok(Array.isArray(chromeAgent.versions), 'Versions should be an array');
assert.ok(chromeAgent.versions.includes('150'), 'Versions should include version 150');
assert.equal(typeof chromeAgent.usage_global['150'], 'number');
assert.equal(getAgent('nonexistent_browser'), null);

// 2. getFeature(featureName) unpacks and returns feature title, status, and browser support stats
const fetchFeature = getFeature('fetch');
assert.ok(fetchFeature !== null, 'Fetch feature should exist');
assert.equal(fetchFeature.title, 'Fetch');
assert.equal(typeof fetchFeature.status, 'string');
assert.ok(fetchFeature.stats && typeof fetchFeature.stats === 'object');
assert.equal(getFeature('nonexistent_feature'), null);

// 3. getFeatureSupport(featureName, browserName, version) returns support status string or null for invalid queries
assert.equal(getFeatureSupport('fetch', 'chrome', '100'), 'y');
assert.equal(getFeatureSupport('fetch', 'ie', '11'), 'n');
assert.equal(getFeatureSupport('css-grid', 'ie', '11'), 'a x #2');
assert.equal(getFeatureSupport('fetch', 'chrome', 'invalid_ver_9999'), null);
assert.equal(getFeatureSupport('nonexistent_feature', 'chrome', '100'), null);

// 4. isFeatureSupported(featureName, browserName, version) returns true for supported browser versions and false otherwise
assert.equal(isFeatureSupported('fetch', 'chrome', '100'), true);
assert.equal(isFeatureSupported('fetch', 'ie', '11'), false);
assert.equal(isFeatureSupported('css-grid', 'chrome', '60'), true);
assert.equal(isFeatureSupported('css-grid', 'chrome', '57'), true);
assert.equal(isFeatureSupported('css-grid', 'ie', '11'), false);
assert.equal(isFeatureSupported('nonexistent_feature', 'chrome', '100'), false);

// 5. getRegionStats(regionData) unpacks regional browser usage statistics
const usStats = getRegionStats(usRegion);
assert.ok(usStats && typeof usStats === 'object');
assert.ok('chrome' in usStats);
assert.equal(typeof usStats.chrome['150'], 'number');

console.log('All caniuse-lite@1.0.30001809 contract assertions passed.');

オリジンシーダー

匿名