UNPKG

disjsx

Version:

A library for creating Discord messages in JSX

35 lines 1.92 kB
import type { DISJSX } from "./disjsxTypes"; import { type ReactNode, type ReactElement } from "react"; /** * Transforms a single React DISJSX component node into its corresponding JSON payload object. * This function is the core of the DISJSX to JSON transformation, mapping each * DISJSX component (e.g., <ActionRow>, <Button>, <Embed>) and its props to the * structure expected by the target API (presumably Discord). * * It recursively processes children for components that can contain other DISJSX elements * (like ActionRow or Container). For textual content within components like TextDisplay * or Embed fields, it utilizes `processChildrenToString` to convert JSX children * into formatted strings. * * @param node The React node to process. Expected to be a DISJSX component. * @returns A JSON payload object representing the component, or null if the node is invalid. */ export declare const processNode: (node: ReactNode) => unknown | null; /** * Helper function to get the DISJSX type from a React node. * Handles both direct elements and function components that return DISJSX elements. * @param node The React node to inspect. * @param loop The number of times the function has been called. * @returns The DISJSX type, or undefined if not a DISJSX component. */ export declare const getDISJSXType: (node: ReactNode, loop?: number) => DISJSX | undefined; /** * Helper function to "unwrap" functional components until a host component * or a DISJSX component (with `disjsxType`) is reached. * @param element The React element to process. * @param loop The number of times the function has been called. * @returns The underlying host or DISJSX React element. * @throws TypeError if a functional component meant for unwrapping returns a non-element. */ export declare const getProcessedElement: (element: ReactElement, loop?: number) => ReactElement; //# sourceMappingURL=utils.d.ts.map