CodeSampleX

示例

node-abi 4.33.0: futureTargets

已验证示例 — npm node-abi 4.33.0: futureTargets. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: node-abi.futureTargets is an array of target specification…

sha256:1196c7b4c2abff131845559aac0b3e9887c465d7f776a31e204d564c58f1b635

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
1
构建过它的签名密钥
1
声明的环境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript 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-09-04

案例

HOW
目标
verify node-abi.futureTargets in pkg:npm/node-abi@4.33.0
包
符号
  • node-abi.futureTargets
环境
node 22.23.2
创建时间
2026-09-04T15:01:35Z

契约

  1. node-abi.futureTargets is an array of target specification objects
  2. each target object in node-abi.futureTargets defines runtime, target, abi, and lts properties
  3. node-abi.futureTargets contains future target objects including electron unreleased targets
  4. node-abi.futureTargets target property specifies the version string and abi specifies the corresponding ABI string
  5. node-abi.futureTargets lts property indicates long-term support status as a boolean
  6. node-abi.futureTargets is a constituent subset included within node-abi.allTargets

文件

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.mjs
  • 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 node-abi.futureTargets in pkg:npm/node-abi@4.33.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/node-abi@4.33.0
Demonstrate these symbols/APIs:
  - node-abi.futureTargets

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:133235b36099fad9ce5f9cdba90d9d6946597bb61f9633b4678b89ee783d3f09","contract":["node-abi.futureTargets is an array of target specification objects","each target object in node-abi.futureTargets defines runtime, target, abi, and lts properties","node-abi.futureTargets contains future target objects including electron unreleased targets","node-abi.futureTargets target property specifies the version string and abi specifies the corresponding ABI string","node-abi.futureTargets lts property indicates long-term support status as a boolean","node-abi.futureTargets is a constituent subset included within node-abi.allTargets"],"goal":"verify node-abi.futureTargets in pkg:npm/node-abi@4.33.0","kind":"HOW","packages":["pkg:npm/node-abi@4.33.0"],"schemaVersion":1,"symbols":["node-abi.futureTargets"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/node-abi@4.33.0"],"schemaVersion":1,"subject":"pkg:npm/node-abi@4.33.0","symbols":["node-abi.futureTargets"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-node-abi-futuretargets",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-node-abi-futuretargets",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "node-abi": "4.33.0"
      }
    },
    "node_modules/node-abi": {
      "version": "4.33.0",
      "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-4.33.0.tgz",
      "integrity": "sha512-vLBWCKb+7LWsX+TbfzWOkw0W81m377tyx3hOweBTjO43CXZnRGS1/JPWs20fr0PgZyDXk6ROYrylsEycK8raDA==",
      "license": "MIT",
      "dependencies": {
        "semver": "^7.6.3"
      },
      "engines": {
        "node": ">=22.12.0"
      }
    },
    "node_modules/semver": {
      "version": "7.8.5",
      "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
      "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
      "license": "ISC",
      "bin": {
        "semver": "bin/semver.js"
      },
      "engines": {
        "node": ">=10"
      }
    }
  }
}
package.json
{
  "name": "sample-node-abi-futuretargets",
  "version": "1.0.0",
  "private": true,
  "description": "verify node-abi.futureTargets in pkg:npm/node-abi@4.33.0",
  "type": "module",
  "main": "src/index.mjs",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "node-abi": "4.33.0"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify node-abi.futureTargets in pkg:npm/node-abi@4.33.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/node-abi@4.33.0"
  ],
  "symbols": [
    "node-abi.futureTargets"
  ]
}
src/index.mjs
import { futureTargets, allTargets, getAbi, getTarget } from 'node-abi';

/**
 * Returns all future targets exported by node-abi.
 * @returns {Array<{runtime: string, target: string, abi: string, lts: boolean}>}
 */
export function getFutureTargets() {
  return futureTargets;
}

/**
 * Finds a future target by its target version string.
 * @param {string} target
 * @returns {{runtime: string, target: string, abi: string, lts: boolean} | undefined}
 */
export function findFutureTarget(target) {
  return futureTargets.find((t) => t.target === target);
}

/**
 * Filters future targets by runtime.
 * @param {string} runtime
 * @returns {Array<{runtime: string, target: string, abi: string, lts: boolean}>}
 */
export function getFutureTargetsByRuntime(runtime) {
  return futureTargets.filter((t) => t.runtime === runtime);
}

/**
 * Filters future targets by ABI identifier.
 * @param {string} abi
 * @returns {Array<{runtime: string, target: string, abi: string, lts: boolean}>}
 */
export function getFutureTargetsByAbi(abi) {
  return futureTargets.filter((t) => t.abi === String(abi));
}

