示例
react-refresh 0.17.0: isLikelyComponentType
已验证示例 — npm react-refresh 0.17.0: isLikelyComponentType. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: isLikelyComponentType returns true for…
sha256:3864b45b2729f5daf211e4cf1397710648b5356526408e1c507a858b5da790eb
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux 24 · ubuntu · glibc 2.39 x64 npm
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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 react-refresh.isLikelyComponentType in pkg:npm/react-refresh@0.17.0
- 符号
-
- react-refresh.isLikelyComponentType
- 创建时间
- 2026-09-04T18:52:58Z
契约
- isLikelyComponentType returns true for PascalCase function components and arrow functions
- isLikelyComponentType returns true for components with uppercase displayName
- isLikelyComponentType returns true for class components with isReactComponent on prototype
- isLikelyComponentType returns true for React forwardRef and memo objects
- isLikelyComponentType returns false for lowercase functions and regular classes
- isLikelyComponentType returns false for plain objects, non-component elements, primitives, and nullish values
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
源代码
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.isLikelyComponentType 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.isLikelyComponentType
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:e845f2386faaf115cd0bd9e3efef61028dbbc42c70ba68d70155c18efe9a4ede","contract":["isLikelyComponentType returns true for PascalCase function components and arrow functions","isLikelyComponentType returns true for components with uppercase displayName","isLikelyComponentType returns true for class components with isReactComponent on prototype","isLikelyComponentType returns true for React forwardRef and memo objects","isLikelyComponentType returns false for lowercase functions and regular classes","isLikelyComponentType returns false for plain objects, non-component elements, primitives, and nullish values"],"goal":"verify react-refresh.isLikelyComponentType in pkg:npm/react-refresh@0.17.0","kind":"HOW","packages":["pkg:npm/react-refresh@0.17.0"],"schemaVersion":1,"symbols":["react-refresh.isLikelyComponentType"]},"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.isLikelyComponentType"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-react-refresh-is-likely-component-type",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-react-refresh-is-likely-component-type",
"version": "1.0.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-is-likely-component-type",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of react-refresh isLikelyComponentType",
"type": "module",
"main": "src/index.js",
"dependencies": {
"react-refresh": "0.17.0"
}
}
{
"schemaVersion": 1,
"goal": "verify react-refresh.isLikelyComponentType in pkg:npm/react-refresh@0.17.0",
"kind": "HOW",
"packages": [
"pkg:npm/react-refresh@0.17.0"
],
"symbols": [
"react-refresh.isLikelyComponentType"
]
}
import { isLikelyComponentType } from 'react-refresh';
/**
* Check if the given value is likely a React component type.
*
* @param {*} type - The value to inspect.
* @returns {boolean} True if the value is likely a component type.
*/
export function checkIsLikelyComponentType(type) {
return isLikelyComponentType(type);
}
export { isLikelyComponentType };
import assert from 'node:assert/strict';
import {
isLikelyComponentType,
checkIsLikelyComponentType,
} from '../src/index.js';
// 1. Export verification
assert.equal(typeof isLikelyComponentType, 'function', 'isLikelyComponentType must be a function');
assert.equal(typeof checkIsLikelyComponentType, 'function', 'checkIsLikelyComponentType helper must be a function');
// 2. PascalCase function components and arrow functions
function ValidComponent() {
return null;
}
assert.equal(isLikelyComponentType(ValidComponent), true, 'PascalCase function must be recognized as component type');
assert.equal(checkIsLikelyComponentType(ValidComponent), true, 'checkIsLikelyComponentType returns true for PascalCase function');
const ArrowComponent = () => null;
assert.equal(isLikelyComponentType(ArrowComponent), true, 'Arrow function with PascalCase name must be recognized as component type');
assert.equal(checkIsLikelyComponentType(ArrowComponent), true, 'checkIsLikelyComponentType returns true for PascalCase arrow function');
// 3. Components with uppercase displayName
const anonymousFunc = (() => function() {
return null;
})();
Object.defineProperty(anonymousFunc, 'name', { value: '' });
anonymousFunc.displayName = 'NamedComponent';
assert.equal(isLikelyComponentType(anonymousFunc), true, 'Function with uppercase displayName must be recognized as component type');
assert.equal(checkIsLikelyComponentType(anonymousFunc), true, 'checkIsLikelyComponentType returns true for function with uppercase displayName');
// 4. Class components with isReactComponent on prototype
class MyClassComponent {}
MyClassComponent.prototype.isReactComponent = true;
assert.equal(isLikelyComponentType(MyClassComponent), true, 'Class component with isReactComponent must be recognized as component type');
assert.equal(checkIsLikelyComponentType(MyClassComponent), true, 'checkIsLikelyComponentType returns true for class component');
// 5. React forwardRef and memo objects
const forwardRefComponent = {
$$typeof: Symbol.for('react.forward_ref'),
render: () => null,
};
assert.equal(isLikelyComponentType(forwardRefComponent), true, 'React forwardRef object must be recognized as component type');
assert.equal(checkIsLikelyComponentType(forwardRefComponent), true, 'checkIsLikelyComponentType returns true for forwardRef');
const memoComponent = {
$$typeof: Symbol.for('react.memo'),
type: ValidComponent,
};
assert.equal(isLikelyComponentType(memoComponent), true, 'React memo object must be recognized as component type');
assert.equal(checkIsLikelyComponentType(memoComponent), true, 'checkIsLikelyComponentType returns true for memo object');
// 6. Lowercase functions and regular classes
function helperFunction() {
return false;
}
assert.equal(isLikelyComponentType(helperFunction), false, 'lowercase function must not be recognized as component type');
assert.equal(checkIsLikelyComponentType(helperFunction), false, 'checkIsLikelyComponentType returns false for lowercase function');
const lowercaseArrow = () => false;
assert.equal(isLikelyComponentType(lowercaseArrow), false, 'lowercase arrow function must not be recognized as component type');
class RegularClass {
method() {}
}
assert.equal(isLikelyComponentType(RegularClass), false, 'regular class without isReactComponent must not be recognized as component type');
// 7. Plain objects, non-component elements, primitives, and nullish values
assert.equal(isLikelyComponentType({}), false, 'plain object must not be recognized as component type');
assert.equal(isLikelyComponentType({ $$typeof: Symbol.for('react.element') }), false, 'React element object must not be recognized as component type');
assert.equal(isLikelyComponentType(null), false, 'null must not be recognized as component type');
assert.equal(isLikelyComponentType(undefined), false, 'undefined must not be recognized as component type');
assert.equal(isLikelyComponentType(42), false, 'number primitive must not be recognized as component type');
assert.equal(isLikelyComponentType('MyComponent'), false, 'string primitive must not be recognized as component type');
assert.equal(isLikelyComponentType(true), false, 'boolean primitive must not be recognized as component type');
console.log('Contract tests passed successfully.');
原始种子者
匿名