CodeSampleX

サンプル

react-refresh 0.17.0: hasUnrecoverableErrors

検証済みサンプル — npm react-refresh 0.17.0: hasUnrecoverableErrors. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: hasUnrecoverableErrors returns false…

sha256:3588ea779a92d3b285a825aabf650a6f190c82f7ce1325ffe76251126e182c9c

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

ケース

HOW
ゴール
verify react-refresh.hasUnrecoverableErrors in pkg:npm/react-refresh@0.17.0
パッケージ
シンボル
  • react-refresh.hasUnrecoverableErrors
環境
node 22.23.2
作成日
2026-09-05T01:31:22Z

コントラクト

  1. hasUnrecoverableErrors returns false initially when no errors have occurred
  2. hasUnrecoverableErrors returns false after registering component types
  3. hasUnrecoverableErrors returns false after performing refresh cycle with performReactRefresh
  4. hasUnrecoverableErrors returns false when invoked repeatedly across multiple calls
  5. hasUnrecoverableErrors returns false and does not throw when invoked with arbitrary arguments

ファイル

  • 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 react-refresh.hasUnrecoverableErrors in pkg:npm/react-refresh@0.17.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/react-refresh@0.17.0
Demonstrate these symbols/APIs:
  - react-refresh.hasUnrecoverableErrors
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:19b4bdc69ff3a63d6f6201fd33e41583ba8d0a1636bb6db2c88e12a503aa3874","constraints":{"executionContext":"node"},"contract":["hasUnrecoverableErrors returns false initially when no errors have occurred","hasUnrecoverableErrors returns false after registering component types","hasUnrecoverableErrors returns false after performing refresh cycle with performReactRefresh","hasUnrecoverableErrors returns false when invoked repeatedly across multiple calls","hasUnrecoverableErrors returns false and does not throw when invoked with arbitrary arguments"],"goal":"verify react-refresh.hasUnrecoverableErrors in pkg:npm/react-refresh@0.17.0","kind":"HOW","packages":["pkg:npm/react-refresh@0.17.0"],"schemaVersion":1,"symbols":["react-refresh.hasUnrecoverableErrors"]},"contractCommand":["node","test/contract.mjs"],"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/react-refresh@0.17.0"],"schemaVersion":1,"subject":"pkg:npm/react-refresh@0.17.0","symbols":["react-refresh.hasUnrecoverableErrors"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-react-refresh-has-unrecoverable-errors",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-react-refresh-has-unrecoverable-errors",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "react-refresh": "0.17.0"
      }
    },
    "node_modules/react-refresh": {
      "version": "0.17.0",
      "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz",
      "integrity": "sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    }
  }
}
package.json
{
  "name": "sample-react-refresh-has-unrecoverable-errors",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "react-refresh": "0.17.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify react-refresh.hasUnrecoverableErrors in pkg:npm/react-refresh@0.17.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/react-refresh@0.17.0"
  ],
  "symbols": [
    "react-refresh.hasUnrecoverableErrors"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.mjs
import refreshRuntimeModule from "react-refresh/runtime";

export const RefreshRuntime =
  refreshRuntimeModule && typeof refreshRuntimeModule === "object" && "default" in refreshRuntimeModule
    ? refreshRuntimeModule.default
    : refreshRuntimeModule;

/**
 * Checks whether Fast Refresh runtime has encountered unrecoverable errors.
 *
 * @param {...any} args - Optional arguments passed to the check function.
 * @returns {boolean} False when the runtime has no unrecoverable errors.
 */
export function hasUnrecoverableErrors(...args) {
  return RefreshRuntime.hasUnrecoverableErrors(...args);
}

/**
 * Registers a component type with a persistent identifier for Fast Refresh.
 *
 * @param {any} type - The component function or object
 * @param {string} id - Persistent identifier for the component family
 */
export function register(type, id) {
  RefreshRuntime.register(type, id);
}

/**
 * Triggers a Fast Refresh cycle across registered components and renderers.
 *
 * @returns {object|null} Refresh cycle result or null if nothing was refreshed
 */
export function performReactRefresh() {
  return RefreshRuntime.performReactRefresh();
}
test/contract.mjs
import assert from "node:assert/strict";
import refreshRuntimeModule from "react-refresh/runtime";
import {
  RefreshRuntime,
  hasUnrecoverableErrors,
  register,
  performReactRefresh
} from "../src/index.mjs";

const rawRuntime =
  refreshRuntimeModule && typeof refreshRuntimeModule === "object" && "default" in refreshRuntimeModule
    ? refreshRuntimeModule.default
    : refreshRuntimeModule;

// Contract 1: hasUnrecoverableErrors returns false initially when no errors have occurred
{
  assert.equal(typeof hasUnrecoverableErrors(), "boolean");
  assert.equal(hasUnrecoverableErrors(), false);
  assert.equal(typeof rawRuntime.hasUnrecoverableErrors, "function");
  assert.equal(rawRuntime.hasUnrecoverableErrors(), false);
}

// Contract 2: hasUnrecoverableErrors returns false after registering component types
{
  function HeaderComponent() {
    return "Header";
  }
  register(HeaderComponent, "HeaderId");
  assert.equal(hasUnrecoverableErrors(), false);
  assert.equal(rawRuntime.hasUnrecoverableErrors(), false);
}

// Contract 3: hasUnrecoverableErrors returns false after performing refresh cycle with performReactRefresh
{
  performReactRefresh();
  assert.equal(hasUnrecoverableErrors(), false);
  assert.equal(rawRuntime.hasUnrecoverableErrors(), false);
}

// Contract 4: hasUnrecoverableErrors returns false when invoked repeatedly across multiple calls
{
  for (let i = 0; i < 5; i++) {
    assert.equal(hasUnrecoverableErrors(), false);
    assert.equal(rawRuntime.hasUnrecoverableErrors(), false);
  }
}

// Contract 5: hasUnrecoverableErrors returns false and does not throw when invoked with arbitrary arguments
{
  assert.equal(hasUnrecoverableErrors(null), false);
  assert.equal(hasUnrecoverableErrors(undefined), false);
  assert.equal(hasUnrecoverableErrors(new Error("simulated runtime error")), false);
  assert.equal(hasUnrecoverableErrors("unexpected string", 123), false);
  assert.equal(hasUnrecoverableErrors({ error: true }), false);
  assert.equal(rawRuntime.hasUnrecoverableErrors(new Error("raw test")), false);
}

console.log("All react-refresh.hasUnrecoverableErrors contract tests passed successfully.");

オリジンシーダー

匿名