/**
 * Checks if a target version belongs to futureTargets.
 * @param {string} target
 * @param {string} [runtime]
 * @returns {boolean}
 */
export function isFutureTarget(target, runtime) {
  return futureTargets.some((t) => t.target === target && (!runtime || t.runtime === runtime));
}

export { futureTargets, allTargets, getAbi, getTarget };
test/contract.mjs
import assert from 'node:assert';
import { futureTargets as rawFutureTargets, allTargets as rawAllTargets, getAbi, getTarget } from 'node-abi';
import {
  futureTargets,
  allTargets,
  getFutureTargets,
  findFutureTarget,
  getFutureTargetsByRuntime,
  getFutureTargetsByAbi,
  isFutureTarget,
} from '../src/index.mjs';

// 1. node-abi.futureTargets is an array of target specification objects
{
  assert.strictEqual(Array.isArray(rawFutureTargets), true, 'rawFutureTargets must be an array');
  assert.strictEqual(Array.isArray(futureTargets), true, 'exported futureTargets must be an array');
  assert.strictEqual(getFutureTargets(), rawFutureTargets, 'getFutureTargets() must return rawFutureTargets');
  assert.ok(futureTargets.length > 0, 'futureTargets must not be empty');
}

// 2. each target object in node-abi.futureTargets defines runtime, target, abi, and lts properties
{
  for (const item of futureTargets) {
    assert.strictEqual(typeof item, 'object', 'each target must be an object');
    assert.notStrictEqual(item, null, 'target object must not be null');

    assert.strictEqual(typeof item.runtime, 'string', 'target.runtime must be a string');
    assert.ok(item.runtime.length > 0, 'target.runtime must not be empty');

    assert.strictEqual(typeof item.target, 'string', 'target.target must be a string');
    assert.ok(item.target.length > 0, 'target.target must not be empty');

    assert.strictEqual(typeof item.abi, 'string', 'target.abi must be a string');
    assert.ok(item.abi.length > 0, 'target.abi must not be empty');

    assert.strictEqual(typeof item.lts, 'boolean', 'target.lts must be a boolean');
  }
}

// 3. node-abi.futureTargets contains future target objects including electron unreleased targets
{
  const electronTargets = getFutureTargetsByRuntime('electron');
  assert.ok(electronTargets.length > 0, 'futureTargets must contain electron runtime targets');
  const target44 = findFutureTarget('44.0.0-alpha.1');
  assert.ok(target44, 'target 44.0.0-alpha.1 must exist in futureTargets');
  assert.strictEqual(target44.runtime, 'electron', 'target 44.0.0-alpha.1 runtime must be electron');
  assert.strictEqual(target44.abi, '149', 'target 44.0.0-alpha.1 abi must be 149');
}

// 4. node-abi.futureTargets target property specifies the version string and abi specifies the corresponding ABI string
{
  const target44 = findFutureTarget('44.0.0-alpha.1');
  assert.ok(target44, 'target 44.0.0-alpha.1 must exist in futureTargets');
  assert.strictEqual(target44.target, '44.0.0-alpha.1');
  assert.strictEqual(target44.abi, '149');

  const abi149Targets = getFutureTargetsByAbi('149');
  assert.ok(abi149Targets.length > 0, 'must find future targets with ABI 149');
  assert.ok(abi149Targets.some((t) => t.target === '44.0.0-alpha.1'), 'ABI 149 targets must include 44.0.0-alpha.1');

  assert.strictEqual(isFutureTarget('44.0.0-alpha.1', 'electron'), true);
  assert.strictEqual(isFutureTarget('non-existent-version', 'electron'), false);
  assert.strictEqual(isFutureTarget('44.0.0-alpha.1', 'node'), false);

  assert.strictEqual(getAbi(target44.target, target44.runtime), target44.abi);
}

// 5. node-abi.futureTargets lts property indicates long-term support status as a boolean
{
  for (const target of futureTargets) {
    assert.strictEqual(typeof target.lts, 'boolean', 'lts must be a boolean');
  }
}

// 6. node-abi.futureTargets is a constituent subset included within node-abi.allTargets
{
  assert.ok(Array.isArray(rawAllTargets), 'allTargets must be an array');
  assert.ok(rawAllTargets.length >= futureTargets.length, 'allTargets must contain at least as many items as futureTargets');

  for (const item of futureTargets) {
    const foundInAll = rawAllTargets.some(
      (t) => t.runtime === item.runtime && t.target === item.target && t.abi === item.abi && t.lts === item.lts
    );
    assert.ok(foundInAll, `target ${item.runtime}@${item.target} must be included within allTargets`);
  }
}

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

原始种子者

匿名