CodeSampleX

Ejemplo

react-is 19.2.8: Lazy

Muestra verificada para npm react-is 19.2.8: Lazy. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó: Lazy is exported as a symbol…

sha256:195b0e1d184fc502fc538ea3032bb5592524335508ab1b48b448f6c70b64633c

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 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

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-06

Caso

HOW
Objetivo
verify react-is.Lazy in pkg:npm/react-is@19.2.8
Paquetes
Símbolos
  • react-is.Lazy
Entorno
node 22.23.2
Creado
2026-09-06T04:31:45Z

Contrato

  1. Lazy is exported as a symbol identifying React lazy component types
  2. Lazy symbol matches Symbol.for('react.lazy') in React 19
  3. Lazy is distinct from other React type symbols like Element, Fragment, Portal, ContextConsumer, and Suspense
  4. typeOf returns Lazy for React 19 elements whose component type has $$typeof equal to Lazy
  5. isLazy returns true for React 19 elements wrapping a Lazy component and false for plain elements or non-elements

Archivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

Descargar el artefacto de código fuente (tar.gz)

Código fuente

PROMPT.md
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@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.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.
csx.json
{"case":{"caseId":"case:sha256:3a8d0d94603a60cfb1808e680dcf82036d48349a37981be7043590c91b6c47cd","contract":["Lazy is exported as a symbol identifying React lazy component types","Lazy symbol matches Symbol.for('react.lazy') in React 19","Lazy is distinct from other React type symbols like Element, Fragment, Portal, ContextConsumer, and Suspense","typeOf returns Lazy for React 19 elements whose component type has $$typeof equal to Lazy","isLazy returns true for React 19 elements wrapping a Lazy component and false for plain elements or non-elements"],"goal":"verify react-is.Lazy in pkg:npm/react-is@19.2.8","kind":"HOW","packages":["pkg:npm/react-is@19.2.8"],"schemaVersion":1,"symbols":["react-is.Lazy"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","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.Lazy"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-react-is-lazy",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-react-is-lazy",
      "version": "1.0.0",
      "license": "MIT-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"
    }
  }
}
package.json
{
  "name": "sample-react-is-lazy",
  "version": "1.0.0",
  "description": "Clean-room verification of react-is Lazy in react-is@19.2.8",
  "type": "module",
  "private": true,
  "license": "MIT-0",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "react-is": "19.2.8"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify react-is.Lazy in pkg:npm/react-is@19.2.8",
  "kind": "HOW",
  "packages": [
    "pkg:npm/react-is@19.2.8"
  ],
  "symbols": [
    "react-is.Lazy"
  ]
}
src/index.js
import {
  Lazy,
  Element,
  Fragment,
  Portal,
  StrictMode,
  Profiler,
  ContextConsumer,
  ContextProvider,
  ForwardRef,
  Suspense,
  SuspenseList,
  Memo,
  isLazy,
  typeOf,
} from 'react-is';

/**
 * Returns the Lazy symbol exported by react-is.
 *
 * @returns {symbol} React lazy type symbol
 */
export function getLazySymbol() {
  return Lazy;
}

/**
 * Checks if a value is a React element wrapping a Lazy component.
 *
 * @param {*} value - The value to inspect
 * @returns {boolean} True if the value is a React lazy element
 */
export function checkIsLazy(value) {
  return isLazy(value);
}

/**
 * Determines the React type symbol of an element.
 *
 * @param {*} element - The React element to inspect
 * @returns {symbol|undefined} The matched React symbol or undefined
 */
export function inspectElementType(element) {
  return typeOf(element);
}

/**
 * Helper to construct a mock React 19 Lazy element.
 *
 * @param {Function} [init] - Lazy initializer function
 * @param {object} [payload] - Lazy payload
 * @returns {object} React 19 lazy element
 */
export function createLazyElement(init = () => null, payload = {}) {
  return {
    $$typeof: Element,
    type: {
      $$typeof: Lazy,
      _payload: payload,
      _init: init,
    },
    props: {},
    key: null,
    ref: null,
  };
}

