Exemplo
react-is 18.3.1: isContextConsumer, isContextProvider, isLazy
Amostra verificada para npm react-is 18.3.1: isContextConsumer, isContextProvider, isLazy. O contrato rodou em node 22 · linux alpine/x64 · docker e passou.
sha256:fce303e8f7894b27b6b81a947313c95bf6e659fc7f5ff4c4e7c92e9f3040eb3d
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-27 |
Caso
HOW- Objetivo
- verify pkg:npm/react-is@18.3.1
- Pacotes
- Símbolos
-
- isContextConsumer
- isContextProvider
- isLazy
- isPortal
- isProfiler
- isStrictMode
- isSuspense
- Criado
- 2026-08-27T14:32:13Z
Contrato
- isContextConsumer detects React Context Consumer elements and typeOf returns ContextConsumer
- isContextProvider detects React Context Provider elements and typeOf returns ContextProvider
- isLazy detects React Lazy component elements and typeOf returns Lazy
- isPortal detects React Portal objects and typeOf returns Portal
- isProfiler detects React Profiler elements and typeOf returns Profiler
- isStrictMode detects React StrictMode elements and typeOf returns StrictMode
- isSuspense detects React Suspense elements and typeOf returns Suspense
- inspectType returns undefined for non-React objects and primitives
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Código-fonte
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 pkg:npm/react-is@18.3.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/react-is@18.3.1
Demonstrate these symbols/APIs:
- isContextConsumer
- isContextProvider
- isLazy
- isPortal
- isProfiler
- isStrictMode
- isSuspense
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:00e07e7e4f4057bc7c9d74388e749999b02be8947cc1551d244b26ebce796b3b","contract":["isContextConsumer detects React Context Consumer elements and typeOf returns ContextConsumer","isContextProvider detects React Context Provider elements and typeOf returns ContextProvider","isLazy detects React Lazy component elements and typeOf returns Lazy","isPortal detects React Portal objects and typeOf returns Portal","isProfiler detects React Profiler elements and typeOf returns Profiler","isStrictMode detects React StrictMode elements and typeOf returns StrictMode","isSuspense detects React Suspense elements and typeOf returns Suspense","inspectType returns undefined for non-React objects and primitives"],"goal":"verify pkg:npm/react-is@18.3.1","kind":"HOW","packages":["pkg:npm/react-is@18.3.1"],"schemaVersion":1,"symbols":["isContextConsumer","isContextProvider","isLazy","isPortal","isProfiler","isStrictMode","isSuspense"]},"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@18.3.1"],"schemaVersion":1,"subject":"pkg:npm/react-is@18.3.1","symbols":["isContextConsumer","isContextProvider","isLazy","isPortal","isProfiler","isStrictMode","isSuspense"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-react-is-types",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-react-is-types",
"version": "1.0.0",
"dependencies": {
"react-is": "18.3.1"
}
},
"node_modules/react-is": {
"version": "18.3.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz",
"integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==",
"license": "MIT"
}
}
}
{
"name": "sample-react-is-types",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of react-is context, portal, lazy, profiler, strict mode, and suspense type checking",
"type": "module",
"main": "src/index.js",
"dependencies": {
"react-is": "18.3.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/react-is@18.3.1",
"kind": "HOW",
"packages": [
"pkg:npm/react-is@18.3.1"
],
"symbols": [
"isContextConsumer",
"isContextProvider",
"isLazy",
"isPortal",
"isProfiler",
"isStrictMode",
"isSuspense"
]
}
import {
isContextConsumer,
isContextProvider,
isLazy,
isPortal,
isProfiler,
isStrictMode,
isSuspense,
typeOf,
ContextConsumer,
ContextProvider,
Lazy,
Portal,
Profiler,
StrictMode,
Suspense,
} from 'react-is';
/**
* Check if the given value is a React Context Consumer element.
*
* @param {*} value - The value to inspect.
* @returns {boolean} True if the value is a Context Consumer element.
*/
export function checkIsContextConsumer(value) {
return isContextConsumer(value);
}
/**
* Check if the given value is a React Context Provider element.
*
* @param {*} value - The value to inspect.
* @returns {boolean} True if the value is a Context Provider element.
*/
export function checkIsContextProvider(value) {
return isContextProvider(value);
}
/**
* Check if the given value is a React Lazy component element.
*
* @param {*} value - The value to inspect.
* @returns {boolean} True if the value is a Lazy component element.
*/
export function checkIsLazy(value) {
return isLazy(value);
}
/**
* Check if the given value is a React Portal.
*
* @param {*} value - The value to inspect.
* @returns {boolean} True if the value is a Portal.
*/
export function checkIsPortal(value) {
return isPortal(value);
}
/**
* Check if the given value is a React Profiler element.
*
* @param {*} value - The value to inspect.
* @returns {boolean} True if the value is a Profiler element.
*/
export function checkIsProfiler(value) {
return isProfiler(value);
}
/**
* Check if the given value is a React StrictMode element.
*
* @param {*} value - The value to inspect.
* @returns {boolean} True if the value is a StrictMode element.
*/
export function checkIsStrictMode(value) {
return isStrictMode(value);
}
/**
* Check if the given value is a React Suspense element.
*
* @param {*} value - The value to inspect.
* @returns {boolean} True if the value is a Suspense element.
*/
export function checkIsSuspense(value) {
return isSuspense(value);
}
/**
* Identify the React element type symbol of a given object.
*
* @param {*} value - The value to inspect.
* @returns {symbol|undefined} The matched React symbol or undefined.
*/
export function inspectType(value) {
return typeOf(value);
}
export {
isContextConsumer,
isContextProvider,
isLazy,
isPortal,
isProfiler,
isStrictMode,
isSuspense,
typeOf,
ContextConsumer,
ContextProvider,
Lazy,
Portal,
Profiler,
StrictMode,
Suspense,
};
import assert from 'node:assert/strict';
import {
checkIsContextConsumer,
checkIsContextProvider,
checkIsLazy,
checkIsPortal,
checkIsProfiler,
checkIsStrictMode,
checkIsSuspense,
inspectType,
isContextConsumer,
isContextProvider,
isLazy,
isPortal,
isProfiler,
isStrictMode,
isSuspense,
typeOf,
ContextConsumer,
ContextProvider,
Lazy,
Portal,
Profiler,
StrictMode,
Suspense,
} from '../src/index.js';
// 1. Function exports verification
assert.equal(typeof isContextConsumer, 'function', 'isContextConsumer should be a function');
assert.equal(typeof isContextProvider, 'function', 'isContextProvider should be a function');
assert.equal(typeof isLazy, 'function', 'isLazy should be a function');
assert.equal(typeof isPortal, 'function', 'isPortal should be a function');
assert.equal(typeof isProfiler, 'function', 'isProfiler should be a function');
assert.equal(typeof isStrictMode, 'function', 'isStrictMode should be a function');
assert.equal(typeof isSuspense, 'function', 'isSuspense should be a function');
assert.equal(typeof typeOf, 'function', 'typeOf should be a function');
assert.equal(typeof checkIsContextConsumer, 'function', 'checkIsContextConsumer helper should be a function');
assert.equal(typeof checkIsContextProvider, 'function', 'checkIsContextProvider helper should be a function');
assert.equal(typeof checkIsLazy, 'function', 'checkIsLazy helper should be a function');
assert.equal(typeof checkIsPortal, 'function', 'checkIsPortal helper should be a function');
assert.equal(typeof checkIsProfiler, 'function', 'checkIsProfiler helper should be a function');
assert.equal(typeof checkIsStrictMode, 'function', 'checkIsStrictMode helper should be a function');
assert.equal(typeof checkIsSuspense, 'function', 'checkIsSuspense helper should be a function');
assert.equal(typeof inspectType, 'function', 'inspectType helper should be a function');
// Common symbols
const REACT_ELEMENT_TYPE = Symbol.for('react.element');
const REACT_PORTAL_TYPE = Symbol.for('react.portal');
const REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
const REACT_PROFILER_TYPE = Symbol.for('react.profiler');
const REACT_PROVIDER_TYPE = Symbol.for('react.provider');
const REACT_CONTEXT_TYPE = Symbol.for('react.context');
const REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
const REACT_LAZY_TYPE = Symbol.for('react.lazy');
// Base negative fixtures
const plainElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: 'div',
props: {},
key: null,
ref: null,
};
// 2. Context Consumer detection
const contextObject = {
$$typeof: REACT_CONTEXT_TYPE,
_context: null,
};
contextObject._context = contextObject;
const consumerElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: contextObject,
props: { children: () => null },
key: null,
ref: null,
};
assert.equal(isContextConsumer(consumerElement), true, 'Valid Context Consumer element must be detected by isContextConsumer');
assert.equal(checkIsContextConsumer(consumerElement), true, 'checkIsContextConsumer helper must return true');
assert.equal(isContextConsumer(plainElement), false, 'plain element is not a Context Consumer');
assert.equal(isContextConsumer(null), false, 'null is not a Context Consumer');
assert.equal(isContextConsumer({}), false, 'empty object is not a Context Consumer');
assert.equal(typeOf(consumerElement), ContextConsumer, 'typeOf(consumerElement) must equal ContextConsumer');
// 3. Context Provider detection
const providerType = {
$$typeof: REACT_PROVIDER_TYPE,
_context: contextObject,
};
const providerElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: providerType,
props: { value: 'test' },
key: null,
ref: null,
};
assert.equal(isContextProvider(providerElement), true, 'Valid Context Provider element must be detected by isContextProvider');
assert.equal(checkIsContextProvider(providerElement), true, 'checkIsContextProvider helper must return true');
assert.equal(isContextProvider(plainElement), false, 'plain element is not a Context Provider');
assert.equal(isContextProvider(consumerElement), false, 'consumer element is not a Context Provider');
assert.equal(isContextProvider(null), false, 'null is not a Context Provider');
assert.equal(typeOf(providerElement), ContextProvider, 'typeOf(providerElement) must equal ContextProvider');
// 4. Lazy component detection
const lazyComponentType = {
$$typeof: REACT_LAZY_TYPE,
_payload: {},
_init: () => null,
};
const lazyElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: lazyComponentType,
props: {},
key: null,
ref: null,
};
assert.equal(isLazy(lazyElement), true, 'Valid Lazy component element must be detected by isLazy');
assert.equal(checkIsLazy(lazyElement), true, 'checkIsLazy helper must return true');
assert.equal(isLazy(plainElement), false, 'plain element is not a Lazy component');
assert.equal(isLazy(null), false, 'null is not a Lazy component');
assert.equal(typeOf(lazyElement), Lazy, 'typeOf(lazyElement) must equal Lazy');
// 5. Portal detection
const portalObject = {
$$typeof: REACT_PORTAL_TYPE,
key: null,
children: [],
containerInfo: {},
implementation: null,
};
assert.equal(isPortal(portalObject), true, 'Valid Portal object must be detected by isPortal');
assert.equal(checkIsPortal(portalObject), true, 'checkIsPortal helper must return true');
assert.equal(isPortal(plainElement), false, 'plain element is not a Portal');
assert.equal(isPortal(null), false, 'null is not a Portal');
assert.equal(typeOf(portalObject), Portal, 'typeOf(portalObject) must equal Portal');
// 6. Profiler detection
const profilerElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: REACT_PROFILER_TYPE,
props: { id: 'test', onRender: () => {} },
key: null,
ref: null,
};
assert.equal(isProfiler(profilerElement), true, 'Valid Profiler element must be detected by isProfiler');
assert.equal(checkIsProfiler(profilerElement), true, 'checkIsProfiler helper must return true');
assert.equal(isProfiler(plainElement), false, 'plain element is not a Profiler');
assert.equal(isProfiler(null), false, 'null is not a Profiler');
assert.equal(typeOf(profilerElement), Profiler, 'typeOf(profilerElement) must equal Profiler');
// 7. StrictMode detection
const strictModeElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: REACT_STRICT_MODE_TYPE,
props: { children: [] },
key: null,
ref: null,
};
assert.equal(isStrictMode(strictModeElement), true, 'Valid StrictMode element must be detected by isStrictMode');
assert.equal(checkIsStrictMode(strictModeElement), true, 'checkIsStrictMode helper must return true');
assert.equal(isStrictMode(plainElement), false, 'plain element is not a StrictMode element');
assert.equal(isStrictMode(null), false, 'null is not a StrictMode element');
assert.equal(typeOf(strictModeElement), StrictMode, 'typeOf(strictModeElement) must equal StrictMode');
// 8. Suspense detection
const suspenseElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: REACT_SUSPENSE_TYPE,
props: { fallback: null, children: [] },
key: null,
ref: null,
};
assert.equal(isSuspense(suspenseElement), true, 'Valid Suspense element must be detected by isSuspense');
assert.equal(checkIsSuspense(suspenseElement), true, 'checkIsSuspense helper must return true');
assert.equal(isSuspense(plainElement), false, 'plain element is not a Suspense element');
assert.equal(isSuspense(null), false, 'null is not a Suspense element');
assert.equal(typeOf(suspenseElement), Suspense, 'typeOf(suspenseElement) must equal Suspense');
// 9. Negative checks for invalid types and helper functions
assert.equal(inspectType(plainElement), Symbol.for('react.element'), 'inspectType returns react.element symbol for plain element');
assert.equal(inspectType({}), undefined, 'inspectType returns undefined for non-React object');
assert.equal(inspectType(null), undefined, 'inspectType returns undefined for null');
assert.equal(inspectType('string'), undefined, 'inspectType returns undefined for primitive string');
console.log('Contract tests passed successfully.');
Seeder de origem
anônimo