test-renderer 0.16.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -10
- package/dist/index.cjs +38 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.js +35 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Test Renderer for React
|
|
2
2
|
|
|
3
|
-
A lightweight
|
|
3
|
+
A lightweight test renderer for React and a modern replacement for the deprecated React Test Renderer.
|
|
4
4
|
|
|
5
5
|
This library is used by [React Native Testing Library](https://github.com/callstack/react-native-testing-library) but should work with any React variant.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
It uses [React Reconciler](https://github.com/facebook/react/tree/main/packages/react-reconciler) to build a custom renderer that operates on host elements by default, and provides escape hatches for complex use-cases. Most React Reconciler options are exposed through `RootOptions`.
|
|
8
8
|
|
|
9
9
|
For release and compatibility policy, see [docs/versioning.md](./docs/versioning.md).
|
|
10
10
|
|
|
@@ -38,13 +38,17 @@ test("renders a component", async () => {
|
|
|
38
38
|
});
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
##
|
|
41
|
+
## React 19 Compatibility Lines
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
Starting with `1.x`, `test-renderer` tracks preferred React 19 compatibility lines while keeping a broad React 19 peer range so installs do not get blocked between React minor releases.
|
|
44
44
|
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
| `test-renderer` version | `react` version | `react-reconciler` version | Notable React features |
|
|
46
|
+
| ----------------------- | --------------- | -------------------------- | ------------------------------------------------------- |
|
|
47
|
+
| `1.0.x` | `19.0` | `~0.31.0` | Actions, `useActionState`, `useOptimistic`, `use` |
|
|
48
|
+
| `1.1.x` | `19.1` | `~0.32.0` | Owner Stack support, CSS-selector-safe `useId()` format |
|
|
49
|
+
| `1.2.x` | `19.2` | `~0.33.0` | `<Activity />`, `useEffectEvent` |
|
|
50
|
+
|
|
51
|
+
These examples are illustrative, not exhaustive. The `1.0.x` and `1.1.x` lines are current, and `1.2.x` is the next planned React 19 line. New React-minor-specific support lands on the matching preferred React / `react-reconciler` line for each `1.x` release, even though the package publishes a broad React 19 peer range.
|
|
48
52
|
|
|
49
53
|
## Test Output Tree
|
|
50
54
|
|
|
@@ -78,7 +82,7 @@ Creates a new test renderer root instance.
|
|
|
78
82
|
|
|
79
83
|
**Returns:** A `Root` object with the following properties:
|
|
80
84
|
|
|
81
|
-
- `render(element: ReactElement)`: Renders a React element into the root. Must be called within `act()`.
|
|
85
|
+
- `render(element: ReactElement)`: Renders a React element into the root. Fragments are supported. Non-element root values such as strings or `null` are not supported. Must be called within `act()`.
|
|
82
86
|
- `unmount()`: Unmounts the root and cleans up. Must be called within `act()`.
|
|
83
87
|
- `container`: A `TestInstance` wrapper that contains the rendered element(s). Use this to query and inspect the rendered tree.
|
|
84
88
|
|
|
@@ -113,8 +117,8 @@ A wrapper around rendered host elements with a DOM-like API for querying and ins
|
|
|
113
117
|
**Properties:**
|
|
114
118
|
|
|
115
119
|
- `type: string`: The element type (e.g., `"View"`, `"div"`). Returns an empty string for the container element.
|
|
116
|
-
- `props: Record<string,
|
|
117
|
-
- `children:
|
|
120
|
+
- `props: Record<string, any>`: The element's props object.
|
|
121
|
+
- `children: TestNode[]`: Array of child nodes (elements and text strings). Hidden children are excluded by default, but are included when `transformHiddenInstanceProps` is configured.
|
|
118
122
|
- `parent: TestInstance | null`: The parent element, or `null` if this is the root container.
|
|
119
123
|
- `unstable_fiber: Fiber | null`: Access to the underlying React Fiber node. **Warning:** This is an unstable API that exposes internal React Reconciler structures which may change without warning in future React versions. Use with caution and only when absolutely necessary.
|
|
120
124
|
|
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
+
let react = require("react");
|
|
24
25
|
let react_reconciler_constants_js = require("react-reconciler/constants.js");
|
|
25
26
|
let react_reconciler = require("react-reconciler");
|
|
26
27
|
react_reconciler = __toESM(react_reconciler);
|
|
@@ -186,6 +187,9 @@ function getTestNodeForInstance(instance) {
|
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
//#endregion
|
|
190
|
+
//#region src/test-utils/react-constants.ts
|
|
191
|
+
const REACT_CONTEXT_TYPE = Symbol.for("react.context");
|
|
192
|
+
//#endregion
|
|
189
193
|
//#region src/utils.ts
|
|
190
194
|
function formatComponentList(names) {
|
|
191
195
|
if (names.length === 0) return "";
|
|
@@ -199,7 +203,7 @@ function formatComponentList(names) {
|
|
|
199
203
|
//#region src/reconciler.ts
|
|
200
204
|
const nodeToInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
201
205
|
let currentUpdatePriority = react_reconciler_constants_js.NoEventPriority;
|
|
202
|
-
const
|
|
206
|
+
const hostConfig = {
|
|
203
207
|
supportsMutation: true,
|
|
204
208
|
supportsPersistence: false,
|
|
205
209
|
createInstance(type, props, rootContainer, _hostContext, internalHandle) {
|
|
@@ -480,19 +484,28 @@ const TestReconciler = (0, react_reconciler.default)({
|
|
|
480
484
|
suspendInstance(type, _props) {
|
|
481
485
|
mark("reconciler/suspendInstance", { type });
|
|
482
486
|
},
|
|
483
|
-
waitForCommitToBeReady(
|
|
484
|
-
mark("reconciler/waitForCommitToBeReady"
|
|
487
|
+
waitForCommitToBeReady(_state, _timeoutOffset) {
|
|
488
|
+
mark("reconciler/waitForCommitToBeReady");
|
|
485
489
|
return null;
|
|
486
490
|
},
|
|
487
491
|
supportsHydration: false,
|
|
488
492
|
NotPendingTransition: null,
|
|
493
|
+
HostTransitionContext: {
|
|
494
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
495
|
+
Provider: null,
|
|
496
|
+
Consumer: null,
|
|
497
|
+
_currentValue: null,
|
|
498
|
+
_currentValue2: null,
|
|
499
|
+
_threadCount: 0
|
|
500
|
+
},
|
|
489
501
|
resetFormInstance(_form) {
|
|
490
502
|
mark("reconciler/resetFormInstance");
|
|
491
503
|
},
|
|
492
504
|
requestPostPaintCallback(_callback) {
|
|
493
505
|
mark("reconciler/requestPostPaintCallback");
|
|
494
506
|
}
|
|
495
|
-
}
|
|
507
|
+
};
|
|
508
|
+
const TestReconciler = (0, react_reconciler.default)(hostConfig);
|
|
496
509
|
/**
|
|
497
510
|
* This method should mutate the `parentInstance` and add the child to its list of children. For example,
|
|
498
511
|
* in the DOM this would translate to a `parentInstance.appendChild(child)` call.
|
|
@@ -548,6 +561,7 @@ const defaultOnCaughtError = (error, errorInfo) => {
|
|
|
548
561
|
const defaultOnRecoverableError = (error, errorInfo) => {
|
|
549
562
|
console.error("Recoverable error:", error, errorInfo);
|
|
550
563
|
};
|
|
564
|
+
const defaultOnDefaultTransitionIndicator = () => {};
|
|
551
565
|
/**
|
|
552
566
|
* Create a new test renderer root instance.
|
|
553
567
|
*
|
|
@@ -567,15 +581,18 @@ function createRoot(options) {
|
|
|
567
581
|
transformHiddenInstanceProps: options?.transformHiddenInstanceProps
|
|
568
582
|
}
|
|
569
583
|
};
|
|
570
|
-
let containerFiber = TestReconciler.createContainer(container, react_reconciler_constants_js.ConcurrentRoot, null, options?.isStrictMode ?? false, false, options?.identifierPrefix ?? "", options?.onUncaughtError ?? defaultOnUncaughtError, options?.onCaughtError ?? defaultOnCaughtError, options?.onRecoverableError ?? defaultOnRecoverableError, null);
|
|
584
|
+
let containerFiber = TestReconciler.createContainer(container, react_reconciler_constants_js.ConcurrentRoot, null, options?.isStrictMode ?? false, false, options?.identifierPrefix ?? "", options?.onUncaughtError ?? defaultOnUncaughtError, options?.onCaughtError ?? defaultOnCaughtError, options?.onRecoverableError ?? defaultOnRecoverableError, defaultOnDefaultTransitionIndicator, null);
|
|
571
585
|
measureEnd("createRoot");
|
|
572
586
|
const render = (element) => {
|
|
573
587
|
if (containerFiber == null) throw new Error("Cannot render after unmount");
|
|
574
588
|
measureStart("render");
|
|
589
|
+
let elementType = "<invalid>";
|
|
575
590
|
try {
|
|
591
|
+
assertValidRootElement(element);
|
|
592
|
+
elementType = String(element.type);
|
|
576
593
|
TestReconciler.updateContainer(element, containerFiber, null, null);
|
|
577
594
|
} finally {
|
|
578
|
-
measureEnd("render", { elementType
|
|
595
|
+
measureEnd("render", { elementType });
|
|
579
596
|
}
|
|
580
597
|
};
|
|
581
598
|
const unmount = () => {
|
|
@@ -598,6 +615,21 @@ function createRoot(options) {
|
|
|
598
615
|
}
|
|
599
616
|
};
|
|
600
617
|
}
|
|
618
|
+
function assertValidRootElement(element) {
|
|
619
|
+
if ((0, react.isValidElement)(element)) return;
|
|
620
|
+
throw new Error(`root.render(...) expects a React element. Fragments are supported, but received ${formatInvalidRootValue(element)}.`);
|
|
621
|
+
}
|
|
622
|
+
function formatInvalidRootValue(value) {
|
|
623
|
+
if (value === null) return "null";
|
|
624
|
+
if (Array.isArray(value)) return "an array";
|
|
625
|
+
switch (typeof value) {
|
|
626
|
+
case "string": return "a string";
|
|
627
|
+
case "number": return "a number";
|
|
628
|
+
case "boolean": return "a boolean";
|
|
629
|
+
case "undefined": return "undefined";
|
|
630
|
+
default: return `a ${typeof value}`;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
601
633
|
//#endregion
|
|
602
634
|
exports.createRoot = createRoot;
|
|
603
635
|
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["NoEventPriority","DefaultEventPriority","ConcurrentRoot"],"sources":["../src/constants.ts","../src/performance.ts","../src/query-all.ts","../src/to-json.ts","../src/test-instance.ts","../src/utils.ts","../src/reconciler.ts","../src/renderer.ts"],"sourcesContent":["export const Tag = {\n Container: \"CONTAINER\",\n Instance: \"INSTANCE\",\n Text: \"TEXT\",\n} as const;\n\n// Container should render as <>{...}</>\nexport const CONTAINER_TYPE = \"\";\n","declare global {\n var TEST_RENDERER_ENABLE_PROFILING: boolean | undefined;\n}\n\nexport function mark(name: string, details?: Record<string, unknown>): void {\n if (!globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n return;\n }\n\n performance.mark(`test-renderer/${name}`, { detail: details });\n}\n\nexport function measureStart(name: string): void {\n if (!globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n return;\n }\n\n performance.mark(`test-renderer/${name}:start`);\n}\n\nexport function measureEnd(name: string, details?: Record<string, unknown>): void {\n if (!globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n return;\n }\n\n performance.mark(`test-renderer/${name}:end`);\n performance.measure(`test-renderer/${name}`, {\n start: `test-renderer/${name}:start`,\n end: `test-renderer/${name}:end`,\n detail: details,\n });\n}\n","import type { TestInstance } from \"./test-instance\";\n\n/**\n * Options for querying elements in the rendered tree.\n */\nexport interface QueryOptions {\n /** Include the instance itself in the results if it matches the predicate. Defaults to false. */\n includeSelf?: boolean;\n\n /** Exclude any ancestors of deepest matched instances even if they match the predicate. Defaults to false. */\n matchDeepestOnly?: boolean;\n}\n\n/**\n * Find all descendant elements matching the predicate.\n *\n * @param instance - Root TestInstance to search from.\n * @param predicate - Function that returns true for matching elements.\n * @param options - Optional query configuration.\n * @returns Array of matching elements in tree order.\n */\nexport function queryAll(\n instance: TestInstance,\n predicate: (instance: TestInstance) => boolean,\n options?: QueryOptions,\n): TestInstance[] {\n const includeSelf = options?.includeSelf ?? false;\n const matchDeepestOnly = options?.matchDeepestOnly ?? false;\n\n const results: TestInstance[] = [];\n\n // Match descendants first but do not add them to results yet.\n const matchingDescendants: TestInstance[] = [];\n\n instance.children.forEach((child) => {\n if (typeof child === \"string\") {\n return;\n }\n\n matchingDescendants.push(...queryAll(child, predicate, { ...options, includeSelf: true }));\n });\n\n if (\n includeSelf &&\n // When matchDeepestOnly = true: add current element only if no descendants match\n (matchingDescendants.length === 0 || !matchDeepestOnly) &&\n predicate(instance)\n ) {\n results.push(instance);\n }\n\n // Add matching descendants after element to preserve original tree walk order.\n results.push(...matchingDescendants);\n\n return results;\n}\n","import { CONTAINER_TYPE, Tag } from \"./constants\";\nimport type { Container, Instance, TextInstance } from \"./reconciler\";\n\n/** A node in the JSON representation - either a JsonElement or a text string. */\nexport type JsonNode = JsonElement | string;\n\n/**\n * JSON representation of a rendered element, compatible with react-test-renderer format.\n */\nexport type JsonElement = {\n type: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: Record<string, any>;\n children: JsonNode[];\n $$typeof: symbol;\n};\n\nexport function containerToJson(container: Container): JsonElement {\n return {\n type: CONTAINER_TYPE,\n props: {},\n children: childrenToJson(container.children),\n $$typeof: Symbol.for(\"react.test.json\"),\n };\n}\n\nexport function instanceToJson(instance: Instance): JsonElement | null {\n const shouldExcludeHidden = instance.rootContainer.config.transformHiddenInstanceProps == null;\n if (instance.isHidden && shouldExcludeHidden) {\n return null;\n }\n\n // We don't include the `children` prop in JSON.\n // Instead, we will include the actual rendered children.\n const { children: _children, ...restProps } = instance.props;\n\n return {\n type: instance.type,\n props: restProps,\n children: childrenToJson(instance.children),\n $$typeof: Symbol.for(\"react.test.json\"),\n };\n}\n\nexport function textInstanceToJson(instance: TextInstance): string | null {\n const shouldExcludeHidden = instance.rootContainer.config.transformHiddenInstanceProps == null;\n if (instance.isHidden && shouldExcludeHidden) {\n return null;\n }\n\n return instance.text;\n}\n\nexport function childrenToJson(children: Array<Instance | TextInstance>): JsonNode[] {\n const result = [];\n\n for (const child of children) {\n if (child.tag === Tag.Instance) {\n const renderedChild = instanceToJson(child);\n if (renderedChild != null) {\n result.push(renderedChild);\n }\n } else {\n const renderedChild = textInstanceToJson(child);\n if (renderedChild != null) {\n result.push(renderedChild);\n }\n }\n }\n\n return result;\n}\n","import type { Fiber } from \"react-reconciler\";\n\nimport { CONTAINER_TYPE, Tag } from \"./constants\";\nimport type { QueryOptions } from \"./query-all\";\nimport { queryAll } from \"./query-all\";\nimport type { Container, Instance, TextInstance } from \"./reconciler\";\nimport type { JsonElement } from \"./to-json\";\nimport { containerToJson, instanceToJson } from \"./to-json\";\n\n/** A node in the rendered tree - either a TestInstance or a text string. */\nexport type TestNode = TestInstance | string;\n\nconst instanceMap = new WeakMap<Instance | Container, TestInstance>();\n\n/**\n * Represents a rendered host element in the test renderer tree.\n * Provides a DOM-like API for querying and inspecting rendered components.\n */\nexport class TestInstance {\n private instance: Instance | Container;\n\n private constructor(instance: Instance | Container) {\n this.instance = instance;\n }\n\n /** The element type (e.g., \"div\", \"span\"). Empty string for container. */\n get type(): string {\n return this.instance.tag === Tag.Instance ? this.instance.type : CONTAINER_TYPE;\n }\n\n /** The element's props object. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get props(): Record<string, any> {\n return this.instance.tag === Tag.Instance ? this.instance.props : {};\n }\n\n /** The parent element, or null if this is the root container. */\n get parent(): TestInstance | null {\n const parentInstance = this.instance.parent;\n if (parentInstance == null) {\n return null;\n }\n\n return TestInstance.fromInstance(parentInstance);\n }\n\n /** Array of child nodes (elements and text strings). Hidden children are excluded by default. */\n get children(): TestNode[] {\n const container =\n this.instance.tag === Tag.Container ? this.instance : this.instance.rootContainer;\n const shouldExcludeHiddenChildren = container.config.transformHiddenInstanceProps == null;\n\n const result = this.instance.children\n .filter((child) => !child.isHidden || !shouldExcludeHiddenChildren)\n .map((child) => getTestNodeForInstance(child));\n return result;\n }\n\n /**\n * Access to the underlying React Fiber node. This is an unstable API that exposes\n * internal react-reconciler structures which may change without warning in future\n * React versions. Use with caution and only when absolutely necessary.\n *\n * @returns The Fiber node for this instance, or null if this is a container.\n */\n get unstable_fiber(): Fiber | null {\n return this.instance.tag === Tag.Instance ? this.instance.unstable_fiber : null;\n }\n\n /**\n * Convert this element to a JSON representation suitable for snapshots.\n *\n * @returns JSON element or null if the element is hidden and hidden nodes are excluded.\n */\n toJSON(): JsonElement | null {\n return this.instance.tag === Tag.Container\n ? containerToJson(this.instance)\n : instanceToJson(this.instance);\n }\n\n /**\n * Find all descendant elements matching the predicate.\n *\n * @param predicate - Function that returns true for matching elements.\n * @param options - Optional query configuration.\n * @returns Array of matching elements.\n */\n queryAll(predicate: (instance: TestInstance) => boolean, options?: QueryOptions): TestInstance[] {\n return queryAll(this, predicate, options);\n }\n\n /** @internal */\n static fromInstance(instance: Instance | Container): TestInstance {\n const testInstance = instanceMap.get(instance);\n if (testInstance) {\n return testInstance;\n }\n\n const result = new TestInstance(instance);\n instanceMap.set(instance, result);\n return result;\n }\n}\n\nfunction getTestNodeForInstance(instance: Instance | TextInstance): TestNode {\n switch (instance.tag) {\n case Tag.Text:\n return instance.text;\n\n case Tag.Instance:\n return TestInstance.fromInstance(instance);\n }\n}\n\n/** @deprecated `HostElement` was renamed to `TestInstance` */\nexport type HostElement = TestInstance;\n","export function formatComponentList(names: string[]): string {\n if (names.length === 0) {\n return \"\";\n }\n\n if (names.length === 1) {\n return `<${names[0]}>`;\n }\n\n if (names.length === 2) {\n return `<${names[0]}> or <${names[1]}>`;\n }\n\n const allButLast = names.slice(0, -1);\n const last = names[names.length - 1];\n\n return `${allButLast.map((name) => `<${name}>`).join(\", \")}, or <${last}>`;\n}\n","import type { Fiber } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\nimport { DefaultEventPriority, NoEventPriority } from \"react-reconciler/constants\";\n\nimport { Tag } from \"./constants\";\nimport { mark, measureEnd, measureStart } from \"./performance\";\nimport { TestInstance } from \"./test-instance\";\nimport { formatComponentList } from \"./utils\";\n\nexport type Type = string;\nexport type Props = Record<string, unknown>;\nexport type TransformHiddenInstanceProps = (input: { props: Props; type: Type }) => Props;\n\ntype ReconcilerConfig = {\n textComponentTypes?: string[];\n publicTextComponentTypes?: string[];\n transformHiddenInstanceProps?: TransformHiddenInstanceProps;\n};\n\nexport type Container = {\n tag: typeof Tag.Container;\n parent: null;\n children: Array<Instance | TextInstance>;\n isHidden: false;\n config: ReconcilerConfig;\n};\n\nexport type Instance = {\n tag: typeof Tag.Instance;\n type: string;\n props: Props;\n propsBeforeHiding: Props | null;\n children: Array<Instance | TextInstance>;\n parent: Container | Instance | null;\n rootContainer: Container;\n isHidden: boolean;\n unstable_fiber: Fiber;\n};\n\nexport type TextInstance = {\n tag: typeof Tag.Text;\n text: string;\n parent: Container | Instance | null;\n rootContainer: Container;\n isHidden: boolean;\n};\n\nexport type SuspenseInstance = object;\nexport type HydratableInstance = object;\nexport type PublicInstance = object | null;\nexport type UpdatePayload = unknown;\nexport type ChildSet = unknown;\nexport type TimeoutHandle = unknown;\nexport type NoTimeout = unknown;\n\ntype HostContext = {\n type: string;\n isInsideText: boolean;\n config: ReconcilerConfig;\n};\n\n// Newer react-reconciler builds expect these event-related host config methods at runtime,\n// but the published @types/react-reconciler package may lag behind and omit them.\ntype ExtendedHostConfig = ReactReconciler.HostConfig<\n Type,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n> & {\n trackSchedulerEvent?: () => void;\n resolveEventType?: () => null | string;\n resolveEventTimeStamp?: () => number;\n};\n\nconst nodeToInstanceMap = new WeakMap<object, Instance>();\n\nlet currentUpdatePriority: number = NoEventPriority;\n\nconst hostConfig: ExtendedHostConfig = {\n /**\n * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.\n *\n * If your target platform is similar to the DOM and has methods similar to `appendChild`, `removeChild`,\n * and so on, you'll want to use the **mutation mode**. This is the same mode used by React DOM, React ART,\n * and the classic React Native renderer.\n *\n * ```js\n * const HostConfig = {\n * // ...\n * supportsMutation: true,\n * // ...\n * }\n * ```\n *\n * Depending on the mode, the reconciler will call different methods on your host config.\n * If you're not sure which one you want, you likely need the mutation mode.\n */\n supportsMutation: true,\n\n /**\n * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.\n *\n * If your target platform has immutable trees, you'll want the **persistent mode** instead. In that mode,\n * existing nodes are never mutated, and instead every change clones the parent tree and then replaces\n * the whole parent tree at the root. This is the node used by the new React Native renderer, codenamed \"Fabric\".\n *\n * ```js\n * const HostConfig = {\n * // ...\n * supportsPersistence: true,\n * // ...\n * }\n * ```\n *\n * Depending on the mode, the reconciler will call different methods on your host config.\n * If you're not sure which one you want, you likely need the mutation mode.\n */\n supportsPersistence: false,\n\n /**\n * #### `createInstance(type, props, rootContainer, hostContext, internalHandle)`\n *\n * This method should return a newly created node. For example, the DOM renderer would call\n * `document.createElement(type)` here and then set the properties from `props`.\n *\n * You can use `rootContainer` to access the root container associated with that tree. For example,\n * in the DOM renderer, this is useful to get the correct `document` reference that the root belongs to.\n *\n * The `hostContext` parameter lets you keep track of some information about your current place in\n * the tree. To learn more about it, see `getChildHostContext` below.\n *\n * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its\n * internal fields, be aware that it may change significantly between versions. You're taking on additional\n * maintenance risk by reading from it, and giving up all guarantees if you write something to it.\n *\n * This method happens **in the render phase**. It can (and usually should) mutate the node it has\n * just created before returning it, but it must not modify any other nodes. It must not register\n * any event handlers on the parent tree. This is because an instance being created doesn't guarantee\n * it would be placed in the tree — it could be left unused and later collected by GC. If you need to do\n * something when an instance is definitely in the tree, look at `commitMount` instead.\n */\n createInstance(\n type: Type,\n props: Props,\n rootContainer: Container,\n _hostContext: HostContext,\n internalHandle: Fiber,\n ) {\n mark(\"reconciler/createInstance\", { type });\n\n return {\n tag: Tag.Instance,\n type,\n props,\n propsBeforeHiding: null,\n isHidden: false,\n children: [],\n parent: null,\n rootContainer,\n unstable_fiber: internalHandle,\n };\n },\n\n /**\n * #### `createTextInstance(text, rootContainer, hostContext, internalHandle)`\n *\n * Same as `createInstance`, but for text nodes. If your renderer doesn't support text nodes, you can\n * throw here.\n */\n createTextInstance(\n text: string,\n rootContainer: Container,\n hostContext: HostContext,\n _internalHandle: Fiber,\n ): TextInstance {\n mark(\"reconciler/createTextInstance\", { text });\n\n if (rootContainer.config.textComponentTypes && !hostContext.isInsideText) {\n const componentTypes =\n rootContainer.config.publicTextComponentTypes ?? rootContainer.config.textComponentTypes;\n\n throw new Error(\n `Invariant Violation: Text strings must be rendered within a ${formatComponentList(\n componentTypes,\n )} component. Detected attempt to render \"${text}\" string within a <${\n hostContext.type\n }> component.`,\n );\n }\n\n return {\n tag: Tag.Text,\n text,\n parent: null,\n rootContainer,\n isHidden: false,\n };\n },\n\n /**\n * #### `appendInitialChild(parentInstance, child)`\n *\n * This method should mutate the `parentInstance` and add the child to its list of children.\n * For example, in the DOM this would translate to a `parentInstance.appendChild(child)` call.\n *\n * This method happens **in the render phase**. It can mutate `parentInstance` and `child`, but it\n * must not modify any other nodes. It's called while the tree is still being built up and not connected\n * to the actual tree on the screen.\n */\n appendInitialChild(parentInstance: Instance, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/appendInitialChild\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n });\n }\n\n appendChild(parentInstance, child);\n },\n\n /**\n * #### `finalizeInitialChildren(instance, type, props, rootContainer, hostContext)`\n *\n * In this method, you can perform some final mutations on the `instance`. Unlike with `createInstance`,\n * by the time `finalizeInitialChildren` is called, all the initial children have already been added to\n * the `instance`, but the instance itself has not yet been connected to the tree on the screen.\n *\n * This method happens **in the render phase**. It can mutate `instance`, but it must not modify any other\n * nodes. It's called while the tree is still being built up and not connected to the actual tree on the screen.\n *\n * There is a second purpose to this method. It lets you specify whether there is some work that needs to\n * happen when the node is connected to the tree on the screen. If you return `true`, the instance will\n * receive a `commitMount` call later. See its documentation below.\n *\n * If you don't want to do anything here, you should return `false`.\n */\n finalizeInitialChildren(\n instance: Instance,\n _type: Type,\n _props: Props,\n _rootContainer: Container,\n _hostContext: HostContext,\n ): boolean {\n mark(\"reconciler/finalizeInitialChildren\", { type: instance.type });\n\n return false;\n },\n\n /**\n * #### `shouldSetTextContent(type, props)`\n *\n * Some target platforms support setting an instance's text content without manually creating a text node.\n * For example, in the DOM, you can set `node.textContent` instead of creating a text node and appending it.\n *\n * If you return `true` from this method, React will assume that this node's children are text, and will\n * not create nodes for them. It will instead rely on you to have filled that text during `createInstance`.\n * This is a performance optimization. For example, the DOM renderer returns `true` only if `type` is a\n * known text-only parent (like `'textarea'`) or if `props.children` has a `'string'` type. If you return `true`,\n * you will need to implement `resetTextContent` too.\n *\n * If you don't want to do anything here, you should return `false`.\n * This method happens **in the render phase**. Do not mutate the tree from it.\n */\n shouldSetTextContent(type: Type, _props: Props): boolean {\n mark(\"reconciler/shouldSetTextContent\", { type, result: false });\n\n return false;\n },\n\n setCurrentUpdatePriority(priority: number) {\n mark(\"reconciler/setCurrentUpdatePriority\", { priority });\n\n currentUpdatePriority = priority;\n },\n\n getCurrentUpdatePriority() {\n return currentUpdatePriority;\n },\n\n resolveUpdatePriority(): number {\n const priority = currentUpdatePriority || DefaultEventPriority;\n mark(\"reconciler/resolveUpdatePriority\", { priority });\n\n return priority;\n },\n\n trackSchedulerEvent() {\n mark(\"reconciler/trackSchedulerEvent\");\n },\n\n resolveEventType(): null {\n mark(\"reconciler/resolveEventType\");\n\n return null;\n },\n\n resolveEventTimeStamp(): number {\n const timestamp = -1.1;\n mark(\"reconciler/resolveEventTimeStamp\", { timestamp });\n\n return timestamp;\n },\n\n shouldAttemptEagerTransition() {\n mark(\"reconciler/shouldAttemptEagerTransition\", { result: false });\n\n return false;\n },\n\n /**\n * #### `getRootHostContext(rootContainer)`\n *\n * This method lets you return the initial host context from the root of the tree. See `getChildHostContext`\n * for the explanation of host context.\n *\n * If you don't intend to use host context, you can return `null`.\n * This method happens **in the render phase**. Do not mutate the tree from it.\n */\n getRootHostContext(rootContainer: Container): HostContext | null {\n mark(\"reconciler/getRootHostContext\");\n\n return {\n type: \"ROOT\",\n config: rootContainer.config,\n isInsideText: false,\n };\n },\n\n /**\n * #### `getChildHostContext(parentHostContext, type, rootContainer)`\n *\n * Host context lets you track some information about where you are in the tree so that it's available\n * inside `createInstance` as the `hostContext` parameter. For example, the DOM renderer uses it to track\n * whether it's inside an HTML or an SVG tree, because `createInstance` implementation needs to be\n * different for them.\n *\n * If the node of this `type` does not influence the context you want to pass down, you can return\n * `parentHostContext`. Alternatively, you can return any custom object representing the information\n * you want to pass down.\n *\n * If you don't want to do anything here, return `parentHostContext`.\n *\n * This method happens **in the render phase**. Do not mutate the tree from it.\n */\n getChildHostContext(parentHostContext: HostContext, type: Type): HostContext {\n mark(\"reconciler/getChildHostContext\", { type });\n\n const isInsideText = Boolean(parentHostContext.config.textComponentTypes?.includes(type));\n return { ...parentHostContext, type: type, isInsideText };\n },\n\n /**\n * #### `getPublicInstance(instance)`\n *\n * Determines what object gets exposed as a ref. You'll likely want to return the `instance` itself. But\n * in some cases it might make sense to only expose some part of it.\n *\n * If you don't want to do anything here, return `instance`.\n */\n getPublicInstance(instance: Instance | TextInstance): PublicInstance {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/getPublicInstance\", {\n type: formatInstanceType(instance),\n });\n }\n\n switch (instance.tag) {\n case Tag.Instance: {\n const testInstance = TestInstance.fromInstance(instance);\n nodeToInstanceMap.set(testInstance, instance);\n return testInstance;\n }\n\n default:\n return null;\n }\n },\n\n /**\n * #### `prepareForCommit(containerInfo)`\n *\n * This method lets you store some information before React starts making changes to the tree on\n * the screen. For example, the DOM renderer stores the current text selection so that it can later\n * restore it. This method is mirrored by `resetAfterCommit`.\n *\n * Even if you don't want to do anything here, you need to return `null` from it.\n */\n prepareForCommit(_containerInfo: Container) {\n mark(\"reconciler/prepareForCommit\");\n measureStart(\"react/commit\");\n\n return null; // noop\n },\n\n /**\n * #### `resetAfterCommit(containerInfo)`\n *\n * This method is called right after React has performed the tree mutations. You can use it to restore\n * something you've stored in `prepareForCommit` — for example, text selection.\n *\n * You can leave it empty.\n */\n resetAfterCommit(_containerInfo: Container): void {\n measureEnd(\"react/commit\");\n mark(\"reconciler/resetAfterCommit\");\n },\n\n /**\n * #### `preparePortalMount(containerInfo)`\n *\n * This method is called for a container that's used as a portal target. Usually you can leave it empty.\n */\n preparePortalMount(_containerInfo: Container): void {\n mark(\"reconciler/preparePortalMount\");\n },\n\n /**\n * #### `scheduleTimeout(fn, delay)`\n *\n * You can proxy this to `setTimeout` or its equivalent in your environment.\n */\n scheduleTimeout(fn: () => void, delay: number): ReturnType<typeof setTimeout> {\n const id = setTimeout(() => {\n mark(\"reconciler/scheduled timeout:start\");\n fn();\n mark(\"reconciler/scheduled timeout:end\");\n }, delay);\n mark(\"reconciler/scheduleTimeout\", { id });\n return id;\n },\n\n /**\n * #### `cancelTimeout(id)`\n *\n * You can proxy this to `clearTimeout` or its equivalent in your environment.\n */\n cancelTimeout(id: ReturnType<typeof setTimeout>): void {\n mark(\"reconciler/cancelTimeout\", { id });\n\n clearTimeout(id);\n },\n\n /**\n * #### `noTimeout`\n *\n * This is a property (not a function) that should be set to something that can never be a valid timeout ID.\n * For example, you can set it to `-1`.\n */\n noTimeout: -1,\n\n /**\n * #### `supportsMicrotasks`\n *\n * Set this to `true` to indicate that your renderer supports `scheduleMicrotask`. We use microtasks as part\n * of our discrete event implementation in React DOM. If you're not sure if your renderer should support this,\n * you probably should. The option to not implement `scheduleMicrotask` exists so that platforms with more control\n * over user events, like React Native, can choose to use a different mechanism.\n */\n supportsMicrotasks: true,\n\n /**\n * #### `scheduleMicrotask(fn)`\n *\n * Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.\n */\n scheduleMicrotask(fn: () => void): ReturnType<typeof queueMicrotask> {\n mark(\"reconciler/scheduleMicrotask\");\n\n queueMicrotask(() => {\n mark(\"reconciler/scheduled microtask:start\");\n fn();\n mark(\"reconciler/scheduled microtask:end\");\n });\n },\n\n /**\n * #### `isPrimaryRenderer`\n *\n * This is a property (not a function) that should be set to `true` if your renderer is the main one on the\n * page. For example, if you're writing a renderer for the Terminal, it makes sense to set it to `true`, but\n * if your renderer is used *on top of* React DOM or some other existing renderer, set it to `false`.\n */\n isPrimaryRenderer: true,\n\n /**\n * Whether the renderer shouldn't trigger missing `act()` warnings\n */\n warnsIfNotActing: true,\n\n getInstanceFromNode(node: object): Fiber | null | undefined {\n mark(\"reconciler/getInstanceFromNode\");\n\n const instance = nodeToInstanceMap.get(node);\n if (instance !== undefined) {\n return instance.unstable_fiber;\n }\n\n return null;\n },\n\n beforeActiveInstanceBlur(): void {\n mark(\"reconciler/beforeActiveInstanceBlur\");\n },\n\n afterActiveInstanceBlur(): void {\n mark(\"reconciler/afterActiveInstanceBlur\");\n },\n\n prepareScopeUpdate(scopeInstance: object, instance: Instance): void {\n mark(\"reconciler/prepareScopeUpdate\");\n\n nodeToInstanceMap.set(scopeInstance, instance);\n },\n\n getInstanceFromScope(scopeInstance: object): Instance | null {\n mark(\"reconciler/getInstanceFromScope\");\n\n return nodeToInstanceMap.get(scopeInstance) ?? null;\n },\n\n detachDeletedInstance(_node: Instance): void {\n mark(\"reconciler/detachDeletedInstance\");\n },\n\n /**\n * #### `appendChild(parentInstance, child)`\n *\n * This method should mutate the `parentInstance` and add the child to its list of children. For example,\n * in the DOM this would translate to a `parentInstance.appendChild(child)` call.\n *\n * Although this method currently runs in the commit phase, you still should not mutate any other nodes\n * in it. If you need to do some additional work when a node is definitely connected to the visible tree, look at `commitMount`.\n */\n appendChild(parentInstance: Instance, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/appendChild\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n });\n }\n\n appendChild(parentInstance, child);\n },\n\n /**\n * #### `appendChildToContainer(container, child)`\n *\n * Same as `appendChild`, but for when a node is attached to the root container. This is useful if attaching\n * to the root has a slightly different implementation, or if the root container nodes are of a different\n * type than the rest of the tree.\n */\n appendChildToContainer(container: Container, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/appendChildToContainer\", {\n childType: formatInstanceType(child),\n });\n }\n\n appendChild(container, child);\n },\n\n /**\n * #### `insertBefore(parentInstance, child, beforeChild)`\n *\n * This method should mutate the `parentInstance` and place the `child` before `beforeChild` in the list of\n * its children. For example, in the DOM this would translate to a `parentInstance.insertBefore(child, beforeChild)` call.\n *\n * Note that React uses this method both for insertions and for reordering nodes. Similar to DOM, it is expected\n * that you can call `insertBefore` to reposition an existing child. Do not mutate any other parts of the tree from it.\n */\n insertBefore(\n parentInstance: Instance,\n child: Instance | TextInstance,\n beforeChild: Instance | TextInstance,\n ): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/insertBefore\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n beforeChildType: formatInstanceType(beforeChild),\n });\n }\n insertBefore(parentInstance, child, beforeChild);\n },\n\n /**\n * #### `insertInContainerBefore(container, child, beforeChild)\n *\n * Same as `insertBefore`, but for when a node is attached to the root container. This is useful if attaching\n * to the root has a slightly different implementation, or if the root container nodes are of a different type\n * than the rest of the tree.\n */\n insertInContainerBefore(\n container: Container,\n child: Instance | TextInstance,\n beforeChild: Instance | TextInstance,\n ): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/insertInContainerBefore\", {\n childType: formatInstanceType(child),\n beforeChildType: formatInstanceType(beforeChild),\n });\n }\n insertBefore(container, child, beforeChild);\n },\n\n /**\n * #### `removeChild(parentInstance, child)`\n *\n * This method should mutate the `parentInstance` to remove the `child` from the list of its children.\n *\n * React will only call it for the top-level node that is being removed. It is expected that garbage collection\n * would take care of the whole subtree. You are not expected to traverse the child tree in it.\n */\n removeChild(parentInstance: Instance, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/removeChild\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n });\n }\n removeChild(parentInstance, child);\n },\n\n /**\n * #### `removeChildFromContainer(container, child)`\n *\n * Same as `removeChild`, but for when a node is detached from the root container. This is useful if attaching\n * to the root has a slightly different implementation, or if the root container nodes are of a different type\n * than the rest of the tree.\n */\n removeChildFromContainer(container: Container, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/removeChildFromContainer\", {\n childType: formatInstanceType(child),\n });\n }\n removeChild(container, child);\n },\n\n /**\n * #### `resetTextContent(instance)`\n *\n * If you returned `true` from `shouldSetTextContent` for the previous props, but returned `false` from\n * `shouldSetTextContent` for the next props, React will call this method so that you can clear the text\n * content you were managing manually. For example, in the DOM you could set `node.textContent = ''`.\n *\n * If you never return `true` from `shouldSetTextContent`, you can leave it empty.\n */\n resetTextContent(instance: Instance): void {\n mark(\"reconciler/resetTextContent\", { type: instance.type });\n },\n\n /**\n * #### `commitTextUpdate(textInstance, prevText, nextText)`\n *\n * This method should mutate the `textInstance` and update its text content to `nextText`.\n *\n * Here, `textInstance` is a node created by `createTextInstance`.\n */\n commitTextUpdate(textInstance: TextInstance, oldText: string, newText: string): void {\n mark(\"reconciler/commitTextUpdate\", { oldText, newText });\n\n textInstance.text = newText;\n },\n\n /**\n * #### `commitMount(instance, type, props, internalHandle)`\n *\n * This method is only called if you returned `true` from `finalizeInitialChildren` for this instance.\n *\n * It lets you do some additional work after the node is actually attached to the tree on the screen for\n * the first time. For example, the DOM renderer uses it to trigger focus on nodes with the `autoFocus` attribute.\n *\n * Note that `commitMount` does not mirror `removeChild` one to one because `removeChild` is only called for\n * the top-level removed node. This is why ideally `commitMount` should not mutate any nodes other than the\n * `instance` itself. For example, if it registers some events on some node above, it will be your responsibility\n * to traverse the tree in `removeChild` and clean them up, which is not ideal.\n *\n * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal\n * fields, be aware that it may change significantly between versions. You're taking on additional maintenance\n * risk by reading from it, and giving up all guarantees if you write something to it.\n *\n * If you never return `true` from `finalizeInitialChildren`, you can leave it empty.\n */\n commitMount(_instance: Instance, type: Type, _props: Props, _internalHandle: Fiber): void {\n mark(\"reconciler/commitMount\", { type });\n },\n\n /**\n * #### `commitUpdate(instance, type, prevProps, nextProps, internalHandle)`\n *\n * This method should mutate the `instance` according to the set of changes in `updatePayload`. Here, `updatePayload`\n * is the object that you've returned from `prepareUpdate` and has an arbitrary structure that makes sense for your\n * renderer. For example, the DOM renderer returns an update payload like `[prop1, value1, prop2, value2, ...]` from\n * `prepareUpdate`, and that structure gets passed into `commitUpdate`. Ideally, all the diffing and calculation\n * should happen inside `prepareUpdate` so that `commitUpdate` can be fast and straightforward.\n *\n * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal fields,\n * be aware that it may change significantly between versions. You're taking on additional maintenance risk by\n * reading from it, and giving up all guarantees if you write something to it.\n */\n // @ts-expect-error @types/react-reconciler types don't fully match react-reconciler's actual Flow types.\n // Correctness is verified through tests.\n commitUpdate(\n instance: Instance,\n type: Type,\n _prevProps: Props,\n nextProps: Props,\n internalHandle: Fiber,\n ): void {\n mark(\"reconciler/commitUpdate\", { type });\n\n instance.type = type;\n if (instance.isHidden && instance.rootContainer.config.transformHiddenInstanceProps != null) {\n instance.propsBeforeHiding = nextProps;\n instance.props = instance.rootContainer.config.transformHiddenInstanceProps({\n props: nextProps,\n type: instance.type,\n });\n } else {\n instance.props = nextProps;\n instance.propsBeforeHiding = null;\n }\n instance.unstable_fiber = internalHandle;\n },\n\n /**\n * #### `hideInstance(instance)`\n *\n * This method should make the `instance` invisible without removing it from the tree. For example, it can apply\n * visual styling to hide it. It is used by Suspense to hide the tree while the fallback is visible.\n */\n hideInstance(instance: Instance): void {\n mark(\"reconciler/hideInstance\", { type: instance.type });\n\n if (instance.isHidden) {\n return;\n }\n\n instance.isHidden = true;\n instance.propsBeforeHiding = instance.props;\n\n const transformHiddenInstanceProps = instance.rootContainer.config.transformHiddenInstanceProps;\n if (transformHiddenInstanceProps) {\n const { props, type } = instance;\n instance.props = transformHiddenInstanceProps({ props, type });\n }\n },\n\n /**\n * #### `hideTextInstance(textInstance)`\n *\n * Same as `hideInstance`, but for nodes created by `createTextInstance`.\n */\n hideTextInstance(textInstance: TextInstance): void {\n mark(\"reconciler/hideTextInstance\", { text: textInstance.text });\n\n textInstance.isHidden = true;\n },\n\n /**\n * #### `unhideInstance(instance, props)`\n *\n * This method should make the `instance` visible, undoing what `hideInstance` did.\n */\n unhideInstance(instance: Instance, _props: Props): void {\n mark(\"reconciler/unhideInstance\", { type: instance.type });\n\n instance.isHidden = false;\n\n const transformHiddenInstanceProps = instance.rootContainer.config.transformHiddenInstanceProps;\n if (transformHiddenInstanceProps && instance.propsBeforeHiding) {\n instance.props = instance.propsBeforeHiding;\n instance.propsBeforeHiding = null;\n }\n },\n\n /**\n * #### `unhideTextInstance(textInstance, text)`\n *\n * Same as `unhideInstance`, but for nodes created by `createTextInstance`.\n */\n unhideTextInstance(textInstance: TextInstance, _text: string): void {\n mark(\"reconciler/unhideTextInstance\", { text: textInstance.text });\n\n textInstance.isHidden = false;\n },\n\n /**\n * #### `clearContainer(container)`\n *\n * This method should mutate the `container` root node and remove all children from it.\n */\n clearContainer(container: Container): void {\n mark(\"reconciler/clearContainer\");\n\n container.children.forEach((child) => {\n child.parent = null;\n });\n\n container.children.splice(0);\n },\n\n /**\n * #### `maySuspendCommit(type, props)`\n *\n * This method is called during render to determine if the Host Component type and props require\n * some kind of loading process to complete before committing an update.\n */\n maySuspendCommit(type: Type, _props: Props): boolean {\n mark(\"reconciler/maySuspendCommit\", { type });\n\n return false;\n },\n\n /**\n * #### `preloadInstance(type, props)`\n *\n * This method may be called during render if the Host Component type and props might suspend a commit.\n * It can be used to initiate any work that might shorten the duration of a suspended commit.\n */\n preloadInstance(type: Type, _props: Props): boolean {\n mark(\"reconciler/preloadInstance\", { type });\n\n return true;\n },\n\n /**\n * #### `startSuspendingCommit()`\n *\n * This method is called just before the commit phase. Use it to set up any necessary state while any Host\n * Components that might suspend this commit are evaluated to determine if the commit must be suspended.\n */\n startSuspendingCommit() {\n mark(\"reconciler/startSuspendingCommit\");\n },\n\n /**\n * #### `suspendInstance(type, props)`\n *\n * This method is called after `startSuspendingCommit` for each Host Component that indicated it might\n * suspend a commit.\n */\n suspendInstance(type: Type, _props: Props) {\n mark(\"reconciler/suspendInstance\", { type });\n },\n\n /**\n * #### `waitForCommitToBeReady()`\n *\n * This method is called after all `suspendInstance` calls are complete.\n *\n * Return `null` if the commit can happen immediately.\n * Return `(initiateCommit: Function) => Function` if the commit must be suspended. The argument to this\n * callback will initiate the commit when called. The return value is a cancellation function that the\n * Reconciler can use to abort the commit.\n */\n waitForCommitToBeReady(type: Type, _props: Props) {\n mark(\"reconciler/waitForCommitToBeReady\", { type });\n\n return null;\n },\n\n // -------------------\n // Hydration Methods\n // (optional)\n // You can optionally implement hydration to \"attach\" to the existing tree during the initial render instead\n // of creating it from scratch. For example, the DOM renderer uses this to attach to an HTML markup.\n //\n // To support hydration, you need to declare `supportsHydration: true` and then implement the methods in\n // the \"Hydration\" section [listed in this file](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js).\n // File an issue if you need help.\n // -------------------\n supportsHydration: false,\n\n NotPendingTransition: null,\n\n resetFormInstance(_form: Instance) {\n mark(\"reconciler/resetFormInstance\");\n },\n\n requestPostPaintCallback(_callback: (endTime: number) => void) {\n mark(\"reconciler/requestPostPaintCallback\");\n },\n};\n\nexport const TestReconciler = ReactReconciler(hostConfig);\n\n/**\n * This method should mutate the `parentInstance` and add the child to its list of children. For example,\n * in the DOM this would translate to a `parentInstance.appendChild(child)` call.\n *\n * Although this method currently runs in the commit phase, you still should not mutate any other nodes\n * in it. If you need to do some additional work when a node is definitely connected to the visible tree,\n * look at `commitMount`.\n */\nfunction appendChild(parentInstance: Container | Instance, child: Instance | TextInstance): void {\n const index = parentInstance.children.indexOf(child);\n if (index !== -1) {\n parentInstance.children.splice(index, 1);\n }\n\n child.parent = parentInstance;\n parentInstance.children.push(child);\n}\n\n/**\n * This method should mutate the `parentInstance` and place the `child` before `beforeChild` in the list\n * of its children. For example, in the DOM this would translate to a\n * `parentInstance.insertBefore(child, beforeChild)` call.\n *\n * Note that React uses this method both for insertions and for reordering nodes. Similar to DOM, it is\n * expected that you can call `insertBefore` to reposition an existing child. Do not mutate any other parts\n * of the tree from it.\n */\nfunction insertBefore(\n parentInstance: Container | Instance,\n child: Instance | TextInstance,\n beforeChild: Instance | TextInstance,\n): void {\n const index = parentInstance.children.indexOf(child);\n if (index !== -1) {\n parentInstance.children.splice(index, 1);\n }\n\n child.parent = parentInstance;\n const beforeIndex = parentInstance.children.indexOf(beforeChild);\n parentInstance.children.splice(beforeIndex, 0, child);\n}\n\n/**\n * This method should mutate the `parentInstance` to remove the `child` from the list of its children.\n *\n * React will only call it for the top-level node that is being removed. It is expected that garbage\n * collection would take care of the whole subtree. You are not expected to traverse the child tree in it.\n */\nfunction removeChild(parentInstance: Container | Instance, child: Instance | TextInstance): void {\n const index = parentInstance.children.indexOf(child);\n parentInstance.children.splice(index, 1);\n child.parent = null;\n}\n\nfunction formatInstanceType(instance: Instance | TextInstance): string {\n return instance.tag === Tag.Text ? `text: \"${instance.text}\"` : instance.type;\n}\n","import type { ReactElement } from \"react\";\nimport { ConcurrentRoot } from \"react-reconciler/constants\";\n\nimport { Tag } from \"./constants\";\nimport { measureEnd, measureStart } from \"./performance\";\nimport type { Container, TransformHiddenInstanceProps } from \"./reconciler\";\nimport { TestReconciler } from \"./reconciler\";\nimport { TestInstance } from \"./test-instance\";\n\n// Refs:\n// https://github.com/facebook/react/blob/main/packages/react-test-renderer/src/ReactFiberConfigTestHost.js\n// https://github.com/facebook/react/blob/main/packages/react-noop-renderer/src/createReactNoop.js\n// https://github.com/facebook/react/blob/main/packages/react-native-renderer/src/ReactFiberConfigFabric.js\n\nconst defaultOnUncaughtError = (error: unknown, errorInfo: ErrorInfo) => {\n console.error(\"Uncaught error:\", error, errorInfo);\n};\nconst defaultOnCaughtError = (error: unknown, errorInfo: ErrorInfo) => {\n console.error(\"Caught error:\", error, errorInfo);\n};\nconst defaultOnRecoverableError = (error: unknown, errorInfo: ErrorInfo) => {\n console.error(\"Recoverable error:\", error, errorInfo);\n};\n\n/**\n * Options for configuring the test renderer root.\n */\nexport type RootOptions = {\n /** Types of host components that are allowed to contain text nodes. Trying to render text outside of these components will throw an error. */\n textComponentTypes?: string[];\n\n /**\n * Host component types to display to users in the error message when they try to render text outside of `textComponentTypes`.\n * Defaults to `textComponentTypes`, but you may want to override the components mentioned in the error message.\n */\n publicTextComponentTypes?: string[];\n\n /**\n * Transform props when React marks a host instance as hidden (e.g. during Suspense fallback).\n * Receives `{ props, type }` and should return a new props object.\n * Avoid mutating the provided `props` object.\n */\n transformHiddenInstanceProps?: TransformHiddenInstanceProps;\n\n /** Callback called when React catches an error in an Error Boundary. Called with the error caught by the Error Boundary, and an errorInfo object containing the componentStack. */\n onCaughtError?: ErrorHandler;\n\n /** Callback called when an error is thrown and not caught by an Error Boundary. Called with the error that was thrown, and an errorInfo object containing the componentStack. */\n onUncaughtError?: ErrorHandler;\n\n /** Callback called when React automatically recovers from errors. Called with an error React throws, and an errorInfo object containing the componentStack. Some recoverable errors may include the original error cause as error.cause. */\n onRecoverableError?: ErrorHandler;\n\n /** A string prefix React uses for IDs generated by useId. Useful to avoid conflicts when using multiple roots on the same page. */\n identifierPrefix?: string;\n\n /** Enable React Strict Mode. */\n isStrictMode?: boolean;\n};\n\n/** Callback for handling React errors. */\nexport type ErrorHandler = (error: unknown, errorInfo: ErrorInfo) => void;\n\n/** Error information provided to error handlers. */\nexport type ErrorInfo = {\n componentStack: string;\n};\n\n/**\n * Root instance returned by createRoot. Provides methods to render and unmount components.\n */\nexport type Root = {\n /** Render a React element into the root. Must be called within act(). */\n render: (element: ReactElement) => void;\n /** Unmount the root and clean up. Must be called within act(). */\n unmount: () => void;\n /** The root container element. */\n container: TestInstance;\n};\n\n/**\n * Create a new test renderer root instance.\n *\n * @param options - Optional configuration for the renderer.\n * @returns A Root instance with render, unmount, and container properties.\n */\nexport function createRoot(options?: RootOptions): Root {\n measureStart(\"createRoot\");\n\n let container: Container | null = {\n tag: Tag.Container,\n parent: null,\n children: [],\n isHidden: false,\n config: {\n textComponentTypes: options?.textComponentTypes,\n publicTextComponentTypes: options?.publicTextComponentTypes,\n transformHiddenInstanceProps: options?.transformHiddenInstanceProps,\n },\n };\n\n // @types/react-reconciler types don't fully match react-reconciler's actual Flow types.\n // The return type is correct at runtime but TypeScript can't verify it statically.\n // Correctness is verified through tests.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let containerFiber = TestReconciler.createContainer(\n container,\n ConcurrentRoot,\n null, // hydrationCallbacks\n options?.isStrictMode ?? false,\n false, // concurrentUpdatesByDefaultOverride\n options?.identifierPrefix ?? \"\",\n options?.onUncaughtError ?? defaultOnUncaughtError,\n options?.onCaughtError ?? defaultOnCaughtError,\n // @ts-expect-error @types/react-reconciler types don't include onRecoverableError parameter\n // in the createContainer signature, but react-reconciler's actual Flow types do.\n // Correctness is verified through tests.\n options?.onRecoverableError ?? defaultOnRecoverableError,\n null, // transitionCallbacks\n );\n\n measureEnd(\"createRoot\");\n\n const render = (element: ReactElement) => {\n if (containerFiber == null) {\n throw new Error(\"Cannot render after unmount\");\n }\n\n measureStart(\"render\");\n try {\n TestReconciler.updateContainer(element, containerFiber, null, null);\n } finally {\n measureEnd(\"render\", { elementType: String(element.type) });\n }\n };\n\n const unmount = () => {\n if (container == null) {\n return;\n }\n\n measureStart(\"unmount\");\n try {\n TestReconciler.updateContainer(null, containerFiber, null, null);\n } finally {\n measureEnd(\"unmount\");\n }\n\n containerFiber = null;\n container = null;\n };\n\n return {\n render,\n unmount,\n get container(): TestInstance {\n if (container == null) {\n throw new Error(\"Cannot access .container on unmounted test renderer\");\n }\n\n return TestInstance.fromInstance(container);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAa,MAAM;CACjB,WAAW;CACX,UAAU;CACV,MAAM;CACP;;;ACAD,SAAgB,KAAK,MAAc,SAAyC;AAC1E,KAAI,CAAC,WAAW,+BACd;AAGF,aAAY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rentRoot"],"sources":["../src/constants.ts","../src/performance.ts","../src/query-all.ts","../src/to-json.ts","../src/test-instance.ts","../src/test-utils/react-constants.ts","../src/utils.ts","../src/reconciler.ts","../src/renderer.ts"],"sourcesContent":["export const Tag = {\n Container: \"CONTAINER\",\n Instance: \"INSTANCE\",\n Text: \"TEXT\",\n} as const;\n\n// Container should render as <>{...}</>\nexport const CONTAINER_TYPE = \"\";\n","declare global {\n var TEST_RENDERER_ENABLE_PROFILING: boolean | undefined;\n}\n\nexport function mark(name: string, details?: Record<string, unknown>): void {\n if (!globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n return;\n }\n\n performance.mark(`test-renderer/${name}`, { detail: details });\n}\n\nexport function measureStart(name: string): void {\n if (!globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n return;\n }\n\n performance.mark(`test-renderer/${name}:start`);\n}\n\nexport function measureEnd(name: string, details?: Record<string, unknown>): void {\n if (!globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n return;\n }\n\n performance.mark(`test-renderer/${name}:end`);\n performance.measure(`test-renderer/${name}`, {\n start: `test-renderer/${name}:start`,\n end: `test-renderer/${name}:end`,\n detail: details,\n });\n}\n","import type { TestInstance } from \"./test-instance\";\n\n/**\n * Options for querying elements in the rendered tree.\n */\nexport interface QueryOptions {\n /** Include the instance itself in the results if it matches the predicate. Defaults to false. */\n includeSelf?: boolean;\n\n /** Exclude any ancestors of deepest matched instances even if they match the predicate. Defaults to false. */\n matchDeepestOnly?: boolean;\n}\n\n/**\n * Find all descendant elements matching the predicate.\n *\n * @param instance - Root TestInstance to search from.\n * @param predicate - Function that returns true for matching elements.\n * @param options - Optional query configuration.\n * @returns Array of matching elements in tree order.\n */\nexport function queryAll(\n instance: TestInstance,\n predicate: (instance: TestInstance) => boolean,\n options?: QueryOptions,\n): TestInstance[] {\n const includeSelf = options?.includeSelf ?? false;\n const matchDeepestOnly = options?.matchDeepestOnly ?? false;\n\n const results: TestInstance[] = [];\n\n // Match descendants first but do not add them to results yet.\n const matchingDescendants: TestInstance[] = [];\n\n instance.children.forEach((child) => {\n if (typeof child === \"string\") {\n return;\n }\n\n matchingDescendants.push(...queryAll(child, predicate, { ...options, includeSelf: true }));\n });\n\n if (\n includeSelf &&\n // When matchDeepestOnly = true: add current element only if no descendants match\n (matchingDescendants.length === 0 || !matchDeepestOnly) &&\n predicate(instance)\n ) {\n results.push(instance);\n }\n\n // Add matching descendants after element to preserve original tree walk order.\n results.push(...matchingDescendants);\n\n return results;\n}\n","import { CONTAINER_TYPE, Tag } from \"./constants\";\nimport type { Container, Instance, TextInstance } from \"./reconciler\";\n\n/** A node in the JSON representation - either a JsonElement or a text string. */\nexport type JsonNode = JsonElement | string;\n\n/**\n * JSON representation of a rendered element, compatible with react-test-renderer format.\n */\nexport type JsonElement = {\n type: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: Record<string, any>;\n children: JsonNode[];\n $$typeof: symbol;\n};\n\nexport function containerToJson(container: Container): JsonElement {\n return {\n type: CONTAINER_TYPE,\n props: {},\n children: childrenToJson(container.children),\n $$typeof: Symbol.for(\"react.test.json\"),\n };\n}\n\nexport function instanceToJson(instance: Instance): JsonElement | null {\n const shouldExcludeHidden = instance.rootContainer.config.transformHiddenInstanceProps == null;\n if (instance.isHidden && shouldExcludeHidden) {\n return null;\n }\n\n // We don't include the `children` prop in JSON.\n // Instead, we will include the actual rendered children.\n const { children: _children, ...restProps } = instance.props;\n\n return {\n type: instance.type,\n props: restProps,\n children: childrenToJson(instance.children),\n $$typeof: Symbol.for(\"react.test.json\"),\n };\n}\n\nexport function textInstanceToJson(instance: TextInstance): string | null {\n const shouldExcludeHidden = instance.rootContainer.config.transformHiddenInstanceProps == null;\n if (instance.isHidden && shouldExcludeHidden) {\n return null;\n }\n\n return instance.text;\n}\n\nexport function childrenToJson(children: Array<Instance | TextInstance>): JsonNode[] {\n const result = [];\n\n for (const child of children) {\n if (child.tag === Tag.Instance) {\n const renderedChild = instanceToJson(child);\n if (renderedChild != null) {\n result.push(renderedChild);\n }\n } else {\n const renderedChild = textInstanceToJson(child);\n if (renderedChild != null) {\n result.push(renderedChild);\n }\n }\n }\n\n return result;\n}\n","import type { Fiber } from \"react-reconciler\";\n\nimport { CONTAINER_TYPE, Tag } from \"./constants\";\nimport type { QueryOptions } from \"./query-all\";\nimport { queryAll } from \"./query-all\";\nimport type { Container, Instance, TextInstance } from \"./reconciler\";\nimport type { JsonElement } from \"./to-json\";\nimport { containerToJson, instanceToJson } from \"./to-json\";\n\n/** A node in the rendered tree - either a TestInstance or a text string. */\nexport type TestNode = TestInstance | string;\n\nconst instanceMap = new WeakMap<Instance | Container, TestInstance>();\n\n/**\n * Represents a rendered host element in the test renderer tree.\n * Provides a DOM-like API for querying and inspecting rendered components.\n */\nexport class TestInstance {\n private instance: Instance | Container;\n\n private constructor(instance: Instance | Container) {\n this.instance = instance;\n }\n\n /** The element type (e.g., \"div\", \"span\"). Empty string for container. */\n get type(): string {\n return this.instance.tag === Tag.Instance ? this.instance.type : CONTAINER_TYPE;\n }\n\n /** The element's props object. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get props(): Record<string, any> {\n return this.instance.tag === Tag.Instance ? this.instance.props : {};\n }\n\n /** The parent element, or null if this is the root container. */\n get parent(): TestInstance | null {\n const parentInstance = this.instance.parent;\n if (parentInstance == null) {\n return null;\n }\n\n return TestInstance.fromInstance(parentInstance);\n }\n\n /** Array of child nodes (elements and text strings). Hidden children are excluded by default. */\n get children(): TestNode[] {\n const container =\n this.instance.tag === Tag.Container ? this.instance : this.instance.rootContainer;\n const shouldExcludeHiddenChildren = container.config.transformHiddenInstanceProps == null;\n\n const result = this.instance.children\n .filter((child) => !child.isHidden || !shouldExcludeHiddenChildren)\n .map((child) => getTestNodeForInstance(child));\n return result;\n }\n\n /**\n * Access to the underlying React Fiber node. This is an unstable API that exposes\n * internal react-reconciler structures which may change without warning in future\n * React versions. Use with caution and only when absolutely necessary.\n *\n * @returns The Fiber node for this instance, or null if this is a container.\n */\n get unstable_fiber(): Fiber | null {\n return this.instance.tag === Tag.Instance ? this.instance.unstable_fiber : null;\n }\n\n /**\n * Convert this element to a JSON representation suitable for snapshots.\n *\n * @returns JSON element or null if the element is hidden and hidden nodes are excluded.\n */\n toJSON(): JsonElement | null {\n return this.instance.tag === Tag.Container\n ? containerToJson(this.instance)\n : instanceToJson(this.instance);\n }\n\n /**\n * Find all descendant elements matching the predicate.\n *\n * @param predicate - Function that returns true for matching elements.\n * @param options - Optional query configuration.\n * @returns Array of matching elements.\n */\n queryAll(predicate: (instance: TestInstance) => boolean, options?: QueryOptions): TestInstance[] {\n return queryAll(this, predicate, options);\n }\n\n /** @internal */\n static fromInstance(instance: Instance | Container): TestInstance {\n const testInstance = instanceMap.get(instance);\n if (testInstance) {\n return testInstance;\n }\n\n const result = new TestInstance(instance);\n instanceMap.set(instance, result);\n return result;\n }\n}\n\nfunction getTestNodeForInstance(instance: Instance | TextInstance): TestNode {\n switch (instance.tag) {\n case Tag.Text:\n return instance.text;\n\n case Tag.Instance:\n return TestInstance.fromInstance(instance);\n }\n}\n","// Source: https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactWorkTags.js#L46\nexport const ReactWorkTag = {\n FunctionComponent: 0,\n ClassComponent: 1,\n HostRoot: 3,\n HostComponent: 5,\n} as const;\n\n// Source: https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactEventPriorities.js\nexport const NoEventPriority = 0;\nexport const DiscreteEventPriority = 2;\nexport const ContinuousEventPriority = 8;\nexport const DefaultEventPriority = 32;\nexport const IdleEventPriority = 0b0010000000000000000000000000000;\n\n// Source: https://github.com/facebook/react/blob/v19.1.0/packages/shared/ReactSymbols.js\nexport const REACT_CONTEXT_TYPE = Symbol.for(\"react.context\");\n","export function formatComponentList(names: string[]): string {\n if (names.length === 0) {\n return \"\";\n }\n\n if (names.length === 1) {\n return `<${names[0]}>`;\n }\n\n if (names.length === 2) {\n return `<${names[0]}> or <${names[1]}>`;\n }\n\n const allButLast = names.slice(0, -1);\n const last = names[names.length - 1];\n\n return `${allButLast.map((name) => `<${name}>`).join(\", \")}, or <${last}>`;\n}\n","import type { Fiber } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\nimport { DefaultEventPriority, NoEventPriority } from \"react-reconciler/constants\";\n\nimport { Tag } from \"./constants\";\nimport { mark, measureEnd, measureStart } from \"./performance\";\nimport { TestInstance } from \"./test-instance\";\nimport { REACT_CONTEXT_TYPE } from \"./test-utils/react-constants\";\nimport { formatComponentList } from \"./utils\";\n\nexport type Type = string;\nexport type Props = Record<string, unknown>;\nexport type TransformHiddenInstanceProps = (input: { props: Props; type: Type }) => Props;\n\ntype ReconcilerConfig = {\n textComponentTypes?: string[];\n publicTextComponentTypes?: string[];\n transformHiddenInstanceProps?: TransformHiddenInstanceProps;\n};\n\nexport type Container = {\n tag: typeof Tag.Container;\n parent: null;\n children: Array<Instance | TextInstance>;\n isHidden: false;\n config: ReconcilerConfig;\n};\n\nexport type Instance = {\n tag: typeof Tag.Instance;\n type: string;\n props: Props;\n propsBeforeHiding: Props | null;\n children: Array<Instance | TextInstance>;\n parent: Container | Instance | null;\n rootContainer: Container;\n isHidden: boolean;\n unstable_fiber: Fiber;\n};\n\nexport type FormInstance = Instance;\n\nexport type TextInstance = {\n tag: typeof Tag.Text;\n text: string;\n parent: Container | Instance | null;\n rootContainer: Container;\n isHidden: boolean;\n};\n\nexport type SuspenseInstance = object;\nexport type SuspendedState = unknown;\nexport type HydratableInstance = object;\nexport type PublicInstance = object | null;\nexport type ChildSet = unknown;\nexport type TimeoutHandle = unknown;\nexport type NoTimeout = unknown;\nexport type TransitionStatus = unknown;\n\ntype HostContext = {\n type: string;\n isInsideText: boolean;\n config: ReconcilerConfig;\n};\n\ntype ExtendedHostConfig = ReactReconciler.HostConfig<\n Type,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n FormInstance,\n PublicInstance,\n HostContext,\n ChildSet,\n TimeoutHandle,\n NoTimeout,\n TransitionStatus\n>;\n\nconst nodeToInstanceMap = new WeakMap<object, Instance>();\n\nlet currentUpdatePriority: number = NoEventPriority;\n\nconst hostConfig: ExtendedHostConfig = {\n /**\n * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.\n *\n * If your target platform is similar to the DOM and has methods similar to `appendChild`, `removeChild`,\n * and so on, you'll want to use the **mutation mode**. This is the same mode used by React DOM, React ART,\n * and the classic React Native renderer.\n *\n * ```js\n * const HostConfig = {\n * // ...\n * supportsMutation: true,\n * // ...\n * }\n * ```\n *\n * Depending on the mode, the reconciler will call different methods on your host config.\n * If you're not sure which one you want, you likely need the mutation mode.\n */\n supportsMutation: true,\n\n /**\n * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.\n *\n * If your target platform has immutable trees, you'll want the **persistent mode** instead. In that mode,\n * existing nodes are never mutated, and instead every change clones the parent tree and then replaces\n * the whole parent tree at the root. This is the node used by the new React Native renderer, codenamed \"Fabric\".\n *\n * ```js\n * const HostConfig = {\n * // ...\n * supportsPersistence: true,\n * // ...\n * }\n * ```\n *\n * Depending on the mode, the reconciler will call different methods on your host config.\n * If you're not sure which one you want, you likely need the mutation mode.\n */\n supportsPersistence: false,\n\n /**\n * #### `createInstance(type, props, rootContainer, hostContext, internalHandle)`\n *\n * This method should return a newly created node. For example, the DOM renderer would call\n * `document.createElement(type)` here and then set the properties from `props`.\n *\n * You can use `rootContainer` to access the root container associated with that tree. For example,\n * in the DOM renderer, this is useful to get the correct `document` reference that the root belongs to.\n *\n * The `hostContext` parameter lets you keep track of some information about your current place in\n * the tree. To learn more about it, see `getChildHostContext` below.\n *\n * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its\n * internal fields, be aware that it may change significantly between versions. You're taking on additional\n * maintenance risk by reading from it, and giving up all guarantees if you write something to it.\n *\n * This method happens **in the render phase**. It can (and usually should) mutate the node it has\n * just created before returning it, but it must not modify any other nodes. It must not register\n * any event handlers on the parent tree. This is because an instance being created doesn't guarantee\n * it would be placed in the tree — it could be left unused and later collected by GC. If you need to do\n * something when an instance is definitely in the tree, look at `commitMount` instead.\n */\n createInstance(\n type: Type,\n props: Props,\n rootContainer: Container,\n _hostContext: HostContext,\n internalHandle: Fiber,\n ) {\n mark(\"reconciler/createInstance\", { type });\n\n return {\n tag: Tag.Instance,\n type,\n props,\n propsBeforeHiding: null,\n isHidden: false,\n children: [],\n parent: null,\n rootContainer,\n unstable_fiber: internalHandle,\n };\n },\n\n /**\n * #### `createTextInstance(text, rootContainer, hostContext, internalHandle)`\n *\n * Same as `createInstance`, but for text nodes. If your renderer doesn't support text nodes, you can\n * throw here.\n */\n createTextInstance(\n text: string,\n rootContainer: Container,\n hostContext: HostContext,\n _internalHandle: Fiber,\n ): TextInstance {\n mark(\"reconciler/createTextInstance\", { text });\n\n if (rootContainer.config.textComponentTypes && !hostContext.isInsideText) {\n const componentTypes =\n rootContainer.config.publicTextComponentTypes ?? rootContainer.config.textComponentTypes;\n\n throw new Error(\n `Invariant Violation: Text strings must be rendered within a ${formatComponentList(\n componentTypes,\n )} component. Detected attempt to render \"${text}\" string within a <${\n hostContext.type\n }> component.`,\n );\n }\n\n return {\n tag: Tag.Text,\n text,\n parent: null,\n rootContainer,\n isHidden: false,\n };\n },\n\n /**\n * #### `appendInitialChild(parentInstance, child)`\n *\n * This method should mutate the `parentInstance` and add the child to its list of children.\n * For example, in the DOM this would translate to a `parentInstance.appendChild(child)` call.\n *\n * This method happens **in the render phase**. It can mutate `parentInstance` and `child`, but it\n * must not modify any other nodes. It's called while the tree is still being built up and not connected\n * to the actual tree on the screen.\n */\n appendInitialChild(parentInstance: Instance, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/appendInitialChild\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n });\n }\n\n appendChild(parentInstance, child);\n },\n\n /**\n * #### `finalizeInitialChildren(instance, type, props, rootContainer, hostContext)`\n *\n * In this method, you can perform some final mutations on the `instance`. Unlike with `createInstance`,\n * by the time `finalizeInitialChildren` is called, all the initial children have already been added to\n * the `instance`, but the instance itself has not yet been connected to the tree on the screen.\n *\n * This method happens **in the render phase**. It can mutate `instance`, but it must not modify any other\n * nodes. It's called while the tree is still being built up and not connected to the actual tree on the screen.\n *\n * There is a second purpose to this method. It lets you specify whether there is some work that needs to\n * happen when the node is connected to the tree on the screen. If you return `true`, the instance will\n * receive a `commitMount` call later. See its documentation below.\n *\n * If you don't want to do anything here, you should return `false`.\n */\n finalizeInitialChildren(\n instance: Instance,\n _type: Type,\n _props: Props,\n _rootContainer: Container,\n _hostContext: HostContext,\n ): boolean {\n mark(\"reconciler/finalizeInitialChildren\", { type: instance.type });\n\n return false;\n },\n\n /**\n * #### `shouldSetTextContent(type, props)`\n *\n * Some target platforms support setting an instance's text content without manually creating a text node.\n * For example, in the DOM, you can set `node.textContent` instead of creating a text node and appending it.\n *\n * If you return `true` from this method, React will assume that this node's children are text, and will\n * not create nodes for them. It will instead rely on you to have filled that text during `createInstance`.\n * This is a performance optimization. For example, the DOM renderer returns `true` only if `type` is a\n * known text-only parent (like `'textarea'`) or if `props.children` has a `'string'` type. If you return `true`,\n * you will need to implement `resetTextContent` too.\n *\n * If you don't want to do anything here, you should return `false`.\n * This method happens **in the render phase**. Do not mutate the tree from it.\n */\n shouldSetTextContent(type: Type, _props: Props): boolean {\n mark(\"reconciler/shouldSetTextContent\", { type, result: false });\n\n return false;\n },\n\n setCurrentUpdatePriority(priority: number) {\n mark(\"reconciler/setCurrentUpdatePriority\", { priority });\n\n currentUpdatePriority = priority;\n },\n\n getCurrentUpdatePriority() {\n return currentUpdatePriority;\n },\n\n resolveUpdatePriority(): number {\n const priority = currentUpdatePriority || DefaultEventPriority;\n mark(\"reconciler/resolveUpdatePriority\", { priority });\n\n return priority;\n },\n\n trackSchedulerEvent() {\n mark(\"reconciler/trackSchedulerEvent\");\n },\n\n resolveEventType(): null {\n mark(\"reconciler/resolveEventType\");\n\n return null;\n },\n\n resolveEventTimeStamp(): number {\n const timestamp = -1.1;\n mark(\"reconciler/resolveEventTimeStamp\", { timestamp });\n\n return timestamp;\n },\n\n shouldAttemptEagerTransition() {\n mark(\"reconciler/shouldAttemptEagerTransition\", { result: false });\n\n return false;\n },\n\n /**\n * #### `getRootHostContext(rootContainer)`\n *\n * This method lets you return the initial host context from the root of the tree. See `getChildHostContext`\n * for the explanation of host context.\n *\n * If you don't intend to use host context, you can return `null`.\n * This method happens **in the render phase**. Do not mutate the tree from it.\n */\n getRootHostContext(rootContainer: Container): HostContext | null {\n mark(\"reconciler/getRootHostContext\");\n\n return {\n type: \"ROOT\",\n config: rootContainer.config,\n isInsideText: false,\n };\n },\n\n /**\n * #### `getChildHostContext(parentHostContext, type, rootContainer)`\n *\n * Host context lets you track some information about where you are in the tree so that it's available\n * inside `createInstance` as the `hostContext` parameter. For example, the DOM renderer uses it to track\n * whether it's inside an HTML or an SVG tree, because `createInstance` implementation needs to be\n * different for them.\n *\n * If the node of this `type` does not influence the context you want to pass down, you can return\n * `parentHostContext`. Alternatively, you can return any custom object representing the information\n * you want to pass down.\n *\n * If you don't want to do anything here, return `parentHostContext`.\n *\n * This method happens **in the render phase**. Do not mutate the tree from it.\n */\n getChildHostContext(parentHostContext: HostContext, type: Type): HostContext {\n mark(\"reconciler/getChildHostContext\", { type });\n\n const isInsideText = Boolean(parentHostContext.config.textComponentTypes?.includes(type));\n return { ...parentHostContext, type: type, isInsideText };\n },\n\n /**\n * #### `getPublicInstance(instance)`\n *\n * Determines what object gets exposed as a ref. You'll likely want to return the `instance` itself. But\n * in some cases it might make sense to only expose some part of it.\n *\n * If you don't want to do anything here, return `instance`.\n */\n getPublicInstance(instance: Instance | TextInstance): PublicInstance {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/getPublicInstance\", {\n type: formatInstanceType(instance),\n });\n }\n\n switch (instance.tag) {\n case Tag.Instance: {\n const testInstance = TestInstance.fromInstance(instance);\n nodeToInstanceMap.set(testInstance, instance);\n return testInstance;\n }\n\n default:\n return null;\n }\n },\n\n /**\n * #### `prepareForCommit(containerInfo)`\n *\n * This method lets you store some information before React starts making changes to the tree on\n * the screen. For example, the DOM renderer stores the current text selection so that it can later\n * restore it. This method is mirrored by `resetAfterCommit`.\n *\n * Even if you don't want to do anything here, you need to return `null` from it.\n */\n prepareForCommit(_containerInfo: Container) {\n mark(\"reconciler/prepareForCommit\");\n measureStart(\"react/commit\");\n\n return null; // noop\n },\n\n /**\n * #### `resetAfterCommit(containerInfo)`\n *\n * This method is called right after React has performed the tree mutations. You can use it to restore\n * something you've stored in `prepareForCommit` — for example, text selection.\n *\n * You can leave it empty.\n */\n resetAfterCommit(_containerInfo: Container): void {\n measureEnd(\"react/commit\");\n mark(\"reconciler/resetAfterCommit\");\n },\n\n /**\n * #### `preparePortalMount(containerInfo)`\n *\n * This method is called for a container that's used as a portal target. Usually you can leave it empty.\n */\n preparePortalMount(_containerInfo: Container): void {\n mark(\"reconciler/preparePortalMount\");\n },\n\n /**\n * #### `scheduleTimeout(fn, delay)`\n *\n * You can proxy this to `setTimeout` or its equivalent in your environment.\n */\n scheduleTimeout(fn: () => void, delay: number): ReturnType<typeof setTimeout> {\n const id = setTimeout(() => {\n mark(\"reconciler/scheduled timeout:start\");\n fn();\n mark(\"reconciler/scheduled timeout:end\");\n }, delay);\n mark(\"reconciler/scheduleTimeout\", { id });\n return id;\n },\n\n /**\n * #### `cancelTimeout(id)`\n *\n * You can proxy this to `clearTimeout` or its equivalent in your environment.\n */\n cancelTimeout(id: ReturnType<typeof setTimeout>): void {\n mark(\"reconciler/cancelTimeout\", { id });\n\n clearTimeout(id);\n },\n\n /**\n * #### `noTimeout`\n *\n * This is a property (not a function) that should be set to something that can never be a valid timeout ID.\n * For example, you can set it to `-1`.\n */\n noTimeout: -1,\n\n /**\n * #### `supportsMicrotasks`\n *\n * Set this to `true` to indicate that your renderer supports `scheduleMicrotask`. We use microtasks as part\n * of our discrete event implementation in React DOM. If you're not sure if your renderer should support this,\n * you probably should. The option to not implement `scheduleMicrotask` exists so that platforms with more control\n * over user events, like React Native, can choose to use a different mechanism.\n */\n supportsMicrotasks: true,\n\n /**\n * #### `scheduleMicrotask(fn)`\n *\n * Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.\n */\n scheduleMicrotask(fn: () => void): ReturnType<typeof queueMicrotask> {\n mark(\"reconciler/scheduleMicrotask\");\n\n queueMicrotask(() => {\n mark(\"reconciler/scheduled microtask:start\");\n fn();\n mark(\"reconciler/scheduled microtask:end\");\n });\n },\n\n /**\n * #### `isPrimaryRenderer`\n *\n * This is a property (not a function) that should be set to `true` if your renderer is the main one on the\n * page. For example, if you're writing a renderer for the Terminal, it makes sense to set it to `true`, but\n * if your renderer is used *on top of* React DOM or some other existing renderer, set it to `false`.\n */\n isPrimaryRenderer: true,\n\n /**\n * Whether the renderer shouldn't trigger missing `act()` warnings\n */\n warnsIfNotActing: true,\n\n getInstanceFromNode(node: object): Fiber | null | undefined {\n mark(\"reconciler/getInstanceFromNode\");\n\n const instance = nodeToInstanceMap.get(node);\n if (instance !== undefined) {\n return instance.unstable_fiber;\n }\n\n return null;\n },\n\n beforeActiveInstanceBlur(): void {\n mark(\"reconciler/beforeActiveInstanceBlur\");\n },\n\n afterActiveInstanceBlur(): void {\n mark(\"reconciler/afterActiveInstanceBlur\");\n },\n\n prepareScopeUpdate(scopeInstance: object, instance: Instance): void {\n mark(\"reconciler/prepareScopeUpdate\");\n\n nodeToInstanceMap.set(scopeInstance, instance);\n },\n\n getInstanceFromScope(scopeInstance: object): Instance | null {\n mark(\"reconciler/getInstanceFromScope\");\n\n return nodeToInstanceMap.get(scopeInstance) ?? null;\n },\n\n detachDeletedInstance(_node: Instance): void {\n mark(\"reconciler/detachDeletedInstance\");\n },\n\n /**\n * #### `appendChild(parentInstance, child)`\n *\n * This method should mutate the `parentInstance` and add the child to its list of children. For example,\n * in the DOM this would translate to a `parentInstance.appendChild(child)` call.\n *\n * Although this method currently runs in the commit phase, you still should not mutate any other nodes\n * in it. If you need to do some additional work when a node is definitely connected to the visible tree, look at `commitMount`.\n */\n appendChild(parentInstance: Instance, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/appendChild\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n });\n }\n\n appendChild(parentInstance, child);\n },\n\n /**\n * #### `appendChildToContainer(container, child)`\n *\n * Same as `appendChild`, but for when a node is attached to the root container. This is useful if attaching\n * to the root has a slightly different implementation, or if the root container nodes are of a different\n * type than the rest of the tree.\n */\n appendChildToContainer(container: Container, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/appendChildToContainer\", {\n childType: formatInstanceType(child),\n });\n }\n\n appendChild(container, child);\n },\n\n /**\n * #### `insertBefore(parentInstance, child, beforeChild)`\n *\n * This method should mutate the `parentInstance` and place the `child` before `beforeChild` in the list of\n * its children. For example, in the DOM this would translate to a `parentInstance.insertBefore(child, beforeChild)` call.\n *\n * Note that React uses this method both for insertions and for reordering nodes. Similar to DOM, it is expected\n * that you can call `insertBefore` to reposition an existing child. Do not mutate any other parts of the tree from it.\n */\n insertBefore(\n parentInstance: Instance,\n child: Instance | TextInstance,\n beforeChild: Instance | TextInstance,\n ): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/insertBefore\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n beforeChildType: formatInstanceType(beforeChild),\n });\n }\n insertBefore(parentInstance, child, beforeChild);\n },\n\n /**\n * #### `insertInContainerBefore(container, child, beforeChild)\n *\n * Same as `insertBefore`, but for when a node is attached to the root container. This is useful if attaching\n * to the root has a slightly different implementation, or if the root container nodes are of a different type\n * than the rest of the tree.\n */\n insertInContainerBefore(\n container: Container,\n child: Instance | TextInstance,\n beforeChild: Instance | TextInstance,\n ): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/insertInContainerBefore\", {\n childType: formatInstanceType(child),\n beforeChildType: formatInstanceType(beforeChild),\n });\n }\n insertBefore(container, child, beforeChild);\n },\n\n /**\n * #### `removeChild(parentInstance, child)`\n *\n * This method should mutate the `parentInstance` to remove the `child` from the list of its children.\n *\n * React will only call it for the top-level node that is being removed. It is expected that garbage collection\n * would take care of the whole subtree. You are not expected to traverse the child tree in it.\n */\n removeChild(parentInstance: Instance, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/removeChild\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n });\n }\n removeChild(parentInstance, child);\n },\n\n /**\n * #### `removeChildFromContainer(container, child)`\n *\n * Same as `removeChild`, but for when a node is detached from the root container. This is useful if attaching\n * to the root has a slightly different implementation, or if the root container nodes are of a different type\n * than the rest of the tree.\n */\n removeChildFromContainer(container: Container, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/removeChildFromContainer\", {\n childType: formatInstanceType(child),\n });\n }\n removeChild(container, child);\n },\n\n /**\n * #### `resetTextContent(instance)`\n *\n * If you returned `true` from `shouldSetTextContent` for the previous props, but returned `false` from\n * `shouldSetTextContent` for the next props, React will call this method so that you can clear the text\n * content you were managing manually. For example, in the DOM you could set `node.textContent = ''`.\n *\n * If you never return `true` from `shouldSetTextContent`, you can leave it empty.\n */\n resetTextContent(instance: Instance): void {\n mark(\"reconciler/resetTextContent\", { type: instance.type });\n },\n\n /**\n * #### `commitTextUpdate(textInstance, prevText, nextText)`\n *\n * This method should mutate the `textInstance` and update its text content to `nextText`.\n *\n * Here, `textInstance` is a node created by `createTextInstance`.\n */\n commitTextUpdate(textInstance: TextInstance, oldText: string, newText: string): void {\n mark(\"reconciler/commitTextUpdate\", { oldText, newText });\n\n textInstance.text = newText;\n },\n\n /**\n * #### `commitMount(instance, type, props, internalHandle)`\n *\n * This method is only called if you returned `true` from `finalizeInitialChildren` for this instance.\n *\n * It lets you do some additional work after the node is actually attached to the tree on the screen for\n * the first time. For example, the DOM renderer uses it to trigger focus on nodes with the `autoFocus` attribute.\n *\n * Note that `commitMount` does not mirror `removeChild` one to one because `removeChild` is only called for\n * the top-level removed node. This is why ideally `commitMount` should not mutate any nodes other than the\n * `instance` itself. For example, if it registers some events on some node above, it will be your responsibility\n * to traverse the tree in `removeChild` and clean them up, which is not ideal.\n *\n * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal\n * fields, be aware that it may change significantly between versions. You're taking on additional maintenance\n * risk by reading from it, and giving up all guarantees if you write something to it.\n *\n * If you never return `true` from `finalizeInitialChildren`, you can leave it empty.\n */\n commitMount(_instance: Instance, type: Type, _props: Props, _internalHandle: Fiber): void {\n mark(\"reconciler/commitMount\", { type });\n },\n\n /**\n * #### `commitUpdate(instance, type, prevProps, nextProps, internalHandle)`\n *\n * This method should mutate the `instance` according to the set of changes in `updatePayload`. Here, `updatePayload`\n * is the object that you've returned from `prepareUpdate` and has an arbitrary structure that makes sense for your\n * renderer. For example, the DOM renderer returns an update payload like `[prop1, value1, prop2, value2, ...]` from\n * `prepareUpdate`, and that structure gets passed into `commitUpdate`. Ideally, all the diffing and calculation\n * should happen inside `prepareUpdate` so that `commitUpdate` can be fast and straightforward.\n *\n * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal fields,\n * be aware that it may change significantly between versions. You're taking on additional maintenance risk by\n * reading from it, and giving up all guarantees if you write something to it.\n */\n commitUpdate(\n instance: Instance,\n type: Type,\n _prevProps: Props,\n nextProps: Props,\n internalHandle: Fiber,\n ): void {\n mark(\"reconciler/commitUpdate\", { type });\n\n instance.type = type;\n if (instance.isHidden && instance.rootContainer.config.transformHiddenInstanceProps != null) {\n instance.propsBeforeHiding = nextProps;\n instance.props = instance.rootContainer.config.transformHiddenInstanceProps({\n props: nextProps,\n type: instance.type,\n });\n } else {\n instance.props = nextProps;\n instance.propsBeforeHiding = null;\n }\n instance.unstable_fiber = internalHandle;\n },\n\n /**\n * #### `hideInstance(instance)`\n *\n * This method should make the `instance` invisible without removing it from the tree. For example, it can apply\n * visual styling to hide it. It is used by Suspense to hide the tree while the fallback is visible.\n */\n hideInstance(instance: Instance): void {\n mark(\"reconciler/hideInstance\", { type: instance.type });\n\n if (instance.isHidden) {\n return;\n }\n\n instance.isHidden = true;\n instance.propsBeforeHiding = instance.props;\n\n const transformHiddenInstanceProps = instance.rootContainer.config.transformHiddenInstanceProps;\n if (transformHiddenInstanceProps) {\n const { props, type } = instance;\n instance.props = transformHiddenInstanceProps({ props, type });\n }\n },\n\n /**\n * #### `hideTextInstance(textInstance)`\n *\n * Same as `hideInstance`, but for nodes created by `createTextInstance`.\n */\n hideTextInstance(textInstance: TextInstance): void {\n mark(\"reconciler/hideTextInstance\", { text: textInstance.text });\n\n textInstance.isHidden = true;\n },\n\n /**\n * #### `unhideInstance(instance, props)`\n *\n * This method should make the `instance` visible, undoing what `hideInstance` did.\n */\n unhideInstance(instance: Instance, _props: Props): void {\n mark(\"reconciler/unhideInstance\", { type: instance.type });\n\n instance.isHidden = false;\n\n const transformHiddenInstanceProps = instance.rootContainer.config.transformHiddenInstanceProps;\n if (transformHiddenInstanceProps && instance.propsBeforeHiding) {\n instance.props = instance.propsBeforeHiding;\n instance.propsBeforeHiding = null;\n }\n },\n\n /**\n * #### `unhideTextInstance(textInstance, text)`\n *\n * Same as `unhideInstance`, but for nodes created by `createTextInstance`.\n */\n unhideTextInstance(textInstance: TextInstance, _text: string): void {\n mark(\"reconciler/unhideTextInstance\", { text: textInstance.text });\n\n textInstance.isHidden = false;\n },\n\n /**\n * #### `clearContainer(container)`\n *\n * This method should mutate the `container` root node and remove all children from it.\n */\n clearContainer(container: Container): void {\n mark(\"reconciler/clearContainer\");\n\n container.children.forEach((child) => {\n child.parent = null;\n });\n\n container.children.splice(0);\n },\n\n /**\n * #### `maySuspendCommit(type, props)`\n *\n * This method is called during render to determine if the Host Component type and props require\n * some kind of loading process to complete before committing an update.\n */\n maySuspendCommit(type: Type, _props: Props): boolean {\n mark(\"reconciler/maySuspendCommit\", { type });\n\n return false;\n },\n\n /**\n * #### `preloadInstance(type, props)`\n *\n * This method may be called during render if the Host Component type and props might suspend a commit.\n * It can be used to initiate any work that might shorten the duration of a suspended commit.\n */\n preloadInstance(type: Type, _props: Props): boolean {\n mark(\"reconciler/preloadInstance\", { type });\n\n return true;\n },\n\n /**\n * #### `startSuspendingCommit()`\n *\n * This method is called just before the commit phase. Use it to set up any necessary state while any Host\n * Components that might suspend this commit are evaluated to determine if the commit must be suspended.\n */\n startSuspendingCommit() {\n mark(\"reconciler/startSuspendingCommit\");\n },\n\n /**\n * #### `suspendInstance(type, props)`\n *\n * This method is called after `startSuspendingCommit` for each Host Component that indicated it might\n * suspend a commit.\n */\n suspendInstance(type: Type, _props: Props) {\n mark(\"reconciler/suspendInstance\", { type });\n },\n\n /**\n * #### `waitForCommitToBeReady(state, timeoutOffset)`\n *\n * This method is called after all `suspendInstance` calls are complete.\n *\n * Return `null` if the commit can happen immediately.\n * Return `(initiateCommit: Function) => Function` if the commit must be suspended. The argument to this\n * callback will initiate the commit when called. The return value is a cancellation function that the\n * Reconciler can use to abort the commit.\n */\n waitForCommitToBeReady(_state?: SuspendedState, _timeoutOffset?: number) {\n mark(\"reconciler/waitForCommitToBeReady\");\n\n return null;\n },\n\n // -------------------\n // Hydration Methods\n // (optional)\n // You can optionally implement hydration to \"attach\" to the existing tree during the initial render instead\n // of creating it from scratch. For example, the DOM renderer uses this to attach to an HTML markup.\n //\n // To support hydration, you need to declare `supportsHydration: true` and then implement the methods in\n // the \"Hydration\" section [listed in this file](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js).\n // File an issue if you need help.\n // -------------------\n supportsHydration: false,\n\n NotPendingTransition: null,\n HostTransitionContext: {\n $$typeof: REACT_CONTEXT_TYPE,\n Provider: null as unknown as ReactReconciler.ReactProviderType<TransitionStatus>,\n Consumer: null as unknown as ReactReconciler.ReactContext<TransitionStatus>,\n _currentValue: null,\n _currentValue2: null,\n _threadCount: 0,\n } as ReactReconciler.ReactContext<TransitionStatus>,\n\n resetFormInstance(_form: Instance) {\n mark(\"reconciler/resetFormInstance\");\n },\n\n requestPostPaintCallback(_callback: (endTime: number) => void) {\n mark(\"reconciler/requestPostPaintCallback\");\n },\n};\n\nexport const TestReconciler = ReactReconciler(hostConfig);\n\n/**\n * This method should mutate the `parentInstance` and add the child to its list of children. For example,\n * in the DOM this would translate to a `parentInstance.appendChild(child)` call.\n *\n * Although this method currently runs in the commit phase, you still should not mutate any other nodes\n * in it. If you need to do some additional work when a node is definitely connected to the visible tree,\n * look at `commitMount`.\n */\nfunction appendChild(parentInstance: Container | Instance, child: Instance | TextInstance): void {\n const index = parentInstance.children.indexOf(child);\n if (index !== -1) {\n parentInstance.children.splice(index, 1);\n }\n\n child.parent = parentInstance;\n parentInstance.children.push(child);\n}\n\n/**\n * This method should mutate the `parentInstance` and place the `child` before `beforeChild` in the list\n * of its children. For example, in the DOM this would translate to a\n * `parentInstance.insertBefore(child, beforeChild)` call.\n *\n * Note that React uses this method both for insertions and for reordering nodes. Similar to DOM, it is\n * expected that you can call `insertBefore` to reposition an existing child. Do not mutate any other parts\n * of the tree from it.\n */\nfunction insertBefore(\n parentInstance: Container | Instance,\n child: Instance | TextInstance,\n beforeChild: Instance | TextInstance,\n): void {\n const index = parentInstance.children.indexOf(child);\n if (index !== -1) {\n parentInstance.children.splice(index, 1);\n }\n\n child.parent = parentInstance;\n const beforeIndex = parentInstance.children.indexOf(beforeChild);\n parentInstance.children.splice(beforeIndex, 0, child);\n}\n\n/**\n * This method should mutate the `parentInstance` to remove the `child` from the list of its children.\n *\n * React will only call it for the top-level node that is being removed. It is expected that garbage\n * collection would take care of the whole subtree. You are not expected to traverse the child tree in it.\n */\nfunction removeChild(parentInstance: Container | Instance, child: Instance | TextInstance): void {\n const index = parentInstance.children.indexOf(child);\n parentInstance.children.splice(index, 1);\n child.parent = null;\n}\n\nfunction formatInstanceType(instance: Instance | TextInstance): string {\n return instance.tag === Tag.Text ? `text: \"${instance.text}\"` : instance.type;\n}\n","import { isValidElement, type ReactElement } from \"react\";\nimport { ConcurrentRoot } from \"react-reconciler/constants\";\n\nimport { Tag } from \"./constants\";\nimport { measureEnd, measureStart } from \"./performance\";\nimport type { Container, TransformHiddenInstanceProps } from \"./reconciler\";\nimport { TestReconciler } from \"./reconciler\";\nimport { TestInstance } from \"./test-instance\";\n\n// Refs:\n// https://github.com/facebook/react/blob/main/packages/react-test-renderer/src/ReactFiberConfigTestHost.js\n// https://github.com/facebook/react/blob/main/packages/react-noop-renderer/src/createReactNoop.js\n// https://github.com/facebook/react/blob/main/packages/react-native-renderer/src/ReactFiberConfigFabric.js\n\nconst defaultOnUncaughtError = (error: unknown, errorInfo: ErrorInfo) => {\n console.error(\"Uncaught error:\", error, errorInfo);\n};\nconst defaultOnCaughtError = (error: unknown, errorInfo: ErrorInfo) => {\n console.error(\"Caught error:\", error, errorInfo);\n};\nconst defaultOnRecoverableError = (error: unknown, errorInfo: ErrorInfo) => {\n console.error(\"Recoverable error:\", error, errorInfo);\n};\nconst defaultOnDefaultTransitionIndicator = () => {};\n\n/**\n * Options for configuring the test renderer root.\n */\nexport type RootOptions = {\n /** Types of host components that are allowed to contain text nodes. Trying to render text outside of these components will throw an error. */\n textComponentTypes?: string[];\n\n /**\n * Host component types to display to users in the error message when they try to render text outside of `textComponentTypes`.\n * Defaults to `textComponentTypes`, but you may want to override the components mentioned in the error message.\n */\n publicTextComponentTypes?: string[];\n\n /**\n * Transform props when React marks a host instance as hidden (e.g. during Suspense fallback).\n * Receives `{ props, type }` and should return a new props object.\n * Avoid mutating the provided `props` object.\n */\n transformHiddenInstanceProps?: TransformHiddenInstanceProps;\n\n /** Callback called when React catches an error in an Error Boundary. Called with the error caught by the Error Boundary, and an errorInfo object containing the componentStack. */\n onCaughtError?: ErrorHandler;\n\n /** Callback called when an error is thrown and not caught by an Error Boundary. Called with the error that was thrown, and an errorInfo object containing the componentStack. */\n onUncaughtError?: ErrorHandler;\n\n /** Callback called when React automatically recovers from errors. Called with an error React throws, and an errorInfo object containing the componentStack. Some recoverable errors may include the original error cause as error.cause. */\n onRecoverableError?: ErrorHandler;\n\n /** A string prefix React uses for IDs generated by useId. Useful to avoid conflicts when using multiple roots on the same page. */\n identifierPrefix?: string;\n\n /** Enable React Strict Mode. */\n isStrictMode?: boolean;\n};\n\n/** Callback for handling React errors. */\nexport type ErrorHandler = (error: unknown, errorInfo: ErrorInfo) => void;\n\n/** Error information provided to error handlers. */\nexport type ErrorInfo = {\n componentStack?: string;\n};\n\n/**\n * Root instance returned by createRoot. Provides methods to render and unmount components.\n */\nexport type Root = {\n /** Render a React element into the root. Must be called within act(). */\n render: (element: ReactElement) => void;\n /** Unmount the root and clean up. Must be called within act(). */\n unmount: () => void;\n /** The root container element. */\n container: TestInstance;\n};\n\n/**\n * Create a new test renderer root instance.\n *\n * @param options - Optional configuration for the renderer.\n * @returns A Root instance with render, unmount, and container properties.\n */\nexport function createRoot(options?: RootOptions): Root {\n measureStart(\"createRoot\");\n\n let container: Container | null = {\n tag: Tag.Container,\n parent: null,\n children: [],\n isHidden: false,\n config: {\n textComponentTypes: options?.textComponentTypes,\n publicTextComponentTypes: options?.publicTextComponentTypes,\n transformHiddenInstanceProps: options?.transformHiddenInstanceProps,\n },\n };\n\n // @types/react-reconciler types don't fully match react-reconciler's actual Flow types.\n // The return type is correct at runtime but TypeScript can't verify it statically.\n // Correctness is verified through tests.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let containerFiber = TestReconciler.createContainer(\n container,\n ConcurrentRoot,\n null, // hydrationCallbacks\n options?.isStrictMode ?? false,\n false, // concurrentUpdatesByDefaultOverride\n options?.identifierPrefix ?? \"\",\n options?.onUncaughtError ?? defaultOnUncaughtError,\n options?.onCaughtError ?? defaultOnCaughtError,\n options?.onRecoverableError ?? defaultOnRecoverableError,\n defaultOnDefaultTransitionIndicator,\n null, // transitionCallbacks\n );\n\n measureEnd(\"createRoot\");\n\n const render = (element: ReactElement) => {\n if (containerFiber == null) {\n throw new Error(\"Cannot render after unmount\");\n }\n\n measureStart(\"render\");\n let elementType = \"<invalid>\";\n try {\n assertValidRootElement(element);\n elementType = String(element.type);\n TestReconciler.updateContainer(element, containerFiber, null, null);\n } finally {\n measureEnd(\"render\", { elementType });\n }\n };\n\n const unmount = () => {\n if (container == null) {\n return;\n }\n\n measureStart(\"unmount\");\n try {\n TestReconciler.updateContainer(null, containerFiber, null, null);\n } finally {\n measureEnd(\"unmount\");\n }\n\n containerFiber = null;\n container = null;\n };\n\n return {\n render,\n unmount,\n get container(): TestInstance {\n if (container == null) {\n throw new Error(\"Cannot access .container on unmounted test renderer\");\n }\n\n return TestInstance.fromInstance(container);\n },\n };\n}\n\nfunction assertValidRootElement(element: ReactElement): void {\n if (isValidElement(element)) {\n return;\n }\n\n throw new Error(\n `root.render(...) expects a React element. Fragments are supported, but received ${formatInvalidRootValue(\n element,\n )}.`,\n );\n}\n\nfunction formatInvalidRootValue(value: unknown): string {\n if (value === null) {\n return \"null\";\n }\n\n if (Array.isArray(value)) {\n return \"an array\";\n }\n\n switch (typeof value) {\n case \"string\":\n return \"a string\";\n case \"number\":\n return \"a number\";\n case \"boolean\":\n return \"a boolean\";\n case \"undefined\":\n return \"undefined\";\n default:\n return `a ${typeof value}`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAa,MAAM;CACjB,WAAW;CACX,UAAU;CACV,MAAM;CACP;;;ACAD,SAAgB,KAAK,MAAc,SAAyC;AAC1E,KAAI,CAAC,WAAW,+BACd;AAGF,aAAY,KAAK,iBAAiB,QAAQ,EAAE,QAAQ,SAAS,CAAC;;AAGhE,SAAgB,aAAa,MAAoB;AAC/C,KAAI,CAAC,WAAW,+BACd;AAGF,aAAY,KAAK,iBAAiB,KAAK,QAAQ;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SAAS,uBAAuB,SAA6B;AAC3D,MAAA,GAAA,MAAA,gBAAmB,QAAQ,CACzB;AAGF,OAAM,IAAI,MACR,mFAAmF,uBACjF,QACD,CAAC,GACH;;AAGH,SAAS,uBAAuB,OAAwB;AACtD,KAAI,UAAU,KACZ,QAAO;AAGT,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO;AAGT,SAAQ,OAAO,OAAf;EACE,KAAK,SACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,KAAK,UACH,QAAO;EACT,KAAK,YACH,QAAO;EACT,QACE,QAAO,KAAK,OAAO"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ReactReconciler, { Fiber, Fiber as Fiber$1 } from "react-reconciler";
|
|
2
1
|
import { ReactElement } from "react";
|
|
2
|
+
import ReactReconciler, { Fiber, Fiber as Fiber$1 } from "react-reconciler";
|
|
3
3
|
|
|
4
4
|
//#region src/reconciler.d.ts
|
|
5
5
|
type Type = string;
|
|
@@ -74,8 +74,6 @@ declare class TestInstance {
|
|
|
74
74
|
*/
|
|
75
75
|
queryAll(predicate: (instance: TestInstance) => boolean, options?: QueryOptions): TestInstance[];
|
|
76
76
|
}
|
|
77
|
-
/** @deprecated `HostElement` was renamed to `TestInstance` */
|
|
78
|
-
type HostElement = TestInstance;
|
|
79
77
|
//#endregion
|
|
80
78
|
//#region src/renderer.d.ts
|
|
81
79
|
/**
|
|
@@ -104,7 +102,7 @@ type RootOptions = {
|
|
|
104
102
|
type ErrorHandler = (error: unknown, errorInfo: ErrorInfo) => void;
|
|
105
103
|
/** Error information provided to error handlers. */
|
|
106
104
|
type ErrorInfo = {
|
|
107
|
-
componentStack
|
|
105
|
+
componentStack?: string;
|
|
108
106
|
};
|
|
109
107
|
/**
|
|
110
108
|
* Root instance returned by createRoot. Provides methods to render and unmount components.
|
|
@@ -122,5 +120,5 @@ type Root = {
|
|
|
122
120
|
*/
|
|
123
121
|
declare function createRoot(options?: RootOptions): Root;
|
|
124
122
|
//#endregion
|
|
125
|
-
export { type Fiber, type
|
|
123
|
+
export { type Fiber, type JsonElement, type JsonNode, type QueryOptions, type Root, type RootOptions, type TestInstance, type TestNode, createRoot };
|
|
126
124
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isValidElement } from "react";
|
|
1
2
|
import { ConcurrentRoot, DefaultEventPriority, NoEventPriority } from "react-reconciler/constants.js";
|
|
2
3
|
import ReactReconciler from "react-reconciler";
|
|
3
4
|
//#region src/constants.ts
|
|
@@ -162,6 +163,9 @@ function getTestNodeForInstance(instance) {
|
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
//#endregion
|
|
166
|
+
//#region src/test-utils/react-constants.ts
|
|
167
|
+
const REACT_CONTEXT_TYPE = Symbol.for("react.context");
|
|
168
|
+
//#endregion
|
|
165
169
|
//#region src/utils.ts
|
|
166
170
|
function formatComponentList(names) {
|
|
167
171
|
if (names.length === 0) return "";
|
|
@@ -456,12 +460,20 @@ const TestReconciler = ReactReconciler({
|
|
|
456
460
|
suspendInstance(type, _props) {
|
|
457
461
|
mark("reconciler/suspendInstance", { type });
|
|
458
462
|
},
|
|
459
|
-
waitForCommitToBeReady(
|
|
460
|
-
mark("reconciler/waitForCommitToBeReady"
|
|
463
|
+
waitForCommitToBeReady(_state, _timeoutOffset) {
|
|
464
|
+
mark("reconciler/waitForCommitToBeReady");
|
|
461
465
|
return null;
|
|
462
466
|
},
|
|
463
467
|
supportsHydration: false,
|
|
464
468
|
NotPendingTransition: null,
|
|
469
|
+
HostTransitionContext: {
|
|
470
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
471
|
+
Provider: null,
|
|
472
|
+
Consumer: null,
|
|
473
|
+
_currentValue: null,
|
|
474
|
+
_currentValue2: null,
|
|
475
|
+
_threadCount: 0
|
|
476
|
+
},
|
|
465
477
|
resetFormInstance(_form) {
|
|
466
478
|
mark("reconciler/resetFormInstance");
|
|
467
479
|
},
|
|
@@ -524,6 +536,7 @@ const defaultOnCaughtError = (error, errorInfo) => {
|
|
|
524
536
|
const defaultOnRecoverableError = (error, errorInfo) => {
|
|
525
537
|
console.error("Recoverable error:", error, errorInfo);
|
|
526
538
|
};
|
|
539
|
+
const defaultOnDefaultTransitionIndicator = () => {};
|
|
527
540
|
/**
|
|
528
541
|
* Create a new test renderer root instance.
|
|
529
542
|
*
|
|
@@ -543,15 +556,18 @@ function createRoot(options) {
|
|
|
543
556
|
transformHiddenInstanceProps: options?.transformHiddenInstanceProps
|
|
544
557
|
}
|
|
545
558
|
};
|
|
546
|
-
let containerFiber = TestReconciler.createContainer(container, ConcurrentRoot, null, options?.isStrictMode ?? false, false, options?.identifierPrefix ?? "", options?.onUncaughtError ?? defaultOnUncaughtError, options?.onCaughtError ?? defaultOnCaughtError, options?.onRecoverableError ?? defaultOnRecoverableError, null);
|
|
559
|
+
let containerFiber = TestReconciler.createContainer(container, ConcurrentRoot, null, options?.isStrictMode ?? false, false, options?.identifierPrefix ?? "", options?.onUncaughtError ?? defaultOnUncaughtError, options?.onCaughtError ?? defaultOnCaughtError, options?.onRecoverableError ?? defaultOnRecoverableError, defaultOnDefaultTransitionIndicator, null);
|
|
547
560
|
measureEnd("createRoot");
|
|
548
561
|
const render = (element) => {
|
|
549
562
|
if (containerFiber == null) throw new Error("Cannot render after unmount");
|
|
550
563
|
measureStart("render");
|
|
564
|
+
let elementType = "<invalid>";
|
|
551
565
|
try {
|
|
566
|
+
assertValidRootElement(element);
|
|
567
|
+
elementType = String(element.type);
|
|
552
568
|
TestReconciler.updateContainer(element, containerFiber, null, null);
|
|
553
569
|
} finally {
|
|
554
|
-
measureEnd("render", { elementType
|
|
570
|
+
measureEnd("render", { elementType });
|
|
555
571
|
}
|
|
556
572
|
};
|
|
557
573
|
const unmount = () => {
|
|
@@ -574,6 +590,21 @@ function createRoot(options) {
|
|
|
574
590
|
}
|
|
575
591
|
};
|
|
576
592
|
}
|
|
593
|
+
function assertValidRootElement(element) {
|
|
594
|
+
if (isValidElement(element)) return;
|
|
595
|
+
throw new Error(`root.render(...) expects a React element. Fragments are supported, but received ${formatInvalidRootValue(element)}.`);
|
|
596
|
+
}
|
|
597
|
+
function formatInvalidRootValue(value) {
|
|
598
|
+
if (value === null) return "null";
|
|
599
|
+
if (Array.isArray(value)) return "an array";
|
|
600
|
+
switch (typeof value) {
|
|
601
|
+
case "string": return "a string";
|
|
602
|
+
case "number": return "a number";
|
|
603
|
+
case "boolean": return "a boolean";
|
|
604
|
+
case "undefined": return "undefined";
|
|
605
|
+
default: return `a ${typeof value}`;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
577
608
|
//#endregion
|
|
578
609
|
export { createRoot };
|
|
579
610
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/constants.ts","../src/performance.ts","../src/query-all.ts","../src/to-json.ts","../src/test-instance.ts","../src/utils.ts","../src/reconciler.ts","../src/renderer.ts"],"sourcesContent":["export const Tag = {\n Container: \"CONTAINER\",\n Instance: \"INSTANCE\",\n Text: \"TEXT\",\n} as const;\n\n// Container should render as <>{...}</>\nexport const CONTAINER_TYPE = \"\";\n","declare global {\n var TEST_RENDERER_ENABLE_PROFILING: boolean | undefined;\n}\n\nexport function mark(name: string, details?: Record<string, unknown>): void {\n if (!globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n return;\n }\n\n performance.mark(`test-renderer/${name}`, { detail: details });\n}\n\nexport function measureStart(name: string): void {\n if (!globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n return;\n }\n\n performance.mark(`test-renderer/${name}:start`);\n}\n\nexport function measureEnd(name: string, details?: Record<string, unknown>): void {\n if (!globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n return;\n }\n\n performance.mark(`test-renderer/${name}:end`);\n performance.measure(`test-renderer/${name}`, {\n start: `test-renderer/${name}:start`,\n end: `test-renderer/${name}:end`,\n detail: details,\n });\n}\n","import type { TestInstance } from \"./test-instance\";\n\n/**\n * Options for querying elements in the rendered tree.\n */\nexport interface QueryOptions {\n /** Include the instance itself in the results if it matches the predicate. Defaults to false. */\n includeSelf?: boolean;\n\n /** Exclude any ancestors of deepest matched instances even if they match the predicate. Defaults to false. */\n matchDeepestOnly?: boolean;\n}\n\n/**\n * Find all descendant elements matching the predicate.\n *\n * @param instance - Root TestInstance to search from.\n * @param predicate - Function that returns true for matching elements.\n * @param options - Optional query configuration.\n * @returns Array of matching elements in tree order.\n */\nexport function queryAll(\n instance: TestInstance,\n predicate: (instance: TestInstance) => boolean,\n options?: QueryOptions,\n): TestInstance[] {\n const includeSelf = options?.includeSelf ?? false;\n const matchDeepestOnly = options?.matchDeepestOnly ?? false;\n\n const results: TestInstance[] = [];\n\n // Match descendants first but do not add them to results yet.\n const matchingDescendants: TestInstance[] = [];\n\n instance.children.forEach((child) => {\n if (typeof child === \"string\") {\n return;\n }\n\n matchingDescendants.push(...queryAll(child, predicate, { ...options, includeSelf: true }));\n });\n\n if (\n includeSelf &&\n // When matchDeepestOnly = true: add current element only if no descendants match\n (matchingDescendants.length === 0 || !matchDeepestOnly) &&\n predicate(instance)\n ) {\n results.push(instance);\n }\n\n // Add matching descendants after element to preserve original tree walk order.\n results.push(...matchingDescendants);\n\n return results;\n}\n","import { CONTAINER_TYPE, Tag } from \"./constants\";\nimport type { Container, Instance, TextInstance } from \"./reconciler\";\n\n/** A node in the JSON representation - either a JsonElement or a text string. */\nexport type JsonNode = JsonElement | string;\n\n/**\n * JSON representation of a rendered element, compatible with react-test-renderer format.\n */\nexport type JsonElement = {\n type: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: Record<string, any>;\n children: JsonNode[];\n $$typeof: symbol;\n};\n\nexport function containerToJson(container: Container): JsonElement {\n return {\n type: CONTAINER_TYPE,\n props: {},\n children: childrenToJson(container.children),\n $$typeof: Symbol.for(\"react.test.json\"),\n };\n}\n\nexport function instanceToJson(instance: Instance): JsonElement | null {\n const shouldExcludeHidden = instance.rootContainer.config.transformHiddenInstanceProps == null;\n if (instance.isHidden && shouldExcludeHidden) {\n return null;\n }\n\n // We don't include the `children` prop in JSON.\n // Instead, we will include the actual rendered children.\n const { children: _children, ...restProps } = instance.props;\n\n return {\n type: instance.type,\n props: restProps,\n children: childrenToJson(instance.children),\n $$typeof: Symbol.for(\"react.test.json\"),\n };\n}\n\nexport function textInstanceToJson(instance: TextInstance): string | null {\n const shouldExcludeHidden = instance.rootContainer.config.transformHiddenInstanceProps == null;\n if (instance.isHidden && shouldExcludeHidden) {\n return null;\n }\n\n return instance.text;\n}\n\nexport function childrenToJson(children: Array<Instance | TextInstance>): JsonNode[] {\n const result = [];\n\n for (const child of children) {\n if (child.tag === Tag.Instance) {\n const renderedChild = instanceToJson(child);\n if (renderedChild != null) {\n result.push(renderedChild);\n }\n } else {\n const renderedChild = textInstanceToJson(child);\n if (renderedChild != null) {\n result.push(renderedChild);\n }\n }\n }\n\n return result;\n}\n","import type { Fiber } from \"react-reconciler\";\n\nimport { CONTAINER_TYPE, Tag } from \"./constants\";\nimport type { QueryOptions } from \"./query-all\";\nimport { queryAll } from \"./query-all\";\nimport type { Container, Instance, TextInstance } from \"./reconciler\";\nimport type { JsonElement } from \"./to-json\";\nimport { containerToJson, instanceToJson } from \"./to-json\";\n\n/** A node in the rendered tree - either a TestInstance or a text string. */\nexport type TestNode = TestInstance | string;\n\nconst instanceMap = new WeakMap<Instance | Container, TestInstance>();\n\n/**\n * Represents a rendered host element in the test renderer tree.\n * Provides a DOM-like API for querying and inspecting rendered components.\n */\nexport class TestInstance {\n private instance: Instance | Container;\n\n private constructor(instance: Instance | Container) {\n this.instance = instance;\n }\n\n /** The element type (e.g., \"div\", \"span\"). Empty string for container. */\n get type(): string {\n return this.instance.tag === Tag.Instance ? this.instance.type : CONTAINER_TYPE;\n }\n\n /** The element's props object. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get props(): Record<string, any> {\n return this.instance.tag === Tag.Instance ? this.instance.props : {};\n }\n\n /** The parent element, or null if this is the root container. */\n get parent(): TestInstance | null {\n const parentInstance = this.instance.parent;\n if (parentInstance == null) {\n return null;\n }\n\n return TestInstance.fromInstance(parentInstance);\n }\n\n /** Array of child nodes (elements and text strings). Hidden children are excluded by default. */\n get children(): TestNode[] {\n const container =\n this.instance.tag === Tag.Container ? this.instance : this.instance.rootContainer;\n const shouldExcludeHiddenChildren = container.config.transformHiddenInstanceProps == null;\n\n const result = this.instance.children\n .filter((child) => !child.isHidden || !shouldExcludeHiddenChildren)\n .map((child) => getTestNodeForInstance(child));\n return result;\n }\n\n /**\n * Access to the underlying React Fiber node. This is an unstable API that exposes\n * internal react-reconciler structures which may change without warning in future\n * React versions. Use with caution and only when absolutely necessary.\n *\n * @returns The Fiber node for this instance, or null if this is a container.\n */\n get unstable_fiber(): Fiber | null {\n return this.instance.tag === Tag.Instance ? this.instance.unstable_fiber : null;\n }\n\n /**\n * Convert this element to a JSON representation suitable for snapshots.\n *\n * @returns JSON element or null if the element is hidden and hidden nodes are excluded.\n */\n toJSON(): JsonElement | null {\n return this.instance.tag === Tag.Container\n ? containerToJson(this.instance)\n : instanceToJson(this.instance);\n }\n\n /**\n * Find all descendant elements matching the predicate.\n *\n * @param predicate - Function that returns true for matching elements.\n * @param options - Optional query configuration.\n * @returns Array of matching elements.\n */\n queryAll(predicate: (instance: TestInstance) => boolean, options?: QueryOptions): TestInstance[] {\n return queryAll(this, predicate, options);\n }\n\n /** @internal */\n static fromInstance(instance: Instance | Container): TestInstance {\n const testInstance = instanceMap.get(instance);\n if (testInstance) {\n return testInstance;\n }\n\n const result = new TestInstance(instance);\n instanceMap.set(instance, result);\n return result;\n }\n}\n\nfunction getTestNodeForInstance(instance: Instance | TextInstance): TestNode {\n switch (instance.tag) {\n case Tag.Text:\n return instance.text;\n\n case Tag.Instance:\n return TestInstance.fromInstance(instance);\n }\n}\n\n/** @deprecated `HostElement` was renamed to `TestInstance` */\nexport type HostElement = TestInstance;\n","export function formatComponentList(names: string[]): string {\n if (names.length === 0) {\n return \"\";\n }\n\n if (names.length === 1) {\n return `<${names[0]}>`;\n }\n\n if (names.length === 2) {\n return `<${names[0]}> or <${names[1]}>`;\n }\n\n const allButLast = names.slice(0, -1);\n const last = names[names.length - 1];\n\n return `${allButLast.map((name) => `<${name}>`).join(\", \")}, or <${last}>`;\n}\n","import type { Fiber } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\nimport { DefaultEventPriority, NoEventPriority } from \"react-reconciler/constants\";\n\nimport { Tag } from \"./constants\";\nimport { mark, measureEnd, measureStart } from \"./performance\";\nimport { TestInstance } from \"./test-instance\";\nimport { formatComponentList } from \"./utils\";\n\nexport type Type = string;\nexport type Props = Record<string, unknown>;\nexport type TransformHiddenInstanceProps = (input: { props: Props; type: Type }) => Props;\n\ntype ReconcilerConfig = {\n textComponentTypes?: string[];\n publicTextComponentTypes?: string[];\n transformHiddenInstanceProps?: TransformHiddenInstanceProps;\n};\n\nexport type Container = {\n tag: typeof Tag.Container;\n parent: null;\n children: Array<Instance | TextInstance>;\n isHidden: false;\n config: ReconcilerConfig;\n};\n\nexport type Instance = {\n tag: typeof Tag.Instance;\n type: string;\n props: Props;\n propsBeforeHiding: Props | null;\n children: Array<Instance | TextInstance>;\n parent: Container | Instance | null;\n rootContainer: Container;\n isHidden: boolean;\n unstable_fiber: Fiber;\n};\n\nexport type TextInstance = {\n tag: typeof Tag.Text;\n text: string;\n parent: Container | Instance | null;\n rootContainer: Container;\n isHidden: boolean;\n};\n\nexport type SuspenseInstance = object;\nexport type HydratableInstance = object;\nexport type PublicInstance = object | null;\nexport type UpdatePayload = unknown;\nexport type ChildSet = unknown;\nexport type TimeoutHandle = unknown;\nexport type NoTimeout = unknown;\n\ntype HostContext = {\n type: string;\n isInsideText: boolean;\n config: ReconcilerConfig;\n};\n\n// Newer react-reconciler builds expect these event-related host config methods at runtime,\n// but the published @types/react-reconciler package may lag behind and omit them.\ntype ExtendedHostConfig = ReactReconciler.HostConfig<\n Type,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n> & {\n trackSchedulerEvent?: () => void;\n resolveEventType?: () => null | string;\n resolveEventTimeStamp?: () => number;\n};\n\nconst nodeToInstanceMap = new WeakMap<object, Instance>();\n\nlet currentUpdatePriority: number = NoEventPriority;\n\nconst hostConfig: ExtendedHostConfig = {\n /**\n * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.\n *\n * If your target platform is similar to the DOM and has methods similar to `appendChild`, `removeChild`,\n * and so on, you'll want to use the **mutation mode**. This is the same mode used by React DOM, React ART,\n * and the classic React Native renderer.\n *\n * ```js\n * const HostConfig = {\n * // ...\n * supportsMutation: true,\n * // ...\n * }\n * ```\n *\n * Depending on the mode, the reconciler will call different methods on your host config.\n * If you're not sure which one you want, you likely need the mutation mode.\n */\n supportsMutation: true,\n\n /**\n * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.\n *\n * If your target platform has immutable trees, you'll want the **persistent mode** instead. In that mode,\n * existing nodes are never mutated, and instead every change clones the parent tree and then replaces\n * the whole parent tree at the root. This is the node used by the new React Native renderer, codenamed \"Fabric\".\n *\n * ```js\n * const HostConfig = {\n * // ...\n * supportsPersistence: true,\n * // ...\n * }\n * ```\n *\n * Depending on the mode, the reconciler will call different methods on your host config.\n * If you're not sure which one you want, you likely need the mutation mode.\n */\n supportsPersistence: false,\n\n /**\n * #### `createInstance(type, props, rootContainer, hostContext, internalHandle)`\n *\n * This method should return a newly created node. For example, the DOM renderer would call\n * `document.createElement(type)` here and then set the properties from `props`.\n *\n * You can use `rootContainer` to access the root container associated with that tree. For example,\n * in the DOM renderer, this is useful to get the correct `document` reference that the root belongs to.\n *\n * The `hostContext` parameter lets you keep track of some information about your current place in\n * the tree. To learn more about it, see `getChildHostContext` below.\n *\n * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its\n * internal fields, be aware that it may change significantly between versions. You're taking on additional\n * maintenance risk by reading from it, and giving up all guarantees if you write something to it.\n *\n * This method happens **in the render phase**. It can (and usually should) mutate the node it has\n * just created before returning it, but it must not modify any other nodes. It must not register\n * any event handlers on the parent tree. This is because an instance being created doesn't guarantee\n * it would be placed in the tree — it could be left unused and later collected by GC. If you need to do\n * something when an instance is definitely in the tree, look at `commitMount` instead.\n */\n createInstance(\n type: Type,\n props: Props,\n rootContainer: Container,\n _hostContext: HostContext,\n internalHandle: Fiber,\n ) {\n mark(\"reconciler/createInstance\", { type });\n\n return {\n tag: Tag.Instance,\n type,\n props,\n propsBeforeHiding: null,\n isHidden: false,\n children: [],\n parent: null,\n rootContainer,\n unstable_fiber: internalHandle,\n };\n },\n\n /**\n * #### `createTextInstance(text, rootContainer, hostContext, internalHandle)`\n *\n * Same as `createInstance`, but for text nodes. If your renderer doesn't support text nodes, you can\n * throw here.\n */\n createTextInstance(\n text: string,\n rootContainer: Container,\n hostContext: HostContext,\n _internalHandle: Fiber,\n ): TextInstance {\n mark(\"reconciler/createTextInstance\", { text });\n\n if (rootContainer.config.textComponentTypes && !hostContext.isInsideText) {\n const componentTypes =\n rootContainer.config.publicTextComponentTypes ?? rootContainer.config.textComponentTypes;\n\n throw new Error(\n `Invariant Violation: Text strings must be rendered within a ${formatComponentList(\n componentTypes,\n )} component. Detected attempt to render \"${text}\" string within a <${\n hostContext.type\n }> component.`,\n );\n }\n\n return {\n tag: Tag.Text,\n text,\n parent: null,\n rootContainer,\n isHidden: false,\n };\n },\n\n /**\n * #### `appendInitialChild(parentInstance, child)`\n *\n * This method should mutate the `parentInstance` and add the child to its list of children.\n * For example, in the DOM this would translate to a `parentInstance.appendChild(child)` call.\n *\n * This method happens **in the render phase**. It can mutate `parentInstance` and `child`, but it\n * must not modify any other nodes. It's called while the tree is still being built up and not connected\n * to the actual tree on the screen.\n */\n appendInitialChild(parentInstance: Instance, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/appendInitialChild\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n });\n }\n\n appendChild(parentInstance, child);\n },\n\n /**\n * #### `finalizeInitialChildren(instance, type, props, rootContainer, hostContext)`\n *\n * In this method, you can perform some final mutations on the `instance`. Unlike with `createInstance`,\n * by the time `finalizeInitialChildren` is called, all the initial children have already been added to\n * the `instance`, but the instance itself has not yet been connected to the tree on the screen.\n *\n * This method happens **in the render phase**. It can mutate `instance`, but it must not modify any other\n * nodes. It's called while the tree is still being built up and not connected to the actual tree on the screen.\n *\n * There is a second purpose to this method. It lets you specify whether there is some work that needs to\n * happen when the node is connected to the tree on the screen. If you return `true`, the instance will\n * receive a `commitMount` call later. See its documentation below.\n *\n * If you don't want to do anything here, you should return `false`.\n */\n finalizeInitialChildren(\n instance: Instance,\n _type: Type,\n _props: Props,\n _rootContainer: Container,\n _hostContext: HostContext,\n ): boolean {\n mark(\"reconciler/finalizeInitialChildren\", { type: instance.type });\n\n return false;\n },\n\n /**\n * #### `shouldSetTextContent(type, props)`\n *\n * Some target platforms support setting an instance's text content without manually creating a text node.\n * For example, in the DOM, you can set `node.textContent` instead of creating a text node and appending it.\n *\n * If you return `true` from this method, React will assume that this node's children are text, and will\n * not create nodes for them. It will instead rely on you to have filled that text during `createInstance`.\n * This is a performance optimization. For example, the DOM renderer returns `true` only if `type` is a\n * known text-only parent (like `'textarea'`) or if `props.children` has a `'string'` type. If you return `true`,\n * you will need to implement `resetTextContent` too.\n *\n * If you don't want to do anything here, you should return `false`.\n * This method happens **in the render phase**. Do not mutate the tree from it.\n */\n shouldSetTextContent(type: Type, _props: Props): boolean {\n mark(\"reconciler/shouldSetTextContent\", { type, result: false });\n\n return false;\n },\n\n setCurrentUpdatePriority(priority: number) {\n mark(\"reconciler/setCurrentUpdatePriority\", { priority });\n\n currentUpdatePriority = priority;\n },\n\n getCurrentUpdatePriority() {\n return currentUpdatePriority;\n },\n\n resolveUpdatePriority(): number {\n const priority = currentUpdatePriority || DefaultEventPriority;\n mark(\"reconciler/resolveUpdatePriority\", { priority });\n\n return priority;\n },\n\n trackSchedulerEvent() {\n mark(\"reconciler/trackSchedulerEvent\");\n },\n\n resolveEventType(): null {\n mark(\"reconciler/resolveEventType\");\n\n return null;\n },\n\n resolveEventTimeStamp(): number {\n const timestamp = -1.1;\n mark(\"reconciler/resolveEventTimeStamp\", { timestamp });\n\n return timestamp;\n },\n\n shouldAttemptEagerTransition() {\n mark(\"reconciler/shouldAttemptEagerTransition\", { result: false });\n\n return false;\n },\n\n /**\n * #### `getRootHostContext(rootContainer)`\n *\n * This method lets you return the initial host context from the root of the tree. See `getChildHostContext`\n * for the explanation of host context.\n *\n * If you don't intend to use host context, you can return `null`.\n * This method happens **in the render phase**. Do not mutate the tree from it.\n */\n getRootHostContext(rootContainer: Container): HostContext | null {\n mark(\"reconciler/getRootHostContext\");\n\n return {\n type: \"ROOT\",\n config: rootContainer.config,\n isInsideText: false,\n };\n },\n\n /**\n * #### `getChildHostContext(parentHostContext, type, rootContainer)`\n *\n * Host context lets you track some information about where you are in the tree so that it's available\n * inside `createInstance` as the `hostContext` parameter. For example, the DOM renderer uses it to track\n * whether it's inside an HTML or an SVG tree, because `createInstance` implementation needs to be\n * different for them.\n *\n * If the node of this `type` does not influence the context you want to pass down, you can return\n * `parentHostContext`. Alternatively, you can return any custom object representing the information\n * you want to pass down.\n *\n * If you don't want to do anything here, return `parentHostContext`.\n *\n * This method happens **in the render phase**. Do not mutate the tree from it.\n */\n getChildHostContext(parentHostContext: HostContext, type: Type): HostContext {\n mark(\"reconciler/getChildHostContext\", { type });\n\n const isInsideText = Boolean(parentHostContext.config.textComponentTypes?.includes(type));\n return { ...parentHostContext, type: type, isInsideText };\n },\n\n /**\n * #### `getPublicInstance(instance)`\n *\n * Determines what object gets exposed as a ref. You'll likely want to return the `instance` itself. But\n * in some cases it might make sense to only expose some part of it.\n *\n * If you don't want to do anything here, return `instance`.\n */\n getPublicInstance(instance: Instance | TextInstance): PublicInstance {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/getPublicInstance\", {\n type: formatInstanceType(instance),\n });\n }\n\n switch (instance.tag) {\n case Tag.Instance: {\n const testInstance = TestInstance.fromInstance(instance);\n nodeToInstanceMap.set(testInstance, instance);\n return testInstance;\n }\n\n default:\n return null;\n }\n },\n\n /**\n * #### `prepareForCommit(containerInfo)`\n *\n * This method lets you store some information before React starts making changes to the tree on\n * the screen. For example, the DOM renderer stores the current text selection so that it can later\n * restore it. This method is mirrored by `resetAfterCommit`.\n *\n * Even if you don't want to do anything here, you need to return `null` from it.\n */\n prepareForCommit(_containerInfo: Container) {\n mark(\"reconciler/prepareForCommit\");\n measureStart(\"react/commit\");\n\n return null; // noop\n },\n\n /**\n * #### `resetAfterCommit(containerInfo)`\n *\n * This method is called right after React has performed the tree mutations. You can use it to restore\n * something you've stored in `prepareForCommit` — for example, text selection.\n *\n * You can leave it empty.\n */\n resetAfterCommit(_containerInfo: Container): void {\n measureEnd(\"react/commit\");\n mark(\"reconciler/resetAfterCommit\");\n },\n\n /**\n * #### `preparePortalMount(containerInfo)`\n *\n * This method is called for a container that's used as a portal target. Usually you can leave it empty.\n */\n preparePortalMount(_containerInfo: Container): void {\n mark(\"reconciler/preparePortalMount\");\n },\n\n /**\n * #### `scheduleTimeout(fn, delay)`\n *\n * You can proxy this to `setTimeout` or its equivalent in your environment.\n */\n scheduleTimeout(fn: () => void, delay: number): ReturnType<typeof setTimeout> {\n const id = setTimeout(() => {\n mark(\"reconciler/scheduled timeout:start\");\n fn();\n mark(\"reconciler/scheduled timeout:end\");\n }, delay);\n mark(\"reconciler/scheduleTimeout\", { id });\n return id;\n },\n\n /**\n * #### `cancelTimeout(id)`\n *\n * You can proxy this to `clearTimeout` or its equivalent in your environment.\n */\n cancelTimeout(id: ReturnType<typeof setTimeout>): void {\n mark(\"reconciler/cancelTimeout\", { id });\n\n clearTimeout(id);\n },\n\n /**\n * #### `noTimeout`\n *\n * This is a property (not a function) that should be set to something that can never be a valid timeout ID.\n * For example, you can set it to `-1`.\n */\n noTimeout: -1,\n\n /**\n * #### `supportsMicrotasks`\n *\n * Set this to `true` to indicate that your renderer supports `scheduleMicrotask`. We use microtasks as part\n * of our discrete event implementation in React DOM. If you're not sure if your renderer should support this,\n * you probably should. The option to not implement `scheduleMicrotask` exists so that platforms with more control\n * over user events, like React Native, can choose to use a different mechanism.\n */\n supportsMicrotasks: true,\n\n /**\n * #### `scheduleMicrotask(fn)`\n *\n * Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.\n */\n scheduleMicrotask(fn: () => void): ReturnType<typeof queueMicrotask> {\n mark(\"reconciler/scheduleMicrotask\");\n\n queueMicrotask(() => {\n mark(\"reconciler/scheduled microtask:start\");\n fn();\n mark(\"reconciler/scheduled microtask:end\");\n });\n },\n\n /**\n * #### `isPrimaryRenderer`\n *\n * This is a property (not a function) that should be set to `true` if your renderer is the main one on the\n * page. For example, if you're writing a renderer for the Terminal, it makes sense to set it to `true`, but\n * if your renderer is used *on top of* React DOM or some other existing renderer, set it to `false`.\n */\n isPrimaryRenderer: true,\n\n /**\n * Whether the renderer shouldn't trigger missing `act()` warnings\n */\n warnsIfNotActing: true,\n\n getInstanceFromNode(node: object): Fiber | null | undefined {\n mark(\"reconciler/getInstanceFromNode\");\n\n const instance = nodeToInstanceMap.get(node);\n if (instance !== undefined) {\n return instance.unstable_fiber;\n }\n\n return null;\n },\n\n beforeActiveInstanceBlur(): void {\n mark(\"reconciler/beforeActiveInstanceBlur\");\n },\n\n afterActiveInstanceBlur(): void {\n mark(\"reconciler/afterActiveInstanceBlur\");\n },\n\n prepareScopeUpdate(scopeInstance: object, instance: Instance): void {\n mark(\"reconciler/prepareScopeUpdate\");\n\n nodeToInstanceMap.set(scopeInstance, instance);\n },\n\n getInstanceFromScope(scopeInstance: object): Instance | null {\n mark(\"reconciler/getInstanceFromScope\");\n\n return nodeToInstanceMap.get(scopeInstance) ?? null;\n },\n\n detachDeletedInstance(_node: Instance): void {\n mark(\"reconciler/detachDeletedInstance\");\n },\n\n /**\n * #### `appendChild(parentInstance, child)`\n *\n * This method should mutate the `parentInstance` and add the child to its list of children. For example,\n * in the DOM this would translate to a `parentInstance.appendChild(child)` call.\n *\n * Although this method currently runs in the commit phase, you still should not mutate any other nodes\n * in it. If you need to do some additional work when a node is definitely connected to the visible tree, look at `commitMount`.\n */\n appendChild(parentInstance: Instance, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/appendChild\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n });\n }\n\n appendChild(parentInstance, child);\n },\n\n /**\n * #### `appendChildToContainer(container, child)`\n *\n * Same as `appendChild`, but for when a node is attached to the root container. This is useful if attaching\n * to the root has a slightly different implementation, or if the root container nodes are of a different\n * type than the rest of the tree.\n */\n appendChildToContainer(container: Container, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/appendChildToContainer\", {\n childType: formatInstanceType(child),\n });\n }\n\n appendChild(container, child);\n },\n\n /**\n * #### `insertBefore(parentInstance, child, beforeChild)`\n *\n * This method should mutate the `parentInstance` and place the `child` before `beforeChild` in the list of\n * its children. For example, in the DOM this would translate to a `parentInstance.insertBefore(child, beforeChild)` call.\n *\n * Note that React uses this method both for insertions and for reordering nodes. Similar to DOM, it is expected\n * that you can call `insertBefore` to reposition an existing child. Do not mutate any other parts of the tree from it.\n */\n insertBefore(\n parentInstance: Instance,\n child: Instance | TextInstance,\n beforeChild: Instance | TextInstance,\n ): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/insertBefore\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n beforeChildType: formatInstanceType(beforeChild),\n });\n }\n insertBefore(parentInstance, child, beforeChild);\n },\n\n /**\n * #### `insertInContainerBefore(container, child, beforeChild)\n *\n * Same as `insertBefore`, but for when a node is attached to the root container. This is useful if attaching\n * to the root has a slightly different implementation, or if the root container nodes are of a different type\n * than the rest of the tree.\n */\n insertInContainerBefore(\n container: Container,\n child: Instance | TextInstance,\n beforeChild: Instance | TextInstance,\n ): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/insertInContainerBefore\", {\n childType: formatInstanceType(child),\n beforeChildType: formatInstanceType(beforeChild),\n });\n }\n insertBefore(container, child, beforeChild);\n },\n\n /**\n * #### `removeChild(parentInstance, child)`\n *\n * This method should mutate the `parentInstance` to remove the `child` from the list of its children.\n *\n * React will only call it for the top-level node that is being removed. It is expected that garbage collection\n * would take care of the whole subtree. You are not expected to traverse the child tree in it.\n */\n removeChild(parentInstance: Instance, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/removeChild\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n });\n }\n removeChild(parentInstance, child);\n },\n\n /**\n * #### `removeChildFromContainer(container, child)`\n *\n * Same as `removeChild`, but for when a node is detached from the root container. This is useful if attaching\n * to the root has a slightly different implementation, or if the root container nodes are of a different type\n * than the rest of the tree.\n */\n removeChildFromContainer(container: Container, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/removeChildFromContainer\", {\n childType: formatInstanceType(child),\n });\n }\n removeChild(container, child);\n },\n\n /**\n * #### `resetTextContent(instance)`\n *\n * If you returned `true` from `shouldSetTextContent` for the previous props, but returned `false` from\n * `shouldSetTextContent` for the next props, React will call this method so that you can clear the text\n * content you were managing manually. For example, in the DOM you could set `node.textContent = ''`.\n *\n * If you never return `true` from `shouldSetTextContent`, you can leave it empty.\n */\n resetTextContent(instance: Instance): void {\n mark(\"reconciler/resetTextContent\", { type: instance.type });\n },\n\n /**\n * #### `commitTextUpdate(textInstance, prevText, nextText)`\n *\n * This method should mutate the `textInstance` and update its text content to `nextText`.\n *\n * Here, `textInstance` is a node created by `createTextInstance`.\n */\n commitTextUpdate(textInstance: TextInstance, oldText: string, newText: string): void {\n mark(\"reconciler/commitTextUpdate\", { oldText, newText });\n\n textInstance.text = newText;\n },\n\n /**\n * #### `commitMount(instance, type, props, internalHandle)`\n *\n * This method is only called if you returned `true` from `finalizeInitialChildren` for this instance.\n *\n * It lets you do some additional work after the node is actually attached to the tree on the screen for\n * the first time. For example, the DOM renderer uses it to trigger focus on nodes with the `autoFocus` attribute.\n *\n * Note that `commitMount` does not mirror `removeChild` one to one because `removeChild` is only called for\n * the top-level removed node. This is why ideally `commitMount` should not mutate any nodes other than the\n * `instance` itself. For example, if it registers some events on some node above, it will be your responsibility\n * to traverse the tree in `removeChild` and clean them up, which is not ideal.\n *\n * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal\n * fields, be aware that it may change significantly between versions. You're taking on additional maintenance\n * risk by reading from it, and giving up all guarantees if you write something to it.\n *\n * If you never return `true` from `finalizeInitialChildren`, you can leave it empty.\n */\n commitMount(_instance: Instance, type: Type, _props: Props, _internalHandle: Fiber): void {\n mark(\"reconciler/commitMount\", { type });\n },\n\n /**\n * #### `commitUpdate(instance, type, prevProps, nextProps, internalHandle)`\n *\n * This method should mutate the `instance` according to the set of changes in `updatePayload`. Here, `updatePayload`\n * is the object that you've returned from `prepareUpdate` and has an arbitrary structure that makes sense for your\n * renderer. For example, the DOM renderer returns an update payload like `[prop1, value1, prop2, value2, ...]` from\n * `prepareUpdate`, and that structure gets passed into `commitUpdate`. Ideally, all the diffing and calculation\n * should happen inside `prepareUpdate` so that `commitUpdate` can be fast and straightforward.\n *\n * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal fields,\n * be aware that it may change significantly between versions. You're taking on additional maintenance risk by\n * reading from it, and giving up all guarantees if you write something to it.\n */\n // @ts-expect-error @types/react-reconciler types don't fully match react-reconciler's actual Flow types.\n // Correctness is verified through tests.\n commitUpdate(\n instance: Instance,\n type: Type,\n _prevProps: Props,\n nextProps: Props,\n internalHandle: Fiber,\n ): void {\n mark(\"reconciler/commitUpdate\", { type });\n\n instance.type = type;\n if (instance.isHidden && instance.rootContainer.config.transformHiddenInstanceProps != null) {\n instance.propsBeforeHiding = nextProps;\n instance.props = instance.rootContainer.config.transformHiddenInstanceProps({\n props: nextProps,\n type: instance.type,\n });\n } else {\n instance.props = nextProps;\n instance.propsBeforeHiding = null;\n }\n instance.unstable_fiber = internalHandle;\n },\n\n /**\n * #### `hideInstance(instance)`\n *\n * This method should make the `instance` invisible without removing it from the tree. For example, it can apply\n * visual styling to hide it. It is used by Suspense to hide the tree while the fallback is visible.\n */\n hideInstance(instance: Instance): void {\n mark(\"reconciler/hideInstance\", { type: instance.type });\n\n if (instance.isHidden) {\n return;\n }\n\n instance.isHidden = true;\n instance.propsBeforeHiding = instance.props;\n\n const transformHiddenInstanceProps = instance.rootContainer.config.transformHiddenInstanceProps;\n if (transformHiddenInstanceProps) {\n const { props, type } = instance;\n instance.props = transformHiddenInstanceProps({ props, type });\n }\n },\n\n /**\n * #### `hideTextInstance(textInstance)`\n *\n * Same as `hideInstance`, but for nodes created by `createTextInstance`.\n */\n hideTextInstance(textInstance: TextInstance): void {\n mark(\"reconciler/hideTextInstance\", { text: textInstance.text });\n\n textInstance.isHidden = true;\n },\n\n /**\n * #### `unhideInstance(instance, props)`\n *\n * This method should make the `instance` visible, undoing what `hideInstance` did.\n */\n unhideInstance(instance: Instance, _props: Props): void {\n mark(\"reconciler/unhideInstance\", { type: instance.type });\n\n instance.isHidden = false;\n\n const transformHiddenInstanceProps = instance.rootContainer.config.transformHiddenInstanceProps;\n if (transformHiddenInstanceProps && instance.propsBeforeHiding) {\n instance.props = instance.propsBeforeHiding;\n instance.propsBeforeHiding = null;\n }\n },\n\n /**\n * #### `unhideTextInstance(textInstance, text)`\n *\n * Same as `unhideInstance`, but for nodes created by `createTextInstance`.\n */\n unhideTextInstance(textInstance: TextInstance, _text: string): void {\n mark(\"reconciler/unhideTextInstance\", { text: textInstance.text });\n\n textInstance.isHidden = false;\n },\n\n /**\n * #### `clearContainer(container)`\n *\n * This method should mutate the `container` root node and remove all children from it.\n */\n clearContainer(container: Container): void {\n mark(\"reconciler/clearContainer\");\n\n container.children.forEach((child) => {\n child.parent = null;\n });\n\n container.children.splice(0);\n },\n\n /**\n * #### `maySuspendCommit(type, props)`\n *\n * This method is called during render to determine if the Host Component type and props require\n * some kind of loading process to complete before committing an update.\n */\n maySuspendCommit(type: Type, _props: Props): boolean {\n mark(\"reconciler/maySuspendCommit\", { type });\n\n return false;\n },\n\n /**\n * #### `preloadInstance(type, props)`\n *\n * This method may be called during render if the Host Component type and props might suspend a commit.\n * It can be used to initiate any work that might shorten the duration of a suspended commit.\n */\n preloadInstance(type: Type, _props: Props): boolean {\n mark(\"reconciler/preloadInstance\", { type });\n\n return true;\n },\n\n /**\n * #### `startSuspendingCommit()`\n *\n * This method is called just before the commit phase. Use it to set up any necessary state while any Host\n * Components that might suspend this commit are evaluated to determine if the commit must be suspended.\n */\n startSuspendingCommit() {\n mark(\"reconciler/startSuspendingCommit\");\n },\n\n /**\n * #### `suspendInstance(type, props)`\n *\n * This method is called after `startSuspendingCommit` for each Host Component that indicated it might\n * suspend a commit.\n */\n suspendInstance(type: Type, _props: Props) {\n mark(\"reconciler/suspendInstance\", { type });\n },\n\n /**\n * #### `waitForCommitToBeReady()`\n *\n * This method is called after all `suspendInstance` calls are complete.\n *\n * Return `null` if the commit can happen immediately.\n * Return `(initiateCommit: Function) => Function` if the commit must be suspended. The argument to this\n * callback will initiate the commit when called. The return value is a cancellation function that the\n * Reconciler can use to abort the commit.\n */\n waitForCommitToBeReady(type: Type, _props: Props) {\n mark(\"reconciler/waitForCommitToBeReady\", { type });\n\n return null;\n },\n\n // -------------------\n // Hydration Methods\n // (optional)\n // You can optionally implement hydration to \"attach\" to the existing tree during the initial render instead\n // of creating it from scratch. For example, the DOM renderer uses this to attach to an HTML markup.\n //\n // To support hydration, you need to declare `supportsHydration: true` and then implement the methods in\n // the \"Hydration\" section [listed in this file](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js).\n // File an issue if you need help.\n // -------------------\n supportsHydration: false,\n\n NotPendingTransition: null,\n\n resetFormInstance(_form: Instance) {\n mark(\"reconciler/resetFormInstance\");\n },\n\n requestPostPaintCallback(_callback: (endTime: number) => void) {\n mark(\"reconciler/requestPostPaintCallback\");\n },\n};\n\nexport const TestReconciler = ReactReconciler(hostConfig);\n\n/**\n * This method should mutate the `parentInstance` and add the child to its list of children. For example,\n * in the DOM this would translate to a `parentInstance.appendChild(child)` call.\n *\n * Although this method currently runs in the commit phase, you still should not mutate any other nodes\n * in it. If you need to do some additional work when a node is definitely connected to the visible tree,\n * look at `commitMount`.\n */\nfunction appendChild(parentInstance: Container | Instance, child: Instance | TextInstance): void {\n const index = parentInstance.children.indexOf(child);\n if (index !== -1) {\n parentInstance.children.splice(index, 1);\n }\n\n child.parent = parentInstance;\n parentInstance.children.push(child);\n}\n\n/**\n * This method should mutate the `parentInstance` and place the `child` before `beforeChild` in the list\n * of its children. For example, in the DOM this would translate to a\n * `parentInstance.insertBefore(child, beforeChild)` call.\n *\n * Note that React uses this method both for insertions and for reordering nodes. Similar to DOM, it is\n * expected that you can call `insertBefore` to reposition an existing child. Do not mutate any other parts\n * of the tree from it.\n */\nfunction insertBefore(\n parentInstance: Container | Instance,\n child: Instance | TextInstance,\n beforeChild: Instance | TextInstance,\n): void {\n const index = parentInstance.children.indexOf(child);\n if (index !== -1) {\n parentInstance.children.splice(index, 1);\n }\n\n child.parent = parentInstance;\n const beforeIndex = parentInstance.children.indexOf(beforeChild);\n parentInstance.children.splice(beforeIndex, 0, child);\n}\n\n/**\n * This method should mutate the `parentInstance` to remove the `child` from the list of its children.\n *\n * React will only call it for the top-level node that is being removed. It is expected that garbage\n * collection would take care of the whole subtree. You are not expected to traverse the child tree in it.\n */\nfunction removeChild(parentInstance: Container | Instance, child: Instance | TextInstance): void {\n const index = parentInstance.children.indexOf(child);\n parentInstance.children.splice(index, 1);\n child.parent = null;\n}\n\nfunction formatInstanceType(instance: Instance | TextInstance): string {\n return instance.tag === Tag.Text ? `text: \"${instance.text}\"` : instance.type;\n}\n","import type { ReactElement } from \"react\";\nimport { ConcurrentRoot } from \"react-reconciler/constants\";\n\nimport { Tag } from \"./constants\";\nimport { measureEnd, measureStart } from \"./performance\";\nimport type { Container, TransformHiddenInstanceProps } from \"./reconciler\";\nimport { TestReconciler } from \"./reconciler\";\nimport { TestInstance } from \"./test-instance\";\n\n// Refs:\n// https://github.com/facebook/react/blob/main/packages/react-test-renderer/src/ReactFiberConfigTestHost.js\n// https://github.com/facebook/react/blob/main/packages/react-noop-renderer/src/createReactNoop.js\n// https://github.com/facebook/react/blob/main/packages/react-native-renderer/src/ReactFiberConfigFabric.js\n\nconst defaultOnUncaughtError = (error: unknown, errorInfo: ErrorInfo) => {\n console.error(\"Uncaught error:\", error, errorInfo);\n};\nconst defaultOnCaughtError = (error: unknown, errorInfo: ErrorInfo) => {\n console.error(\"Caught error:\", error, errorInfo);\n};\nconst defaultOnRecoverableError = (error: unknown, errorInfo: ErrorInfo) => {\n console.error(\"Recoverable error:\", error, errorInfo);\n};\n\n/**\n * Options for configuring the test renderer root.\n */\nexport type RootOptions = {\n /** Types of host components that are allowed to contain text nodes. Trying to render text outside of these components will throw an error. */\n textComponentTypes?: string[];\n\n /**\n * Host component types to display to users in the error message when they try to render text outside of `textComponentTypes`.\n * Defaults to `textComponentTypes`, but you may want to override the components mentioned in the error message.\n */\n publicTextComponentTypes?: string[];\n\n /**\n * Transform props when React marks a host instance as hidden (e.g. during Suspense fallback).\n * Receives `{ props, type }` and should return a new props object.\n * Avoid mutating the provided `props` object.\n */\n transformHiddenInstanceProps?: TransformHiddenInstanceProps;\n\n /** Callback called when React catches an error in an Error Boundary. Called with the error caught by the Error Boundary, and an errorInfo object containing the componentStack. */\n onCaughtError?: ErrorHandler;\n\n /** Callback called when an error is thrown and not caught by an Error Boundary. Called with the error that was thrown, and an errorInfo object containing the componentStack. */\n onUncaughtError?: ErrorHandler;\n\n /** Callback called when React automatically recovers from errors. Called with an error React throws, and an errorInfo object containing the componentStack. Some recoverable errors may include the original error cause as error.cause. */\n onRecoverableError?: ErrorHandler;\n\n /** A string prefix React uses for IDs generated by useId. Useful to avoid conflicts when using multiple roots on the same page. */\n identifierPrefix?: string;\n\n /** Enable React Strict Mode. */\n isStrictMode?: boolean;\n};\n\n/** Callback for handling React errors. */\nexport type ErrorHandler = (error: unknown, errorInfo: ErrorInfo) => void;\n\n/** Error information provided to error handlers. */\nexport type ErrorInfo = {\n componentStack: string;\n};\n\n/**\n * Root instance returned by createRoot. Provides methods to render and unmount components.\n */\nexport type Root = {\n /** Render a React element into the root. Must be called within act(). */\n render: (element: ReactElement) => void;\n /** Unmount the root and clean up. Must be called within act(). */\n unmount: () => void;\n /** The root container element. */\n container: TestInstance;\n};\n\n/**\n * Create a new test renderer root instance.\n *\n * @param options - Optional configuration for the renderer.\n * @returns A Root instance with render, unmount, and container properties.\n */\nexport function createRoot(options?: RootOptions): Root {\n measureStart(\"createRoot\");\n\n let container: Container | null = {\n tag: Tag.Container,\n parent: null,\n children: [],\n isHidden: false,\n config: {\n textComponentTypes: options?.textComponentTypes,\n publicTextComponentTypes: options?.publicTextComponentTypes,\n transformHiddenInstanceProps: options?.transformHiddenInstanceProps,\n },\n };\n\n // @types/react-reconciler types don't fully match react-reconciler's actual Flow types.\n // The return type is correct at runtime but TypeScript can't verify it statically.\n // Correctness is verified through tests.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let containerFiber = TestReconciler.createContainer(\n container,\n ConcurrentRoot,\n null, // hydrationCallbacks\n options?.isStrictMode ?? false,\n false, // concurrentUpdatesByDefaultOverride\n options?.identifierPrefix ?? \"\",\n options?.onUncaughtError ?? defaultOnUncaughtError,\n options?.onCaughtError ?? defaultOnCaughtError,\n // @ts-expect-error @types/react-reconciler types don't include onRecoverableError parameter\n // in the createContainer signature, but react-reconciler's actual Flow types do.\n // Correctness is verified through tests.\n options?.onRecoverableError ?? defaultOnRecoverableError,\n null, // transitionCallbacks\n );\n\n measureEnd(\"createRoot\");\n\n const render = (element: ReactElement) => {\n if (containerFiber == null) {\n throw new Error(\"Cannot render after unmount\");\n }\n\n measureStart(\"render\");\n try {\n TestReconciler.updateContainer(element, containerFiber, null, null);\n } finally {\n measureEnd(\"render\", { elementType: String(element.type) });\n }\n };\n\n const unmount = () => {\n if (container == null) {\n return;\n }\n\n measureStart(\"unmount\");\n try {\n TestReconciler.updateContainer(null, containerFiber, null, null);\n } finally {\n measureEnd(\"unmount\");\n }\n\n containerFiber = null;\n container = null;\n };\n\n return {\n render,\n unmount,\n get container(): TestInstance {\n if (container == null) {\n throw new Error(\"Cannot access .container on unmounted test renderer\");\n }\n\n return TestInstance.fromInstance(container);\n },\n };\n}\n"],"mappings":";;;AAAA,MAAa,MAAM;CACjB,WAAW;CACX,UAAU;CACV,MAAM;CACP;;;ACAD,SAAgB,KAAK,MAAc,SAAyC;AAC1E,KAAI,CAAC,WAAW,+BACd;AAGF,aAAY,KAAK,iBAAiB,QAAQ,EAAE,QAAQ,SAAS,CAAC;;AAGhE,SAAgB,aAAa,MAAoB;AAC/C,KAAI,CAAC,WAAW,+BACd;AAGF,aAAY,KAAK,iBAAiB,KAAK,QAAQ;;AAGjD,SAAgB,WAAW,MAAc,SAAyC;AAChF,KAAI,CAAC,WAAW,+BACd;AAGF,aAAY,KAAK,iBAAiB,KAAK,MAAM;AAC7C,aAAY,QAAQ,iBAAiB,QAAQ;EAC3C,OAAO,iBAAiB,KAAK;EAC7B,KAAK,iBAAiB,KAAK;EAC3B,QAAQ;EACT,CAAC;;;;;;;;;;;;ACTJ,SAAgB,SACd,UACA,WACA,SACgB;CAChB,MAAM,cAAc,SAAS,eAAe;CAC5C,MAAM,mBAAmB,SAAS,oBAAoB;CAEtD,MAAM,UAA0B,EAA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SAAS,mBAAmB,wBAC5B,SAAS,iBAAiB,sBAI1B,SAAS,sBAAsB,2BAC/B,KACD;AAED,YAAW,aAAa;CAExB,MAAM,UAAU,YAA0B;AACxC,MAAI,kBAAkB,KACpB,OAAM,IAAI,MAAM,8BAA8B;AAGhD,eAAa,SAAS;AACtB,MAAI;AACF,kBAAe,gBAAgB,SAAS,gBAAgB,MAAM,KAAK;YAC3D;AACR,cAAW,UAAU,EAAE,aAAa,OAAO,QAAQ,KAAK,EAAE,CAAC;;;CAI/D,MAAM,gBAAgB;AACpB,MAAI,aAAa,KACf;AAGF,eAAa,UAAU;AACvB,MAAI;AACF,kBAAe,gBAAgB,MAAM,gBAAgB,MAAM,KAAK;YACxD;AACR,cAAW,UAAU;;AAGvB,mBAAiB;AACjB,cAAY;;AAGd,QAAO;EACL;EACA;EACA,IAAI,YAA0B;AAC5B,OAAI,aAAa,KACf,OAAM,IAAI,MAAM,sDAAsD;AAGxE,UAAO,aAAa,aAAa,UAAU;;EAE9C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/constants.ts","../src/performance.ts","../src/query-all.ts","../src/to-json.ts","../src/test-instance.ts","../src/test-utils/react-constants.ts","../src/utils.ts","../src/reconciler.ts","../src/renderer.ts"],"sourcesContent":["export const Tag = {\n Container: \"CONTAINER\",\n Instance: \"INSTANCE\",\n Text: \"TEXT\",\n} as const;\n\n// Container should render as <>{...}</>\nexport const CONTAINER_TYPE = \"\";\n","declare global {\n var TEST_RENDERER_ENABLE_PROFILING: boolean | undefined;\n}\n\nexport function mark(name: string, details?: Record<string, unknown>): void {\n if (!globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n return;\n }\n\n performance.mark(`test-renderer/${name}`, { detail: details });\n}\n\nexport function measureStart(name: string): void {\n if (!globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n return;\n }\n\n performance.mark(`test-renderer/${name}:start`);\n}\n\nexport function measureEnd(name: string, details?: Record<string, unknown>): void {\n if (!globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n return;\n }\n\n performance.mark(`test-renderer/${name}:end`);\n performance.measure(`test-renderer/${name}`, {\n start: `test-renderer/${name}:start`,\n end: `test-renderer/${name}:end`,\n detail: details,\n });\n}\n","import type { TestInstance } from \"./test-instance\";\n\n/**\n * Options for querying elements in the rendered tree.\n */\nexport interface QueryOptions {\n /** Include the instance itself in the results if it matches the predicate. Defaults to false. */\n includeSelf?: boolean;\n\n /** Exclude any ancestors of deepest matched instances even if they match the predicate. Defaults to false. */\n matchDeepestOnly?: boolean;\n}\n\n/**\n * Find all descendant elements matching the predicate.\n *\n * @param instance - Root TestInstance to search from.\n * @param predicate - Function that returns true for matching elements.\n * @param options - Optional query configuration.\n * @returns Array of matching elements in tree order.\n */\nexport function queryAll(\n instance: TestInstance,\n predicate: (instance: TestInstance) => boolean,\n options?: QueryOptions,\n): TestInstance[] {\n const includeSelf = options?.includeSelf ?? false;\n const matchDeepestOnly = options?.matchDeepestOnly ?? false;\n\n const results: TestInstance[] = [];\n\n // Match descendants first but do not add them to results yet.\n const matchingDescendants: TestInstance[] = [];\n\n instance.children.forEach((child) => {\n if (typeof child === \"string\") {\n return;\n }\n\n matchingDescendants.push(...queryAll(child, predicate, { ...options, includeSelf: true }));\n });\n\n if (\n includeSelf &&\n // When matchDeepestOnly = true: add current element only if no descendants match\n (matchingDescendants.length === 0 || !matchDeepestOnly) &&\n predicate(instance)\n ) {\n results.push(instance);\n }\n\n // Add matching descendants after element to preserve original tree walk order.\n results.push(...matchingDescendants);\n\n return results;\n}\n","import { CONTAINER_TYPE, Tag } from \"./constants\";\nimport type { Container, Instance, TextInstance } from \"./reconciler\";\n\n/** A node in the JSON representation - either a JsonElement or a text string. */\nexport type JsonNode = JsonElement | string;\n\n/**\n * JSON representation of a rendered element, compatible with react-test-renderer format.\n */\nexport type JsonElement = {\n type: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: Record<string, any>;\n children: JsonNode[];\n $$typeof: symbol;\n};\n\nexport function containerToJson(container: Container): JsonElement {\n return {\n type: CONTAINER_TYPE,\n props: {},\n children: childrenToJson(container.children),\n $$typeof: Symbol.for(\"react.test.json\"),\n };\n}\n\nexport function instanceToJson(instance: Instance): JsonElement | null {\n const shouldExcludeHidden = instance.rootContainer.config.transformHiddenInstanceProps == null;\n if (instance.isHidden && shouldExcludeHidden) {\n return null;\n }\n\n // We don't include the `children` prop in JSON.\n // Instead, we will include the actual rendered children.\n const { children: _children, ...restProps } = instance.props;\n\n return {\n type: instance.type,\n props: restProps,\n children: childrenToJson(instance.children),\n $$typeof: Symbol.for(\"react.test.json\"),\n };\n}\n\nexport function textInstanceToJson(instance: TextInstance): string | null {\n const shouldExcludeHidden = instance.rootContainer.config.transformHiddenInstanceProps == null;\n if (instance.isHidden && shouldExcludeHidden) {\n return null;\n }\n\n return instance.text;\n}\n\nexport function childrenToJson(children: Array<Instance | TextInstance>): JsonNode[] {\n const result = [];\n\n for (const child of children) {\n if (child.tag === Tag.Instance) {\n const renderedChild = instanceToJson(child);\n if (renderedChild != null) {\n result.push(renderedChild);\n }\n } else {\n const renderedChild = textInstanceToJson(child);\n if (renderedChild != null) {\n result.push(renderedChild);\n }\n }\n }\n\n return result;\n}\n","import type { Fiber } from \"react-reconciler\";\n\nimport { CONTAINER_TYPE, Tag } from \"./constants\";\nimport type { QueryOptions } from \"./query-all\";\nimport { queryAll } from \"./query-all\";\nimport type { Container, Instance, TextInstance } from \"./reconciler\";\nimport type { JsonElement } from \"./to-json\";\nimport { containerToJson, instanceToJson } from \"./to-json\";\n\n/** A node in the rendered tree - either a TestInstance or a text string. */\nexport type TestNode = TestInstance | string;\n\nconst instanceMap = new WeakMap<Instance | Container, TestInstance>();\n\n/**\n * Represents a rendered host element in the test renderer tree.\n * Provides a DOM-like API for querying and inspecting rendered components.\n */\nexport class TestInstance {\n private instance: Instance | Container;\n\n private constructor(instance: Instance | Container) {\n this.instance = instance;\n }\n\n /** The element type (e.g., \"div\", \"span\"). Empty string for container. */\n get type(): string {\n return this.instance.tag === Tag.Instance ? this.instance.type : CONTAINER_TYPE;\n }\n\n /** The element's props object. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get props(): Record<string, any> {\n return this.instance.tag === Tag.Instance ? this.instance.props : {};\n }\n\n /** The parent element, or null if this is the root container. */\n get parent(): TestInstance | null {\n const parentInstance = this.instance.parent;\n if (parentInstance == null) {\n return null;\n }\n\n return TestInstance.fromInstance(parentInstance);\n }\n\n /** Array of child nodes (elements and text strings). Hidden children are excluded by default. */\n get children(): TestNode[] {\n const container =\n this.instance.tag === Tag.Container ? this.instance : this.instance.rootContainer;\n const shouldExcludeHiddenChildren = container.config.transformHiddenInstanceProps == null;\n\n const result = this.instance.children\n .filter((child) => !child.isHidden || !shouldExcludeHiddenChildren)\n .map((child) => getTestNodeForInstance(child));\n return result;\n }\n\n /**\n * Access to the underlying React Fiber node. This is an unstable API that exposes\n * internal react-reconciler structures which may change without warning in future\n * React versions. Use with caution and only when absolutely necessary.\n *\n * @returns The Fiber node for this instance, or null if this is a container.\n */\n get unstable_fiber(): Fiber | null {\n return this.instance.tag === Tag.Instance ? this.instance.unstable_fiber : null;\n }\n\n /**\n * Convert this element to a JSON representation suitable for snapshots.\n *\n * @returns JSON element or null if the element is hidden and hidden nodes are excluded.\n */\n toJSON(): JsonElement | null {\n return this.instance.tag === Tag.Container\n ? containerToJson(this.instance)\n : instanceToJson(this.instance);\n }\n\n /**\n * Find all descendant elements matching the predicate.\n *\n * @param predicate - Function that returns true for matching elements.\n * @param options - Optional query configuration.\n * @returns Array of matching elements.\n */\n queryAll(predicate: (instance: TestInstance) => boolean, options?: QueryOptions): TestInstance[] {\n return queryAll(this, predicate, options);\n }\n\n /** @internal */\n static fromInstance(instance: Instance | Container): TestInstance {\n const testInstance = instanceMap.get(instance);\n if (testInstance) {\n return testInstance;\n }\n\n const result = new TestInstance(instance);\n instanceMap.set(instance, result);\n return result;\n }\n}\n\nfunction getTestNodeForInstance(instance: Instance | TextInstance): TestNode {\n switch (instance.tag) {\n case Tag.Text:\n return instance.text;\n\n case Tag.Instance:\n return TestInstance.fromInstance(instance);\n }\n}\n","// Source: https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactWorkTags.js#L46\nexport const ReactWorkTag = {\n FunctionComponent: 0,\n ClassComponent: 1,\n HostRoot: 3,\n HostComponent: 5,\n} as const;\n\n// Source: https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactEventPriorities.js\nexport const NoEventPriority = 0;\nexport const DiscreteEventPriority = 2;\nexport const ContinuousEventPriority = 8;\nexport const DefaultEventPriority = 32;\nexport const IdleEventPriority = 0b0010000000000000000000000000000;\n\n// Source: https://github.com/facebook/react/blob/v19.1.0/packages/shared/ReactSymbols.js\nexport const REACT_CONTEXT_TYPE = Symbol.for(\"react.context\");\n","export function formatComponentList(names: string[]): string {\n if (names.length === 0) {\n return \"\";\n }\n\n if (names.length === 1) {\n return `<${names[0]}>`;\n }\n\n if (names.length === 2) {\n return `<${names[0]}> or <${names[1]}>`;\n }\n\n const allButLast = names.slice(0, -1);\n const last = names[names.length - 1];\n\n return `${allButLast.map((name) => `<${name}>`).join(\", \")}, or <${last}>`;\n}\n","import type { Fiber } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\nimport { DefaultEventPriority, NoEventPriority } from \"react-reconciler/constants\";\n\nimport { Tag } from \"./constants\";\nimport { mark, measureEnd, measureStart } from \"./performance\";\nimport { TestInstance } from \"./test-instance\";\nimport { REACT_CONTEXT_TYPE } from \"./test-utils/react-constants\";\nimport { formatComponentList } from \"./utils\";\n\nexport type Type = string;\nexport type Props = Record<string, unknown>;\nexport type TransformHiddenInstanceProps = (input: { props: Props; type: Type }) => Props;\n\ntype ReconcilerConfig = {\n textComponentTypes?: string[];\n publicTextComponentTypes?: string[];\n transformHiddenInstanceProps?: TransformHiddenInstanceProps;\n};\n\nexport type Container = {\n tag: typeof Tag.Container;\n parent: null;\n children: Array<Instance | TextInstance>;\n isHidden: false;\n config: ReconcilerConfig;\n};\n\nexport type Instance = {\n tag: typeof Tag.Instance;\n type: string;\n props: Props;\n propsBeforeHiding: Props | null;\n children: Array<Instance | TextInstance>;\n parent: Container | Instance | null;\n rootContainer: Container;\n isHidden: boolean;\n unstable_fiber: Fiber;\n};\n\nexport type FormInstance = Instance;\n\nexport type TextInstance = {\n tag: typeof Tag.Text;\n text: string;\n parent: Container | Instance | null;\n rootContainer: Container;\n isHidden: boolean;\n};\n\nexport type SuspenseInstance = object;\nexport type SuspendedState = unknown;\nexport type HydratableInstance = object;\nexport type PublicInstance = object | null;\nexport type ChildSet = unknown;\nexport type TimeoutHandle = unknown;\nexport type NoTimeout = unknown;\nexport type TransitionStatus = unknown;\n\ntype HostContext = {\n type: string;\n isInsideText: boolean;\n config: ReconcilerConfig;\n};\n\ntype ExtendedHostConfig = ReactReconciler.HostConfig<\n Type,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n FormInstance,\n PublicInstance,\n HostContext,\n ChildSet,\n TimeoutHandle,\n NoTimeout,\n TransitionStatus\n>;\n\nconst nodeToInstanceMap = new WeakMap<object, Instance>();\n\nlet currentUpdatePriority: number = NoEventPriority;\n\nconst hostConfig: ExtendedHostConfig = {\n /**\n * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.\n *\n * If your target platform is similar to the DOM and has methods similar to `appendChild`, `removeChild`,\n * and so on, you'll want to use the **mutation mode**. This is the same mode used by React DOM, React ART,\n * and the classic React Native renderer.\n *\n * ```js\n * const HostConfig = {\n * // ...\n * supportsMutation: true,\n * // ...\n * }\n * ```\n *\n * Depending on the mode, the reconciler will call different methods on your host config.\n * If you're not sure which one you want, you likely need the mutation mode.\n */\n supportsMutation: true,\n\n /**\n * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.\n *\n * If your target platform has immutable trees, you'll want the **persistent mode** instead. In that mode,\n * existing nodes are never mutated, and instead every change clones the parent tree and then replaces\n * the whole parent tree at the root. This is the node used by the new React Native renderer, codenamed \"Fabric\".\n *\n * ```js\n * const HostConfig = {\n * // ...\n * supportsPersistence: true,\n * // ...\n * }\n * ```\n *\n * Depending on the mode, the reconciler will call different methods on your host config.\n * If you're not sure which one you want, you likely need the mutation mode.\n */\n supportsPersistence: false,\n\n /**\n * #### `createInstance(type, props, rootContainer, hostContext, internalHandle)`\n *\n * This method should return a newly created node. For example, the DOM renderer would call\n * `document.createElement(type)` here and then set the properties from `props`.\n *\n * You can use `rootContainer` to access the root container associated with that tree. For example,\n * in the DOM renderer, this is useful to get the correct `document` reference that the root belongs to.\n *\n * The `hostContext` parameter lets you keep track of some information about your current place in\n * the tree. To learn more about it, see `getChildHostContext` below.\n *\n * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its\n * internal fields, be aware that it may change significantly between versions. You're taking on additional\n * maintenance risk by reading from it, and giving up all guarantees if you write something to it.\n *\n * This method happens **in the render phase**. It can (and usually should) mutate the node it has\n * just created before returning it, but it must not modify any other nodes. It must not register\n * any event handlers on the parent tree. This is because an instance being created doesn't guarantee\n * it would be placed in the tree — it could be left unused and later collected by GC. If you need to do\n * something when an instance is definitely in the tree, look at `commitMount` instead.\n */\n createInstance(\n type: Type,\n props: Props,\n rootContainer: Container,\n _hostContext: HostContext,\n internalHandle: Fiber,\n ) {\n mark(\"reconciler/createInstance\", { type });\n\n return {\n tag: Tag.Instance,\n type,\n props,\n propsBeforeHiding: null,\n isHidden: false,\n children: [],\n parent: null,\n rootContainer,\n unstable_fiber: internalHandle,\n };\n },\n\n /**\n * #### `createTextInstance(text, rootContainer, hostContext, internalHandle)`\n *\n * Same as `createInstance`, but for text nodes. If your renderer doesn't support text nodes, you can\n * throw here.\n */\n createTextInstance(\n text: string,\n rootContainer: Container,\n hostContext: HostContext,\n _internalHandle: Fiber,\n ): TextInstance {\n mark(\"reconciler/createTextInstance\", { text });\n\n if (rootContainer.config.textComponentTypes && !hostContext.isInsideText) {\n const componentTypes =\n rootContainer.config.publicTextComponentTypes ?? rootContainer.config.textComponentTypes;\n\n throw new Error(\n `Invariant Violation: Text strings must be rendered within a ${formatComponentList(\n componentTypes,\n )} component. Detected attempt to render \"${text}\" string within a <${\n hostContext.type\n }> component.`,\n );\n }\n\n return {\n tag: Tag.Text,\n text,\n parent: null,\n rootContainer,\n isHidden: false,\n };\n },\n\n /**\n * #### `appendInitialChild(parentInstance, child)`\n *\n * This method should mutate the `parentInstance` and add the child to its list of children.\n * For example, in the DOM this would translate to a `parentInstance.appendChild(child)` call.\n *\n * This method happens **in the render phase**. It can mutate `parentInstance` and `child`, but it\n * must not modify any other nodes. It's called while the tree is still being built up and not connected\n * to the actual tree on the screen.\n */\n appendInitialChild(parentInstance: Instance, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/appendInitialChild\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n });\n }\n\n appendChild(parentInstance, child);\n },\n\n /**\n * #### `finalizeInitialChildren(instance, type, props, rootContainer, hostContext)`\n *\n * In this method, you can perform some final mutations on the `instance`. Unlike with `createInstance`,\n * by the time `finalizeInitialChildren` is called, all the initial children have already been added to\n * the `instance`, but the instance itself has not yet been connected to the tree on the screen.\n *\n * This method happens **in the render phase**. It can mutate `instance`, but it must not modify any other\n * nodes. It's called while the tree is still being built up and not connected to the actual tree on the screen.\n *\n * There is a second purpose to this method. It lets you specify whether there is some work that needs to\n * happen when the node is connected to the tree on the screen. If you return `true`, the instance will\n * receive a `commitMount` call later. See its documentation below.\n *\n * If you don't want to do anything here, you should return `false`.\n */\n finalizeInitialChildren(\n instance: Instance,\n _type: Type,\n _props: Props,\n _rootContainer: Container,\n _hostContext: HostContext,\n ): boolean {\n mark(\"reconciler/finalizeInitialChildren\", { type: instance.type });\n\n return false;\n },\n\n /**\n * #### `shouldSetTextContent(type, props)`\n *\n * Some target platforms support setting an instance's text content without manually creating a text node.\n * For example, in the DOM, you can set `node.textContent` instead of creating a text node and appending it.\n *\n * If you return `true` from this method, React will assume that this node's children are text, and will\n * not create nodes for them. It will instead rely on you to have filled that text during `createInstance`.\n * This is a performance optimization. For example, the DOM renderer returns `true` only if `type` is a\n * known text-only parent (like `'textarea'`) or if `props.children` has a `'string'` type. If you return `true`,\n * you will need to implement `resetTextContent` too.\n *\n * If you don't want to do anything here, you should return `false`.\n * This method happens **in the render phase**. Do not mutate the tree from it.\n */\n shouldSetTextContent(type: Type, _props: Props): boolean {\n mark(\"reconciler/shouldSetTextContent\", { type, result: false });\n\n return false;\n },\n\n setCurrentUpdatePriority(priority: number) {\n mark(\"reconciler/setCurrentUpdatePriority\", { priority });\n\n currentUpdatePriority = priority;\n },\n\n getCurrentUpdatePriority() {\n return currentUpdatePriority;\n },\n\n resolveUpdatePriority(): number {\n const priority = currentUpdatePriority || DefaultEventPriority;\n mark(\"reconciler/resolveUpdatePriority\", { priority });\n\n return priority;\n },\n\n trackSchedulerEvent() {\n mark(\"reconciler/trackSchedulerEvent\");\n },\n\n resolveEventType(): null {\n mark(\"reconciler/resolveEventType\");\n\n return null;\n },\n\n resolveEventTimeStamp(): number {\n const timestamp = -1.1;\n mark(\"reconciler/resolveEventTimeStamp\", { timestamp });\n\n return timestamp;\n },\n\n shouldAttemptEagerTransition() {\n mark(\"reconciler/shouldAttemptEagerTransition\", { result: false });\n\n return false;\n },\n\n /**\n * #### `getRootHostContext(rootContainer)`\n *\n * This method lets you return the initial host context from the root of the tree. See `getChildHostContext`\n * for the explanation of host context.\n *\n * If you don't intend to use host context, you can return `null`.\n * This method happens **in the render phase**. Do not mutate the tree from it.\n */\n getRootHostContext(rootContainer: Container): HostContext | null {\n mark(\"reconciler/getRootHostContext\");\n\n return {\n type: \"ROOT\",\n config: rootContainer.config,\n isInsideText: false,\n };\n },\n\n /**\n * #### `getChildHostContext(parentHostContext, type, rootContainer)`\n *\n * Host context lets you track some information about where you are in the tree so that it's available\n * inside `createInstance` as the `hostContext` parameter. For example, the DOM renderer uses it to track\n * whether it's inside an HTML or an SVG tree, because `createInstance` implementation needs to be\n * different for them.\n *\n * If the node of this `type` does not influence the context you want to pass down, you can return\n * `parentHostContext`. Alternatively, you can return any custom object representing the information\n * you want to pass down.\n *\n * If you don't want to do anything here, return `parentHostContext`.\n *\n * This method happens **in the render phase**. Do not mutate the tree from it.\n */\n getChildHostContext(parentHostContext: HostContext, type: Type): HostContext {\n mark(\"reconciler/getChildHostContext\", { type });\n\n const isInsideText = Boolean(parentHostContext.config.textComponentTypes?.includes(type));\n return { ...parentHostContext, type: type, isInsideText };\n },\n\n /**\n * #### `getPublicInstance(instance)`\n *\n * Determines what object gets exposed as a ref. You'll likely want to return the `instance` itself. But\n * in some cases it might make sense to only expose some part of it.\n *\n * If you don't want to do anything here, return `instance`.\n */\n getPublicInstance(instance: Instance | TextInstance): PublicInstance {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/getPublicInstance\", {\n type: formatInstanceType(instance),\n });\n }\n\n switch (instance.tag) {\n case Tag.Instance: {\n const testInstance = TestInstance.fromInstance(instance);\n nodeToInstanceMap.set(testInstance, instance);\n return testInstance;\n }\n\n default:\n return null;\n }\n },\n\n /**\n * #### `prepareForCommit(containerInfo)`\n *\n * This method lets you store some information before React starts making changes to the tree on\n * the screen. For example, the DOM renderer stores the current text selection so that it can later\n * restore it. This method is mirrored by `resetAfterCommit`.\n *\n * Even if you don't want to do anything here, you need to return `null` from it.\n */\n prepareForCommit(_containerInfo: Container) {\n mark(\"reconciler/prepareForCommit\");\n measureStart(\"react/commit\");\n\n return null; // noop\n },\n\n /**\n * #### `resetAfterCommit(containerInfo)`\n *\n * This method is called right after React has performed the tree mutations. You can use it to restore\n * something you've stored in `prepareForCommit` — for example, text selection.\n *\n * You can leave it empty.\n */\n resetAfterCommit(_containerInfo: Container): void {\n measureEnd(\"react/commit\");\n mark(\"reconciler/resetAfterCommit\");\n },\n\n /**\n * #### `preparePortalMount(containerInfo)`\n *\n * This method is called for a container that's used as a portal target. Usually you can leave it empty.\n */\n preparePortalMount(_containerInfo: Container): void {\n mark(\"reconciler/preparePortalMount\");\n },\n\n /**\n * #### `scheduleTimeout(fn, delay)`\n *\n * You can proxy this to `setTimeout` or its equivalent in your environment.\n */\n scheduleTimeout(fn: () => void, delay: number): ReturnType<typeof setTimeout> {\n const id = setTimeout(() => {\n mark(\"reconciler/scheduled timeout:start\");\n fn();\n mark(\"reconciler/scheduled timeout:end\");\n }, delay);\n mark(\"reconciler/scheduleTimeout\", { id });\n return id;\n },\n\n /**\n * #### `cancelTimeout(id)`\n *\n * You can proxy this to `clearTimeout` or its equivalent in your environment.\n */\n cancelTimeout(id: ReturnType<typeof setTimeout>): void {\n mark(\"reconciler/cancelTimeout\", { id });\n\n clearTimeout(id);\n },\n\n /**\n * #### `noTimeout`\n *\n * This is a property (not a function) that should be set to something that can never be a valid timeout ID.\n * For example, you can set it to `-1`.\n */\n noTimeout: -1,\n\n /**\n * #### `supportsMicrotasks`\n *\n * Set this to `true` to indicate that your renderer supports `scheduleMicrotask`. We use microtasks as part\n * of our discrete event implementation in React DOM. If you're not sure if your renderer should support this,\n * you probably should. The option to not implement `scheduleMicrotask` exists so that platforms with more control\n * over user events, like React Native, can choose to use a different mechanism.\n */\n supportsMicrotasks: true,\n\n /**\n * #### `scheduleMicrotask(fn)`\n *\n * Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.\n */\n scheduleMicrotask(fn: () => void): ReturnType<typeof queueMicrotask> {\n mark(\"reconciler/scheduleMicrotask\");\n\n queueMicrotask(() => {\n mark(\"reconciler/scheduled microtask:start\");\n fn();\n mark(\"reconciler/scheduled microtask:end\");\n });\n },\n\n /**\n * #### `isPrimaryRenderer`\n *\n * This is a property (not a function) that should be set to `true` if your renderer is the main one on the\n * page. For example, if you're writing a renderer for the Terminal, it makes sense to set it to `true`, but\n * if your renderer is used *on top of* React DOM or some other existing renderer, set it to `false`.\n */\n isPrimaryRenderer: true,\n\n /**\n * Whether the renderer shouldn't trigger missing `act()` warnings\n */\n warnsIfNotActing: true,\n\n getInstanceFromNode(node: object): Fiber | null | undefined {\n mark(\"reconciler/getInstanceFromNode\");\n\n const instance = nodeToInstanceMap.get(node);\n if (instance !== undefined) {\n return instance.unstable_fiber;\n }\n\n return null;\n },\n\n beforeActiveInstanceBlur(): void {\n mark(\"reconciler/beforeActiveInstanceBlur\");\n },\n\n afterActiveInstanceBlur(): void {\n mark(\"reconciler/afterActiveInstanceBlur\");\n },\n\n prepareScopeUpdate(scopeInstance: object, instance: Instance): void {\n mark(\"reconciler/prepareScopeUpdate\");\n\n nodeToInstanceMap.set(scopeInstance, instance);\n },\n\n getInstanceFromScope(scopeInstance: object): Instance | null {\n mark(\"reconciler/getInstanceFromScope\");\n\n return nodeToInstanceMap.get(scopeInstance) ?? null;\n },\n\n detachDeletedInstance(_node: Instance): void {\n mark(\"reconciler/detachDeletedInstance\");\n },\n\n /**\n * #### `appendChild(parentInstance, child)`\n *\n * This method should mutate the `parentInstance` and add the child to its list of children. For example,\n * in the DOM this would translate to a `parentInstance.appendChild(child)` call.\n *\n * Although this method currently runs in the commit phase, you still should not mutate any other nodes\n * in it. If you need to do some additional work when a node is definitely connected to the visible tree, look at `commitMount`.\n */\n appendChild(parentInstance: Instance, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/appendChild\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n });\n }\n\n appendChild(parentInstance, child);\n },\n\n /**\n * #### `appendChildToContainer(container, child)`\n *\n * Same as `appendChild`, but for when a node is attached to the root container. This is useful if attaching\n * to the root has a slightly different implementation, or if the root container nodes are of a different\n * type than the rest of the tree.\n */\n appendChildToContainer(container: Container, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/appendChildToContainer\", {\n childType: formatInstanceType(child),\n });\n }\n\n appendChild(container, child);\n },\n\n /**\n * #### `insertBefore(parentInstance, child, beforeChild)`\n *\n * This method should mutate the `parentInstance` and place the `child` before `beforeChild` in the list of\n * its children. For example, in the DOM this would translate to a `parentInstance.insertBefore(child, beforeChild)` call.\n *\n * Note that React uses this method both for insertions and for reordering nodes. Similar to DOM, it is expected\n * that you can call `insertBefore` to reposition an existing child. Do not mutate any other parts of the tree from it.\n */\n insertBefore(\n parentInstance: Instance,\n child: Instance | TextInstance,\n beforeChild: Instance | TextInstance,\n ): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/insertBefore\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n beforeChildType: formatInstanceType(beforeChild),\n });\n }\n insertBefore(parentInstance, child, beforeChild);\n },\n\n /**\n * #### `insertInContainerBefore(container, child, beforeChild)\n *\n * Same as `insertBefore`, but for when a node is attached to the root container. This is useful if attaching\n * to the root has a slightly different implementation, or if the root container nodes are of a different type\n * than the rest of the tree.\n */\n insertInContainerBefore(\n container: Container,\n child: Instance | TextInstance,\n beforeChild: Instance | TextInstance,\n ): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/insertInContainerBefore\", {\n childType: formatInstanceType(child),\n beforeChildType: formatInstanceType(beforeChild),\n });\n }\n insertBefore(container, child, beforeChild);\n },\n\n /**\n * #### `removeChild(parentInstance, child)`\n *\n * This method should mutate the `parentInstance` to remove the `child` from the list of its children.\n *\n * React will only call it for the top-level node that is being removed. It is expected that garbage collection\n * would take care of the whole subtree. You are not expected to traverse the child tree in it.\n */\n removeChild(parentInstance: Instance, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/removeChild\", {\n parentType: parentInstance.type,\n childType: formatInstanceType(child),\n });\n }\n removeChild(parentInstance, child);\n },\n\n /**\n * #### `removeChildFromContainer(container, child)`\n *\n * Same as `removeChild`, but for when a node is detached from the root container. This is useful if attaching\n * to the root has a slightly different implementation, or if the root container nodes are of a different type\n * than the rest of the tree.\n */\n removeChildFromContainer(container: Container, child: Instance | TextInstance): void {\n if (globalThis.TEST_RENDERER_ENABLE_PROFILING) {\n mark(\"reconciler/removeChildFromContainer\", {\n childType: formatInstanceType(child),\n });\n }\n removeChild(container, child);\n },\n\n /**\n * #### `resetTextContent(instance)`\n *\n * If you returned `true` from `shouldSetTextContent` for the previous props, but returned `false` from\n * `shouldSetTextContent` for the next props, React will call this method so that you can clear the text\n * content you were managing manually. For example, in the DOM you could set `node.textContent = ''`.\n *\n * If you never return `true` from `shouldSetTextContent`, you can leave it empty.\n */\n resetTextContent(instance: Instance): void {\n mark(\"reconciler/resetTextContent\", { type: instance.type });\n },\n\n /**\n * #### `commitTextUpdate(textInstance, prevText, nextText)`\n *\n * This method should mutate the `textInstance` and update its text content to `nextText`.\n *\n * Here, `textInstance` is a node created by `createTextInstance`.\n */\n commitTextUpdate(textInstance: TextInstance, oldText: string, newText: string): void {\n mark(\"reconciler/commitTextUpdate\", { oldText, newText });\n\n textInstance.text = newText;\n },\n\n /**\n * #### `commitMount(instance, type, props, internalHandle)`\n *\n * This method is only called if you returned `true` from `finalizeInitialChildren` for this instance.\n *\n * It lets you do some additional work after the node is actually attached to the tree on the screen for\n * the first time. For example, the DOM renderer uses it to trigger focus on nodes with the `autoFocus` attribute.\n *\n * Note that `commitMount` does not mirror `removeChild` one to one because `removeChild` is only called for\n * the top-level removed node. This is why ideally `commitMount` should not mutate any nodes other than the\n * `instance` itself. For example, if it registers some events on some node above, it will be your responsibility\n * to traverse the tree in `removeChild` and clean them up, which is not ideal.\n *\n * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal\n * fields, be aware that it may change significantly between versions. You're taking on additional maintenance\n * risk by reading from it, and giving up all guarantees if you write something to it.\n *\n * If you never return `true` from `finalizeInitialChildren`, you can leave it empty.\n */\n commitMount(_instance: Instance, type: Type, _props: Props, _internalHandle: Fiber): void {\n mark(\"reconciler/commitMount\", { type });\n },\n\n /**\n * #### `commitUpdate(instance, type, prevProps, nextProps, internalHandle)`\n *\n * This method should mutate the `instance` according to the set of changes in `updatePayload`. Here, `updatePayload`\n * is the object that you've returned from `prepareUpdate` and has an arbitrary structure that makes sense for your\n * renderer. For example, the DOM renderer returns an update payload like `[prop1, value1, prop2, value2, ...]` from\n * `prepareUpdate`, and that structure gets passed into `commitUpdate`. Ideally, all the diffing and calculation\n * should happen inside `prepareUpdate` so that `commitUpdate` can be fast and straightforward.\n *\n * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal fields,\n * be aware that it may change significantly between versions. You're taking on additional maintenance risk by\n * reading from it, and giving up all guarantees if you write something to it.\n */\n commitUpdate(\n instance: Instance,\n type: Type,\n _prevProps: Props,\n nextProps: Props,\n internalHandle: Fiber,\n ): void {\n mark(\"reconciler/commitUpdate\", { type });\n\n instance.type = type;\n if (instance.isHidden && instance.rootContainer.config.transformHiddenInstanceProps != null) {\n instance.propsBeforeHiding = nextProps;\n instance.props = instance.rootContainer.config.transformHiddenInstanceProps({\n props: nextProps,\n type: instance.type,\n });\n } else {\n instance.props = nextProps;\n instance.propsBeforeHiding = null;\n }\n instance.unstable_fiber = internalHandle;\n },\n\n /**\n * #### `hideInstance(instance)`\n *\n * This method should make the `instance` invisible without removing it from the tree. For example, it can apply\n * visual styling to hide it. It is used by Suspense to hide the tree while the fallback is visible.\n */\n hideInstance(instance: Instance): void {\n mark(\"reconciler/hideInstance\", { type: instance.type });\n\n if (instance.isHidden) {\n return;\n }\n\n instance.isHidden = true;\n instance.propsBeforeHiding = instance.props;\n\n const transformHiddenInstanceProps = instance.rootContainer.config.transformHiddenInstanceProps;\n if (transformHiddenInstanceProps) {\n const { props, type } = instance;\n instance.props = transformHiddenInstanceProps({ props, type });\n }\n },\n\n /**\n * #### `hideTextInstance(textInstance)`\n *\n * Same as `hideInstance`, but for nodes created by `createTextInstance`.\n */\n hideTextInstance(textInstance: TextInstance): void {\n mark(\"reconciler/hideTextInstance\", { text: textInstance.text });\n\n textInstance.isHidden = true;\n },\n\n /**\n * #### `unhideInstance(instance, props)`\n *\n * This method should make the `instance` visible, undoing what `hideInstance` did.\n */\n unhideInstance(instance: Instance, _props: Props): void {\n mark(\"reconciler/unhideInstance\", { type: instance.type });\n\n instance.isHidden = false;\n\n const transformHiddenInstanceProps = instance.rootContainer.config.transformHiddenInstanceProps;\n if (transformHiddenInstanceProps && instance.propsBeforeHiding) {\n instance.props = instance.propsBeforeHiding;\n instance.propsBeforeHiding = null;\n }\n },\n\n /**\n * #### `unhideTextInstance(textInstance, text)`\n *\n * Same as `unhideInstance`, but for nodes created by `createTextInstance`.\n */\n unhideTextInstance(textInstance: TextInstance, _text: string): void {\n mark(\"reconciler/unhideTextInstance\", { text: textInstance.text });\n\n textInstance.isHidden = false;\n },\n\n /**\n * #### `clearContainer(container)`\n *\n * This method should mutate the `container` root node and remove all children from it.\n */\n clearContainer(container: Container): void {\n mark(\"reconciler/clearContainer\");\n\n container.children.forEach((child) => {\n child.parent = null;\n });\n\n container.children.splice(0);\n },\n\n /**\n * #### `maySuspendCommit(type, props)`\n *\n * This method is called during render to determine if the Host Component type and props require\n * some kind of loading process to complete before committing an update.\n */\n maySuspendCommit(type: Type, _props: Props): boolean {\n mark(\"reconciler/maySuspendCommit\", { type });\n\n return false;\n },\n\n /**\n * #### `preloadInstance(type, props)`\n *\n * This method may be called during render if the Host Component type and props might suspend a commit.\n * It can be used to initiate any work that might shorten the duration of a suspended commit.\n */\n preloadInstance(type: Type, _props: Props): boolean {\n mark(\"reconciler/preloadInstance\", { type });\n\n return true;\n },\n\n /**\n * #### `startSuspendingCommit()`\n *\n * This method is called just before the commit phase. Use it to set up any necessary state while any Host\n * Components that might suspend this commit are evaluated to determine if the commit must be suspended.\n */\n startSuspendingCommit() {\n mark(\"reconciler/startSuspendingCommit\");\n },\n\n /**\n * #### `suspendInstance(type, props)`\n *\n * This method is called after `startSuspendingCommit` for each Host Component that indicated it might\n * suspend a commit.\n */\n suspendInstance(type: Type, _props: Props) {\n mark(\"reconciler/suspendInstance\", { type });\n },\n\n /**\n * #### `waitForCommitToBeReady(state, timeoutOffset)`\n *\n * This method is called after all `suspendInstance` calls are complete.\n *\n * Return `null` if the commit can happen immediately.\n * Return `(initiateCommit: Function) => Function` if the commit must be suspended. The argument to this\n * callback will initiate the commit when called. The return value is a cancellation function that the\n * Reconciler can use to abort the commit.\n */\n waitForCommitToBeReady(_state?: SuspendedState, _timeoutOffset?: number) {\n mark(\"reconciler/waitForCommitToBeReady\");\n\n return null;\n },\n\n // -------------------\n // Hydration Methods\n // (optional)\n // You can optionally implement hydration to \"attach\" to the existing tree during the initial render instead\n // of creating it from scratch. For example, the DOM renderer uses this to attach to an HTML markup.\n //\n // To support hydration, you need to declare `supportsHydration: true` and then implement the methods in\n // the \"Hydration\" section [listed in this file](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js).\n // File an issue if you need help.\n // -------------------\n supportsHydration: false,\n\n NotPendingTransition: null,\n HostTransitionContext: {\n $$typeof: REACT_CONTEXT_TYPE,\n Provider: null as unknown as ReactReconciler.ReactProviderType<TransitionStatus>,\n Consumer: null as unknown as ReactReconciler.ReactContext<TransitionStatus>,\n _currentValue: null,\n _currentValue2: null,\n _threadCount: 0,\n } as ReactReconciler.ReactContext<TransitionStatus>,\n\n resetFormInstance(_form: Instance) {\n mark(\"reconciler/resetFormInstance\");\n },\n\n requestPostPaintCallback(_callback: (endTime: number) => void) {\n mark(\"reconciler/requestPostPaintCallback\");\n },\n};\n\nexport const TestReconciler = ReactReconciler(hostConfig);\n\n/**\n * This method should mutate the `parentInstance` and add the child to its list of children. For example,\n * in the DOM this would translate to a `parentInstance.appendChild(child)` call.\n *\n * Although this method currently runs in the commit phase, you still should not mutate any other nodes\n * in it. If you need to do some additional work when a node is definitely connected to the visible tree,\n * look at `commitMount`.\n */\nfunction appendChild(parentInstance: Container | Instance, child: Instance | TextInstance): void {\n const index = parentInstance.children.indexOf(child);\n if (index !== -1) {\n parentInstance.children.splice(index, 1);\n }\n\n child.parent = parentInstance;\n parentInstance.children.push(child);\n}\n\n/**\n * This method should mutate the `parentInstance` and place the `child` before `beforeChild` in the list\n * of its children. For example, in the DOM this would translate to a\n * `parentInstance.insertBefore(child, beforeChild)` call.\n *\n * Note that React uses this method both for insertions and for reordering nodes. Similar to DOM, it is\n * expected that you can call `insertBefore` to reposition an existing child. Do not mutate any other parts\n * of the tree from it.\n */\nfunction insertBefore(\n parentInstance: Container | Instance,\n child: Instance | TextInstance,\n beforeChild: Instance | TextInstance,\n): void {\n const index = parentInstance.children.indexOf(child);\n if (index !== -1) {\n parentInstance.children.splice(index, 1);\n }\n\n child.parent = parentInstance;\n const beforeIndex = parentInstance.children.indexOf(beforeChild);\n parentInstance.children.splice(beforeIndex, 0, child);\n}\n\n/**\n * This method should mutate the `parentInstance` to remove the `child` from the list of its children.\n *\n * React will only call it for the top-level node that is being removed. It is expected that garbage\n * collection would take care of the whole subtree. You are not expected to traverse the child tree in it.\n */\nfunction removeChild(parentInstance: Container | Instance, child: Instance | TextInstance): void {\n const index = parentInstance.children.indexOf(child);\n parentInstance.children.splice(index, 1);\n child.parent = null;\n}\n\nfunction formatInstanceType(instance: Instance | TextInstance): string {\n return instance.tag === Tag.Text ? `text: \"${instance.text}\"` : instance.type;\n}\n","import { isValidElement, type ReactElement } from \"react\";\nimport { ConcurrentRoot } from \"react-reconciler/constants\";\n\nimport { Tag } from \"./constants\";\nimport { measureEnd, measureStart } from \"./performance\";\nimport type { Container, TransformHiddenInstanceProps } from \"./reconciler\";\nimport { TestReconciler } from \"./reconciler\";\nimport { TestInstance } from \"./test-instance\";\n\n// Refs:\n// https://github.com/facebook/react/blob/main/packages/react-test-renderer/src/ReactFiberConfigTestHost.js\n// https://github.com/facebook/react/blob/main/packages/react-noop-renderer/src/createReactNoop.js\n// https://github.com/facebook/react/blob/main/packages/react-native-renderer/src/ReactFiberConfigFabric.js\n\nconst defaultOnUncaughtError = (error: unknown, errorInfo: ErrorInfo) => {\n console.error(\"Uncaught error:\", error, errorInfo);\n};\nconst defaultOnCaughtError = (error: unknown, errorInfo: ErrorInfo) => {\n console.error(\"Caught error:\", error, errorInfo);\n};\nconst defaultOnRecoverableError = (error: unknown, errorInfo: ErrorInfo) => {\n console.error(\"Recoverable error:\", error, errorInfo);\n};\nconst defaultOnDefaultTransitionIndicator = () => {};\n\n/**\n * Options for configuring the test renderer root.\n */\nexport type RootOptions = {\n /** Types of host components that are allowed to contain text nodes. Trying to render text outside of these components will throw an error. */\n textComponentTypes?: string[];\n\n /**\n * Host component types to display to users in the error message when they try to render text outside of `textComponentTypes`.\n * Defaults to `textComponentTypes`, but you may want to override the components mentioned in the error message.\n */\n publicTextComponentTypes?: string[];\n\n /**\n * Transform props when React marks a host instance as hidden (e.g. during Suspense fallback).\n * Receives `{ props, type }` and should return a new props object.\n * Avoid mutating the provided `props` object.\n */\n transformHiddenInstanceProps?: TransformHiddenInstanceProps;\n\n /** Callback called when React catches an error in an Error Boundary. Called with the error caught by the Error Boundary, and an errorInfo object containing the componentStack. */\n onCaughtError?: ErrorHandler;\n\n /** Callback called when an error is thrown and not caught by an Error Boundary. Called with the error that was thrown, and an errorInfo object containing the componentStack. */\n onUncaughtError?: ErrorHandler;\n\n /** Callback called when React automatically recovers from errors. Called with an error React throws, and an errorInfo object containing the componentStack. Some recoverable errors may include the original error cause as error.cause. */\n onRecoverableError?: ErrorHandler;\n\n /** A string prefix React uses for IDs generated by useId. Useful to avoid conflicts when using multiple roots on the same page. */\n identifierPrefix?: string;\n\n /** Enable React Strict Mode. */\n isStrictMode?: boolean;\n};\n\n/** Callback for handling React errors. */\nexport type ErrorHandler = (error: unknown, errorInfo: ErrorInfo) => void;\n\n/** Error information provided to error handlers. */\nexport type ErrorInfo = {\n componentStack?: string;\n};\n\n/**\n * Root instance returned by createRoot. Provides methods to render and unmount components.\n */\nexport type Root = {\n /** Render a React element into the root. Must be called within act(). */\n render: (element: ReactElement) => void;\n /** Unmount the root and clean up. Must be called within act(). */\n unmount: () => void;\n /** The root container element. */\n container: TestInstance;\n};\n\n/**\n * Create a new test renderer root instance.\n *\n * @param options - Optional configuration for the renderer.\n * @returns A Root instance with render, unmount, and container properties.\n */\nexport function createRoot(options?: RootOptions): Root {\n measureStart(\"createRoot\");\n\n let container: Container | null = {\n tag: Tag.Container,\n parent: null,\n children: [],\n isHidden: false,\n config: {\n textComponentTypes: options?.textComponentTypes,\n publicTextComponentTypes: options?.publicTextComponentTypes,\n transformHiddenInstanceProps: options?.transformHiddenInstanceProps,\n },\n };\n\n // @types/react-reconciler types don't fully match react-reconciler's actual Flow types.\n // The return type is correct at runtime but TypeScript can't verify it statically.\n // Correctness is verified through tests.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let containerFiber = TestReconciler.createContainer(\n container,\n ConcurrentRoot,\n null, // hydrationCallbacks\n options?.isStrictMode ?? false,\n false, // concurrentUpdatesByDefaultOverride\n options?.identifierPrefix ?? \"\",\n options?.onUncaughtError ?? defaultOnUncaughtError,\n options?.onCaughtError ?? defaultOnCaughtError,\n options?.onRecoverableError ?? defaultOnRecoverableError,\n defaultOnDefaultTransitionIndicator,\n null, // transitionCallbacks\n );\n\n measureEnd(\"createRoot\");\n\n const render = (element: ReactElement) => {\n if (containerFiber == null) {\n throw new Error(\"Cannot render after unmount\");\n }\n\n measureStart(\"render\");\n let elementType = \"<invalid>\";\n try {\n assertValidRootElement(element);\n elementType = String(element.type);\n TestReconciler.updateContainer(element, containerFiber, null, null);\n } finally {\n measureEnd(\"render\", { elementType });\n }\n };\n\n const unmount = () => {\n if (container == null) {\n return;\n }\n\n measureStart(\"unmount\");\n try {\n TestReconciler.updateContainer(null, containerFiber, null, null);\n } finally {\n measureEnd(\"unmount\");\n }\n\n containerFiber = null;\n container = null;\n };\n\n return {\n render,\n unmount,\n get container(): TestInstance {\n if (container == null) {\n throw new Error(\"Cannot access .container on unmounted test renderer\");\n }\n\n return TestInstance.fromInstance(container);\n },\n };\n}\n\nfunction assertValidRootElement(element: ReactElement): void {\n if (isValidElement(element)) {\n return;\n }\n\n throw new Error(\n `root.render(...) expects a React element. Fragments are supported, but received ${formatInvalidRootValue(\n element,\n )}.`,\n );\n}\n\nfunction formatInvalidRootValue(value: unknown): string {\n if (value === null) {\n return \"null\";\n }\n\n if (Array.isArray(value)) {\n return \"an array\";\n }\n\n switch (typeof value) {\n case \"string\":\n return \"a string\";\n case \"number\":\n return \"a number\";\n case \"boolean\":\n return \"a boolean\";\n case \"undefined\":\n return \"undefined\";\n default:\n return `a ${typeof value}`;\n }\n}\n"],"mappings":";;;;AAAA,MAAa,MAAM;CACjB,WAAW;CACX,UAAU;CACV,MAAM;CACP;;;ACAD,SAAgB,KAAK,MAAc,SAAyC;AAC1E,KAAI,CAAC,WAAW,+BACd;AAGF,aAAY,KAAK,iBAAiB,QAAQ,EAAE,QAAQ,SAAS,CAAC;;AAGhE,SAAgB,aAAa,MAAoB;AAC/C,KAAI,CAAC,WAAW,+BACd;AAGF,aAAY,KAAK,iBAAiB,KAAK,QAAQ;;AAGjD,SAAgB,WAAW,MAAc,SAAyC;AAChF,KAAI,CAAC,WAAW,+BACd;AAGF,aAAY,KAAK,iBAAiB,KAAK,MAAM;AAC7C,aAAY,QAAQ,iBAAiB,QAAQ;EAC3C,OAAO,iBAAiB,KAAK;EAC7B,KAAK,iBAAiB,KAAK;EAC3B,QAAQ;EACT,CAAC;;;;;;;;;;;;ACTJ,SAAgB,SACd,UACA,WACA,SACgB;CAChB,MAAM,cAAc,SAAS,eAAe;CAC5C,MAAM,mBAAmB,SAAS,oBAAoB;CAEtD,MAAM,UAA0B,EAAE;CAGlC,MAAM,sBAAsC,EAAE;AAE9C,UAAS,SAAS,SAAS,UAAU;AACnC,MAAI,OAAO,UAAU,SACnB;AAGF,sBAAoB,KAAK,GAAG,SAAS,OAAO,WAAW;GAAE,GAAG;GAAS,aAAa;GAAM,CAAC,CAAC;GAC1F;AAEF,KACE,gBAEC,oBAAoB,WAAW,KAAK,CAAC,qBACtC,UAAU,SAAS,CAEn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A0B;AACxC,MAAI,kBAAkB,KACpB,OAAM,IAAI,MAAM,8BAA8B;AAGhD,eAAa,SAAS;EACtB,IAAI,cAAc;AAClB,MAAI;AACF,0BAAuB,QAAQ;AAC/B,iBAAc,OAAO,QAAQ,KAAK;AAClC,kBAAe,gBAAgB,SAAS,gBAAgB,MAAM,KAAK;YAC3D;AACR,cAAW,UAAU,EAAE,aAAa,CAAC;;;CAIzC,MAAM,gBAAgB;AACpB,MAAI,aAAa,KACf;AAGF,eAAa,UAAU;AACvB,MAAI;AACF,kBAAe,gBAAgB,MAAM,gBAAgB,MAAM,KAAK;YACxD;AACR,cAAW,UAAU;;AAGvB,mBAAiB;AACjB,cAAY;;AAGd,QAAO;EACL;EACA;EACA,IAAI,YAA0B;AAC5B,OAAI,aAAa,KACf,OAAM,IAAI,MAAM,sDAAsD;AAGxE,UAAO,aAAa,aAAa,UAAU;;EAE9C;;AAGH,SAAS,uBAAuB,SAA6B;AAC3D,KAAI,eAAe,QAAQ,CACzB;AAGF,OAAM,IAAI,MACR,mFAAmF,uBACjF,QACD,CAAC,GACH;;AAGH,SAAS,uBAAuB,OAAwB;AACtD,KAAI,UAAU,KACZ,QAAO;AAGT,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO;AAGT,SAAQ,OAAO,OAAf;EACE,KAAK,SACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,KAAK,UACH,QAAO;EACT,KAAK,YACH,QAAO;EACT,QACE,QAAO,KAAK,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "test-renderer",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A lightweight
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "A lightweight test renderer for React and a modern replacement for the deprecated React Test Renderer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jest",
|
|
7
7
|
"react",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"release": "release-it"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@types/react-reconciler": "~0.
|
|
55
|
-
"react-reconciler": "~0.
|
|
54
|
+
"@types/react-reconciler": "~0.32.0",
|
|
55
|
+
"react-reconciler": "~0.32.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@eslint/js": "^10.0.1",
|