/** * Shim mapping `react/jsx-runtime` (and jsx-dev-runtime) to WordPress' * bundled `window.ReactJSXRuntime` (core script handle `react-jsx-runtime`, * WP 6.6+). On older WP the global is absent, so a tiny createElement-based * fallback keeps the automatic JSX transform working. ONLY aliased in * vite.editor.config.ts (see react.ts). */ const w = window as any; const runtime = w.ReactJSXRuntime ?? null; function createElementJsx(type: any, props: any, key: any) { const { children, ...rest } = props ?? {}; if (key !== undefined) { rest.key = key; } const childArgs = children === undefined ? [] : Array.isArray(children) ? children : [children]; return w.React.createElement(type, rest, ...childArgs); } export const Fragment = runtime?.Fragment ?? w.React?.Fragment; export const jsx = runtime?.jsx ?? createElementJsx; export const jsxs = runtime?.jsxs ?? createElementJsx; // jsx-dev-runtime shape (dev builds only; extra args are ignored by the fallback). export const jsxDEV = w.ReactJSXDevRuntime?.jsxDEV ?? createElementJsx; export default { Fragment, jsx, jsxs, jsxDEV };