Ejemplo
react-refresh 0.18.0: getFamilyByType
Muestra verificada para npm react-refresh 0.18.0: getFamilyByType. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.
sha256:6b1bb9a000514f669de1bb4ee2f537c5ab1f9b35b0ba915e6959ba24b9e84c32
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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-06 |
Caso
HOW- Objetivo
- verify react-refresh.getFamilyByType in pkg:npm/react-refresh@0.18.0
- Paquetes
- Símbolos
-
- react-refresh.getFamilyByType
- Entorno
- node 22.23.2
- Creado
- 2026-09-06T12:50:03Z
Contrato
- getFamilyByType returns undefined for an unregistered component type
- getFamilyByType returns a family object containing current property for a registered component type
- getFamilyByType returns the identical family reference for an updated component type registered with the same id
- getFamilyByType returns distinct family references for component types registered with different ids
- getFamilyByType returns undefined when called with null, undefined, or primitive values
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Código fuente
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.getFamilyByType in pkg:npm/react-refresh@0.18.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/react-refresh@0.18.0
Demonstrate these symbols/APIs:
- react-refresh.getFamilyByType
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.
{"case":{"caseId":"case:sha256:5b2f7382431638c0037dac065233a63b74dda1a806d9a663a14a9fc2cac99501","constraints":{"executionContext":"node"},"contract":["getFamilyByType returns undefined for an unregistered component type","getFamilyByType returns a family object containing current property for a registered component type","getFamilyByType returns the identical family reference for an updated component type registered with the same id","getFamilyByType returns distinct family references for component types registered with different ids","getFamilyByType returns undefined when called with null, undefined, or primitive values"],"goal":"verify react-refresh.getFamilyByType in pkg:npm/react-refresh@0.18.0","kind":"HOW","packages":["pkg:npm/react-refresh@0.18.0"],"schemaVersion":1,"symbols":["react-refresh.getFamilyByType"]},"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.18.0"],"schemaVersion":1,"subject":"pkg:npm/react-refresh@0.18.0","symbols":["react-refresh.getFamilyByType"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-react-refresh-get-family-by-type",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-react-refresh-get-family-by-type",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"react-refresh": "0.18.0"
}
},
"node_modules/react-refresh": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.18.0.tgz",
"integrity": "sha512-QgT5//D3jfjJb6Gsjxv0Slpj23ip+HtOpnNgnb2S5zU3CB26G/IDPGoy4RJB42wzFE46DRsstbW6tKHoKbhAxw==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
}
}
}
{
"name": "sample-react-refresh-get-family-by-type",
"version": "1.0.0",
"private": true,
"description": "Clean-room code sample for react-refresh@0.18.0",
"license": "MIT-0",
"dependencies": {
"react-refresh": "0.18.0"
}
}
{
"schemaVersion": 1,
"goal": "verify react-refresh.getFamilyByType in pkg:npm/react-refresh@0.18.0",
"kind": "HOW",
"packages": [
"pkg:npm/react-refresh@0.18.0"
],
"symbols": [
"react-refresh.getFamilyByType"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const refreshRuntimeModule = require("react-refresh/runtime");
const RefreshRuntime =
refreshRuntimeModule && typeof refreshRuntimeModule === "object" && "default" in refreshRuntimeModule
? refreshRuntimeModule.default
: refreshRuntimeModule;
/**
* Returns the family object associated with a given component type, or undefined if not registered.
*
* @param {Function|object} type - The component function or object
* @returns {object|undefined}
*/
function getFamilyByType(type) {
return RefreshRuntime.getFamilyByType(type);
}
/**
* Registers a component type with a persistent identifier for Fast Refresh.
*
* @param {Function|object} type - The component function or object
* @param {string} id - Persistent identifier for the component family
*/
function register(type, id) {
RefreshRuntime.register(type, id);
}
module.exports = {
RefreshRuntime,
getFamilyByType,
register
};
import assert from "node:assert/strict";
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
const rawRuntime = require("react-refresh/runtime");
const { RefreshRuntime, getFamilyByType, register } = require("../src/index.js");
// Contract 1: getFamilyByType returns undefined for an unregistered component type
{
function UnregisteredComponent() {
return "unregistered";
}
assert.equal(getFamilyByType(UnregisteredComponent), undefined);
assert.equal(rawRuntime.getFamilyByType(UnregisteredComponent), undefined);
}
// Contract 2: getFamilyByType returns a family object containing current property for a registered component type
function ComponentA() {
return "ComponentA";
}
{
register(ComponentA, "ComponentA");
const familyA = getFamilyByType(ComponentA);
assert.notEqual(familyA, undefined);
assert.equal(typeof familyA, "object");
assert.equal(familyA.current, ComponentA);
const rawFamilyA = rawRuntime.getFamilyByType(ComponentA);
assert.equal(rawFamilyA, familyA);
}
// Contract 3: getFamilyByType returns the identical family reference for an updated component type registered with the same id
function ComponentA_v2() {
return "ComponentA_v2";
}
{
register(ComponentA_v2, "ComponentA");
const familyA_v2 = getFamilyByType(ComponentA_v2);
const familyA = getFamilyByType(ComponentA);
assert.notEqual(familyA_v2, undefined);
assert.equal(familyA_v2, familyA);
}
// Contract 4: getFamilyByType returns distinct family references for component types registered with different ids
function ComponentB() {
return "ComponentB";
}
{
register(ComponentB, "ComponentB");
const familyB = getFamilyByType(ComponentB);
const familyA = getFamilyByType(ComponentA);
assert.notEqual(familyB, undefined);
assert.notEqual(familyB, familyA);
assert.equal(familyB.current, ComponentB);
}
// Contract 5: getFamilyByType returns undefined when called with null, undefined, or primitive values
{
assert.equal(getFamilyByType(null), undefined);
assert.equal(getFamilyByType(undefined), undefined);
assert.equal(getFamilyByType(0), undefined);
assert.equal(getFamilyByType(42), undefined);
assert.equal(getFamilyByType(""), undefined);
assert.equal(getFamilyByType("ComponentA"), undefined);
assert.equal(getFamilyByType(true), undefined);
assert.equal(getFamilyByType(Symbol("comp")), undefined);
}
console.log("All react-refresh.getFamilyByType contract tests passed successfully.");
Seeder de origen
anónimo