universal-test-renderer 0.2.0 → 0.3.1-react19.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/dist/index.cjs +183 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +188 -70
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/reconciler.ts","../src/utils.ts","../src/constants.ts","../src/render-to-json.ts","../src/host-element.ts","../src/renderer.ts"],"sourcesContent":["export { createRenderer } from \"./renderer\";\nexport { CONTAINER_TYPE } from \"./constants\";\n\nexport type { Renderer, RendererOptions } from \"./renderer\";\nexport type { HostElement, HostElementProps, HostNode } from \"./host-element\";\nexport type { JsonElement, JsonNode } from \"./render-to-json\";\n","import { ReactElement } from \"react\";\nimport ReactReconciler, { Fiber } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\nimport { formatComponentList } from \"./utils\";\n\nexport type Type = string;\nexport type Props = Record<string, unknown>;\nexport type OpaqueHandle = Fiber;\n\nexport type Container = {\n tag: \"CONTAINER\";\n children: Array<Instance | TextInstance>;\n parent: null;\n\n // Access to key options passed to createRenderer\n textComponents?: string[];\n createNodeMock: (element: ReactElement) => object;\n};\n\nexport type Instance = {\n tag: \"INSTANCE\";\n type: string;\n props: Props;\n children: Array<Instance | TextInstance>;\n parent: Container | Instance | null;\n rootContainer: Container;\n isHidden: boolean;\n internalHandle: OpaqueHandle;\n};\n\nexport type TextInstance = {\n tag: \"TEXT\";\n text: string;\n parent: Container | Instance | null;\n isHidden: boolean;\n};\n\nexport type SuspenseInstance = object;\nexport type HydratableInstance = object;\nexport type PublicInstance = object | TextInstance;\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};\n\nconst UPDATE_SIGNAL = {};\nconst nodeToInstanceMap = new WeakMap<object, Instance>();\n\n// if (__DEV__) {\n// Object.freeze(UPDATE_SIGNAL);\n// }\n\nconst hostConfig: 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 /**\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 * 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: OpaqueHandle\n ) {\n return {\n tag: \"INSTANCE\",\n type,\n props,\n isHidden: false,\n children: [],\n parent: null,\n rootContainer,\n internalHandle,\n };\n },\n\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: OpaqueHandle\n ): TextInstance {\n if (rootContainer.textComponents && !hostContext.isInsideText) {\n throw new Error(\n `Invariant Violation: Text strings must be rendered within a ${formatComponentList(\n rootContainer.textComponents\n )} component. Detected attempt to render \"${text}\" string within a <${\n hostContext.type\n }> component.`\n );\n }\n\n return {\n tag: \"TEXT\",\n text,\n parent: null,\n isHidden: false,\n };\n },\n\n appendInitialChild: appendChild,\n\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 return false;\n },\n\n /**\n * React calls this method so that you can compare the previous and the next props, and decide whether you\n * need to update the underlying instance or not. If you don't need to update it, return `null`. If you\n * need to update it, you can return an arbitrary object representing the changes that need to happen.\n * Then in `commitUpdate` you would need to apply those changes to the instance.\n *\n * This method happens **in the render phase**. It should only *calculate* the update — but not apply it!\n * For example, the DOM renderer returns an array that looks like `[prop1, value1, prop2, value2, ...]`\n * for all props that have actually changed. And only in `commitUpdate` it applies those changes. You should\n * calculate as much as you can in `prepareUpdate` so that `commitUpdate` can be very fast and straightforward.\n *\n * See the meaning of `rootContainer` and `hostContext` in the `createInstance` documentation.\n */\n prepareUpdate(\n _instance: Instance,\n _type: Type,\n _oldProps: Props,\n _newProps: Props,\n _rootContainer: Container,\n _hostContext: HostContext\n ) {\n return UPDATE_SIGNAL;\n },\n\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 return false;\n },\n\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 return { type: \"ROOT\", isInsideText: false };\n },\n\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(\n parentHostContext: HostContext,\n type: Type,\n rootContainer: Container\n ): HostContext {\n const isInsideText = Boolean(rootContainer.textComponents?.includes(type));\n return { type: type, isInsideText };\n },\n\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 switch (instance.tag) {\n case \"INSTANCE\": {\n const createNodeMock = instance.rootContainer.createNodeMock;\n const mockNode = createNodeMock({\n type: instance.type,\n props: instance.props,\n key: null,\n });\n\n //if (typeof mockNode === \"object\" && mockNode !== null) {\n nodeToInstanceMap.set(mockNode, instance);\n //}\n\n return mockNode;\n }\n\n default:\n return instance;\n }\n },\n\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 return null; // noop\n },\n\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 // noop\n },\n\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 // noop\n },\n\n /**\n * You can proxy this to `setTimeout` or its equivalent in your environment.\n */\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n\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 * 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 * Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.\n */\n scheduleMicrotask: queueMicrotask,\n\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 /**\n * To implement this method, you'll need some constants available on the special `react-reconciler/constants` entry point:\n *\n * ```\n * import {\n * DiscreteEventPriority,\n * ContinuousEventPriority,\n * DefaultEventPriority,\n * } from 'react-reconciler/constants';\n *\n * const HostConfig = {\n * // ...\n * getCurrentEventPriority() {\n * return DefaultEventPriority;\n * },\n * // ...\n * }\n *\n * const MyRenderer = Reconciler(HostConfig);\n * ```\n *\n * The constant you return depends on which event, if any, is being handled right now. (In the browser, you can\n * check this using `window.event && window.event.type`).\n *\n * - **Discrete events**: If the active event is directly caused by the user (such as mouse and keyboard events)\n * and each event in a sequence is intentional (e.g. click), return DiscreteEventPriority. This tells React that\n * they should interrupt any background work and cannot be batched across time.\n *\n * - **Continuous events**: If the active event is directly caused by the user but the user can't distinguish between\n * individual events in a sequence (e.g. mouseover), return ContinuousEventPriority. This tells React they\n * should interrupt any background work but can be batched across time.\n *\n * - **Other events / No active event**: In all other cases, return DefaultEventPriority. This tells React that\n * this event is considered background work, and interactive events will be prioritized over it.\n *\n * You can consult the `getCurrentEventPriority()` implementation in `ReactDOMHostConfig.js` for a reference implementation.\n */\n getCurrentEventPriority() {\n return DefaultEventPriority;\n },\n\n getInstanceFromNode(node: object): OpaqueHandle | null | undefined {\n const instance = nodeToInstanceMap.get(node);\n if (instance !== undefined) {\n return instance.internalHandle;\n }\n\n return null;\n },\n\n beforeActiveInstanceBlur(): void {\n // noop\n },\n\n afterActiveInstanceBlur(): void {\n // noop\n },\n\n prepareScopeUpdate(scopeInstance: object, instance: Instance): void {\n nodeToInstanceMap.set(scopeInstance, instance);\n },\n\n getInstanceFromScope(scopeInstance: object): Instance | null {\n return nodeToInstanceMap.get(scopeInstance) ?? null;\n },\n\n detachDeletedInstance(_node: Instance): void {\n // noop\n },\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, look at `commitMount`.\n */\n appendChild: appendChild,\n\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: appendChild,\n\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: insertBefore,\n\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: insertBefore,\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 collection\n * would take care of the whole subtree. You are not expected to traverse the child tree in it.\n */\n removeChild: removeChild,\n\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: removeChild,\n\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 // noop\n },\n\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(\n textInstance: TextInstance,\n _oldText: string,\n newText: string\n ): void {\n textInstance.text = newText;\n },\n\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(\n _instance: Instance,\n _type: Type,\n _props: Props,\n _internalHandle: OpaqueHandle\n ): void {\n // noop\n },\n\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 _updatePayload: UpdatePayload,\n type: Type,\n _prevProps: Props,\n nextProps: Props,\n internalHandle: OpaqueHandle\n ): void {\n instance.type = type;\n instance.props = nextProps;\n instance.internalHandle = internalHandle;\n },\n\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 instance.isHidden = true;\n },\n\n /**\n * Same as `hideInstance`, but for nodes created by `createTextInstance`.\n */\n hideTextInstance(textInstance: TextInstance): void {\n textInstance.isHidden = true;\n },\n\n /**\n * This method should make the `instance` visible, undoing what `hideInstance` did.\n */\n unhideInstance(instance: Instance, _props: Props): void {\n instance.isHidden = false;\n },\n\n /**\n * Same as `unhideInstance`, but for nodes created by `createTextInstance`.\n */\n unhideTextInstance(textInstance: TextInstance, _text: string): void {\n textInstance.isHidden = false;\n },\n\n /**\n * This method should mutate the `container` root node and remove all children from it.\n */\n clearContainer(container: Container): void {\n container.children.forEach((child) => {\n child.parent = null;\n });\n\n container.children.splice(0);\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\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(\n parentInstance: Container | Instance,\n child: 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 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(\n parentInstance: Container | Instance,\n child: Instance | TextInstance\n): void {\n const index = parentInstance.children.indexOf(child);\n parentInstance.children.splice(index, 1);\n child.parent = null;\n}\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","export const CONTAINER_TYPE = \"CONTAINER\";\n","import { CONTAINER_TYPE } from \"./constants\";\nimport { Container, Instance, TextInstance } from \"./reconciler\";\n\nexport type JsonNode = JsonElement | string;\n\nexport type JsonElement = {\n type: string;\n props: object;\n children: Array<JsonNode> | null;\n $$typeof: symbol;\n};\n\nexport function renderToJson(\n instance: Container | Instance | TextInstance\n): JsonNode | null {\n if (`isHidden` in instance && instance.isHidden) {\n // Omit timed out children from output entirely. This seems like the least\n // surprising behavior. We could perhaps add a separate API that includes\n // them, if it turns out people need it.\n return null;\n }\n\n switch (instance.tag) {\n case \"TEXT\":\n return instance.text;\n\n case \"INSTANCE\": {\n // We don't include the `children` prop in JSON.\n // Instead, we will include the actual rendered children.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { children, ...props } = instance.props;\n\n let renderedChildren = null;\n if (instance.children.length) {\n for (let i = 0; i < instance.children.length; i++) {\n const renderedChild = renderToJson(instance.children[i]);\n if (renderedChild !== null) {\n if (renderedChildren === null) {\n renderedChildren = [renderedChild];\n } else {\n renderedChildren.push(renderedChild);\n }\n }\n }\n }\n\n const result = {\n type: instance.type,\n props: props,\n children: renderedChildren,\n $$typeof: Symbol.for(\"react.test.json\"),\n };\n // This is needed for JEST to format snapshot as JSX.\n Object.defineProperty(result, \"$$typeof\", {\n value: Symbol.for(\"react.test.json\"),\n });\n return result;\n }\n\n case \"CONTAINER\": {\n let renderedChildren = null;\n if (instance.children.length) {\n for (let i = 0; i < instance.children.length; i++) {\n const renderedChild = renderToJson(instance.children[i]);\n if (renderedChild !== null) {\n if (renderedChildren === null) {\n renderedChildren = [renderedChild];\n } else {\n renderedChildren.push(renderedChild);\n }\n }\n }\n }\n\n const result = {\n type: CONTAINER_TYPE,\n props: {},\n children: renderedChildren,\n $$typeof: Symbol.for(\"react.test.json\"),\n };\n // This is needed for JEST to format snapshot as JSX.\n Object.defineProperty(result, \"$$typeof\", {\n value: Symbol.for(\"react.test.json\"),\n });\n return result;\n }\n }\n}\n\nexport function renderChildrenToJson(\n children: Array<Instance | TextInstance> | null\n) {\n let result = null;\n if (children?.length) {\n for (let i = 0; i < children.length; i++) {\n const renderedChild = renderToJson(children[i]);\n if (renderedChild !== null) {\n if (result === null) {\n result = [renderedChild];\n } else {\n result.push(renderedChild);\n }\n }\n }\n }\n\n return result;\n}\n","import { CONTAINER_TYPE } from \"./constants\";\nimport { Container, Instance, TextInstance } from \"./reconciler\";\nimport { JsonNode, renderToJson } from \"./render-to-json\";\n\nexport type HostNode = HostElement | string;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type HostElementProps = Record<string, any>;\n\nconst instanceToHostElementMap = new WeakMap<\n Container | Instance,\n HostElement\n>();\n\nexport class HostElement {\n private instance: Instance | Container;\n\n private constructor(instance: Instance | Container) {\n this.instance = instance;\n }\n\n get type(): string {\n return this.instance.tag === \"INSTANCE\"\n ? this.instance.type\n : CONTAINER_TYPE;\n }\n\n get props(): HostElementProps {\n if (this.instance.tag === \"CONTAINER\") {\n return {};\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { children, ...restProps } = this.instance.props;\n return restProps;\n }\n\n get children(): HostNode[] {\n const result = this.instance.children\n .filter((child) => !child.isHidden)\n .map((child) => HostElement.fromInstance(child));\n return result;\n }\n\n get parent(): HostElement | null {\n const parentInstance = this.instance.parent;\n if (parentInstance == null) {\n return null;\n }\n\n switch (parentInstance.tag) {\n case \"INSTANCE\":\n return HostElement.fromInstance(parentInstance) as HostElement;\n\n case \"CONTAINER\":\n return HostElement.fromContainer(parentInstance);\n }\n }\n\n get $$typeof(): symbol {\n return Symbol.for(\"react.test.json\");\n }\n\n toJSON(): JsonNode | null {\n return renderToJson(this.instance);\n }\n\n /** @internal */\n static fromContainer(container: Container): HostElement {\n const hostElement = instanceToHostElementMap.get(container);\n if (hostElement) {\n return hostElement;\n }\n\n const result = new HostElement(container);\n instanceToHostElementMap.set(container, result);\n return result;\n }\n\n /** @internal */\n static fromInstance(instance: Instance | TextInstance): HostNode {\n switch (instance.tag) {\n case \"TEXT\":\n return instance.text;\n\n case \"INSTANCE\": {\n const hostElement = instanceToHostElementMap.get(instance);\n if (hostElement) {\n return hostElement;\n }\n\n const result = new HostElement(instance);\n instanceToHostElementMap.set(instance, result);\n return result;\n }\n }\n }\n}\n","import { ReactElement } from \"react\";\nimport { Container, TestReconciler } from \"./reconciler\";\nimport { HostElement } from \"./host-element\";\nimport { FiberRoot } from \"react-reconciler\";\nimport { ConcurrentRoot, LegacyRoot } from \"react-reconciler/constants\";\n\n// Refs:\n// https://github.com/facebook/react/blob/v18.3.1/packages/react-noop-renderer/src/createReactNoop.js\n// https://github.com/facebook/react/blob/v18.3.1/packages/react-native-renderer/src/ReactNativeHostConfig.js\n// https://github.com/facebook/react/blob/v18.3.1/packages/react-native-renderer/src/ReactFabricHostConfig.js\n\nexport type RendererOptions = {\n textComponents?: string[];\n isConcurrent?: boolean;\n createNodeMock?: (element: ReactElement) => object;\n};\n\nexport type Renderer = {\n render: (element: ReactElement) => void;\n unmount: () => void;\n container: HostElement;\n root: HostElement | null;\n};\n\nexport function createRenderer(options?: RendererOptions): Renderer {\n let container: Container | null = {\n tag: \"CONTAINER\",\n children: [],\n parent: null,\n textComponents: options?.textComponents,\n createNodeMock: options?.createNodeMock ?? (() => ({})),\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let containerFiber: FiberRoot = TestReconciler.createContainer(\n container,\n options?.isConcurrent ? ConcurrentRoot : LegacyRoot,\n null, // no hydration callback\n false, // isStrictMode\n null, // concurrentUpdatesByDefaultOverride\n \"id\", // identifierPrefix\n () => {}, // onRecoverableError\n null // transitionCallbacks\n );\n\n const render = (element: ReactElement) => {\n TestReconciler.updateContainer(element, containerFiber, null, null);\n };\n\n const unmount = () => {\n if (containerFiber == null || container == null) {\n return;\n }\n\n TestReconciler.updateContainer(null, containerFiber, null, null);\n\n container = null;\n containerFiber = null;\n };\n\n return {\n render,\n unmount,\n get root(): HostElement | null {\n if (containerFiber == null || container == null) {\n throw new Error(\"Can't access .root on unmounted test renderer\");\n }\n\n if (container.children.length === 0) {\n return null;\n }\n\n const root = HostElement.fromInstance(container.children[0]);\n if (typeof root === \"string\") {\n throw new Error(\"Cannot render string as root element\");\n }\n\n return root;\n },\n\n get container(): HostElement {\n if (containerFiber == null || container == null) {\n throw new Error(\"Can't access .container on unmounted test renderer\");\n }\n\n return HostElement.fromContainer(container);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA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MACxD;AAEA,aAAO;AAAA,IACT;AAAA,IAEA,IAAI,YAAyB;AAC3B,UAAI,kBAAkB,QAAQ,aAAa,MAAM;AAC/C,cAAM,IAAI,MAAM,oDAAoD;AAAA,MACtE;AAEA,aAAO,YAAY,cAAc,SAAS;AAAA,IAC5C;AAAA,EACF;AACF;","names":["ReactReconciler","import_constants"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/reconciler.ts","../src/utils.ts","../src/constants.ts","../src/render-to-json.ts","../src/host-element.ts","../src/renderer.ts"],"sourcesContent":["export { createRenderer } from \"./renderer\";\nexport { CONTAINER_TYPE } from \"./constants\";\n\nexport type { Renderer, RendererOptions } from \"./renderer\";\nexport type { HostElement, HostElementProps, HostNode } from \"./host-element\";\nexport type { JsonElement, JsonNode } from \"./render-to-json\";\n","import { ReactElement } from \"react\";\nimport ReactReconciler, { Fiber } from \"react-reconciler\";\nimport {\n DefaultEventPriority,\n // @ts-expect-error missing types\n NoEventPriority,\n} from \"react-reconciler/constants\";\nimport { formatComponentList } from \"./utils\";\n\nexport type Type = string;\nexport type Props = Record<string, unknown>;\nexport type OpaqueHandle = Fiber;\n\ntype ReconcilerConfig = {\n textComponents?: string[];\n createNodeMock: (element: ReactElement) => object;\n};\n\nexport type Container = {\n tag: \"CONTAINER\";\n children: Array<Instance | TextInstance>;\n parent: null;\n config: ReconcilerConfig;\n};\n\nexport type Instance = {\n tag: \"INSTANCE\";\n type: string;\n props: Props;\n children: Array<Instance | TextInstance>;\n parent: Container | Instance | null;\n rootContainer: Container;\n isHidden: boolean;\n internalHandle: OpaqueHandle;\n};\n\nexport type TextInstance = {\n tag: \"TEXT\";\n text: string;\n parent: Container | Instance | null;\n isHidden: boolean;\n};\n\nexport type SuspenseInstance = object;\nexport type HydratableInstance = object;\nexport type PublicInstance = object | TextInstance;\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\nconst nodeToInstanceMap = new WeakMap<object, Instance>();\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\nlet currentUpdatePriority: number = NoEventPriority;\n\nconst hostConfig: 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 /**\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: OpaqueHandle\n ) {\n return {\n tag: \"INSTANCE\",\n type,\n props,\n isHidden: false,\n children: [],\n parent: null,\n rootContainer,\n 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: OpaqueHandle\n ): TextInstance {\n if (rootContainer.config.textComponents && !hostContext.isInsideText) {\n throw new Error(\n `Invariant Violation: Text strings must be rendered within a ${formatComponentList(\n rootContainer.config.textComponents\n )} component. Detected attempt to render \"${text}\" string within a <${\n hostContext.type\n }> component.`\n );\n }\n\n return {\n tag: \"TEXT\",\n text,\n parent: null,\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: appendChild,\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 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 return false;\n },\n\n setCurrentUpdatePriority(newPriority: number) {\n currentUpdatePriority = newPriority;\n },\n\n getCurrentUpdatePriority() {\n return currentUpdatePriority;\n },\n\n resolveUpdatePriority(): number {\n return currentUpdatePriority || DefaultEventPriority;\n },\n\n shouldAttemptEagerTransition() {\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 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 const isInsideText = Boolean(\n parentHostContext.config.textComponents?.includes(type)\n );\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 switch (instance.tag) {\n case \"INSTANCE\": {\n const createNodeMock = instance.rootContainer.config.createNodeMock;\n const mockNode = createNodeMock({\n type: instance.type,\n props: instance.props,\n key: null,\n });\n\n //if (typeof mockNode === \"object\" && mockNode !== null) {\n nodeToInstanceMap.set(mockNode, instance);\n //}\n\n return mockNode;\n }\n\n default:\n return instance;\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 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 // noop\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 // noop\n },\n\n /**\n * #### `scheduleTimeout(fn, delay)`\n *\n * You can proxy this to `setTimeout` or its equivalent in your environment.\n */\n scheduleTimeout: setTimeout,\n\n /**\n * #### `cancelTimeout(id)`\n *\n * You can proxy this to `clearTimeout` or its equivalent in your environment.\n */\n cancelTimeout: clearTimeout,\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: queueMicrotask,\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): OpaqueHandle | null | undefined {\n const instance = nodeToInstanceMap.get(node);\n if (instance !== undefined) {\n return instance.internalHandle;\n }\n\n return null;\n },\n\n beforeActiveInstanceBlur(): void {\n // noop\n },\n\n afterActiveInstanceBlur(): void {\n // noop\n },\n\n prepareScopeUpdate(scopeInstance: object, instance: Instance): void {\n nodeToInstanceMap.set(scopeInstance, instance);\n },\n\n getInstanceFromScope(scopeInstance: object): Instance | null {\n return nodeToInstanceMap.get(scopeInstance) ?? null;\n },\n\n detachDeletedInstance(_node: Instance): void {},\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: appendChild,\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: appendChild,\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: insertBefore,\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: insertBefore,\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: removeChild,\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: removeChild,\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 // noop\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(\n textInstance: TextInstance,\n _oldText: string,\n newText: string\n ): void {\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(\n _instance: Instance,\n _type: Type,\n _props: Props,\n _internalHandle: OpaqueHandle\n ): void {\n // noop\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 are not updated\n commitUpdate(\n instance: Instance,\n type: Type,\n _prevProps: Props,\n nextProps: Props,\n internalHandle: OpaqueHandle\n ): void {\n instance.type = type;\n instance.props = nextProps;\n instance.internalHandle = 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 instance.isHidden = true;\n },\n\n /**\n * #### `hideTextInstance(textInstance)`\n *\n * Same as `hideInstance`, but for nodes created by `createTextInstance`.\n */\n hideTextInstance(textInstance: TextInstance): void {\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 instance.isHidden = false;\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 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 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 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 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\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() {},\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() {\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\n requestPostPaintCallback(_callback: (endTime: number) => void) {},\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(\n parentInstance: Container | Instance,\n child: 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 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(\n parentInstance: Container | Instance,\n child: Instance | TextInstance\n): void {\n const index = parentInstance.children.indexOf(child);\n parentInstance.children.splice(index, 1);\n child.parent = null;\n}\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","export const CONTAINER_TYPE = \"CONTAINER\";\n","import { CONTAINER_TYPE } from \"./constants\";\nimport { Container, Instance, TextInstance } from \"./reconciler\";\n\nexport type JsonNode = JsonElement | string;\n\nexport type JsonElement = {\n type: string;\n props: object;\n children: Array<JsonNode> | null;\n $$typeof: symbol;\n};\n\nexport function renderToJson(\n instance: Container | Instance | TextInstance\n): JsonNode | null {\n if (`isHidden` in instance && instance.isHidden) {\n // Omit timed out children from output entirely. This seems like the least\n // surprising behavior. We could perhaps add a separate API that includes\n // them, if it turns out people need it.\n return null;\n }\n\n switch (instance.tag) {\n case \"TEXT\":\n return instance.text;\n\n case \"INSTANCE\": {\n // We don't include the `children` prop in JSON.\n // Instead, we will include the actual rendered children.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { children, ...props } = instance.props;\n\n let renderedChildren = null;\n if (instance.children.length) {\n for (let i = 0; i < instance.children.length; i++) {\n const renderedChild = renderToJson(instance.children[i]);\n if (renderedChild !== null) {\n if (renderedChildren === null) {\n renderedChildren = [renderedChild];\n } else {\n renderedChildren.push(renderedChild);\n }\n }\n }\n }\n\n const result = {\n type: instance.type,\n props: props,\n children: renderedChildren,\n $$typeof: Symbol.for(\"react.test.json\"),\n };\n // This is needed for JEST to format snapshot as JSX.\n Object.defineProperty(result, \"$$typeof\", {\n value: Symbol.for(\"react.test.json\"),\n });\n return result;\n }\n\n case \"CONTAINER\": {\n let renderedChildren = null;\n if (instance.children.length) {\n for (let i = 0; i < instance.children.length; i++) {\n const renderedChild = renderToJson(instance.children[i]);\n if (renderedChild !== null) {\n if (renderedChildren === null) {\n renderedChildren = [renderedChild];\n } else {\n renderedChildren.push(renderedChild);\n }\n }\n }\n }\n\n const result = {\n type: CONTAINER_TYPE,\n props: {},\n children: renderedChildren,\n $$typeof: Symbol.for(\"react.test.json\"),\n };\n // This is needed for JEST to format snapshot as JSX.\n Object.defineProperty(result, \"$$typeof\", {\n value: Symbol.for(\"react.test.json\"),\n });\n return result;\n }\n }\n}\n\nexport function renderChildrenToJson(\n children: Array<Instance | TextInstance> | null\n) {\n let result = null;\n if (children?.length) {\n for (let i = 0; i < children.length; i++) {\n const renderedChild = renderToJson(children[i]);\n if (renderedChild !== null) {\n if (result === null) {\n result = [renderedChild];\n } else {\n result.push(renderedChild);\n }\n }\n }\n }\n\n return result;\n}\n","import { CONTAINER_TYPE } from \"./constants\";\nimport { Container, Instance, TextInstance } from \"./reconciler\";\nimport { JsonNode, renderToJson } from \"./render-to-json\";\n\nexport type HostNode = HostElement | string;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type HostElementProps = Record<string, any>;\n\nconst instanceToHostElementMap = new WeakMap<\n Container | Instance,\n HostElement\n>();\n\nexport class HostElement {\n private instance: Instance | Container;\n\n private constructor(instance: Instance | Container) {\n this.instance = instance;\n }\n\n get type(): string {\n return this.instance.tag === \"INSTANCE\"\n ? this.instance.type\n : CONTAINER_TYPE;\n }\n\n get props(): HostElementProps {\n if (this.instance.tag === \"CONTAINER\") {\n return {};\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { children, ...restProps } = this.instance.props;\n return restProps;\n }\n\n get children(): HostNode[] {\n const result = this.instance.children\n .filter((child) => !child.isHidden)\n .map((child) => HostElement.fromInstance(child));\n return result;\n }\n\n get parent(): HostElement | null {\n const parentInstance = this.instance.parent;\n if (parentInstance == null) {\n return null;\n }\n\n switch (parentInstance.tag) {\n case \"INSTANCE\":\n return HostElement.fromInstance(parentInstance) as HostElement;\n\n case \"CONTAINER\":\n return HostElement.fromContainer(parentInstance);\n }\n }\n\n get $$typeof(): symbol {\n return Symbol.for(\"react.test.json\");\n }\n\n toJSON(): JsonNode | null {\n return renderToJson(this.instance);\n }\n\n /** @internal */\n static fromContainer(container: Container): HostElement {\n const hostElement = instanceToHostElementMap.get(container);\n if (hostElement) {\n return hostElement;\n }\n\n const result = new HostElement(container);\n instanceToHostElementMap.set(container, result);\n return result;\n }\n\n /** @internal */\n static fromInstance(instance: Instance | TextInstance): HostNode {\n switch (instance.tag) {\n case \"TEXT\":\n return instance.text;\n\n case \"INSTANCE\": {\n const hostElement = instanceToHostElementMap.get(instance);\n if (hostElement) {\n return hostElement;\n }\n\n const result = new HostElement(instance);\n instanceToHostElementMap.set(instance, result);\n return result;\n }\n }\n }\n}\n","import { ReactElement } from \"react\";\nimport { Container, TestReconciler } from \"./reconciler\";\nimport { HostElement } from \"./host-element\";\nimport { FiberRoot } from \"react-reconciler\";\nimport { ConcurrentRoot, LegacyRoot } from \"react-reconciler/constants\";\n\n// Refs:\n// https://github.com/facebook/react/blob/v18.3.1/packages/react-noop-renderer/src/createReactNoop.js\n// https://github.com/facebook/react/blob/v18.3.1/packages/react-native-renderer/src/ReactNativeHostConfig.js\n// https://github.com/facebook/react/blob/v18.3.1/packages/react-native-renderer/src/ReactFabricHostConfig.js\n\nexport type RendererOptions = {\n textComponents?: string[];\n isConcurrent?: boolean;\n createNodeMock?: (element: ReactElement) => object;\n};\n\nexport type Renderer = {\n render: (element: ReactElement) => void;\n unmount: () => void;\n container: HostElement;\n root: HostElement | null;\n};\n\nexport function createRenderer(options?: RendererOptions): Renderer {\n let container: Container | null = {\n tag: \"CONTAINER\",\n children: [],\n parent: null,\n config: {\n textComponents: options?.textComponents,\n createNodeMock: options?.createNodeMock ?? (() => ({})),\n },\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let containerFiber: FiberRoot = TestReconciler.createContainer(\n container,\n options?.isConcurrent ? ConcurrentRoot : LegacyRoot,\n null, // hydration callbacks\n false, // isStrictMode\n null, // concurrentUpdatesByDefaultOverride\n \"id\", // identifierPrefix\n () => {}, // onUncaughtError\n () => {}, // onCaughtError\n // @ts-expect-error missing types\n () => {}, // onRecoverableError\n null // transitionCallbacks\n );\n\n const render = (element: ReactElement) => {\n TestReconciler.updateContainer(element, containerFiber, null, null);\n };\n\n const unmount = () => {\n if (containerFiber == null || container == null) {\n return;\n }\n\n TestReconciler.updateContainer(null, containerFiber, null, null);\n\n container = null;\n containerFiber = null;\n };\n\n return {\n render,\n unmount,\n get root(): HostElement | null {\n if (containerFiber == null || container == null) {\n throw new Error(\"Can't access .root on unmounted test renderer\");\n }\n\n if (container.children.length === 0) {\n return null;\n }\n\n const root = HostElement.fromInstance(container.children[0]);\n if (typeof root === \"string\") {\n throw new Error(\"Cannot render string as root element\");\n }\n\n return root;\n },\n\n get container(): HostElement {\n if (containerFiber == null || container == null) {\n throw new Error(\"Can't access .container on unmounted test renderer\");\n }\n\n return HostElement.fromContainer(container);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,8BAAuC;AACvC,uBAIO;;;ACNA,SAAS,oBAAoB,OAAyB;AAC3D,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO;AAAA,EACT;A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