Пример
react-is 17.0.2: Lazy
Проверенный пример — npm react-is 17.0.2: Lazy. Контракт выполнен на node 22 · linux debian/x64 · docker и пройден: Lazy is exported as a symbol matching…
sha256:4c06bfc5595ecfef284361c99b26b48df97939d4cefb23914032a8668d78d97b
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
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-06 |
Кейс
HOW- Цель
- verify react-is.Lazy in pkg:npm/react-is@17.0.2
- Пакеты
- Символы
-
- react-is.Lazy
- Создан
- 2026-09-06T07:47:46Z
Контракт
- Lazy is exported as a symbol matching Symbol.for('react.lazy')
- Lazy represents the $$typeof identifier used for React lazy component types
- isLazy returns true for React elements wrapping a lazy component and false for plain elements or non-elements
- typeOf returns Lazy for React elements with a lazy component type and distinguishes them from other React types
Файлы
- 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-is.Lazy in pkg:npm/react-is@17.0.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/react-is@17.0.2
Demonstrate these symbols/APIs:
- react-is.Lazy
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:e1458a03787a05be9a8bee7e494165dd1e8e859aa39a90a2e88004df3f2a42e5","contract":["Lazy is exported as a symbol matching Symbol.for('react.lazy')","Lazy represents the $$typeof identifier used for React lazy component types","isLazy returns true for React elements wrapping a lazy component and false for plain elements or non-elements","typeOf returns Lazy for React elements with a lazy component type and distinguishes them from other React types"],"goal":"verify react-is.Lazy in pkg:npm/react-is@17.0.2","kind":"HOW","packages":["pkg:npm/react-is@17.0.2"],"schemaVersion":1,"symbols":["react-is.Lazy"]},"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-is@17.0.2"],"schemaVersion":1,"subject":"pkg:npm/react-is@17.0.2","symbols":["react-is.Lazy"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-react-is-lazy",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-react-is-lazy",
"version": "1.0.0",
"dependencies": {
"react-is": "17.0.2"
}
},
"node_modules/react-is": {
"version": "17.0.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
"license": "MIT"
}
}
}
{
"name": "sample-react-is-lazy",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of react-is.Lazy in react-is 17.0.2",
"type": "module",
"main": "src/index.js",
"dependencies": {
"react-is": "17.0.2"
}
}
{
"schemaVersion": 1,
"goal": "verify react-is.Lazy in pkg:npm/react-is@17.0.2",
"kind": "HOW",
"packages": [
"pkg:npm/react-is@17.0.2"
],
"symbols": [
"react-is.Lazy"
]
}
import { Lazy, Element, isLazy, typeOf, isValidElementType } from 'react-is';
/**
* Return the Lazy symbol exported by react-is.
*
* @returns {symbol} The React lazy identifier symbol.
*/
export function getLazySymbol() {
return Lazy;
}
/**
* Check if the provided symbol matches react-is Lazy.
*
* @param {*} sym - Symbol or value to compare.
* @returns {boolean} True if matching react-is Lazy.
*/
export function isMatchingLazySymbol(sym) {
return sym === Lazy;
}
/**
* Create a lazy component descriptor tagged with the Lazy symbol.
*
* @param {Function} [loader] - Factory function returning dynamic import promise.
* @returns {object} Object with $$typeof set to Lazy.
*/
export function createLazyComponent(loader = () => Promise.resolve({ default: () => null })) {
return {
$$typeof: Lazy,
_payload: {
_status: -1,
_result: loader,
},
_init: () => {},
};
}
/**
* Create a React element object wrapping a lazy component.
*
* @param {object} lazyComponent - Lazy component descriptor.
* @param {object} [props] - Element properties.
* @returns {object} Object with $$typeof set to Element and type set to lazyComponent.
*/
export function createLazyElement(lazyComponent, props = {}) {
return {
$$typeof: Element,
type: lazyComponent,
props,
key: null,
ref: null,
};
}
/**
* Verify whether an object is recognized as a React lazy element.
*
* @param {*} value - The value to inspect.
* @returns {boolean} True if the value is a React lazy element.
*/
export function checkIsLazy(value) {
return isLazy(value);
}
/**
* Identify whether the typeOf helper resolves the value to the Lazy symbol.
*
* @param {*} value - The value to inspect.
* @returns {boolean} True if typeOf(value) === Lazy.
*/
export function isLazyTypeOf(value) {
return typeOf(value) === Lazy;
}
export { Lazy, Element, isLazy, typeOf, isValidElementType };
import assert from 'node:assert/strict';
import {
Lazy,
Element,
isLazy,
typeOf,
isValidElementType,
getLazySymbol,
isMatchingLazySymbol,
createLazyComponent,
createLazyElement,
checkIsLazy,
isLazyTypeOf,
} from '../src/index.js';
// 1. Lazy export assertion
assert.equal(typeof Lazy, 'symbol', 'Lazy must be exported as a symbol');
assert.equal(Lazy, Symbol.for('react.lazy'), 'Lazy must equal Symbol.for("react.lazy")');
assert.equal(getLazySymbol(), Lazy, 'getLazySymbol helper must return Lazy');
assert.equal(isMatchingLazySymbol(Lazy), true, 'isMatchingLazySymbol must return true for Lazy');
assert.equal(isMatchingLazySymbol(Symbol.for('react.lazy')), true, 'isMatchingLazySymbol must return true for Symbol.for("react.lazy")');
assert.equal(isMatchingLazySymbol(Symbol.for('react.element')), false, 'isMatchingLazySymbol must return false for other symbols');
// 2. Lazy component representation
const lazyComponent = createLazyComponent();
assert.equal(lazyComponent.$$typeof, Lazy, 'Lazy component descriptor must have $$typeof equal to Lazy');
assert.equal(isValidElementType(lazyComponent), true, 'isValidElementType must recognize lazy component as valid element type');
// 3. isLazy detection
const lazyElement = createLazyElement(lazyComponent, { id: 'test-lazy' });
assert.equal(lazyElement.$$typeof, Element, 'lazyElement must have $$typeof equal to Element');
assert.equal(lazyElement.type, lazyComponent, 'lazyElement type must be the lazy component');
assert.equal(isLazy(lazyElement), true, 'isLazy must return true for React element wrapping a lazy component');
assert.equal(checkIsLazy(lazyElement), true, 'checkIsLazy helper must return true for lazy element');
const plainElement = {
$$typeof: Element,
type: 'div',
props: {},
key: null,
ref: null,
};
assert.equal(isLazy(plainElement), false, 'isLazy must return false for plain element');
assert.equal(checkIsLazy(plainElement), false, 'checkIsLazy helper must return false for plain element');
assert.equal(isLazy(lazyComponent), false, 'isLazy returns false for raw component descriptor without element wrapper');
assert.equal(checkIsLazy(null), false, 'checkIsLazy must return false for null');
assert.equal(checkIsLazy(undefined), false, 'checkIsLazy must return false for undefined');
// 4. typeOf identification matching Lazy
assert.equal(typeOf(lazyElement), Lazy, 'typeOf must return Lazy for React element wrapping a lazy component');
assert.equal(isLazyTypeOf(lazyElement), true, 'isLazyTypeOf helper must return true for lazy element');
assert.notEqual(typeOf(plainElement), Lazy, 'typeOf for plain element must not equal Lazy');
assert.equal(typeOf(plainElement), Element, 'typeOf for plain element must equal Element');
assert.equal(isLazyTypeOf(plainElement), false, 'isLazyTypeOf helper must return false for plain element');
assert.equal(typeOf({}), undefined, 'typeOf on non-element must return undefined');
assert.equal(isLazyTypeOf({}), false, 'isLazyTypeOf helper must return false for empty object');
console.log('Contract passed: react-is.Lazy verified successfully.');
Исходный сидер
аноним