sitegen/framework/engine/jsx-runtime.ts
clover caruso f1d4be2553 feat: dynamic page regeneration (#24)
the asset system is reworked to support "dynamic" entries, where each
entry is a separate file on disk containing the latest generation's
headers+raw+gzip+zstd. when calling view.regenerate, it will look for
pages that had "export const regenerate" during generation, and render
those pages using the view system, but then store the results as assets
instead of sending as a response.

pages configured as regenerable are also bundled as views, using the
non-aliasing key "page:${page.id}". this cannot alias because file
paths may not contain a colon.
2025-08-11 22:43:27 -07:00

54 lines
1.5 KiB
TypeScript

export const Fragment = ({ children }: { children: render.Node[] }) => children;
export function jsx(
type: string | render.Component,
props: Record<string, unknown>,
): render.Element {
if (typeof type !== "function" && typeof type !== "string") {
throw new Error("Invalid component type: " + render.inspect(type));
}
return [render.kElement, type, props];
}
export function jsxDEV(
type: string | render.Component,
props: Record<string, unknown>,
// Unused with the clover engine
_key: string,
// Unused with the clover engine
_isStaticChildren: boolean,
source: render.SrcLoc,
): render.Element {
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}: ` +
render.inspect(type) +
". Clover SSR element must be a function or string",
);
}
// Construct an `ssr.Element`
return [render.kElement, type, props, "", source];
}
// jsxs
export { jsx as jsxs };
declare global {
namespace JSX {
interface IntrinsicElements {
[name: string]: Record<string, unknown>;
}
interface ElementChildrenAttribute {
children: Node;
}
type Element = render.Element;
type ElementType = keyof IntrinsicElements | render.Component;
type ElementClass = ReturnType<render.Component>;
}
}
import * as render from "#engine/render";