react-intlayer
Version:
Easily internationalize i18n your React applications with type-safe multilingual content management.
59 lines (57 loc) • 1.92 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
let react = require("react");
//#region src/markdown/runtime.ts
/**
* React-specific runtime for the markdown processor.
* Implements the MarkdownRuntime interface using React's primitives.
*/
const reactRuntime = {
/**
* Creates a React element.
* Handles the conversion of props and children to React format.
*/
createElement: (type, props, ...children) => {
if (children.length === 0) return (0, react.createElement)(type, props);
if (children.length === 1) return (0, react.createElement)(type, props, children[0]);
return (0, react.createElement)(type, props, ...children);
},
/**
* Clones a React element with new props.
*/
cloneElement: (element, props, ...children) => {
if (children.length === 0) return (0, react.cloneElement)(element, props);
return (0, react.cloneElement)(element, props, ...children);
},
/**
* React Fragment component.
*/
Fragment: react.Fragment,
/**
* React-specific prop normalization.
* React uses className instead of class, htmlFor instead of for, etc.
* The core processor already handles ATTRIBUTE_TO_NODE_PROP_MAP,
* so this is mostly a no-op but can be used for additional React-specific transforms.
*/
normalizeProps: (_tag, props) => {
return props;
}
};
/**
* Creates a React runtime with custom createElement for advanced use cases.
* Useful for wrapping elements or adding middleware.
*/
const createReactRuntime = (options = {}) => {
const { onCreateElement } = options;
if (onCreateElement) return {
...reactRuntime,
createElement: (type, props, ...children) => {
return onCreateElement(type, props, children);
}
};
return reactRuntime;
};
//#endregion
exports.createReactRuntime = createReactRuntime;
exports.reactRuntime = reactRuntime;
//# sourceMappingURL=runtime.cjs.map