Ejemplo
react-refresh 0.17.0: getFamilyByType
Muestra verificada para npm react-refresh 0.17.0: getFamilyByType. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.
sha256:37e342f9b7dac076e2774f2065ba1e622cba4d76cdf1769c5c4568652d60ba13
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
linux 24 · ubuntu · glibc 2.39 x64 npm
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-04 |
Caso
HOW- Objetivo
- verify react-refresh.getFamilyByType in pkg:npm/react-refresh@0.17.0
- Paquetes
- Símbolos
-
- react-refresh.getFamilyByType
- Creado
- 2026-09-04T18:21:48Z
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.mjs
- 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.17.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/react-refresh@0.17.0
Demonstrate these symbols/APIs:
- react-refresh.getFamilyByType
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:a0b91d8ff7a21b35a534c710043efc3b5d0e208be053063716550d9f9ad28e24","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.17.0","kind":"HOW","packages":["pkg:npm/react-refresh@0.17.0"],"schemaVersion":1,"symbols":["react-refresh.getFamilyByType"]},"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/react-refresh@0.17.0"],"schemaVersion":1,"subject":"pkg:npm/react-refresh@0.17.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.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"
}
}
}
}
{
"name": "sample-react-refresh-get-family-by-type",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"react-refresh": "0.17.0"
}
}
{
"schemaVersion": 1,
"goal": "verify react-refresh.getFamilyByType in pkg:npm/react-refresh@0.17.0",
"kind": "HOW",
"packages": [
"pkg:npm/react-refresh@0.17.0"
],
"symbols": [
"react-refresh.getFamilyByType"
]
}
import refreshRuntimeModule from "react-refresh/runtime";
export 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 {any} type - The component function or object
* @returns {object|undefined}
*/
export function getFamilyByType(type) {
return RefreshRuntime.getFamilyByType(type);
}
/**
* 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);
}
import assert from "node:assert/strict";
import refreshRuntimeModule from "react-refresh/runtime";
import { RefreshRuntime, getFamilyByType, register } from "../src/index.mjs";
const rawRuntime =
refreshRuntimeModule && typeof refreshRuntimeModule === "object" && "default" in refreshRuntimeModule
? refreshRuntimeModule.default
: refreshRuntimeModule;
// 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