UNPKG

woby

Version:

A high-performance framework with fine-grained observable/signal-based reactivity for building rich applications.

60 lines (59 loc) 2.44 kB
import "./fragment-CrJfXftf.js"; import { a as wrapElement, w as wrapCloneElement } from "./wrap_clone_element-CPcdGL7P.js"; import { n as isObject, i as isFunction, k as isString, o as isSVGElement, p as isNode, q as isVoidChild, u as untrack, r as createSVGNode, t as createHTMLNode, v as setProps, m as setChild, F as FragmentUtils, S as SYMBOL_CLONE } from "./setters-Ddu0s6oK.js"; const createElement = (component, _props, ..._children) => { const children = _children.length > 1 ? _children : _children.length > 0 ? _children[0] : void 0; const hasChildren = !isVoidChild(children); const { ...rest } = _props ?? {}; if (hasChildren && isObject(_props) && "children" in _props) { throw new Error('Providing "children" both as a prop and as rest arguments is forbidden'); } if (isFunction(component)) { const props = hasChildren ? { ..._props, children } : _props; return wrapElement(() => { return untrack(() => component.call(component, props)); }); } else if (isString(component)) { const isSVG = isSVGElement(component); const createNode = isSVG ? createSVGNode : createHTMLNode; return wrapElement(() => { const child = createNode(component); if (isSVG) child["isSVG"] = true; const stack = new Error(); untrack(() => { if (_props) { setProps(child, _props, stack); } if (hasChildren) { setChild(child, children, FragmentUtils.make(), stack); } }); return child; }); } else if (isNode(component)) { return wrapElement(() => component); } else { throw new Error("Invalid component"); } }; function jsx(component, props, ...children) { if (typeof children === "string") return wrapCloneElement(createElement(component, props ?? {}, children), component, props); if (!props) props = {}; if (typeof children === "string") Object.assign(props, { children }); return wrapCloneElement(createElement(component, props, props == null ? void 0 : props.key), component, props); } const jsxDEV = (component, props, key, isStatic, source, self) => { if (key) Object.assign(props, { key }); return wrapCloneElement(createElement(component, props), component, props); }; const getMeta = (target) => target == null ? void 0 : target[SYMBOL_CLONE]; export { jsxDEV as a, createElement as c, getMeta as g, jsx as j }; //# sourceMappingURL=runtime-DHiCLtGC.js.map