Пример
react-is 19.2.8: Portal
Проверенный пример — npm react-is 19.2.8: Portal. Контракт выполнен на node 22 · linux debian/x64 · docker и пройден: Portal is exported as a symbol matching…
sha256:e5c60879aa3cfd6414532ab317b6ab2191aeb9d820307cef03414c866b06d128
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| 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.Portal in pkg:npm/react-is@19.2.8
- Пакеты
- Символы
-
- react-is.Portal
- Окружение
- node 22.23.2
- Создан
- 2026-09-06T05:46:14Z
Контракт
- Portal is exported as a symbol matching Symbol.for('react.portal')
- Portal is distinct from other React 19 symbols including Element, Fragment, and StrictMode
- isValidElementType returns false for Portal symbol
- isPortal identifies valid React portal objects created with Portal symbol
- typeOf returns Portal symbol for valid React portal objects and undefined for non-element objects
- isPortal returns false for standard React elements, Portal symbol itself, plain objects, null, undefined, and primitives
Файлы
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Исходный код
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.Portal in pkg:npm/react-is@19.2.8
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/react-is@19.2.8
Demonstrate these symbols/APIs:
- react-is.Portal
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:d0ab530cfe1cbd00c36eee7fca752fd5846ac96713aeaffd00a49f76201f8868","constraints":{"executionContext":"node"},"contract":["Portal is exported as a symbol matching Symbol.for('react.portal')","Portal is distinct from other React 19 symbols including Element, Fragment, and StrictMode","isValidElementType returns false for Portal symbol","isPortal identifies valid React portal objects created with Portal symbol","typeOf returns Portal symbol for valid React portal objects and undefined for non-element objects","isPortal returns false for standard React elements, Portal symbol itself, plain objects, null, undefined, and primitives"],"goal":"verify react-is.Portal in pkg:npm/react-is@19.2.8","kind":"HOW","packages":["pkg:npm/react-is@19.2.8"],"schemaVersion":1,"symbols":["react-is.Portal"]},"contractCommand":["node","test/contract.js"],"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-is@19.2.8"],"schemaVersion":1,"subject":"pkg:npm/react-is@19.2.8","symbols":["react-is.Portal"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-react-is-portal",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-react-is-portal",
"version": "1.0.0",
"dependencies": {
"react-is": "19.2.8"
}
},
"node_modules/react-is": {
"version": "19.2.8",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-19.2.8.tgz",
"integrity": "sha512-s5un28nYxKJw5gvUHyW5PCC28CvBqLu9r3cWgzHT4Vo/5fqqkFcdRYsGcKf50WMPpjjFZS5d76fn3YCo2njKwQ==",
"license": "MIT"
}
}
}
{
"name": "sample-react-is-portal",
"version": "1.0.0",
"description": "verify react-is.Portal in pkg:npm/react-is@19.2.8",
"main": "src/index.js",
"dependencies": {
"react-is": "19.2.8"
}
}
{
"schemaVersion": 1,
"goal": "verify react-is.Portal in pkg:npm/react-is@19.2.8",
"kind": "HOW",
"packages": [
"pkg:npm/react-is@19.2.8"
],
"symbols": [
"react-is.Portal"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const {
Portal,
Element,
Fragment,
StrictMode,
Profiler,
ContextConsumer,
ContextProvider,
ForwardRef,
Suspense,
SuspenseList,
Memo,
Lazy,
isPortal,
isElement,
isValidElementType,
typeOf,
} = require('react-is');
/**
* Creates a representation of a React portal object.
*
* @param {*} children - Portal children content.
* @param {object} [containerInfo={}] - Target container information.
* @param {string|null} [key=null] - Key for the portal.
* @returns {object} React portal representation object.
*/
function createPortalObject(children = null, containerInfo = {}, key = null) {
return {
$$typeof: Portal,
key,
children,
containerInfo,
implementation: null,
};
}
/**
* Checks whether a given value is a React portal object.
*
* @param {*} value - The value to test.
* @returns {boolean} True if the value is a portal.
*/
function checkIsPortal(value) {
return isPortal(value);
}
/**
* Inspects a value and returns its React element type symbol.
*
* @param {*} value - The value to inspect.
* @returns {symbol|undefined} The element type symbol or undefined.
*/
function inspectTypeOf(value) {
return typeOf(value);
}
/**
* Checks whether a given type is a valid React element type.
*
* @param {*} type - The type to test.
* @returns {boolean} True if the type is a valid element type.
*/
function checkIsValidElementType(type) {
return isValidElementType(type);
}
module.exports = {
Portal,
Element,
Fragment,
StrictMode,
Profiler,
ContextConsumer,
ContextProvider,
ForwardRef,
Suspense,
SuspenseList,
Memo,
Lazy,
isPortal,
isElement,
isValidElementType,
typeOf,
createPortalObject,
checkIsPortal,
inspectTypeOf,
checkIsValidElementType,
};
const assert = require('node:assert/strict');
const reactIs = require('react-is');
const {
Portal,
Element,
Fragment,
StrictMode,
Profiler,
ContextConsumer,
ContextProvider,
ForwardRef,
Suspense,
SuspenseList,
Memo,
Lazy,
isPortal,
isElement,
isValidElementType,
typeOf,
createPortalObject,
checkIsPortal,
inspectTypeOf,
checkIsValidElementType,
} = require('../src/index.js');
// Contract 1: Portal is exported as a symbol matching Symbol.for('react.portal')
assert.equal(typeof Portal, 'symbol', 'Portal must be a symbol');
assert.equal(Portal, Symbol.for('react.portal'), 'Portal must match Symbol.for("react.portal")');
assert.equal(reactIs.Portal, Portal, 'reactIs.Portal must equal named import Portal');
// Contract 2: Portal is distinct from other React 19 symbols including Element, Fragment, and StrictMode
assert.notEqual(Portal, Element, 'Portal must be distinct from Element');
assert.notEqual(Portal, Fragment, 'Portal must be distinct from Fragment');
assert.notEqual(Portal, StrictMode, 'Portal must be distinct from StrictMode');
assert.notEqual(Portal, Profiler, 'Portal must be distinct from Profiler');
assert.notEqual(Portal, ContextConsumer, 'Portal must be distinct from ContextConsumer');
assert.notEqual(Portal, ContextProvider, 'Portal must be distinct from ContextProvider');
assert.notEqual(Portal, ForwardRef, 'Portal must be distinct from ForwardRef');
assert.notEqual(Portal, Suspense, 'Portal must be distinct from Suspense');
assert.notEqual(Portal, SuspenseList, 'Portal must be distinct from SuspenseList');
assert.notEqual(Portal, Memo, 'Portal must be distinct from Memo');
assert.notEqual(Portal, Lazy, 'Portal must be distinct from Lazy');
// Contract 3: isValidElementType returns false for Portal symbol
assert.equal(checkIsValidElementType(Portal), false, 'Portal cannot be used as an element type');
assert.equal(isValidElementType(Portal), false, 'isValidElementType(Portal) must be false');
assert.equal(reactIs.isValidElementType(Portal), false, 'reactIs.isValidElementType(Portal) must be false');
assert.equal(checkIsValidElementType('div'), true, 'HTML tags must be valid element types');
assert.equal(checkIsValidElementType(Fragment), true, 'Fragment must be a valid element type');
// Contract 4: isPortal identifies valid React portal objects created with Portal symbol
const portalWithContent = createPortalObject('portal content', { id: 'modal-root' }, 'portal-key');
assert.equal(checkIsPortal(portalWithContent), true, 'Portal object must be identified by checkIsPortal');
assert.equal(isPortal(portalWithContent), true, 'Portal object must be identified by isPortal');
assert.equal(reactIs.isPortal(portalWithContent), true, 'Portal object must be identified by reactIs.isPortal');
assert.equal(isElement(portalWithContent), false, 'Portal object must not be identified as a standard element');
const emptyPortal = createPortalObject();
assert.equal(isPortal(emptyPortal), true, 'Empty portal object must be identified by isPortal');
const directPortal = {
$$typeof: Symbol.for('react.portal'),
key: null,
children: null,
containerInfo: {},
implementation: null,
};
assert.equal(isPortal(directPortal), true, 'Direct portal structure must be identified by isPortal');
// Contract 5: typeOf returns Portal symbol for valid React portal objects and undefined for non-element objects
assert.equal(inspectTypeOf(portalWithContent), Portal, 'inspectTypeOf must return Portal symbol for portal object');
assert.equal(typeOf(portalWithContent), Portal, 'typeOf must return Portal symbol for portal object');
assert.equal(reactIs.typeOf(portalWithContent), Portal, 'reactIs.typeOf must return Portal symbol for portal object');
assert.equal(typeOf(emptyPortal), Portal, 'typeOf must return Portal symbol for empty portal');
assert.equal(typeOf(directPortal), Portal, 'typeOf must return Portal symbol for direct portal');
assert.equal(inspectTypeOf({}), undefined, 'inspectTypeOf on plain object must return undefined');
assert.equal(typeOf({}), undefined, 'typeOf on plain object must return undefined');
assert.equal(typeOf(null), undefined, 'typeOf on null must return undefined');
assert.equal(typeOf(undefined), undefined, 'typeOf on undefined must return undefined');
assert.equal(typeOf('portal'), undefined, 'typeOf on string must return undefined');
assert.equal(typeOf(12345), undefined, 'typeOf on number must return undefined');
// Contract 6: isPortal returns false for standard React elements, Portal symbol itself, plain objects, null, undefined, and primitives
const standardElement = {
$$typeof: Element,
type: 'div',
props: { id: 'root' },
key: null,
ref: null,
};
assert.equal(checkIsPortal(standardElement), false, 'Standard React element must not be a portal');
assert.equal(isPortal(standardElement), false, 'Standard React element must not be a portal');
assert.equal(isPortal(Portal), false, 'Portal symbol itself must not be a portal instance');
assert.equal(isPortal({}), false, 'Empty object must return false');
assert.equal(isPortal(null), false, 'null must return false');
assert.equal(isPortal(undefined), false, 'undefined must return false');
assert.equal(isPortal('react.portal'), false, 'String must return false');
assert.equal(isPortal(12345), false, 'Number must return false');
assert.equal(isPortal(true), false, 'Boolean must return false');
assert.equal(isPortal([]), false, 'Array must return false');
console.log('All react-is.Portal contract tests passed.');
Исходный сидер
аноним