CodeSampleX

Exemplo

react-is 17.0.2: Lazy

Amostra verificada para npm react-is 17.0.2: Lazy. O contrato rodou em node 22 · linux debian/x64 · docker e passou: Lazy is exported as a symbol matching…

sha256:4c06bfc5595ecfef284361c99b26b48df97939d4cefb23914032a8668d78d97b

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 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@17.0.2
Pacotes
Símbolos
  • react-is.Lazy
Criado
2026-09-06T07:47:46Z

Contrato

  1. Lazy is exported as a symbol matching Symbol.for('react.lazy')
  2. Lazy represents the $$typeof identifier used for React lazy component types
  3. isLazy returns true for React elements wrapping a lazy component and false for plain elements or non-elements
  4. typeOf returns Lazy for React elements with a lazy component type and distinguishes them from other React types

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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@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.
csx.json
{"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"}
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",
      "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"
    }
  }
}
package.json
{
  "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"
  }
}
spec.json
{
  "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"
  ]
}
src/index.js
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 };
test/contract.mjs
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.');

Seeder de origem

anônimo