From 9d45bd2154b6b189b3b5911722598716dd2bdd77 Mon Sep 17 00:00:00 2001 From: wsbrunson Date: Mon, 23 Sep 2024 15:37:58 +0000 Subject: [PATCH] ci: check in dist folder --- dist/jsx-pragmatic-demo.js | 57 +++++++------- dist/jsx-pragmatic.js | 73 +++++++++--------- dist/jsx-pragmatic.min.js | 2 +- dist/jsx-pragmatic.min.js.map | 2 +- dist/module/component/index.js | 4 +- dist/module/component/regex.js | 87 ++++++++-------------- dist/module/component/style.js | 9 +-- dist/module/constants.js | 8 +- dist/module/index.js | 8 +- dist/module/node.js | 70 +++--------------- dist/module/renderers/dom.js | 127 ++++++++++---------------------- dist/module/renderers/html.js | 44 ++++------- dist/module/renderers/index.js | 12 +-- dist/module/renderers/preact.js | 30 +++----- dist/module/renderers/react.js | 32 +++----- dist/module/renderers/regex.js | 14 +--- dist/module/renderers/text.js | 15 ++-- dist/module/types.js | 1 - dist/module/util.js | 9 +-- 19 files changed, 221 insertions(+), 383 deletions(-) diff --git a/dist/jsx-pragmatic-demo.js b/dist/jsx-pragmatic-demo.js index 99c62bd..03f095d 100644 --- a/dist/jsx-pragmatic-demo.js +++ b/dist/jsx-pragmatic-demo.js @@ -194,6 +194,7 @@ "iframe" !== el.tagName.toLowerCase() || props.id || el.setAttribute("id", "jsx-iframe-" + "xxxxxxxxxx".replace(/./g, (function() { return "0123456789abcdef".charAt(Math.floor(Math.random() * "0123456789abcdef".length)); }))); + "iframe" !== el.tagName.toLowerCase() || props.srcdoc || props.src || el.setAttribute("srcdoc", ""); } var ADD_CHILDREN = ((_ADD_CHILDREN = {}).iframe = function(el, node) { var firstChild = node.children[0]; @@ -207,37 +208,39 @@ var child = firstChild.render(function(opts) { void 0 === opts && (opts = {}); var _opts$doc = opts.doc, doc = void 0 === _opts$doc ? document : _opts$doc; - return function domRenderer(node) { - if ("component" === node.type) return node.renderComponent(domRenderer); + var _xmlNamespaceDomRenderer = function(node, xmlNamespace) { + if ("component" === node.type) return node.renderComponent((function(childNode) { + return _xmlNamespaceDomRenderer(childNode, xmlNamespace); + })); + if ("text" === node.type) return createTextElement(doc, node); + if ("element" === node.type) { + var el = function(doc, node, xmlNamespace) { + return doc.createElementNS(xmlNamespace, node.name); + }(doc, node, xmlNamespace); + addProps(el, node); + addChildren(el, node, doc, (function(childNode) { + return _xmlNamespaceDomRenderer(childNode, xmlNamespace); + })); + return el; + } + throw new TypeError("Unhandleable node"); + }; + var _domRenderer = function(node) { + if ("component" === node.type) return node.renderComponent(_domRenderer); if ("text" === node.type) return createTextElement(doc, node); if ("element" === node.type) { var xmlNamespace = ELEMENT_DEFAULT_XML_NAMESPACE[node.name.toLowerCase()]; - if (xmlNamespace) return function xmlNamespaceDomRenderer(node, xmlNamespace) { - if ("component" === node.type) return node.renderComponent((function(childNode) { - return xmlNamespaceDomRenderer(childNode, xmlNamespace); - })); - if ("text" === node.type) return createTextElement(doc, node); - if ("element" === node.type) { - var el = function(doc, node, xmlNamespace) { - return doc.createElementNS(xmlNamespace, node.name); - }(doc, node, xmlNamespace); - addProps(el, node); - addChildren(el, node, doc, (function(childNode) { - return xmlNamespaceDomRenderer(childNode, xmlNamespace); - })); - return el; - } - throw new TypeError("Unhandleable node"); - }(node, xmlNamespace); + if (xmlNamespace) return _xmlNamespaceDomRenderer(node, xmlNamespace); var el = function(doc, node) { return node.props.el ? node.props.el : doc.createElement(node.name); }(doc, node); addProps(el, node); - addChildren(el, node, doc, domRenderer); + addChildren(el, node, doc, _domRenderer); return el; } throw new TypeError("Unhandleable node"); }; + return _domRenderer; }({ doc: doc })); @@ -273,13 +276,15 @@ } else (ADD_CHILDREN[node.name] || ADD_CHILDREN.default)(el, node, renderer); } function regex() { + var regexRenderer = _textRenderer = function(node) { + if ("component" === node.type) return [].concat(node.renderComponent(_textRenderer)).join(""); + if ("element" === node.type) throw new Error("Text renderer does not support basic elements"); + if ("text" === node.type) return node.text; + throw new TypeError("Unhandleable node: " + node.type); + }; + var _textRenderer; return function(nodeInstance) { - return new RegExp(function textRenderer(node) { - if ("component" === node.type) return [].concat(node.renderComponent(textRenderer)).join(""); - if ("element" === node.type) throw new Error("Text renderer does not support basic elements"); - if ("text" === node.type) return node.text; - throw new TypeError("Unhandleable node: " + node.type); - }(nodeInstance)); + return new RegExp(regexRenderer(nodeInstance)); }; } regex.node = function(el, props) { diff --git a/dist/jsx-pragmatic.js b/dist/jsx-pragmatic.js index 8e9b05f..3fc9036 100644 --- a/dist/jsx-pragmatic.js +++ b/dist/jsx-pragmatic.js @@ -240,12 +240,13 @@ return children; }; function text_text() { - return function textRenderer(node) { - if (node.type === NODE_TYPE.COMPONENT) return [].concat(node.renderComponent(textRenderer)).join(""); + var _textRenderer = function(node) { + if (node.type === NODE_TYPE.COMPONENT) return [].concat(node.renderComponent(_textRenderer)).join(""); if (node.type === NODE_TYPE.ELEMENT) throw new Error("Text renderer does not support basic elements"); if (node.type === NODE_TYPE.TEXT) return node.text; throw new TypeError("Unhandleable node: " + node.type); }; + return _textRenderer; } function isDefined(val) { return null != val; @@ -271,6 +272,7 @@ "iframe" !== el.tagName.toLowerCase() || props.id || el.setAttribute("id", "jsx-iframe-" + "xxxxxxxxxx".replace(/./g, (function() { return "0123456789abcdef".charAt(Math.floor(Math.random() * "0123456789abcdef".length)); }))); + "iframe" !== el.tagName.toLowerCase() || props.srcdoc || props.src || el.setAttribute("srcdoc", ""); } var ADD_CHILDREN = ((_ADD_CHILDREN = {}).iframe = function(el, node) { var firstChild = node.children[0]; @@ -318,37 +320,39 @@ function dom(opts) { void 0 === opts && (opts = {}); var _opts$doc = opts.doc, doc = void 0 === _opts$doc ? document : _opts$doc; - return function domRenderer(node) { - if (node.type === NODE_TYPE.COMPONENT) return node.renderComponent(domRenderer); + var _xmlNamespaceDomRenderer = function(node, xmlNamespace) { + if (node.type === NODE_TYPE.COMPONENT) return node.renderComponent((function(childNode) { + return _xmlNamespaceDomRenderer(childNode, xmlNamespace); + })); + if (node.type === NODE_TYPE.TEXT) return createTextElement(doc, node); + if (node.type === NODE_TYPE.ELEMENT) { + var el = function(doc, node, xmlNamespace) { + return doc.createElementNS(xmlNamespace, node.name); + }(doc, node, xmlNamespace); + addProps(el, node); + addChildren(el, node, doc, (function(childNode) { + return _xmlNamespaceDomRenderer(childNode, xmlNamespace); + })); + return el; + } + throw new TypeError("Unhandleable node"); + }; + var _domRenderer = function(node) { + if (node.type === NODE_TYPE.COMPONENT) return node.renderComponent(_domRenderer); if (node.type === NODE_TYPE.TEXT) return createTextElement(doc, node); if (node.type === NODE_TYPE.ELEMENT) { var xmlNamespace = ELEMENT_DEFAULT_XML_NAMESPACE[node.name.toLowerCase()]; - if (xmlNamespace) return function xmlNamespaceDomRenderer(node, xmlNamespace) { - if (node.type === NODE_TYPE.COMPONENT) return node.renderComponent((function(childNode) { - return xmlNamespaceDomRenderer(childNode, xmlNamespace); - })); - if (node.type === NODE_TYPE.TEXT) return createTextElement(doc, node); - if (node.type === NODE_TYPE.ELEMENT) { - var el = function(doc, node, xmlNamespace) { - return doc.createElementNS(xmlNamespace, node.name); - }(doc, node, xmlNamespace); - addProps(el, node); - addChildren(el, node, doc, (function(childNode) { - return xmlNamespaceDomRenderer(childNode, xmlNamespace); - })); - return el; - } - throw new TypeError("Unhandleable node"); - }(node, xmlNamespace); + if (xmlNamespace) return _xmlNamespaceDomRenderer(node, xmlNamespace); var el = function(doc, node) { return node.props.el ? node.props.el : doc.createElement(node.name); }(doc, node); addProps(el, node); - addChildren(el, node, doc, domRenderer); + addChildren(el, node, doc, _domRenderer); return el; } throw new TypeError("Unhandleable node"); }; + return _domRenderer; } function _extends() { return (_extends = Object.assign || function(target) { @@ -371,21 +375,22 @@ function react(_temp) { var React = (void 0 === _temp ? {} : _temp).React; if (!React) throw new Error("Must pass React library to react renderer"); - return function reactRenderer(node) { + var _reactRenderer = function(node) { if (node.type === NODE_TYPE.COMPONENT) return React.createElement.apply(React, [ function() { - return node.renderComponent(reactRenderer) || null; - }, node.props ].concat(node.renderChildren(reactRenderer))); + return node.renderComponent(_reactRenderer) || null; + }, node.props ].concat(node.renderChildren(_reactRenderer))); if (node.type === NODE_TYPE.ELEMENT) return React.createElement.apply(React, [ node.name, (props = node.props, innerHTML = props.innerHTML, _extends({ dangerouslySetInnerHTML: innerHTML ? { __html: innerHTML } : null, className: props.class - }, _objectWithoutPropertiesLoose(props, _excluded))) ].concat(node.renderChildren(reactRenderer))); + }, _objectWithoutPropertiesLoose(props, _excluded))) ].concat(node.renderChildren(_reactRenderer))); var props, innerHTML; if (node.type === NODE_TYPE.TEXT) return node.text; throw new TypeError("Unhandleable node"); }; + return _reactRenderer; } var SELF_CLOSING_TAGS = { br: !0 @@ -394,8 +399,8 @@ return text.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'").replace(/\//g, "/"); } function html() { - return function htmlRenderer(node) { - if (node.type === NODE_TYPE.COMPONENT) return [].concat(node.renderComponent(htmlRenderer)).join(""); + var _htmlRenderer = function(node) { + if (node.type === NODE_TYPE.COMPONENT) return [].concat(node.renderComponent(_htmlRenderer)).join(""); if (node.type === NODE_TYPE.ELEMENT) { var renderedProps = (props = node.props, (keys = Object.keys(props).filter((function(key) { var val = props[key]; @@ -407,32 +412,34 @@ return "" === val ? htmlEncode(key) : htmlEncode(key) + '="' + htmlEncode(val.toString()) + '"'; })).join(" ") : ""); if (SELF_CLOSING_TAGS[node.name]) return "<" + node.name + renderedProps + " />"; - var renderedChildren = "string" == typeof node.props.innerHTML ? node.props.innerHTML : node.renderChildren(htmlRenderer).join(""); + var renderedChildren = "string" == typeof node.props.innerHTML ? node.props.innerHTML : node.renderChildren(_htmlRenderer).join(""); return "<" + node.name + renderedProps + ">" + renderedChildren + ""; } var props, keys; if (node.type === NODE_TYPE.TEXT) return htmlEncode(node.text); throw new TypeError("Unhandleable node: " + node.type); }; + return _htmlRenderer; } var preact_excluded = [ "innerHTML" ]; function preact(_temp) { var Preact = (void 0 === _temp ? {} : _temp).Preact; if (!Preact) throw new Error("Must pass Preact library to react renderer"); - return function reactRenderer(node) { + var _reactRenderer = function(node) { if (node.type === NODE_TYPE.COMPONENT) return Preact.h.apply(Preact, [ function() { - return node.renderComponent(reactRenderer) || null; - }, node.props ].concat(node.renderChildren(reactRenderer))); + return node.renderComponent(_reactRenderer) || null; + }, node.props ].concat(node.renderChildren(_reactRenderer))); if (node.type === NODE_TYPE.ELEMENT) return Preact.h.apply(Preact, [ node.name, (props = node.props, innerHTML = props.innerHTML, _extends({ dangerouslySetInnerHTML: innerHTML ? { __html: innerHTML } : null - }, _objectWithoutPropertiesLoose(props, preact_excluded))) ].concat(node.renderChildren(reactRenderer))); + }, _objectWithoutPropertiesLoose(props, preact_excluded))) ].concat(node.renderChildren(_reactRenderer))); var props, innerHTML; if (node.type === NODE_TYPE.TEXT) return node.text; throw new TypeError("Unhandleable node"); }; + return _reactRenderer; } function regex() { var regexRenderer = text_text(); diff --git a/dist/jsx-pragmatic.min.js b/dist/jsx-pragmatic.min.js index 07a1b94..a4246a0 100644 --- a/dist/jsx-pragmatic.min.js +++ b/dist/jsx-pragmatic.min.js @@ -1,2 +1,2 @@ -!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("pragmatic",[],r):"object"==typeof exports?exports.pragmatic=r():e.pragmatic=r()}("undefined"!=typeof self?self:this,(function(){return function(e){var r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(t,o,function(r){return e[r]}.bind(null,o));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return{}.hasOwnProperty.call(e,r)},n.p="",n(n.s=0)}([function(e,r,n){"use strict";n.r(r),n.d(r,"ElementNode",(function(){return i})),n.d(r,"FragmentNode",(function(){return u})),n.d(r,"TextNode",(function(){return p})),n.d(r,"ComponentNode",(function(){return c})),n.d(r,"node",(function(){return s})),n.d(r,"Fragment",(function(){return h})),n.d(r,"text",(function(){return y})),n.d(r,"dom",(function(){return M})),n.d(r,"react",(function(){return O})),n.d(r,"html",(function(){return j})),n.d(r,"preact",(function(){return A})),n.d(r,"regex",(function(){return H})),n.d(r,"NODE_TYPE",(function(){return t})),n.d(r,"Style",(function(){return S})),n.d(r,"Regex",(function(){return U})),n.d(r,"RegexText",(function(){return G})),n.d(r,"RegexWord",(function(){return k})),n.d(r,"RegexCharacters",(function(){return F})),n.d(r,"RegexGroup",(function(){return W})),n.d(r,"RegexUnion",(function(){return $}));var t={ELEMENT:"element",TEXT:"text",COMPONENT:"component",FRAGMENT:"fragment"};function o(e,r){for(var n=[],t=0;t1?new u(r):void 0}(this.component(this.props,this.children));if(r)return r.render(e)},r.render=function(e){return e(this)},r.renderChildren=function(e){return o(this.children,e)},e}();function a(e){for(var r=[],n=0;n2?n-2:0),o=2;o=0||(o[n]=e[n]);return o}var C=["innerHTML","class"];function O(e){var r=(void 0===e?{}:e).React;if(!r)throw new Error("Must pass React library to react renderer");return function e(n){if(n.type===t.COMPONENT)return r.createElement.apply(r,[function(){return n.renderComponent(e)||null},n.props].concat(n.renderChildren(e)));if(n.type===t.ELEMENT)return r.createElement.apply(r,[n.name,(o=n.props,i=o.innerHTML,b({dangerouslySetInnerHTML:i?{__html:i}:null,className:o.class},N(o,C)))].concat(n.renderChildren(e)));var o,i;if(n.type===t.TEXT)return n.text;throw new TypeError("Unhandleable node")}}var L={br:!0};function R(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function j(){return function e(r){if(r.type===t.COMPONENT)return[].concat(r.renderComponent(e)).join("");if(r.type===t.ELEMENT){var n=(i=r.props,(u=Object.keys(i).filter((function(e){var r=i[e];return"innerHTML"!==e&&("string"==typeof r||"number"==typeof r||!0===r)}))).length?" "+u.map((function(e){var r=i[e];if(!0===r)return""+R(e);if("string"!=typeof r&&"number"!=typeof r)throw new TypeError("Unexpected prop type: "+typeof r);return""===r?R(e):R(e)+'="'+R(r.toString())+'"'})).join(" "):"");if(L[r.name])return"<"+r.name+n+" />";var o="string"==typeof r.props.innerHTML?r.props.innerHTML:r.renderChildren(e).join("");return"<"+r.name+n+">"+o+""}var i,u;if(r.type===t.TEXT)return R(r.text);throw new TypeError("Unhandleable node: "+r.type)}}var P=["innerHTML"];function A(e){var r=(void 0===e?{}:e).Preact;if(!r)throw new Error("Must pass Preact library to react renderer");return function e(n){if(n.type===t.COMPONENT)return r.h.apply(r,[function(){return n.renderComponent(e)||null},n.props].concat(n.renderChildren(e)));if(n.type===t.ELEMENT)return r.h.apply(r,[n.name,(o=n.props,i=o.innerHTML,b({dangerouslySetInnerHTML:i?{__html:i}:null},N(o,P)))].concat(n.renderChildren(e)));var o,i;if(n.type===t.TEXT)return n.text;throw new TypeError("Unhandleable node")}}function H(){var e=y();return function(r){return new RegExp(e(r))}}function S(e){var r=e.css,n=e.nonce,t=e.children;return s(h,null,s("style",{innerHTML:"string"==typeof r?r:r._getCss(),nonce:n}),t)}H.node=function(e,r){for(var n=arguments.length,t=new Array(n>2?n-2:0),o=2;o"),E.push.apply(E,r),E.push(")"),v(n)&&("number"==typeof n?E.push("{"+n+"}"):!0===n&&E.push("+")),(v(t)||v(o))&&E.push("{"+(t||"")+","+(o||"")+"}"),c&&E.push("?"),E}function $(e,r){for(var n=[],t=0,o=r=X("RegexGroup",r);t1?new u(r):void 0}(this.component(this.props,this.children));if(r)return r.render(e)},r.render=function(e){return e(this)},r.renderChildren=function(e){return o(this.children,e)},e}();function p(e){for(var r=[],n=0;n2?n-2:0),o=2;o=0||(o[n]=e[n]);return o}var C=["innerHTML","class"];function L(e){var r=(void 0===e?{}:e).React;if(!r)throw new Error("Must pass React library to react renderer");var n=function(e){if(e.type===t.COMPONENT)return r.createElement.apply(r,[function(){return e.renderComponent(n)||null},e.props].concat(e.renderChildren(n)));if(e.type===t.ELEMENT)return r.createElement.apply(r,[e.name,(o=e.props,i=o.innerHTML,b({dangerouslySetInnerHTML:i?{__html:i}:null,className:o.class},N(o,C)))].concat(e.renderChildren(n)));var o,i;if(e.type===t.TEXT)return e.text;throw new TypeError("Unhandleable node")};return n}var O={br:!0};function R(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function j(){var e=function(r){if(r.type===t.COMPONENT)return[].concat(r.renderComponent(e)).join("");if(r.type===t.ELEMENT){var n=(i=r.props,(u=Object.keys(i).filter((function(e){var r=i[e];return"innerHTML"!==e&&("string"==typeof r||"number"==typeof r||!0===r)}))).length?" "+u.map((function(e){var r=i[e];if(!0===r)return""+R(e);if("string"!=typeof r&&"number"!=typeof r)throw new TypeError("Unexpected prop type: "+typeof r);return""===r?R(e):R(e)+'="'+R(r.toString())+'"'})).join(" "):"");if(O[r.name])return"<"+r.name+n+" />";var o="string"==typeof r.props.innerHTML?r.props.innerHTML:r.renderChildren(e).join("");return"<"+r.name+n+">"+o+""}var i,u;if(r.type===t.TEXT)return R(r.text);throw new TypeError("Unhandleable node: "+r.type)};return e}var P=["innerHTML"];function A(e){var r=(void 0===e?{}:e).Preact;if(!r)throw new Error("Must pass Preact library to react renderer");var n=function(e){if(e.type===t.COMPONENT)return r.h.apply(r,[function(){return e.renderComponent(n)||null},e.props].concat(e.renderChildren(n)));if(e.type===t.ELEMENT)return r.h.apply(r,[e.name,(o=e.props,i=o.innerHTML,b({dangerouslySetInnerHTML:i?{__html:i}:null},N(o,P)))].concat(e.renderChildren(n)));var o,i;if(e.type===t.TEXT)return e.text;throw new TypeError("Unhandleable node")};return n}function H(){var e=y();return function(r){return new RegExp(e(r))}}function S(e){var r=e.css,n=e.nonce,t=e.children;return s(h,null,s("style",{innerHTML:"string"==typeof r?r:r._getCss(),nonce:n}),t)}H.node=function(e,r){for(var n=arguments.length,t=new Array(n>2?n-2:0),o=2;o"),E.push.apply(E,r),E.push(")"),v(n)&&("number"==typeof n?E.push("{"+n+"}"):!0===n&&E.push("+")),(v(t)||v(o))&&E.push("{"+(t||"")+","+(o||"")+"}"),a&&E.push("?"),E}function $(e,r){for(var n=[],t=0,o=r=X("RegexGroup",r);t = (N) => O;\nexport type NodeRendererFactory = (L) => NodeRenderer;\n\ntype Primitive = string | boolean | number;\ntype NullablePrimitive = Primitive | null | void;\n\nexport type NodeType = ElementNode | TextNode | FragmentNode | ComponentNode<*>; // eslint-disable-line no-use-before-define\nexport type ChildNodeType = ElementNode | TextNode | ComponentNode<*>; // eslint-disable-line no-use-before-define\nexport type ChildType = ChildNodeType | Primitive | $ReadOnlyArray;\nexport type ChildrenType = $ReadOnlyArray;\nexport type NullableChildType = $ReadOnlyArray | ChildNodeType | NullablePrimitive;\nexport type NullableChildrenType = $ReadOnlyArray;\n\nexport type ComponentFunctionType

= (P, ChildrenType) => NullableChildType;\n\nexport type CreateElementNode =

(string, P, ...NullableChildrenType) => ElementNode; // eslint-disable-line no-undef, no-use-before-define\nexport type CreateComponentNode =

(ComponentFunctionType

, P, ...NullableChildrenType) => ComponentNode<*>; // eslint-disable-line no-undef, no-use-before-define\nexport type CreateNullComponentNode =

(ComponentFunctionType

, null, ...NullableChildrenType) => ComponentNode<*>; // eslint-disable-line no-undef, no-use-before-define\n\nexport type CreateNode = CreateNullComponentNode & CreateComponentNode & CreateElementNode;\n\nfunction renderChildren(children : $ReadOnlyArray>, renderer : NodeRenderer<*, *>) : $ReadOnlyArray { // eslint-disable-line no-use-before-define\n const result = [];\n\n for (const child of children) {\n const renderedChild = child.render(renderer);\n\n if (!renderedChild) {\n continue;\n } else if (Array.isArray(renderedChild)) {\n for (const subchild of renderedChild) {\n if (subchild) {\n result.push(subchild);\n }\n }\n } else {\n result.push(renderedChild);\n }\n }\n\n return result;\n}\n\nexport class ElementNode {\n type : (typeof NODE_TYPE.ELEMENT) = NODE_TYPE.ELEMENT;\n\n name : string;\n props : NodePropsType;\n children : $ReadOnlyArray>; // eslint-disable-line no-use-before-define\n onRender : ?(T) => void; // eslint-disable-line no-undef\n\n constructor(name : string, props : NodePropsType, children : $ReadOnlyArray>) { // eslint-disable-line no-use-before-define\n this.name = name;\n this.props = props || {};\n this.children = children;\n\n const onRender = this.props.onRender;\n if (typeof onRender === 'function') {\n this.onRender = onRender;\n delete props.onRender;\n }\n }\n\n render(renderer : NodeRenderer<*, *>) : T {\n const el = renderer(this);\n if (this.onRender) {\n this.onRender(el);\n }\n return el;\n }\n\n renderChildren(renderer : NodeRenderer<*, *>) : $ReadOnlyArray {\n return renderChildren(this.children, renderer);\n }\n}\n\nexport class FragmentNode {\n type : (typeof NODE_TYPE.FRAGMENT) = NODE_TYPE.FRAGMENT;\n\n children : $ReadOnlyArray>; // eslint-disable-line no-use-before-define\n\n constructor(children : $ReadOnlyArray>) { // eslint-disable-line no-use-before-define\n this.children = children;\n }\n\n render(renderer : NodeRenderer<*, *>) : $ReadOnlyArray {\n return renderChildren(this.children, renderer);\n }\n}\n\nexport class TextNode {\n type : (typeof NODE_TYPE.TEXT) = NODE_TYPE.TEXT;\n\n text : string;\n\n constructor(text : string) {\n this.text = text;\n }\n\n render(renderer : NodeRenderer<*, *>) : T {\n return renderer(this);\n }\n}\n\n// eslint-disable-next-line no-unused-vars\nexport class ComponentNode

{\n type : (typeof NODE_TYPE.COMPONENT) = NODE_TYPE.COMPONENT;\n\n component : ComponentFunctionType;\n props : NodePropsType;\n // eslint-disable-next-line no-use-before-define\n children : $ReadOnlyArray>;\n\n constructor(component : ComponentFunctionType, props : NodePropsType, children : $ReadOnlyArray>) {\n this.component = component;\n this.props = props || {};\n this.children = children;\n\n this.props.children = children;\n }\n\n renderComponent(renderer : NodeRenderer<*, *>) : * {\n const child = normalizeChild(this.component(this.props, this.children)); // eslint-disable-line no-use-before-define\n if (child) {\n return child.render(renderer);\n }\n }\n\n render(renderer : NodeRenderer<*, *>) : T {\n return renderer(this);\n }\n\n renderChildren(renderer : NodeRenderer<*, *>) : $ReadOnlyArray {\n return renderChildren(this.children, renderer);\n }\n}\n\nfunction normalizeChildren(children : NullableChildrenType) : $ReadOnlyArray> {\n const result = [];\n\n for (const child of children) {\n if (!child) {\n continue;\n } else if (typeof child === 'string' || typeof child === 'number') {\n result.push(new TextNode(child.toString()));\n } else if (typeof child === 'boolean') {\n continue;\n } else if (Array.isArray(child)) {\n for (const subchild of normalizeChildren(child)) {\n result.push(subchild);\n }\n } else if (child && (child.type === NODE_TYPE.ELEMENT || child.type === NODE_TYPE.TEXT || child.type === NODE_TYPE.COMPONENT)) {\n result.push(child);\n } else {\n throw new TypeError(`Unrecognized node type: ${ typeof child }`);\n }\n }\n\n return result;\n}\n\nfunction normalizeChild(child) : ElementNode | TextNode | ComponentNode<*> | FragmentNode | void {\n const children = normalizeChildren(Array.isArray(child) ? child : [ child ]);\n\n if (children.length === 1) {\n return children[0];\n } else if (children.length > 1) {\n return new FragmentNode(children);\n }\n}\n\nexport const node : CreateNode =

(element, props : P, ...children) => {\n children = normalizeChildren(children);\n\n if (typeof element === 'string') {\n // $FlowFixMe\n return new ElementNode(element, props, children);\n }\n\n if (typeof element === 'function') {\n // $FlowFixMe\n return new ComponentNode<*>(element, props, children);\n }\n\n throw new TypeError(`Expected jsx element to be a string or a function`);\n};\n\nexport const Fragment : ComponentFunctionType = (props, children) => {\n return children;\n};\n","/* @flow */\n/* eslint unicorn/prefer-spread: off */\n\nimport { ComponentNode, TextNode, ElementNode, type NodeRenderer } from '../node';\nimport { NODE_TYPE } from '../constants';\n\ntype TextRenderer = NodeRenderer, string>;\n\nexport function text() : TextRenderer {\n\n const textRenderer = (node) => {\n if (node.type === NODE_TYPE.COMPONENT) {\n return [].concat(node.renderComponent(textRenderer)).join('');\n }\n\n if (node.type === NODE_TYPE.ELEMENT) {\n throw new Error(`Text renderer does not support basic elements`);\n }\n\n if (node.type === NODE_TYPE.TEXT) {\n return node.text;\n }\n\n throw new TypeError(`Unhandleable node: ${ node.type }`);\n };\n\n return textRenderer;\n}\n","/* @flow */\n\nconst ALPHA_CHARS = '0123456789abcdef';\n\nexport function uniqueID() : string {\n return 'xxxxxxxxxx'.replace(/./g, () => ALPHA_CHARS.charAt(Math.floor(Math.random() * ALPHA_CHARS.length)));\n}\n\n// eslint-disable-next-line flowtype/no-weak-types\nexport function isDefined(val : any) : boolean %checks {\n return (val !== null && typeof val !== 'undefined');\n}\n","/* @flow */\n\nimport { ComponentNode, TextNode, type NodeRenderer, ElementNode } from '../node';\nimport { NODE_TYPE } from '../constants';\nimport { uniqueID } from '../util';\n\ntype DomNodeRenderer = NodeRenderer;\ntype DomTextRenderer = NodeRenderer;\ntype DomComponentRenderer = NodeRenderer, HTMLElement | TextNode | $ReadOnlyArray | void>;\ntype DomRenderer = DomComponentRenderer & DomNodeRenderer & DomTextRenderer;\n\nconst ELEMENT_TAG = {\n HTML: 'html',\n IFRAME: 'iframe',\n SCRIPT: 'script',\n SVG: 'svg',\n DEFAULT: 'default'\n};\n\nconst ELEMENT_PROP = {\n ID: 'id',\n INNER_HTML: 'innerHTML',\n EL: 'el',\n XLINK_HREF: 'xlink:href'\n};\n\nconst ELEMENT_DEFAULT_XML_NAMESPACE : {| [$Values] : string |} = {\n [ ELEMENT_TAG.SVG ]: 'http://www.w3.org/2000/svg'\n};\n\nconst ATTRIBUTE_DEFAULT_XML_NAMESPACE : {| [$Values] : string |} = {\n [ ELEMENT_PROP.XLINK_HREF ]: 'http://www.w3.org/1999/xlink'\n};\n\nfunction fixScripts(el : HTMLElement | Element, doc : Document = window.document) {\n for (const script of el.querySelectorAll('script')) {\n const parentNode = script.parentNode;\n\n if (!parentNode) {\n continue;\n }\n\n const newScript = doc.createElement('script');\n newScript.text = script.textContent;\n parentNode.replaceChild(newScript, script);\n }\n}\n\nfunction createElement(doc : Document, node : ElementNode) : HTMLElement | Element {\n if (node.props[ELEMENT_PROP.EL]) {\n return node.props[ELEMENT_PROP.EL];\n } else {\n return doc.createElement(node.name);\n }\n}\n\nfunction createElementWithXMLNamespace(doc : Document, node : ElementNode, xmlNamespace : string) : HTMLElement | Element {\n return doc.createElementNS(xmlNamespace, node.name);\n}\n\nfunction createTextElement(doc : Document, node : TextNode) : Text {\n return doc.createTextNode(node.text);\n}\n\nfunction addProps(el : HTMLElement | Element, node) {\n const props = node.props;\n\n for (const prop of Object.keys(props)) {\n const val = props[prop];\n\n if (val === null || typeof val === 'undefined' || prop === ELEMENT_PROP.EL || prop === ELEMENT_PROP.INNER_HTML) {\n continue;\n }\n\n if (prop.match(/^on[A-Z][a-z]/) && typeof val === 'function') {\n el.addEventListener(prop.slice(2).toLowerCase(), val);\n } else if (typeof val === 'string' || typeof val === 'number') {\n const xmlNamespace = ATTRIBUTE_DEFAULT_XML_NAMESPACE[prop];\n if (xmlNamespace) {\n el.setAttributeNS(xmlNamespace, prop, val.toString());\n } else {\n el.setAttribute(prop, val.toString());\n }\n } else if (typeof val === 'boolean') {\n if (val === true) {\n el.setAttribute(prop, '');\n }\n }\n }\n\n if (el.tagName.toLowerCase() === ELEMENT_TAG.IFRAME && !props.id) {\n el.setAttribute(ELEMENT_PROP.ID, `jsx-iframe-${ uniqueID() }`);\n }\n}\nconst ADD_CHILDREN : { [string] : (HTMLElement | Element, ElementNode, DomNodeRenderer) => void } = {\n\n [ ELEMENT_TAG.IFRAME ]: (el, node) => {\n const firstChild = node.children[0];\n\n if (node.children.length !== 1 || !(firstChild && firstChild.type === NODE_TYPE.ELEMENT) || firstChild.name !== ELEMENT_TAG.HTML) {\n throw new Error(`Expected only single html element node as child of ${ ELEMENT_TAG.IFRAME } element`);\n }\n \n el.addEventListener('load', () => {\n\n // $FlowFixMe\n const win = el.contentWindow;\n \n if (!win) {\n throw new Error(`Expected frame to have contentWindow`);\n }\n\n const doc = win.document;\n const docElement = doc.documentElement;\n\n while (docElement.children && docElement.children.length) {\n docElement.removeChild(docElement.children[0]);\n }\n\n // eslint-disable-next-line no-use-before-define\n const child : HTMLElement = firstChild.render(dom({ doc }));\n \n while (child.children.length) {\n docElement.appendChild(child.children[0]);\n }\n });\n },\n\n [ ELEMENT_TAG.SCRIPT ]: (el, node) => {\n const firstChild = node.children[0];\n\n if (node.children.length !== 1 || !(firstChild && firstChild.type === NODE_TYPE.TEXT)) {\n throw new Error(`Expected only single text node as child of ${ ELEMENT_TAG.SCRIPT } element`);\n }\n \n // $FlowFixMe\n el.text = firstChild.text;\n },\n\n [ ELEMENT_TAG.DEFAULT ]: (el, node, renderer) => {\n for (const child of node.renderChildren(renderer)) {\n el.appendChild(child);\n }\n }\n};\n\nfunction addChildren(el : HTMLElement | Element, node : ElementNode, doc : Document, renderer : DomNodeRenderer) {\n if (node.props.hasOwnProperty(ELEMENT_PROP.INNER_HTML)) {\n\n if (node.children.length) {\n throw new Error(`Expected no children to be passed when ${ ELEMENT_PROP.INNER_HTML } prop is set`);\n }\n\n const html = node.props[ELEMENT_PROP.INNER_HTML];\n\n if (typeof html !== 'string') {\n throw new TypeError(`${ ELEMENT_PROP.INNER_HTML } prop must be string`);\n }\n\n if (node.name === ELEMENT_TAG.SCRIPT) {\n // $FlowFixMe\n el.text = html;\n } else {\n el.innerHTML = html;\n fixScripts(el, doc);\n }\n\n } else {\n const addChildrenToElement = ADD_CHILDREN[node.name] || ADD_CHILDREN[ELEMENT_TAG.DEFAULT];\n addChildrenToElement(el, node, renderer);\n }\n}\n\ntype DomOptions = {|\n doc? : Document\n|};\n\nconst getDefaultDomOptions = () : DomOptions => {\n // $FlowFixMe\n return {};\n};\n\nexport function dom(opts? : DomOptions = getDefaultDomOptions()) : DomRenderer {\n const { doc = document } = opts;\n \n const xmlNamespaceDomRenderer = (node : ElementNode, xmlNamespace : string) : HTMLElement => {\n if (node.type === NODE_TYPE.COMPONENT) {\n return node.renderComponent(childNode => xmlNamespaceDomRenderer(childNode, xmlNamespace));\n }\n \n if (node.type === NODE_TYPE.TEXT) {\n // $FlowFixMe\n return createTextElement(doc, node);\n }\n \n if (node.type === NODE_TYPE.ELEMENT) {\n const el = createElementWithXMLNamespace(doc, node, xmlNamespace);\n addProps(el, node);\n addChildren(el, node, doc, childNode => xmlNamespaceDomRenderer(childNode, xmlNamespace));\n // $FlowFixMe\n return el;\n }\n\n throw new TypeError(`Unhandleable node`);\n };\n \n const domRenderer : DomRenderer = (node) => {\n if (node.type === NODE_TYPE.COMPONENT) {\n return node.renderComponent(domRenderer);\n }\n \n if (node.type === NODE_TYPE.TEXT) {\n // $FlowFixMe\n return createTextElement(doc, node);\n }\n \n if (node.type === NODE_TYPE.ELEMENT) {\n const xmlNamespace = ELEMENT_DEFAULT_XML_NAMESPACE[node.name.toLowerCase()];\n\n if (xmlNamespace) {\n // $FlowFixMe\n return xmlNamespaceDomRenderer(node, xmlNamespace);\n }\n\n const el = createElement(doc, node);\n addProps(el, node);\n addChildren(el, node, doc, domRenderer);\n // $FlowFixMe\n return el;\n }\n\n throw new TypeError(`Unhandleable node`);\n };\n\n return domRenderer;\n}\n","export default function _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}","export default function _objectWithoutPropertiesLoose(source, excluded) {\n if (source == null) return {};\n var target = {};\n var sourceKeys = Object.keys(source);\n var key, i;\n\n for (i = 0; i < sourceKeys.length; i++) {\n key = sourceKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n target[key] = source[key];\n }\n\n return target;\n}","/* @flow */\n\nimport type { Node } from 'react';\n\nimport { ComponentNode, TextNode, ElementNode, type NodeRenderer, type NodePropsType } from '../node';\nimport { NODE_TYPE } from '../constants';\n\ntype ReactType = {|\n createElement : Function\n|};\n\ntype ReactRenderer = NodeRenderer, Node | string | null>;\n\nfunction mapReactProps(props : NodePropsType) : NodePropsType {\n const { innerHTML, class: className, ...remainingProps } = props;\n\n const dangerouslySetInnerHTML = innerHTML\n ? { __html: innerHTML }\n : null;\n\n // $FlowFixMe\n return {\n dangerouslySetInnerHTML,\n className,\n ...remainingProps\n };\n}\n\nexport function react({ React } : {| React : ReactType |} = {}) : ReactRenderer {\n if (!React) {\n throw new Error(`Must pass React library to react renderer`);\n }\n\n const reactRenderer = (node) => {\n if (node.type === NODE_TYPE.COMPONENT) {\n return React.createElement(() => (node.renderComponent(reactRenderer) || null), node.props, ...node.renderChildren(reactRenderer));\n }\n\n if (node.type === NODE_TYPE.ELEMENT) {\n return React.createElement(node.name, mapReactProps(node.props), ...node.renderChildren(reactRenderer));\n }\n\n if (node.type === NODE_TYPE.TEXT) {\n return node.text;\n }\n\n throw new TypeError(`Unhandleable node`);\n };\n\n return reactRenderer;\n}\n","/* @flow */\n/* eslint unicorn/prefer-spread: off */\n\nimport { ComponentNode, TextNode, ElementNode, type NodePropsType, type NodeRenderer } from '../node';\nimport { NODE_TYPE } from '../constants';\n\ntype HTMLRenderer = NodeRenderer, string>;\n\nconst ELEMENT_PROP = {\n INNER_HTML: 'innerHTML'\n};\n\nconst SELF_CLOSING_TAGS = {\n br: true\n};\n\nfunction htmlEncode(text : string) : string {\n return text\n .replace(/&/g, '&')\n .replace(//g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(/\\//g, '/');\n}\n\nfunction propsToHTML(props : NodePropsType) : string {\n const keys = Object.keys(props).filter(key => {\n const val = props[key];\n\n if (key === ELEMENT_PROP.INNER_HTML) {\n return false;\n }\n\n if (typeof val === 'string' || typeof val === 'number' || val === true) {\n return true;\n }\n\n return false;\n });\n\n if (!keys.length) {\n return '';\n }\n\n const pairs = keys.map(key => {\n const val = props[key];\n\n if (val === true) {\n return `${ htmlEncode(key) }`;\n }\n\n if (typeof val !== 'string' && typeof val !== 'number') {\n throw new TypeError(`Unexpected prop type: ${ typeof val }`);\n }\n\n if (val === '') {\n return htmlEncode(key);\n }\n\n return `${ htmlEncode(key) }=\"${ htmlEncode(val.toString()) }\"`;\n });\n\n return ` ${ pairs.join(' ') }`;\n}\n\nexport function html() : HTMLRenderer {\n\n const htmlRenderer = (node) => {\n if (node.type === NODE_TYPE.COMPONENT) {\n return [].concat(node.renderComponent(htmlRenderer)).join('');\n }\n\n if (node.type === NODE_TYPE.ELEMENT) {\n const renderedProps = propsToHTML(node.props);\n\n if (SELF_CLOSING_TAGS[node.name]) {\n return `<${ node.name }${ renderedProps } />`;\n } else {\n const renderedChildren = (typeof node.props[ELEMENT_PROP.INNER_HTML] === 'string')\n ? node.props[ELEMENT_PROP.INNER_HTML]\n : node.renderChildren(htmlRenderer).join('');\n\n return `<${ node.name }${ renderedProps }>${ renderedChildren }`;\n }\n }\n\n if (node.type === NODE_TYPE.TEXT) {\n return htmlEncode(node.text);\n }\n\n throw new TypeError(`Unhandleable node: ${ node.type }`);\n };\n\n return htmlRenderer;\n}\n","/* @flow */\n\nimport { ComponentNode, TextNode, ElementNode, type NodeRenderer, type NodePropsType } from '../node';\nimport { NODE_TYPE } from '../constants';\n\ntype PreactType = {|\n h : Function\n|};\n\ntype PreactNode = {||};\n\ntype PreactRenderer = NodeRenderer, PreactNode | string | null>;\n\nfunction mapPreactProps(props : NodePropsType) : NodePropsType {\n const { innerHTML, ...remainingProps } = props;\n\n const dangerouslySetInnerHTML = innerHTML\n ? { __html: innerHTML }\n : null;\n\n // $FlowFixMe\n return {\n dangerouslySetInnerHTML,\n ...remainingProps\n };\n}\n\nexport function preact({ Preact } : {| Preact : PreactType |} = {}) : PreactRenderer {\n if (!Preact) {\n throw new Error(`Must pass Preact library to react renderer`);\n }\n \n const reactRenderer = (node) => {\n if (node.type === NODE_TYPE.COMPONENT) {\n return Preact.h(() => (node.renderComponent(reactRenderer) || null), node.props, ...node.renderChildren(reactRenderer));\n }\n \n if (node.type === NODE_TYPE.ELEMENT) {\n return Preact.h(node.name, mapPreactProps(node.props), ...node.renderChildren(reactRenderer));\n }\n \n if (node.type === NODE_TYPE.TEXT) {\n return node.text;\n }\n\n throw new TypeError(`Unhandleable node`);\n };\n\n return reactRenderer;\n}\n","/* @flow */\n\nimport { node, ComponentNode, TextNode, ElementNode, type NodeRenderer } from '../node';\n\nimport { text } from './text';\n\ntype RegexRenderer = NodeRenderer, RegExp>;\n\nexport function regex() : RegexRenderer {\n const regexRenderer = text();\n\n // eslint-disable-next-line security/detect-non-literal-regexp\n return (nodeInstance) => new RegExp(regexRenderer(nodeInstance));\n}\n\n// $FlowFixMe\nregex.node = (el, props, ...children) => {\n // $FlowFixMe\n const nodeInstance = node(el, props, ...children);\n\n if (el.renderer) {\n return nodeInstance.render(el.renderer());\n }\n\n return nodeInstance;\n};\n","/* @flow */\n/** @jsx node */\n\nimport { Fragment, node, type ChildType, type NullableChildrenType } from '../node';\n\ntype StyleProps = {|\n css : string | {| _getCss : () => string |},\n nonce? : ?string,\n children? : ?NullableChildrenType\n|};\n\nexport function Style({ css, nonce, children } : StyleProps) : ChildType {\n return (\n \n