CodeSampleX

Ejemplo

react-is 17.0.2: StrictMode

Muestra verificada para npm react-is 17.0.2: StrictMode. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.

sha256:1ef425ccadb5a5bf6696ce427b3331b9a5a7ad7cff02ba5192f3c90c4f967867

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.StrictMode in pkg:npm/react-is@17.0.2
Paquetes
Símbolos
  • react-is.StrictMode
Entorno
node 22.23.2
Creado
2026-09-06T10:39:17Z

Contrato

  1. react-is exports StrictMode matching Symbol.for('react.strict_mode')
  2. isValidElementType identifies StrictMode as a valid React element type
  3. isStrictMode detects valid React 17 StrictMode elements
  4. isStrictMode returns false for StrictMode symbol itself, non-strictmode elements, and primitives
  5. typeOf returns StrictMode symbol for valid strictmode elements and undefined for non-elements

Archivos

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

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.StrictMode 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.StrictMode
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.
csx.json
{"case":{"caseId":"case:sha256:30757d822c0a6b1c4c0be2645c7507de4ec2cb7ceaaf53f8c664044bb4792f4b","constraints":{"executionContext":"node"},"contract":["react-is exports StrictMode matching Symbol.for('react.strict_mode')","isValidElementType identifies StrictMode as a valid React element type","isStrictMode detects valid React 17 StrictMode elements","isStrictMode returns false for StrictMode symbol itself, non-strictmode elements, and primitives","typeOf returns StrictMode symbol for valid strictmode elements and undefined for non-elements"],"goal":"verify react-is.StrictMode in pkg:npm/react-is@17.0.2","kind":"HOW","packages":["pkg:npm/react-is@17.0.2"],"schemaVersion":1,"symbols":["react-is.StrictMode"]},"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@17.0.2"],"schemaVersion":1,"subject":"pkg:npm/react-is@17.0.2","symbols":["react-is.StrictMode"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-react-is-strictmode",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-react-is-strictmode",
      "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-strictmode",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of react-is.StrictMode in pkg:npm/react-is@17.0.2",
  "main": "src/index.js",
  "dependencies": {
    "react-is": "17.0.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify react-is.StrictMode in pkg:npm/react-is@17.0.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/react-is@17.0.2"
  ],
  "symbols": [
    "react-is.StrictMode"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const reactIs = require('react-is');
const {
  StrictMode,
  Element,
  isStrictMode,
  isValidElementType,
  typeOf,
} = reactIs;

/**
 * Creates a React 17 element representation.
 *
 * @param {*} type - The element type.
 * @param {Object} [props={}] - Element properties.
 * @returns {Object} React element object.
 */
function createElement(type, props = {}) {
  return {
    $$typeof: Element || Symbol.for('react.element'),
    type,
    props,
    key: null,
    ref: null,
  };
}

/**
 * Creates a React 17 StrictMode element representation.
 *
 * @param {*} [children] - Children to include in props.
 * @returns {Object} React StrictMode element object.
 */
function createStrictModeElement(children) {
  const props = children !== undefined ? { children } : {};
  return createElement(StrictMode, props);
}

/**
 * Checks whether a given object is a React StrictMode element.
 *
 * @param {*} value - The value to test.
 * @returns {boolean} True if the value is a StrictMode element.
 */
function checkIsStrictMode(value) {
  return isStrictMode(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 valid.
 */
function checkIsValidElementType(type) {
  return isValidElementType(type);
}

/**
 * Inspects the React type of a given value.
 *
 * @param {*} value - The value to inspect.
 * @returns {*|undefined} Type symbol or undefined.
 */
function inspectTypeOf(value) {
  return typeOf(value);
}

module.exports = {
  StrictMode,
  Element,
  createElement,
  createStrictModeElement,
  checkIsStrictMode,
  checkIsValidElementType,
  inspectTypeOf,
};
test/contract.js
const assert = require('node:assert/strict');
const reactIs = require('react-is');
const {
  StrictMode,
  Element,
  createElement,
  createStrictModeElement,
  checkIsStrictMode,
  checkIsValidElementType,
  inspectTypeOf,
} = require('../src/index.js');

// Contract 1: react-is exports StrictMode matching Symbol.for('react.strict_mode')
assert.equal(typeof StrictMode, 'symbol', 'StrictMode must be a symbol');
assert.equal(StrictMode, Symbol.for('react.strict_mode'), 'StrictMode must match Symbol.for("react.strict_mode")');
assert.equal(reactIs.StrictMode, StrictMode, 'Default import StrictMode must match exported StrictMode');

// Contract 2: isValidElementType identifies StrictMode as a valid React element type
assert.equal(checkIsValidElementType(StrictMode), true, 'StrictMode must be recognized as a valid element type');
assert.equal(reactIs.isValidElementType(StrictMode), true, 'react-is.isValidElementType must return true for StrictMode');
assert.equal(checkIsValidElementType('div'), true, 'String tag must be a valid element type');
assert.equal(checkIsValidElementType(() => null), true, 'Function component must be a valid element type');
assert.equal(checkIsValidElementType(123), false, 'Number must not be a valid element type');
assert.equal(checkIsValidElementType(null), false, 'null must not be a valid element type');
assert.equal(checkIsValidElementType(undefined), false, 'undefined must not be a valid element type');

// Contract 3: isStrictMode detects valid React 17 StrictMode elements
const strictModeWithChildren = createStrictModeElement(['child1', 'child2']);
assert.equal(checkIsStrictMode(strictModeWithChildren), true, 'StrictMode element with children must be detected by checkIsStrictMode');
assert.equal(reactIs.isStrictMode(strictModeWithChildren), true, 'StrictMode element with children must be detected by reactIs.isStrictMode');

const emptyStrictMode = createStrictModeElement();
assert.equal(checkIsStrictMode(emptyStrictMode), true, 'Empty StrictMode element must be detected by checkIsStrictMode');
assert.equal(reactIs.isStrictMode(emptyStrictMode), true, 'Empty StrictMode element must be detected by reactIs.isStrictMode');

// Contract 4: isStrictMode returns false for StrictMode symbol itself, non-strictmode elements, and primitives
assert.equal(checkIsStrictMode(StrictMode), false, 'StrictMode symbol itself is not an element instance');
assert.equal(reactIs.isStrictMode(StrictMode), false, 'StrictMode symbol itself must return false from isStrictMode');

const divElement = createElement('div', { id: 'root' });
assert.equal(checkIsStrictMode(divElement), false, 'Plain div element must not be identified as a StrictMode');
assert.equal(reactIs.isStrictMode(divElement), false, 'Plain div element must return false from isStrictMode');

const fragmentElement = createElement(Symbol.for('react.fragment'));
assert.equal(checkIsStrictMode(fragmentElement), false, 'Fragment element must not be identified as a StrictMode');

const transitionalElement = {
  $$typeof: Symbol.for('react.transitional.element'),
  type: StrictMode,
  props: {},
  key: null,
  ref: null,
};
assert.equal(checkIsStrictMode(transitionalElement), false, 'React 19 transitional element is not recognized by React 17 react-is');

assert.equal(checkIsStrictMode(null), false, 'null must return false');
assert.equal(checkIsStrictMode(undefined), false, 'undefined must return false');
assert.equal(checkIsStrictMode({}), false, 'Plain object must return false');
assert.equal(checkIsStrictMode('react.strict_mode'), false, 'String must return false');
assert.equal(checkIsStrictMode(42), false, 'Number must return false');

// Contract 5: typeOf returns StrictMode symbol for valid strictmode elements and undefined for non-elements
assert.equal(inspectTypeOf(strictModeWithChildren), StrictMode, 'inspectTypeOf must return StrictMode symbol for strictmode element');
assert.equal(reactIs.typeOf(strictModeWithChildren), StrictMode, 'reactIs.typeOf must return StrictMode symbol for strictmode element');
assert.equal(inspectTypeOf(emptyStrictMode), StrictMode, 'inspectTypeOf must return StrictMode symbol for empty strictmode element');

assert.equal(inspectTypeOf(divElement), Element, 'inspectTypeOf returns Element symbol for plain element');
assert.equal(inspectTypeOf(fragmentElement), Symbol.for('react.fragment'), 'inspectTypeOf returns Fragment symbol');
assert.equal(inspectTypeOf(StrictMode), undefined, 'inspectTypeOf returns undefined for StrictMode symbol');
assert.equal(inspectTypeOf(null), undefined, 'inspectTypeOf returns undefined for null');
assert.equal(inspectTypeOf(undefined), undefined, 'inspectTypeOf returns undefined for undefined');
assert.equal(inspectTypeOf({}), undefined, 'inspectTypeOf returns undefined for plain object');
assert.equal(inspectTypeOf(transitionalElement), undefined, 'inspectTypeOf returns undefined for non-React-17 element');

console.log('All react-is.StrictMode contract assertions passed.');

Seeder de origen

anónimo