Home / File/ evaluator.ts — react Source File

evaluator.ts — react Source File

Architecture documentation for evaluator.ts, a typescript file in the react codebase. 9 imports, 1 dependents.

File typescript BabelCompiler Optimization 9 imports 1 dependents 5 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  e04df78a_8312_1a6c_3ce1_ea408e44a1d7["evaluator.ts"]
  9afdd6fb_14c3_0a52_8105_2d82e58c5c28["shared-runtime.ts"]
  e04df78a_8312_1a6c_3ce1_ea408e44a1d7 --> 9afdd6fb_14c3_0a52_8105_2d82e58c5c28
  8b0887f0_d007_0d5f_9960_53272a0978f8["initFbt"]
  e04df78a_8312_1a6c_3ce1_ea408e44a1d7 --> 8b0887f0_d007_0d5f_9960_53272a0978f8
  3c44ef67_7a19_657e_bba6_9d9cff25667a["toJSON"]
  e04df78a_8312_1a6c_3ce1_ea408e44a1d7 --> 3c44ef67_7a19_657e_bba6_9d9cff25667a
  9adf9051_2ce4_6a22_5a47_ad6ee61b1f13["react"]
  e04df78a_8312_1a6c_3ce1_ea408e44a1d7 --> 9adf9051_2ce4_6a22_5a47_ad6ee61b1f13
  0a7e71c9_7116_9188_39b8_92cd974c7e3d["jsdom"]
  e04df78a_8312_1a6c_3ce1_ea408e44a1d7 --> 0a7e71c9_7116_9188_39b8_92cd974c7e3d
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  e04df78a_8312_1a6c_3ce1_ea408e44a1d7 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  e38503ff_90ab_2fd6_8dbb_f5a5a0bd5a1b["util"]
  e04df78a_8312_1a6c_3ce1_ea408e44a1d7 --> e38503ff_90ab_2fd6_8dbb_f5a5a0bd5a1b
  3d45252d_d5b7_7967_8ef9_8c2bccea9e5a["v4"]
  e04df78a_8312_1a6c_3ce1_ea408e44a1d7 --> 3d45252d_d5b7_7967_8ef9_8c2bccea9e5a
  d157601a_1234_7a9e_01ed_b9c8b76dc5e4["v4"]
  e04df78a_8312_1a6c_3ce1_ea408e44a1d7 --> d157601a_1234_7a9e_01ed_b9c8b76dc5e4
  f8b6e051_0f7f_6e15_4727_f99783e05cbb["index.ts"]
  f8b6e051_0f7f_6e15_4727_f99783e05cbb --> e04df78a_8312_1a6c_3ce1_ea408e44a1d7
  style e04df78a_8312_1a6c_3ce1_ea408e44a1d7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import {render} from '@testing-library/react';
import {JSDOM} from 'jsdom';
import React, {MutableRefObject} from 'react';
import util from 'util';
import {z} from 'zod/v4';
import {fromZodError} from 'zod-validation-error/v4';
import {initFbt, toJSON} from './shared-runtime';

/**
 * Set up the global environment for JSDOM tests.
 * This is a hack to let us share code and setup between the test
 * and runner environments. As an alternative, we could evaluate all setup
 * in the jsdom test environment (which provides more isolation), but that
 * may be slower.
 */
const {window: testWindow} = new JSDOM(undefined);
(globalThis as any).document = testWindow.document;
(globalThis as any).window = testWindow.window;
(globalThis as any).React = React;
(globalThis as any).render = render;
initFbt();

(globalThis as any).placeholderFn = function (..._args: Array<any>) {
  throw new Error('Fixture not implemented!');
};
export type EvaluatorResult = {
  kind: 'ok' | 'exception' | 'UnexpectedError';
  value: string;
  logs: Array<string>;
};

/**
 * Define types and schemas for fixture entrypoint
 */
const EntrypointSchema = z.strictObject({
  fn: z.union([z.function(), z.object({})]),
  params: z.array(z.any()),

  // DEPRECATED, unused
  isComponent: z.optional(z.boolean()),

  // if enabled, the `fn` is assumed to be a component and this is assumed
  // to be an array of props. the component is mounted once and rendered
  // once per set of props in this array.
  sequentialRenders: z.optional(z.nullable(z.array(z.any()))).default(null),
});
const ExportSchema = z.object({
  FIXTURE_ENTRYPOINT: EntrypointSchema,
});

const NO_ERROR_SENTINEL = Symbol();
/**
 * Wraps WrapperTestComponent in an error boundary to simplify re-rendering
// ... (251 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does evaluator.ts do?
evaluator.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in evaluator.ts?
evaluator.ts defines 5 function(s): WrapperTestComponent, doEval, evaluateFixtureExport, placeholderFn, renderComponentSequentiallyForEachProps.
What does evaluator.ts depend on?
evaluator.ts imports 9 module(s): initFbt, jsdom, react, react, shared-runtime.ts, toJSON, util, v4, and 1 more.
What files import evaluator.ts?
evaluator.ts is imported by 1 file(s): index.ts.
Where is evaluator.ts in the architecture?
evaluator.ts is located at compiler/packages/snap/src/sprout/evaluator.ts (domain: BabelCompiler, subdomain: Optimization, directory: compiler/packages/snap/src/sprout).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free