export {
  Lazy,
  Element,
  Fragment,
  Portal,
  StrictMode,
  Profiler,
  ContextConsumer,
  ContextProvider,
  ForwardRef,
  Suspense,
  SuspenseList,
  Memo,
  isLazy,
  typeOf,
};
test/contract.mjs
import assert from 'node:assert/strict';
import {
  Lazy,
  Element,
  Fragment,
  Portal,
  StrictMode,
  Profiler,
  ContextConsumer,
  ContextProvider,
  ForwardRef,
  Suspense,
  SuspenseList,
  Memo,
  isLazy,
  typeOf,
  getLazySymbol,
  checkIsLazy,
  inspectElementType,
  createLazyElement,
} from '../src/index.js';

// 1. Lazy is exported as a symbol identifying React lazy component types
assert.equal(typeof Lazy, 'symbol', 'Lazy should be exported as a symbol');
assert.equal(getLazySymbol(), Lazy, 'getLazySymbol() should return Lazy');

// 2. Lazy symbol matches Symbol.for('react.lazy') in React 19
assert.equal(Lazy, Symbol.for('react.lazy'), 'Lazy must equal Symbol.for("react.lazy")');

// 3. Lazy is distinct from other React type symbols like Element, Fragment, Portal, ContextConsumer, and Suspense
assert.notEqual(Lazy, Element, 'Lazy must be distinct from Element');
assert.notEqual(Lazy, Fragment, 'Lazy must be distinct from Fragment');
assert.notEqual(Lazy, Portal, 'Lazy must be distinct from Portal');
assert.notEqual(Lazy, StrictMode, 'Lazy must be distinct from StrictMode');
assert.notEqual(Lazy, Profiler, 'Lazy must be distinct from Profiler');
assert.notEqual(Lazy, ContextConsumer, 'Lazy must be distinct from ContextConsumer');
assert.notEqual(Lazy, ContextProvider, 'Lazy must be distinct from ContextProvider');
assert.notEqual(Lazy, ForwardRef, 'Lazy must be distinct from ForwardRef');
assert.notEqual(Lazy, Suspense, 'Lazy must be distinct from Suspense');
assert.notEqual(Lazy, SuspenseList, 'Lazy must be distinct from SuspenseList');
assert.notEqual(Lazy, Memo, 'Lazy must be distinct from Memo');

// 4. typeOf returns Lazy for React 19 elements whose component type has $$typeof equal to Lazy
const lazyElement = createLazyElement();
assert.equal(typeOf(lazyElement), Lazy, 'typeOf must return Lazy for React 19 lazy element');
assert.equal(inspectElementType(lazyElement), Lazy, 'inspectElementType must return Lazy for React 19 lazy element');

const rawLazyComponent = {
  $$typeof: Lazy,
  _payload: {},
  _init: () => null,
};
assert.equal(typeOf(rawLazyComponent), undefined, 'typeOf must return undefined for raw unmounted lazy component');

// 5. isLazy returns true for React 19 elements wrapping a Lazy component and false for plain elements or non-elements
assert.equal(isLazy(lazyElement), true, 'isLazy must return true for lazy element');
assert.equal(checkIsLazy(lazyElement), true, 'checkIsLazy helper must return true for lazy element');
assert.equal(isLazy(rawLazyComponent), false, 'isLazy must return false for raw unmounted lazy component');

const plainElement = {
  $$typeof: Element,
  type: 'div',
  props: {},
  key: null,
  ref: null,
};
assert.equal(isLazy(plainElement), false, 'isLazy must return false for plain HTML tag element');

const legacyElement = {
  $$typeof: Symbol.for('react.element'),
  type: rawLazyComponent,
  props: {},
  key: null,
  ref: null,
};
assert.equal(isLazy(legacyElement), false, 'isLazy must return false for legacy React 18 element');

assert.equal(isLazy(null), false, 'isLazy must return false for null');
assert.equal(isLazy(undefined), false, 'isLazy must return false for undefined');
assert.equal(isLazy({}), false, 'isLazy must return false for empty object');
assert.equal(isLazy('string'), false, 'isLazy must return false for primitive string');
assert.equal(isLazy(123), false, 'isLazy must return false for primitive number');

console.log('Contract tests passed successfully.');

Seeder de origen

anónimo