sitegen/framework/engine/jsx-runtime.ts

46 lines
1.3 KiB
TypeScript

export const Fragment = ({ children }: { children: engine.Node[] }) => children;
export function jsx(
type: string | engine.Component,
props: Record<string, unknown>,
): engine.Element {
if (typeof type !== "function" && typeof type !== "string") {
throw new Error("Invalid component type: " + engine.inspect(type));
}
return [engine.kElement, type, props];
}
export function jsxDEV(
type: string | engine.Component,
props: Record<string, unknown>,
// Unused with the clover engine
_key: string,
// Unused with the clover engine
_isStaticChildren: boolean,
// Unused with the clover engine
_source: unknown,
): engine.Element {
if (typeof type !== "function" && typeof type !== "string") {
throw new Error("Invalid component type: " + engine.inspect(type));
}
return [engine.kElement, type, props];
}
// jsxs
export { jsx as jsxs };
declare global {
namespace JSX {
interface IntrinsicElements {
[name: string]: Record<string, unknown>;
}
interface ElementChildrenAttribute {
children: unknown;
}
type Element = engine.Node;
type ElementType = keyof IntrinsicElements | engine.Component;
type ElementClass = ReturnType<engine.Component>;
}
}
import * as engine from "./ssr.ts";