2025-08-02 19:22:07 -07:00
|
|
|
export const Fragment = ({ children }: { children: render.Node[] }) => children;
|
2025-07-07 20:58:02 -07:00
|
|
|
|
|
|
|
export function jsx(
|
2025-08-02 19:22:07 -07:00
|
|
|
type: string | render.Component,
|
2025-07-07 20:58:02 -07:00
|
|
|
props: Record<string, unknown>,
|
2025-08-02 19:22:07 -07:00
|
|
|
): render.Element {
|
2025-07-07 20:58:02 -07:00
|
|
|
if (typeof type !== "function" && typeof type !== "string") {
|
2025-08-02 19:22:07 -07:00
|
|
|
throw new Error("Invalid component type: " + render.inspect(type));
|
2025-07-07 20:58:02 -07:00
|
|
|
}
|
2025-08-02 19:22:07 -07:00
|
|
|
return [render.kElement, type, props];
|
2025-07-07 20:58:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
export function jsxDEV(
|
2025-08-02 19:22:07 -07:00
|
|
|
type: string | render.Component,
|
2025-07-07 20:58:02 -07:00
|
|
|
props: Record<string, unknown>,
|
|
|
|
// Unused with the clover engine
|
|
|
|
_key: string,
|
|
|
|
// Unused with the clover engine
|
|
|
|
_isStaticChildren: boolean,
|
2025-08-02 19:22:07 -07:00
|
|
|
source: render.SrcLoc,
|
|
|
|
): render.Element {
|
2025-07-07 20:58:02 -07:00
|
|
|
const { fileName, lineNumber, columnNumber } = source;
|
|
|
|
|
|
|
|
// Assert the component type is valid to render.
|
|
|
|
if (typeof type !== "function" && typeof type !== "string") {
|
|
|
|
throw new Error(
|
|
|
|
`Invalid component type at ${fileName}:${lineNumber}:${columnNumber}: ` +
|
2025-08-02 19:22:07 -07:00
|
|
|
render.inspect(type) +
|
2025-07-07 20:58:02 -07:00
|
|
|
". Clover SSR element must be a function or string",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Construct an `ssr.Element`
|
2025-08-02 19:22:07 -07:00
|
|
|
return [render.kElement, type, props, "", source];
|
2025-07-07 20:58:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// jsxs
|
|
|
|
export { jsx as jsxs };
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
namespace JSX {
|
|
|
|
interface IntrinsicElements {
|
|
|
|
[name: string]: Record<string, unknown>;
|
|
|
|
}
|
|
|
|
interface ElementChildrenAttribute {
|
|
|
|
children: Node;
|
|
|
|
}
|
2025-08-02 19:22:07 -07:00
|
|
|
type Element = render.Element;
|
|
|
|
type ElementType = keyof IntrinsicElements | render.Component;
|
|
|
|
type ElementClass = ReturnType<render.Component>;
|
2025-07-07 20:58:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-08-11 22:43:27 -07:00
|
|
|
import * as render from "#engine/render";
|