Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

preact-render-to-string

Package Overview
Dependencies
Maintainers
11
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

preact-render-to-string - npm Package Compare versions

Comparing version 6.0.0-experimental.0 to 6.0.0

dist/index.umd.js

2

dist/commonjs.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],t):t((e||self).preactRenderToString={},e.preact)}(this,function(e,t){var n=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,r=/[&<>"]/;function o(e){var t=String(e);return r.test(t)?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):t}var i=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},a=function(e,t,n){return String(e).length>(t||40)||!n&&-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},l={};function s(e){var t="";for(var r in e){var o=e[r];null!=o&&""!==o&&(t&&(t+=" "),t+="-"==r[0]?r:l[r]||(l[r]=r.replace(/([A-Z])/g,"-$1").toLowerCase()),t+=": ",t+=o,"number"==typeof o&&!1===n.test(r)&&(t+="px"),t+=";")}return t||void 0}function f(e,t){for(var n in t)e[n]=t[n];return e}function p(e,t){return Array.isArray(t)?t.reduce(p,e):null!=t&&!1!==t&&e.push(t),e}var u={shallow:!0},c=[],d=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,_=/[\s\n\\/='"\0<>]/,v=function(){};y.render=y;var g=function(e,t){return y(e,t,u)},h=[];function y(e,n,r){n=n||{},r=r||{};var o=t.options.__s;t.options.__s=!0;var i=m(e,n,r);return t.options.__c&&t.options.__c(e,h),h.length=0,t.options.__s=o,i}function m(e,n,r,l,u,g){if(null==e||"boolean"==typeof e)return"";if("object"!=typeof e)return o(e);var h=r.pretty,y=h&&"string"==typeof h?h:"\t";if(Array.isArray(e)){for(var x="",b=0;b<e.length;b++)h&&b>0&&(x+="\n"),x+=m(e[b],n,r,l,u,g);return x}var S,w=e.type,k=e.props,O=!1;if("function"==typeof w){if(O=!0,!r.shallow||!l&&!1!==r.renderRootComponent){if(w===t.Fragment){var T=[];return p(T,e.props.children),m(T,n,r,!1!==r.shallowHighOrder,u,g)}var C,A=e.__c={__v:e,context:n,props:e.props,setState:v,forceUpdate:v,data:{}};t.options.__b&&t.options.__b(e);var j=function(e,t){return{type:e.type,props:e.props,data:{},c:t}}(e,n);if(t.options.__r&&t.options.__r(j),w.prototype&&"function"==typeof w.prototype.render){var F=w.contextType,H=F&&n[F.__c],M=null!=F?H?H.props.value:F.__:n;(A=e.__c=new w(k,M)).__v=e,A._dirty=A.__d=!0,A.props=k,null==A.state&&(A.state={}),null==A._nextState&&null==A.__s&&(A._nextState=A.__s=A.state),A.context=M,w.getDerivedStateFromProps?A.state=f(f({},A.state),w.getDerivedStateFromProps(A.props,A.state)):A.componentWillMount&&(A.componentWillMount(),A.state=A._nextState!==A.state?A._nextState:A.__s!==A.state?A.__s:A.state),C=A.render(A.props,A.state,A.context)}else{var $=w.contextType,L=$&&n[$.__c];C=w.call(e.__c,k,null!=$?L?L.props.value:$.__:n)}return A.getChildContext&&(n=f(f({},n),A.getChildContext())),t.options.diffed&&t.options.diffed(e),m(C,n,r,!1!==r.shallowHighOrder,u,g)}w=(S=w).displayName||S!==Function&&S.name||function(e){var t=(Function.prototype.toString.call(e).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!t){for(var n=-1,r=c.length;r--;)if(c[r]===e){n=r;break}n<0&&(n=c.push(e)-1),t="UnnamedComponent"+n}return t}(S)}var R,E,q="<"+w;if(k){var D=Object.keys(k);r&&!0===r.sortAttributes&&D.sort();for(var N=0;N<D.length;N++){var P=D[N],U=k[P];if("children"!==P){if(!_.test(P)&&(r&&r.allAttributes||"key"!==P&&"ref"!==P&&"__self"!==P&&"__source"!==P)){if("defaultValue"===P)P="value";else if("className"===P){if(void 0!==k.class)continue;P="class"}else u&&P.match(/^xlink:?./)&&(P=P.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===P){if(k.for)continue;P="for"}"style"===P&&U&&"object"==typeof U&&(U=s(U)),"a"===P[0]&&"r"===P[1]&&"boolean"==typeof U&&(U=String(U));var W=r.attributeHook&&r.attributeHook(P,U,n,r,O);if(W||""===W)q+=W;else if("dangerouslySetInnerHTML"===P)E=U&&U.__html;else if("textarea"===w&&"value"===P)R=U;else if((U||0===U||""===U)&&"function"!=typeof U){if(!(!0!==U&&""!==U||(U=P,r&&r.xml))){q+=" "+P;continue}if("value"===P){if("select"===w){g=U;continue}"option"===w&&g==U&&(q+=" selected")}q+=" "+P+'="'+o(U)+'"'}}}else R=U}}if(h){var z=q.replace(/\n\s*/," ");z===q||~z.indexOf("\n")?h&&~q.indexOf("\n")&&(q+="\n"):q=z}if(q+=">",_.test(w))throw new Error(w+" is not a valid HTML tag name in "+q);var I,V=d.test(w)||r.voidElements&&r.voidElements.test(w),Z=[];if(E)h&&a(E)&&(E="\n"+y+i(E,y)),q+=E;else if(null!=R&&p(I=[],R).length){for(var B=h&&~q.indexOf("\n"),G=!1,J=0;J<I.length;J++){var K=I[J];if(null!=K&&!1!==K){var Q=m(K,n,r,!0,"svg"===w||"foreignObject"!==w&&u,g);if(h&&!B&&a(Q)&&(B=!0),Q)if(h){var X=Q.length>0&&"<"!=Q[0];G&&X?Z[Z.length-1]+=Q:Z.push(Q),G=X}else Z.push(Q)}}if(h&&B)for(var Y=Z.length;Y--;)Z[Y]="\n"+y+i(Z[Y],y)}if(Z.length||E)q+=Z.join("");else if(r&&r.xml)return q.substring(0,q.length-1)+" />";return!V||I||E?(h&&~q.indexOf("\n")&&(q+="\n"),q+="</"+w+">"):q=q.replace(/>$/," />"),q}y.shallowRender=g,e.default=y,e.render=y,e.renderToStaticMarkup=y,e.renderToString=y,e.shallowRender=g});
var e=require("preact"),t=/[\s\n\\/='"\0<>]/,r=/^xlink:?./,o=/["&<]/;function n(e){if(0===e.length||!1===o.test(e))return e;for(var t=0,r=0,n="",a="";r<e.length;r++){switch(e.charCodeAt(r)){case 34:a="&quot;";break;case 38:a="&amp;";break;case 60:a="&lt;";break;default:continue}r!==t&&(n+=e.slice(t,r)),n+=a,t=r+1}return r!==t&&(n+=e.slice(t,r)),n}var a={},i=new Set(["animation-iteration-count","border-image-outset","border-image-slice","border-image-width","box-flex","box-flex-group","box-ordinal-group","column-count","fill-opacity","flex","flex-grow","flex-negative","flex-order","flex-positive","flex-shrink","flood-opacity","font-weight","grid-column","grid-row","line-clamp","line-height","opacity","order","orphans","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","widows","z-index","zoom"]),s=/[A-Z]/g;function l(e){var t="";for(var r in e){var o=e[r];if(null!=o&&""!==o){var n="-"==r[0]?r:a[r]||(a[r]=r.replace(s,"-$&").toLowerCase()),l=";";"number"!=typeof o||n.startsWith("--")||i.has(n)||(l="px;"),t=t+n+":"+o+l}}return t||void 0}var c,u,p,f,_=[],d=Array.isArray,v=Object.assign;function h(){this.__d=!0}var g={};function m(e,t){var r=e.type,o=new r(e.props,t);return e.__c=o,o.__v=e,o.props=e.props,o.context=t,o.__d=!0,null==o.state&&(o.state=g),null==o.__s&&(o.__s=o.state),r.getDerivedStateFromProps?o.state=v({},o.state,r.getDerivedStateFromProps(o.props,o.state)):o.componentWillMount&&(o.componentWillMount(),o.state=o.__s!==o.state?o.__s:o.state),p&&p(e),o.render(o.props,o.state,t)}function y(o,a,i,s,_){if(null==o||!0===o||!1===o||""===o)return"";if("object"!=typeof o)return"function"==typeof o?"":n(o+"");if(d(o)){var g="";_.__k=o;for(var x=0;x<o.length;x++){var w=o[x];null!=w&&"boolean"!=typeof w&&(g+=y(w,a,i,s,_))}return g}if(void 0!==o.constructor)return"";o.__=_,c&&c(o);var C,S,F,j=o.type,A=o.props,L=a;if("function"==typeof j){if(j===e.Fragment)S=A.children;else{if(null!=(C=j.contextType)){var M=a[C.__c];L=M?M.props.value:C.__}if(j.prototype&&"function"==typeof j.prototype.render)S=m(o,L),F=o.__c;else{o.__c=F={__v:o,props:A,context:L,setState:h,forceUpdate:h,__d:!0,__h:[]};for(var z=0;F.__d&&z++<25;)F.__d=!1,p&&p(o),S=j.call(F,A,L);F.__d=!0}null!=F.getChildContext&&(a=v({},a,F.getChildContext()))}var T=y(S=null!=S&&S.type===e.Fragment&&null==S.key?S.props.children:S,a,i,s,o);return u&&u(o),o.__=void 0,f&&f(o),T}var W,q="<"+j,D="";for(var H in A){var O=A[H];switch(H){case"children":W=O;continue;case"key":case"ref":case"__self":case"__source":continue;case"htmlFor":if("for"in A)continue;H="for";break;case"className":if("class"in A)continue;H="class";break;case"defaultChecked":H="checked";break;case"defaultSelected":H="selected";break;case"defaultValue":case"value":switch(H="value",j){case"textarea":W=O;continue;case"select":s=O;continue;case"option":s!=O||"selected"in A||(q+=" selected")}break;case"dangerouslySetInnerHTML":D=O&&O.__html;continue;case"style":"object"==typeof O&&(O=l(O));break;default:if(i&&r.test(H))H=H.toLowerCase().replace(b,"xlink:");else{if(t.test(H))continue;"-"!==H[4]&&"draggable"!==H||null==O||(O+="")}}null!=O&&!1!==O&&"function"!=typeof O&&(q=!0===O||""===O?q+" "+H:q+" "+H+'="'+n(O+"")+'"')}if(t.test(j))throw new Error(j+" is not a valid HTML tag name in "+q+">");return D||("string"==typeof W?D=n(W):null!=W&&!1!==W&&!0!==W&&(D=y(W,a,"svg"===j||"foreignObject"!==j&&i,s,o))),u&&u(o),o.__=void 0,f&&f(o),!D&&k.has(j)?q+"/>":q+">"+D+"</"+j+">"}var b=/^xlink:?/,k=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]);module.exports=function(t,r){var o=e.options.__s;e.options.__s=!0,c=e.options.__b,u=e.options.diffed,p=e.options.__r,f=e.options.unmount;var n=e.h(e.Fragment,null);n.__k=[t];try{return y(t,r||g,!1,void 0,n)}finally{e.options.__c&&e.options.__c(t,_),e.options.__s=o,_.length=0}};
//# sourceMappingURL=index.js.map
import { VNode } from 'preact';
interface Options {
shallow?: boolean;
xml?: boolean;
pretty?: boolean | string;
}
export function render(vnode: VNode, context?: any, options?: Options): string;
export function renderToString(
vnode: VNode,
context?: any,
options?: Options
): string;
export function shallowRender(vnode: VNode, context?: any): string;
export default render;
export default function renderToString(vnode: VNode, context?: any): string;

@@ -1,2 +0,2 @@

import{options as e,Fragment as t}from"preact";var r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,n=/[&<>"]/;function o(e){var t=String(e);return n.test(t)?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):t}var a=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},i=function(e,t,r){return String(e).length>(t||40)||!r&&-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},l={};function s(e){var t="";for(var n in e){var o=e[n];null!=o&&""!==o&&(t&&(t+=" "),t+="-"==n[0]?n:l[n]||(l[n]=n.replace(/([A-Z])/g,"-$1").toLowerCase()),t+=": ",t+=o,"number"==typeof o&&!1===r.test(n)&&(t+="px"),t+=";")}return t||void 0}function f(e,t){for(var r in t)e[r]=t[r];return e}function p(e,t){return Array.isArray(t)?t.reduce(p,e):null!=t&&!1!==t&&e.push(t),e}var u={shallow:!0},c=[],_=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,v=/[\s\n\\/='"\0<>]/,d=function(){};m.render=m;var g=function(e,t){return m(e,t,u)},h=[];function m(t,r,n){r=r||{},n=n||{};var o=e.__s;e.__s=!0;var a=y(t,r,n);return e.__c&&e.__c(t,h),h.length=0,e.__s=o,a}function y(r,n,l,u,g,h){if(null==r||"boolean"==typeof r)return"";if("object"!=typeof r)return o(r);var m=l.pretty,x=m&&"string"==typeof m?m:"\t";if(Array.isArray(r)){for(var b="",S=0;S<r.length;S++)m&&S>0&&(b+="\n"),b+=y(r[S],n,l,u,g,h);return b}var w,k=r.type,O=r.props,C=!1;if("function"==typeof k){if(C=!0,!l.shallow||!u&&!1!==l.renderRootComponent){if(k===t){var A=[];return p(A,r.props.children),y(A,n,l,!1!==l.shallowHighOrder,g,h)}var H,j=r.__c={__v:r,context:n,props:r.props,setState:d,forceUpdate:d,data:{}};e.__b&&e.__b(r);var F=function(e,t){return{type:e.type,props:e.props,data:{},c:t}}(r,n);if(e.__r&&e.__r(F),k.prototype&&"function"==typeof k.prototype.render){var M=k.contextType,T=M&&n[M.__c],$=null!=M?T?T.props.value:M.__:n;(j=r.__c=new k(O,$)).__v=r,j._dirty=j.__d=!0,j.props=O,null==j.state&&(j.state={}),null==j._nextState&&null==j.__s&&(j._nextState=j.__s=j.state),j.context=$,k.getDerivedStateFromProps?j.state=f(f({},j.state),k.getDerivedStateFromProps(j.props,j.state)):j.componentWillMount&&(j.componentWillMount(),j.state=j._nextState!==j.state?j._nextState:j.__s!==j.state?j.__s:j.state),H=j.render(j.props,j.state,j.context)}else{var L=k.contextType,E=L&&n[L.__c];H=k.call(r.__c,O,null!=L?E?E.props.value:L.__:n)}return j.getChildContext&&(n=f(f({},n),j.getChildContext())),e.diffed&&e.diffed(r),y(H,n,l,!1!==l.shallowHighOrder,g,h)}k=(w=k).displayName||w!==Function&&w.name||function(e){var t=(Function.prototype.toString.call(e).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!t){for(var r=-1,n=c.length;n--;)if(c[n]===e){r=n;break}r<0&&(r=c.push(e)-1),t="UnnamedComponent"+r}return t}(w)}var D,N,P="<"+k;if(O){var R=Object.keys(O);l&&!0===l.sortAttributes&&R.sort();for(var U=0;U<R.length;U++){var W=R[U],q=O[W];if("children"!==W){if(!v.test(W)&&(l&&l.allAttributes||"key"!==W&&"ref"!==W&&"__self"!==W&&"__source"!==W)){if("defaultValue"===W)W="value";else if("className"===W){if(void 0!==O.class)continue;W="class"}else g&&W.match(/^xlink:?./)&&(W=W.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===W){if(O.for)continue;W="for"}"style"===W&&q&&"object"==typeof q&&(q=s(q)),"a"===W[0]&&"r"===W[1]&&"boolean"==typeof q&&(q=String(q));var z=l.attributeHook&&l.attributeHook(W,q,n,l,C);if(z||""===z)P+=z;else if("dangerouslySetInnerHTML"===W)N=q&&q.__html;else if("textarea"===k&&"value"===W)D=q;else if((q||0===q||""===q)&&"function"!=typeof q){if(!(!0!==q&&""!==q||(q=W,l&&l.xml))){P+=" "+W;continue}if("value"===W){if("select"===k){h=q;continue}"option"===k&&h==q&&(P+=" selected")}P+=" "+W+'="'+o(q)+'"'}}}else D=q}}if(m){var I=P.replace(/\n\s*/," ");I===P||~I.indexOf("\n")?m&&~P.indexOf("\n")&&(P+="\n"):P=I}if(P+=">",v.test(k))throw new Error(k+" is not a valid HTML tag name in "+P);var V,Z=_.test(k)||l.voidElements&&l.voidElements.test(k),B=[];if(N)m&&i(N)&&(N="\n"+x+a(N,x)),P+=N;else if(null!=D&&p(V=[],D).length){for(var G=m&&~P.indexOf("\n"),J=!1,K=0;K<V.length;K++){var Q=V[K];if(null!=Q&&!1!==Q){var X=y(Q,n,l,!0,"svg"===k||"foreignObject"!==k&&g,h);if(m&&!G&&i(X)&&(G=!0),X)if(m){var Y=X.length>0&&"<"!=X[0];J&&Y?B[B.length-1]+=X:B.push(X),J=Y}else B.push(X)}}if(m&&G)for(var ee=B.length;ee--;)B[ee]="\n"+x+a(B[ee],x)}if(B.length||N)P+=B.join("");else if(l&&l.xml)return P.substring(0,P.length-1)+" />";return!Z||V||N?(m&&~P.indexOf("\n")&&(P+="\n"),P+="</"+k+">"):P=P.replace(/>$/," />"),P}m.shallowRender=g;export default m;export{m as render,m as renderToStaticMarkup,m as renderToString,g as shallowRender};
import{options as e,h as t,Fragment as r}from"preact";var o=/[\s\n\\/='"\0<>]/,a=/^xlink:?./,n=/["&<]/;function i(e){if(0===e.length||!1===n.test(e))return e;for(var t=0,r=0,o="",a="";r<e.length;r++){switch(e.charCodeAt(r)){case 34:a="&quot;";break;case 38:a="&amp;";break;case 60:a="&lt;";break;default:continue}r!==t&&(o+=e.slice(t,r)),o+=a,t=r+1}return r!==t&&(o+=e.slice(t,r)),o}var s={},l=new Set(["animation-iteration-count","border-image-outset","border-image-slice","border-image-width","box-flex","box-flex-group","box-ordinal-group","column-count","fill-opacity","flex","flex-grow","flex-negative","flex-order","flex-positive","flex-shrink","flood-opacity","font-weight","grid-column","grid-row","line-clamp","line-height","opacity","order","orphans","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","widows","z-index","zoom"]),c=/[A-Z]/g;function u(e){var t="";for(var r in e){var o=e[r];if(null!=o&&""!==o){var a="-"==r[0]?r:s[r]||(s[r]=r.replace(c,"-$&").toLowerCase()),n=";";"number"!=typeof o||a.startsWith("--")||l.has(a)||(n="px;"),t=t+a+":"+o+n}}return t||void 0}var f,_,p,d,v=[],h=Array.isArray,g=Object.assign;function y(o,a){var n=e.__s;e.__s=!0,f=e.__b,_=e.diffed,p=e.__r,d=e.unmount;var i=t(r,null);i.__k=[o];try{return x(o,a||b,!1,void 0,i)}finally{e.__c&&e.__c(o,v),e.__s=n,v.length=0}}function m(){this.__d=!0}var b={};function k(e,t){var r=e.type,o=new r(e.props,t);return e.__c=o,o.__v=e,o.props=e.props,o.context=t,o.__d=!0,null==o.state&&(o.state=b),null==o.__s&&(o.__s=o.state),r.getDerivedStateFromProps?o.state=g({},o.state,r.getDerivedStateFromProps(o.props,o.state)):o.componentWillMount&&(o.componentWillMount(),o.state=o.__s!==o.state?o.__s:o.state),p&&p(e),o.render(o.props,o.state,t)}function x(e,t,n,s,l){if(null==e||!0===e||!1===e||""===e)return"";if("object"!=typeof e)return"function"==typeof e?"":i(e+"");if(h(e)){var c="";l.__k=e;for(var v=0;v<e.length;v++){var y=e[v];null!=y&&"boolean"!=typeof y&&(c+=x(y,t,n,s,l))}return c}if(void 0!==e.constructor)return"";e.__=l,f&&f(e);var b,S,j,A=e.type,L=e.props,M=t;if("function"==typeof A){if(A===r)S=L.children;else{if(null!=(b=A.contextType)){var z=t[b.__c];M=z?z.props.value:b.__}if(A.prototype&&"function"==typeof A.prototype.render)S=k(e,M),j=e.__c;else{e.__c=j={__v:e,props:L,context:M,setState:m,forceUpdate:m,__d:!0,__h:[]};for(var F=0;j.__d&&F++<25;)j.__d=!1,p&&p(e),S=A.call(j,L,M);j.__d=!0}null!=j.getChildContext&&(t=g({},t,j.getChildContext()))}var T=x(S=null!=S&&S.type===r&&null==S.key?S.props.children:S,t,n,s,e);return _&&_(e),e.__=void 0,d&&d(e),T}var W,D="<"+A,H="";for(var O in L){var P=L[O];switch(O){case"children":W=P;continue;case"key":case"ref":case"__self":case"__source":continue;case"htmlFor":if("for"in L)continue;O="for";break;case"className":if("class"in L)continue;O="class";break;case"defaultChecked":O="checked";break;case"defaultSelected":O="selected";break;case"defaultValue":case"value":switch(O="value",A){case"textarea":W=P;continue;case"select":s=P;continue;case"option":s!=P||"selected"in L||(D+=" selected")}break;case"dangerouslySetInnerHTML":H=P&&P.__html;continue;case"style":"object"==typeof P&&(P=u(P));break;default:if(n&&a.test(O))O=O.toLowerCase().replace(w,"xlink:");else{if(o.test(O))continue;"-"!==O[4]&&"draggable"!==O||null==P||(P+="")}}null!=P&&!1!==P&&"function"!=typeof P&&(D=!0===P||""===P?D+" "+O:D+" "+O+'="'+i(P+"")+'"')}if(o.test(A))throw new Error(A+" is not a valid HTML tag name in "+D+">");return H||("string"==typeof W?H=i(W):null!=W&&!1!==W&&!0!==W&&(H=x(W,t,"svg"===A||"foreignObject"!==A&&n,s,e))),_&&_(e),e.__=void 0,d&&d(e),!H&&C.has(A)?D+"/>":D+">"+H+"</"+A+">"}var w=/^xlink:?/,C=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]);export default y;
//# sourceMappingURL=index.module.js.map

@@ -1,2 +0,2 @@

var t;t=function(t,n){if("function"!=typeof Symbol){var e=0;Symbol=function(t){return"@@"+t+ ++e},Symbol.for=function(t){return"@@"+t}}var r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,o=/[&<>"]/;function i(t){var n=String(t);return o.test(n)?n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):n}var a=function(t,n){return String(t).replace(/(\n+)/g,"$1"+(n||"\t"))},u=function(t,n,e){return String(t).length>(n||40)||!e&&-1!==String(t).indexOf("\n")||-1!==String(t).indexOf("<")},c={};function f(t){var n="";for(var e in t){var o=t[e];null!=o&&""!==o&&(n&&(n+=" "),n+="-"==e[0]?e:c[e]||(c[e]=e.replace(/([A-Z])/g,"-$1").toLowerCase()),n+=": ",n+=o,"number"==typeof o&&!1===r.test(e)&&(n+="px"),n+=";")}return n||void 0}function l(t,n){for(var e in n)t[e]=n[e];return t}function s(t,n){return Array.isArray(n)?n.reduce(s,t):null!=n&&!1!==n&&t.push(n),t}var p={shallow:!0},y=[],v=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,g=/[\s\n\\/='"\0<>]/,d=function(){};m.render=m;var b=[];function m(t,e,r){e=e||{},r=r||{};var o=n.options.__s;n.options.__s=!0;var i=h(t,e,r);return n.options.__c&&n.options.__c(t,b),b.length=0,n.options.__s=o,i}function h(t,e,r,o,c,p){if(null==t||"boolean"==typeof t)return"";if("object"!=typeof t)return i(t);var b=r.pretty,m=b&&"string"==typeof b?b:"\t";if(Array.isArray(t)){for(var _="",x=0;x<t.length;x++)b&&x>0&&(_+="\n"),_+=h(t[x],e,r,o,c,p);return _}var j,S=t.type,A=t.props,O=!1;if("function"==typeof S){if(O=!0,!r.shallow||!o&&!1!==r.renderRootComponent){if(S===n.Fragment){var w=[];return s(w,t.props.children),h(w,e,r,!1!==r.shallowHighOrder,c,p)}var k,F=t.__c={__v:t,context:e,props:t.props,setState:d,forceUpdate:d,data:{}};n.options.__b&&n.options.__b(t);var E=function(t,n){return{type:t.type,props:t.props,data:{},c:n}}(t,e);if(n.options.__r&&n.options.__r(E),S.prototype&&"function"==typeof S.prototype.render){var C=S.contextType,M=C&&e[C.__c],N=null!=C?M?M.props.value:C.__:e;(F=t.__c=new S(A,N)).__v=t,F._dirty=F.__d=!0,F.props=A,null==F.state&&(F.state={}),null==F._nextState&&null==F.__s&&(F._nextState=F.__s=F.state),F.context=N,S.getDerivedStateFromProps?F.state=l(l({},F.state),S.getDerivedStateFromProps(F.props,F.state)):F.componentWillMount&&(F.componentWillMount(),F.state=F._nextState!==F.state?F._nextState:F.__s!==F.state?F.__s:F.state),k=F.render(F.props,F.state,F.context)}else{var D=S.contextType,H=D&&e[D.__c];k=S.call(t.__c,A,null!=D?H?H.props.value:D.__:e)}return F.getChildContext&&(e=l(l({},e),F.getChildContext())),n.options.diffed&&n.options.diffed(t),h(k,e,r,!1!==r.shallowHighOrder,c,p)}S=(j=S).displayName||j!==Function&&j.name||function(t){var n=(Function.prototype.toString.call(t).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!n){for(var e=-1,r=y.length;r--;)if(y[r]===t){e=r;break}e<0&&(e=y.push(t)-1),n="UnnamedComponent"+e}return n}(j)}var I,$,T="<"+S;if(A){var U=Object.keys(A);r&&!0===r.sortAttributes&&U.sort();for(var W=0;W<U.length;W++){var L=U[W],P=A[L];if("children"!==L){if(!g.test(L)&&(r&&r.allAttributes||"key"!==L&&"ref"!==L&&"__self"!==L&&"__source"!==L)){if("defaultValue"===L)L="value";else if("className"===L){if(void 0!==A.class)continue;L="class"}else c&&L.match(/^xlink:?./)&&(L=L.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===L){if(A.for)continue;L="for"}"style"===L&&P&&"object"==typeof P&&(P=f(P)),"a"===L[0]&&"r"===L[1]&&"boolean"==typeof P&&(P=String(P));var R=r.attributeHook&&r.attributeHook(L,P,e,r,O);if(R||""===R)T+=R;else if("dangerouslySetInnerHTML"===L)$=P&&P.__html;else if("textarea"===S&&"value"===L)I=P;else if((P||0===P||""===P)&&"function"!=typeof P){if(!(!0!==P&&""!==P||(P=L,r&&r.xml))){T+=" "+L;continue}if("value"===L){if("select"===S){p=P;continue}"option"===S&&p==P&&(T+=" selected")}T+=" "+L+'="'+i(P)+'"'}}}else I=P}}if(b){var J=T.replace(/\n\s*/," ");J===T||~J.indexOf("\n")?b&&~T.indexOf("\n")&&(T+="\n"):T=J}if(T+=">",g.test(S))throw new Error(S+" is not a valid HTML tag name in "+T);var q,V=v.test(S)||r.voidElements&&r.voidElements.test(S),z=[];if($)b&&u($)&&($="\n"+m+a($,m)),T+=$;else if(null!=I&&s(q=[],I).length){for(var B=b&&~T.indexOf("\n"),G=!1,Z=0;Z<q.length;Z++){var K=q[Z];if(null!=K&&!1!==K){var Q=h(K,e,r,!0,"svg"===S||"foreignObject"!==S&&c,p);if(b&&!B&&u(Q)&&(B=!0),Q)if(b){var X=Q.length>0&&"<"!=Q[0];G&&X?z[z.length-1]+=Q:z.push(Q),G=X}else z.push(Q)}}if(b&&B)for(var Y=z.length;Y--;)z[Y]="\n"+m+a(z[Y],m)}if(z.length||$)T+=z.join("");else if(r&&r.xml)return T.substring(0,T.length-1)+" />";return!V||q||$?(b&&~T.indexOf("\n")&&(T+="\n"),T+="</"+S+">"):T=T.replace(/>$/," />"),T}m.shallowRender=function(t,n){return m(t,n,p)};var _=/(\\|\"|\')/g,x=Object.prototype.toString,j=Date.prototype.toISOString,S=Error.prototype.toString,A=RegExp.prototype.toString,O=Symbol.prototype.toString,w=/^Symbol\((.*)\)(.*)$/,k=/\n/gi,F=Object.getOwnPropertySymbols||function(t){return[]};function E(t){return"[object Array]"===t||"[object ArrayBuffer]"===t||"[object DataView]"===t||"[object Float32Array]"===t||"[object Float64Array]"===t||"[object Int8Array]"===t||"[object Int16Array]"===t||"[object Int32Array]"===t||"[object Uint8Array]"===t||"[object Uint8ClampedArray]"===t||"[object Uint16Array]"===t||"[object Uint32Array]"===t}function C(t){return""===t.name?"[Function anonymous]":"[Function "+t.name+"]"}function M(t){return O.call(t).replace(w,"Symbol($1)")}function N(t){return"["+S.call(t)+"]"}function D(t){if(!0===t||!1===t)return""+t;if(void 0===t)return"undefined";if(null===t)return"null";var n=typeof t;if("number"===n)return function(t){return t!=+t?"NaN":0===t&&1/t<0?"-0":""+t}(t);if("string"===n)return'"'+function(t){return t.replace(_,"\\$1")}(t)+'"';if("function"===n)return C(t);if("symbol"===n)return M(t);var e=x.call(t);return"[object WeakMap]"===e?"WeakMap {}":"[object WeakSet]"===e?"WeakSet {}":"[object Function]"===e||"[object GeneratorFunction]"===e?C(t,min):"[object Symbol]"===e?M(t):"[object Date]"===e?j.call(t):"[object Error]"===e?N(t):"[object RegExp]"===e?A.call(t):"[object Arguments]"===e&&0===t.length?"Arguments []":E(e)&&0===t.length?t.constructor.name+" []":t instanceof Error&&N(t)}function H(t,n,e,r,o,i,a,u,c,f){var l="";if(t.length){l+=o;for(var s=e+n,p=0;p<t.length;p++)l+=s+T(t[p],n,s,r,o,i,a,u,c,f),p<t.length-1&&(l+=","+r);l+=o+e}return"["+l+"]"}function I(t,n,e,r,o,i,a,u,c,f){if((i=i.slice()).indexOf(t)>-1)return"[Circular]";i.push(t);var l=++u>a;if(!l&&t.toJSON&&"function"==typeof t.toJSON)return T(t.toJSON(),n,e,r,o,i,a,u,c,f);var s=x.call(t);return"[object Arguments]"===s?l?"[Arguments]":function(t,n,e,r,o,i,a,u,c,f){return(f?"":"Arguments ")+H(t,n,e,r,o,i,a,u,c,f)}(t,n,e,r,o,i,a,u,c,f):E(s)?l?"[Array]":function(t,n,e,r,o,i,a,u,c,f){return(f?"":t.constructor.name+" ")+H(t,n,e,r,o,i,a,u,c,f)}(t,n,e,r,o,i,a,u,c,f):"[object Map]"===s?l?"[Map]":function(t,n,e,r,o,i,a,u,c,f){var l="Map {",s=t.entries(),p=s.next();if(!p.done){l+=o;for(var y=e+n;!p.done;)l+=y+T(p.value[0],n,y,r,o,i,a,u,c,f)+" => "+T(p.value[1],n,y,r,o,i,a,u,c,f),(p=s.next()).done||(l+=","+r);l+=o+e}return l+"}"}(t,n,e,r,o,i,a,u,c,f):"[object Set]"===s?l?"[Set]":function(t,n,e,r,o,i,a,u,c,f){var l="Set {",s=t.entries(),p=s.next();if(!p.done){l+=o;for(var y=e+n;!p.done;)l+=y+T(p.value[1],n,y,r,o,i,a,u,c,f),(p=s.next()).done||(l+=","+r);l+=o+e}return l+"}"}(t,n,e,r,o,i,a,u,c,f):"object"==typeof t?l?"[Object]":function(t,n,e,r,o,i,a,u,c,f){var l=(f?"":t.constructor?t.constructor.name+" ":"Object ")+"{",s=Object.keys(t).sort(),p=F(t);if(p.length&&(s=s.filter(function(t){return!("symbol"==typeof t||"[object Symbol]"===x.call(t))}).concat(p)),s.length){l+=o;for(var y=e+n,v=0;v<s.length;v++){var g=s[v];l+=y+T(g,n,y,r,o,i,a,u,c,f)+": "+T(t[g],n,y,r,o,i,a,u,c,f),v<s.length-1&&(l+=","+r)}l+=o+e}return l+"}"}(t,n,e,r,o,i,a,u,c,f):void 0}function $(t,n,e,r,o,i,a,u,c,f){for(var l,s=!1,p=0;p<c.length;p++)if((l=c[p]).test(t)){s=!0;break}return!!s&&l.print(t,function(t){return T(t,n,e,r,o,i,a,u,c,f)},function(t){var r=e+n;return r+t.replace(k,"\n"+r)},{edgeSpacing:o,spacing:r})}function T(t,n,e,r,o,i,a,u,c,f){return D(t)||$(t,n,e,r,o,i,a,u,c,f)||I(t,n,e,r,o,i,a,u,c,f)}var U={indent:2,min:!1,maxDepth:Infinity,plugins:[]};function W(t){return new Array(t+1).join(" ")}var L={test:function(t){return t&&"object"==typeof t&&"type"in t&&"props"in t&&"key"in t},print:function(t,n,e){return m(t,L.context,L.opts)}},P={plugins:[L]},R={attributeHook:function(t,n,e,r,o){var u=typeof n;if("dangerouslySetInnerHTML"===t)return!1;if(null==n||"function"===u&&!r.functions)return"";if(r.skipFalseAttributes&&!o&&(!1===n||("class"===t||"style"===t)&&""===n))return"";var c="string"==typeof r.pretty?r.pretty:"\t";return"string"!==u?("function"!==u||r.functionNames?(L.context=e,L.opts=r,~(n=function(t,n){var e,r;n?(function(t){if(Object.keys(t).forEach(function(t){if(!U.hasOwnProperty(t))throw new Error("prettyFormat: Invalid option: "+t)}),t.min&&void 0!==t.indent&&0!==t.indent)throw new Error("prettyFormat: Cannot run with min option and indent")}(n),n=function(t){var n={};return Object.keys(U).forEach(function(e){return n[e]=t.hasOwnProperty(e)?t[e]:U[e]}),n.min&&(n.indent=0),n}(n)):n=U;var o=n.min?" ":"\n",i=n.min?"":"\n";if(n&&n.plugins.length){var a=$(t,e=W(n.indent),"",o,i,r=[],n.maxDepth,0,n.plugins,n.min);if(a)return a}return D(t)||(e||(e=W(n.indent)),r||(r=[]),I(t,e,"",o,i,r,n.maxDepth,0,n.plugins,n.min))}(n,P)).indexOf("\n")&&(n=a("\n"+n,c)+"\n")):n="Function",a("\n"+t+"={"+n+"}",c)):"\n"+c+t+'="'+i(n)+'"'},jsx:!0,xml:!1,functions:!0,functionNames:!0,skipFalseAttributes:!0,pretty:" "};function J(t,n,e,r){return m(t,n,e=l(l({},R),e||{}))}t.default=J,t.render=J},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],t):t(self.preactRenderToString={},(void 0).preact);
var t=require("preact");if("function"!=typeof Symbol){var e=0;Symbol=function(t){return"@@"+t+ ++e},Symbol.for=function(t){return"@@"+t}}var n=/^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,r=/[\s\n\\/='"\0<>]/,o=/^xlink:?./,i=/["&<]/;function a(t){if(0===t.length||!1===i.test(t))return t;for(var e=0,n=0,r="",o="";n<t.length;n++){switch(t.charCodeAt(n)){case 34:o="&quot;";break;case 38:o="&amp;";break;case 60:o="&lt;";break;default:continue}n!==e&&(r+=t.slice(e,n)),r+=o,e=n+1}return n!==e&&(r+=t.slice(e,n)),r}var u=function(t,e){return String(t).replace(/(\n+)/g,"$1"+(e||"\t"))},c=function(t,e,n){return String(t).length>(e||40)||!n&&-1!==String(t).indexOf("\n")||-1!==String(t).indexOf("<")},l={},f=new Set(["animation-iteration-count","border-image-outset","border-image-slice","border-image-width","box-flex","box-flex-group","box-ordinal-group","column-count","fill-opacity","flex","flex-grow","flex-negative","flex-order","flex-positive","flex-shrink","flood-opacity","font-weight","grid-column","grid-row","line-clamp","line-height","opacity","order","orphans","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","widows","z-index","zoom"]),s=/[A-Z]/g;function p(t){var e="";for(var n in t){var r=t[n];if(null!=r&&""!==r){var o="-"==n[0]?n:l[n]||(l[n]=n.replace(s,"-$&").toLowerCase()),i=";";"number"!=typeof r||o.startsWith("--")||f.has(o)||(i="px;"),e=e+o+":"+r+i}}return e||void 0}function d(t,e){return Array.isArray(e)?e.reduce(d,t):null!=e&&!1!==e&&t.push(e),t}function g(){this.__d=!0}function y(t,e){return{__v:t,context:e,props:t.props,setState:g,forceUpdate:g,__d:!0,__h:[]}}var b=[],v=[];function m(e,n,r,o){var i=t.options.__s;t.options.__s=!0;try{return h(e,n||{},r,o)}finally{t.options.__c&&t.options.__c(e,v),t.options.__s=i,v.length=0}}function h(e,i,l,f,s,g){if(null==e||"boolean"==typeof e)return"";if("object"!=typeof e)return"function"==typeof e?"":a(e+"");var b=l.pretty,v=b&&"string"==typeof b?b:"\t";if(Array.isArray(e)){for(var m="",x=0;x<e.length;x++)b&&x>0&&(m+="\n"),m+=h(e[x],i,l,f,s,g);return m}if(void 0!==e.constructor)return"";t.options.__b&&t.options.__b(e);var j,S=e.type,k=e.props,w=!1;if("function"==typeof S){if(w=!0,!l.shallow||!f&&!1!==l.renderRootComponent){if(S===t.Fragment){var O=[];return d(O,e.props.children),h(O,i,l,!1!==l.shallowHighOrder,s,g)}var A,F=e.__c=y(e,i),C=t.options.__r,E=i,M=S.contextType;if(null!=M){var H=i[M.__c];E=H?H.props.value:M.__}if(S.prototype&&"function"==typeof S.prototype.render)(F=e.__c=new S(k,E)).__v=e,F._dirty=F.__d=!0,F.props=k,null==F.state&&(F.state={}),null==F._nextState&&null==F.__s&&(F._nextState=F.__s=F.state),F.context=E,S.getDerivedStateFromProps?F.state=Object.assign({},F.state,S.getDerivedStateFromProps(F.props,F.state)):F.componentWillMount&&(F.componentWillMount(),F.state=F._nextState!==F.state?F._nextState:F.__s!==F.state?F.__s:F.state),C&&C(e),A=F.render(F.props,F.state,F.context);else for(var N=0;F.__d&&N++<25;)F.__d=!1,C&&C(e),A=S.call(e.__c,k,E);F.getChildContext&&(i=Object.assign({},i,F.getChildContext()));var D=h(A,i,l,!1!==l.shallowHighOrder,s,g);return t.options.diffed&&t.options.diffed(e),D}S=(j=S).displayName||j!==Function&&j.name||_(j)}var I,W,$="<"+S;if(k){var U=Object.keys(k);l&&!0===l.sortAttributes&&U.sort();for(var L=0;L<U.length;L++){var P=U[L],R=k[P];if("children"!==P){if(!r.test(P)&&(l&&l.allAttributes||"key"!==P&&"ref"!==P&&"__self"!==P&&"__source"!==P)){if("defaultValue"===P)P="value";else if("defaultChecked"===P)P="checked";else if("defaultSelected"===P)P="selected";else if("className"===P){if(void 0!==k.class)continue;P="class"}else s&&o.test(P)&&(P=P.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===P){if(k.for)continue;P="for"}"style"===P&&R&&"object"==typeof R&&(R=p(R)),"a"===P[0]&&"r"===P[1]&&"boolean"==typeof R&&(R=String(R));var T=l.attributeHook&&l.attributeHook(P,R,i,l,w);if(T||""===T)$+=T;else if("dangerouslySetInnerHTML"===P)W=R&&R.__html;else if("textarea"===S&&"value"===P)I=R;else if((R||0===R||""===R)&&"function"!=typeof R){if(!(!0!==R&&""!==R||(R=P,l&&l.xml))){$=$+" "+P;continue}if("value"===P){if("select"===S){g=R;continue}"option"===S&&g==R&&void 0===k.selected&&($+=" selected")}$=$+" "+P+'="'+a(R+"")+'"'}}}else I=R}}if(b){var z=$.replace(/\n\s*/," ");z===$||~z.indexOf("\n")?b&&~$.indexOf("\n")&&($+="\n"):$=z}if($+=">",r.test(S))throw new Error(S+" is not a valid HTML tag name in "+$);var J,q=n.test(S)||l.voidElements&&l.voidElements.test(S),V=[];if(W)b&&c(W)&&(W="\n"+v+u(W,v)),$+=W;else if(null!=I&&d(J=[],I).length){for(var B=b&&~$.indexOf("\n"),G=!1,Z=0;Z<J.length;Z++){var K=J[Z];if(null!=K&&!1!==K){var Q=h(K,i,l,!0,"svg"===S||"foreignObject"!==S&&s,g);if(b&&!B&&c(Q)&&(B=!0),Q)if(b){var X=Q.length>0&&"<"!=Q[0];G&&X?V[V.length-1]+=Q:V.push(Q),G=X}else V.push(Q)}}if(b&&B)for(var Y=V.length;Y--;)V[Y]="\n"+v+u(V[Y],v)}if(t.options.diffed&&t.options.diffed(e),V.length||W)$+=V.join("");else if(l&&l.xml)return $.substring(0,$.length-1)+" />";return!q||J||W?(b&&~$.indexOf("\n")&&($+="\n"),$=$+"</"+S+">"):$=$.replace(/>$/," />"),$}function _(t){var e=(Function.prototype.toString.call(t).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!e){for(var n=-1,r=b.length;r--;)if(b[r]===t){n=r;break}n<0&&(n=b.push(t)-1),e="UnnamedComponent"+n}return e}var x=/(\\|\"|\')/g,j=function(t){return t.replace(x,"\\$1")},S=Object.prototype.toString,k=Date.prototype.toISOString,w=Error.prototype.toString,O=RegExp.prototype.toString,A=Symbol.prototype.toString,F=/^Symbol\((.*)\)(.*)$/,C=/\n/gi,E=Object.getOwnPropertySymbols||function(t){return[]};function M(t){return"[object Array]"===t||"[object ArrayBuffer]"===t||"[object DataView]"===t||"[object Float32Array]"===t||"[object Float64Array]"===t||"[object Int8Array]"===t||"[object Int16Array]"===t||"[object Int32Array]"===t||"[object Uint8Array]"===t||"[object Uint8ClampedArray]"===t||"[object Uint16Array]"===t||"[object Uint32Array]"===t}function H(t){return t!=+t?"NaN":0===t&&1/t<0?"-0":""+t}function N(t){return""===t.name?"[Function anonymous]":"[Function "+t.name+"]"}function D(t){return A.call(t).replace(F,"Symbol($1)")}function I(t){return"["+w.call(t)+"]"}function W(t){if(!0===t||!1===t)return""+t;if(void 0===t)return"undefined";if(null===t)return"null";var e=typeof t;if("number"===e)return H(t);if("string"===e)return'"'+j(t)+'"';if("function"===e)return N(t);if("symbol"===e)return D(t);var n=S.call(t);return"[object WeakMap]"===n?"WeakMap {}":"[object WeakSet]"===n?"WeakSet {}":"[object Function]"===n||"[object GeneratorFunction]"===n?N(t,min):"[object Symbol]"===n?D(t):"[object Date]"===n?k.call(t):"[object Error]"===n?I(t):"[object RegExp]"===n?O.call(t):"[object Arguments]"===n&&0===t.length?"Arguments []":M(n)&&0===t.length?t.constructor.name+" []":t instanceof Error&&I(t)}function $(t,e,n,r,o,i,a,u,c,l){var f="";if(t.length){f+=o;for(var s=n+e,p=0;p<t.length;p++)f+=s+q(t[p],e,s,r,o,i,a,u,c,l),p<t.length-1&&(f+=","+r);f+=o+n}return"["+f+"]"}function U(t,e,n,r,o,i,a,u,c,l){return(l?"":"Arguments ")+$(t,e,n,r,o,i,a,u,c,l)}function L(t,e,n,r,o,i,a,u,c,l){return(l?"":t.constructor.name+" ")+$(t,e,n,r,o,i,a,u,c,l)}function P(t,e,n,r,o,i,a,u,c,l){var f="Map {",s=t.entries(),p=s.next();if(!p.done){f+=o;for(var d=n+e;!p.done;)f+=d+q(p.value[0],e,d,r,o,i,a,u,c,l)+" => "+q(p.value[1],e,d,r,o,i,a,u,c,l),(p=s.next()).done||(f+=","+r);f+=o+n}return f+"}"}function R(t,e,n,r,o,i,a,u,c,l){var f=(l?"":t.constructor?t.constructor.name+" ":"Object ")+"{",s=Object.keys(t).sort(),p=E(t);if(p.length&&(s=s.filter(function(t){return!("symbol"==typeof t||"[object Symbol]"===S.call(t))}).concat(p)),s.length){f+=o;for(var d=n+e,g=0;g<s.length;g++){var y=s[g];f+=d+q(y,e,d,r,o,i,a,u,c,l)+": "+q(t[y],e,d,r,o,i,a,u,c,l),g<s.length-1&&(f+=","+r)}f+=o+n}return f+"}"}function T(t,e,n,r,o,i,a,u,c,l){var f="Set {",s=t.entries(),p=s.next();if(!p.done){f+=o;for(var d=n+e;!p.done;)f+=d+q(p.value[1],e,d,r,o,i,a,u,c,l),(p=s.next()).done||(f+=","+r);f+=o+n}return f+"}"}function z(t,e,n,r,o,i,a,u,c,l){if((i=i.slice()).indexOf(t)>-1)return"[Circular]";i.push(t);var f=++u>a;if(!f&&t.toJSON&&"function"==typeof t.toJSON)return q(t.toJSON(),e,n,r,o,i,a,u,c,l);var s=S.call(t);return"[object Arguments]"===s?f?"[Arguments]":U(t,e,n,r,o,i,a,u,c,l):M(s)?f?"[Array]":L(t,e,n,r,o,i,a,u,c,l):"[object Map]"===s?f?"[Map]":P(t,e,n,r,o,i,a,u,c,l):"[object Set]"===s?f?"[Set]":T(t,e,n,r,o,i,a,u,c,l):"object"==typeof t?f?"[Object]":R(t,e,n,r,o,i,a,u,c,l):void 0}function J(t,e,n,r,o,i,a,u,c,l){for(var f,s=!1,p=0;p<c.length;p++)if((f=c[p]).test(t)){s=!0;break}return!!s&&f.print(t,function(t){return q(t,e,n,r,o,i,a,u,c,l)},function(t){var r=n+e;return r+t.replace(C,"\n"+r)},{edgeSpacing:o,spacing:r})}function q(t,e,n,r,o,i,a,u,c,l){return W(t)||J(t,e,n,r,o,i,a,u,c,l)||z(t,e,n,r,o,i,a,u,c,l)}var V={indent:2,min:!1,maxDepth:Infinity,plugins:[]};function B(t){if(Object.keys(t).forEach(function(t){if(!V.hasOwnProperty(t))throw new Error("prettyFormat: Invalid option: "+t)}),t.min&&void 0!==t.indent&&0!==t.indent)throw new Error("prettyFormat: Cannot run with min option and indent")}function G(t){var e={};return Object.keys(V).forEach(function(n){return e[n]=t.hasOwnProperty(n)?t[n]:V[n]}),e.min&&(e.indent=0),e}function Z(t){return new Array(t+1).join(" ")}var K=function(t,e){var n,r;e?(B(e),e=G(e)):e=V;var o=e.min?" ":"\n",i=e.min?"":"\n";if(e&&e.plugins.length){var a=J(t,n=Z(e.indent),"",o,i,r=[],e.maxDepth,0,e.plugins,e.min);if(a)return a}return W(t)||(n||(n=Z(e.indent)),r||(r=[]),z(t,n,"",o,i,r,e.maxDepth,0,e.plugins,e.min))},Q={test:function(t){return t&&"object"==typeof t&&"type"in t&&"props"in t&&"key"in t},print:function(t,e,n){return m(t,Q.context,Q.opts,!0)}},X={plugins:[Q]},Y={attributeHook:function(t,e,n,r,o){var i=typeof e;if("dangerouslySetInnerHTML"===t)return!1;if(null==e||"function"===i&&!r.functions)return"";if(r.skipFalseAttributes&&!o&&(!1===e||("class"===t||"style"===t)&&""===e))return"";var c="string"==typeof r.pretty?r.pretty:"\t";return"string"!==i?("function"!==i||r.functionNames?(Q.context=n,Q.opts=r,~(e=K(e,X)).indexOf("\n")&&(e=u("\n"+e,c)+"\n")):e="Function",u("\n"+t+"={"+e+"}",c)):"\n"+c+t+'="'+a(e)+'"'},jsx:!0,xml:!1,functions:!0,functionNames:!0,skipFalseAttributes:!0,pretty:" "};function tt(t,e,n){var r=Object.assign({},Y,n||{});return r.jsx||(r.attributeHook=null),m(t,e,r)}var et={shallow:!0};exports.default=tt,exports.render=tt,exports.shallowRender=function(t,e,n){return tt(t,e,Object.assign({},et,n||{}))};
//# sourceMappingURL=jsx.js.map

@@ -6,9 +6,17 @@ import { VNode } from 'preact';

xml?: boolean;
pretty?: boolean | string;
shallow?: boolean;
functions?: boolean;
functionNames?: boolean;
skipFalseAttributes?: boolean;
pretty?: boolean | string;
}
export function render(vnode: VNode, context?: any, options?: Options): string;
export default function renderToStringPretty(
vnode: VNode,
context?: any,
options?: Options
): string;
export function shallowRender(vnode: VNode, context?: any): string;
export default render;

@@ -1,2 +0,2 @@

import{options as t,Fragment as n}from"preact";if("function"!=typeof Symbol){var e=0;Symbol=function(t){return"@@"+t+ ++e},Symbol.for=function(t){return"@@"+t}}var r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,o=/[&<>"]/;function i(t){var n=String(t);return o.test(n)?n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):n}var a=function(t,n){return String(t).replace(/(\n+)/g,"$1"+(n||"\t"))},c=function(t,n,e){return String(t).length>(n||40)||!e&&-1!==String(t).indexOf("\n")||-1!==String(t).indexOf("<")},u={};function l(t){var n="";for(var e in t){var o=t[e];null!=o&&""!==o&&(n&&(n+=" "),n+="-"==e[0]?e:u[e]||(u[e]=e.replace(/([A-Z])/g,"-$1").toLowerCase()),n+=": ",n+=o,"number"==typeof o&&!1===r.test(e)&&(n+="px"),n+=";")}return n||void 0}function f(t,n){for(var e in n)t[e]=n[e];return t}function s(t,n){return Array.isArray(n)?n.reduce(s,t):null!=n&&!1!==n&&t.push(n),t}var p={shallow:!0},y=[],g=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,b=/[\s\n\\/='"\0<>]/,d=function(){};v.render=v;var m=[];function v(n,e,r){e=e||{},r=r||{};var o=t.__s;t.__s=!0;var i=h(n,e,r);return t.__c&&t.__c(n,m),m.length=0,t.__s=o,i}function h(e,r,o,u,p,m){if(null==e||"boolean"==typeof e)return"";if("object"!=typeof e)return i(e);var v=o.pretty,_=v&&"string"==typeof v?v:"\t";if(Array.isArray(e)){for(var x="",j=0;j<e.length;j++)v&&j>0&&(x+="\n"),x+=h(e[j],r,o,u,p,m);return x}var S,A=e.type,O=e.props,w=!1;if("function"==typeof A){if(w=!0,!o.shallow||!u&&!1!==o.renderRootComponent){if(A===n){var k=[];return s(k,e.props.children),h(k,r,o,!1!==o.shallowHighOrder,p,m)}var F,E=e.__c={__v:e,context:r,props:e.props,setState:d,forceUpdate:d,data:{}};t.__b&&t.__b(e);var C=function(t,n){return{type:t.type,props:t.props,data:{},c:n}}(e,r);if(t.__r&&t.__r(C),A.prototype&&"function"==typeof A.prototype.render){var M=A.contextType,N=M&&r[M.__c],D=null!=M?N?N.props.value:M.__:r;(E=e.__c=new A(O,D)).__v=e,E._dirty=E.__d=!0,E.props=O,null==E.state&&(E.state={}),null==E._nextState&&null==E.__s&&(E._nextState=E.__s=E.state),E.context=D,A.getDerivedStateFromProps?E.state=f(f({},E.state),A.getDerivedStateFromProps(E.props,E.state)):E.componentWillMount&&(E.componentWillMount(),E.state=E._nextState!==E.state?E._nextState:E.__s!==E.state?E.__s:E.state),F=E.render(E.props,E.state,E.context)}else{var H=A.contextType,I=H&&r[H.__c];F=A.call(e.__c,O,null!=H?I?I.props.value:H.__:r)}return E.getChildContext&&(r=f(f({},r),E.getChildContext())),t.diffed&&t.diffed(e),h(F,r,o,!1!==o.shallowHighOrder,p,m)}A=(S=A).displayName||S!==Function&&S.name||function(t){var n=(Function.prototype.toString.call(t).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!n){for(var e=-1,r=y.length;r--;)if(y[r]===t){e=r;break}e<0&&(e=y.push(t)-1),n="UnnamedComponent"+e}return n}(S)}var $,U,W="<"+A;if(O){var L=Object.keys(O);o&&!0===o.sortAttributes&&L.sort();for(var P=0;P<L.length;P++){var T=L[P],R=O[T];if("children"!==T){if(!b.test(T)&&(o&&o.allAttributes||"key"!==T&&"ref"!==T&&"__self"!==T&&"__source"!==T)){if("defaultValue"===T)T="value";else if("className"===T){if(void 0!==O.class)continue;T="class"}else p&&T.match(/^xlink:?./)&&(T=T.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===T){if(O.for)continue;T="for"}"style"===T&&R&&"object"==typeof R&&(R=l(R)),"a"===T[0]&&"r"===T[1]&&"boolean"==typeof R&&(R=String(R));var J=o.attributeHook&&o.attributeHook(T,R,r,o,w);if(J||""===J)W+=J;else if("dangerouslySetInnerHTML"===T)U=R&&R.__html;else if("textarea"===A&&"value"===T)$=R;else if((R||0===R||""===R)&&"function"!=typeof R){if(!(!0!==R&&""!==R||(R=T,o&&o.xml))){W+=" "+T;continue}if("value"===T){if("select"===A){m=R;continue}"option"===A&&m==R&&(W+=" selected")}W+=" "+T+'="'+i(R)+'"'}}}else $=R}}if(v){var V=W.replace(/\n\s*/," ");V===W||~V.indexOf("\n")?v&&~W.indexOf("\n")&&(W+="\n"):W=V}if(W+=">",b.test(A))throw new Error(A+" is not a valid HTML tag name in "+W);var q,z=g.test(A)||o.voidElements&&o.voidElements.test(A),B=[];if(U)v&&c(U)&&(U="\n"+_+a(U,_)),W+=U;else if(null!=$&&s(q=[],$).length){for(var G=v&&~W.indexOf("\n"),Z=!1,K=0;K<q.length;K++){var Q=q[K];if(null!=Q&&!1!==Q){var X=h(Q,r,o,!0,"svg"===A||"foreignObject"!==A&&p,m);if(v&&!G&&c(X)&&(G=!0),X)if(v){var Y=X.length>0&&"<"!=X[0];Z&&Y?B[B.length-1]+=X:B.push(X),Z=Y}else B.push(X)}}if(v&&G)for(var tt=B.length;tt--;)B[tt]="\n"+_+a(B[tt],_)}if(B.length||U)W+=B.join("");else if(o&&o.xml)return W.substring(0,W.length-1)+" />";return!z||q||U?(v&&~W.indexOf("\n")&&(W+="\n"),W+="</"+A+">"):W=W.replace(/>$/," />"),W}v.shallowRender=function(t,n){return v(t,n,p)};const _=/(\\|\"|\')/g,x=Object.prototype.toString,j=Date.prototype.toISOString,S=Error.prototype.toString,A=RegExp.prototype.toString,O=Symbol.prototype.toString,w=/^Symbol\((.*)\)(.*)$/,k=/\n/gi,F=Object.getOwnPropertySymbols||(t=>[]);function E(t){return"[object Array]"===t||"[object ArrayBuffer]"===t||"[object DataView]"===t||"[object Float32Array]"===t||"[object Float64Array]"===t||"[object Int8Array]"===t||"[object Int16Array]"===t||"[object Int32Array]"===t||"[object Uint8Array]"===t||"[object Uint8ClampedArray]"===t||"[object Uint16Array]"===t||"[object Uint32Array]"===t}function C(t){return""===t.name?"[Function anonymous]":"[Function "+t.name+"]"}function M(t){return O.call(t).replace(w,"Symbol($1)")}function N(t){return"["+S.call(t)+"]"}function D(t){if(!0===t||!1===t)return""+t;if(void 0===t)return"undefined";if(null===t)return"null";const n=typeof t;if("number"===n)return function(t){return t!=+t?"NaN":0===t&&1/t<0?"-0":""+t}(t);if("string"===n)return'"'+function(t){return t.replace(_,"\\$1")}(t)+'"';if("function"===n)return C(t);if("symbol"===n)return M(t);const e=x.call(t);return"[object WeakMap]"===e?"WeakMap {}":"[object WeakSet]"===e?"WeakSet {}":"[object Function]"===e||"[object GeneratorFunction]"===e?C(t,min):"[object Symbol]"===e?M(t):"[object Date]"===e?j.call(t):"[object Error]"===e?N(t):"[object RegExp]"===e?A.call(t):"[object Arguments]"===e&&0===t.length?"Arguments []":E(e)&&0===t.length?t.constructor.name+" []":t instanceof Error&&N(t)}function H(t,n,e,r,o,i,a,c,u,l){let f="";if(t.length){f+=o;const s=e+n;for(let e=0;e<t.length;e++)f+=s+U(t[e],n,s,r,o,i,a,c,u,l),e<t.length-1&&(f+=","+r);f+=o+e}return"["+f+"]"}function I(t,n,e,r,o,i,a,c,u,l){if((i=i.slice()).indexOf(t)>-1)return"[Circular]";i.push(t);const f=++c>a;if(!f&&t.toJSON&&"function"==typeof t.toJSON)return U(t.toJSON(),n,e,r,o,i,a,c,u,l);const s=x.call(t);return"[object Arguments]"===s?f?"[Arguments]":function(t,n,e,r,o,i,a,c,u,l){return(l?"":"Arguments ")+H(t,n,e,r,o,i,a,c,u,l)}(t,n,e,r,o,i,a,c,u,l):E(s)?f?"[Array]":function(t,n,e,r,o,i,a,c,u,l){return(l?"":t.constructor.name+" ")+H(t,n,e,r,o,i,a,c,u,l)}(t,n,e,r,o,i,a,c,u,l):"[object Map]"===s?f?"[Map]":function(t,n,e,r,o,i,a,c,u,l){let f="Map {";const s=t.entries();let p=s.next();if(!p.done){f+=o;const t=e+n;for(;!p.done;)f+=t+U(p.value[0],n,t,r,o,i,a,c,u,l)+" => "+U(p.value[1],n,t,r,o,i,a,c,u,l),p=s.next(),p.done||(f+=","+r);f+=o+e}return f+"}"}(t,n,e,r,o,i,a,c,u,l):"[object Set]"===s?f?"[Set]":function(t,n,e,r,o,i,a,c,u,l){let f="Set {";const s=t.entries();let p=s.next();if(!p.done){f+=o;const t=e+n;for(;!p.done;)f+=t+U(p.value[1],n,t,r,o,i,a,c,u,l),p=s.next(),p.done||(f+=","+r);f+=o+e}return f+"}"}(t,n,e,r,o,i,a,c,u,l):"object"==typeof t?f?"[Object]":function(t,n,e,r,o,i,a,c,u,l){let f=(l?"":t.constructor?t.constructor.name+" ":"Object ")+"{",s=Object.keys(t).sort();const p=F(t);if(p.length&&(s=s.filter(t=>!("symbol"==typeof t||"[object Symbol]"===x.call(t))).concat(p)),s.length){f+=o;const p=e+n;for(let e=0;e<s.length;e++){const y=s[e];f+=p+U(y,n,p,r,o,i,a,c,u,l)+": "+U(t[y],n,p,r,o,i,a,c,u,l),e<s.length-1&&(f+=","+r)}f+=o+e}return f+"}"}(t,n,e,r,o,i,a,c,u,l):void 0}function $(t,n,e,r,o,i,a,c,u,l){let f,s=!1;for(let n=0;n<u.length;n++)if(f=u[n],f.test(t)){s=!0;break}return!!s&&f.print(t,function(t){return U(t,n,e,r,o,i,a,c,u,l)},function(t){const r=e+n;return r+t.replace(k,"\n"+r)},{edgeSpacing:o,spacing:r})}function U(t,n,e,r,o,i,a,c,u,l){return D(t)||$(t,n,e,r,o,i,a,c,u,l)||I(t,n,e,r,o,i,a,c,u,l)}const W={indent:2,min:!1,maxDepth:Infinity,plugins:[]};function L(t){return new Array(t+1).join(" ")}var P={test:function(t){return t&&"object"==typeof t&&"type"in t&&"props"in t&&"key"in t},print:function(t,n,e){return v(t,P.context,P.opts)}},T={plugins:[P]},R={attributeHook:function(t,n,e,r,o){var c=typeof n;if("dangerouslySetInnerHTML"===t)return!1;if(null==n||"function"===c&&!r.functions)return"";if(r.skipFalseAttributes&&!o&&(!1===n||("class"===t||"style"===t)&&""===n))return"";var u="string"==typeof r.pretty?r.pretty:"\t";return"string"!==c?("function"!==c||r.functionNames?(P.context=e,P.opts=r,~(n=function(t,n){let e,r;n?(function(t){if(Object.keys(t).forEach(t=>{if(!W.hasOwnProperty(t))throw new Error("prettyFormat: Invalid option: "+t)}),t.min&&void 0!==t.indent&&0!==t.indent)throw new Error("prettyFormat: Cannot run with min option and indent")}(n),n=function(t){const n={};return Object.keys(W).forEach(e=>n[e]=t.hasOwnProperty(e)?t[e]:W[e]),n.min&&(n.indent=0),n}(n)):n=W;const o=n.min?" ":"\n",i=n.min?"":"\n";if(n&&n.plugins.length){e=L(n.indent),r=[];var a=$(t,e,"",o,i,r,n.maxDepth,0,n.plugins,n.min);if(a)return a}return D(t)||(e||(e=L(n.indent)),r||(r=[]),I(t,e,"",o,i,r,n.maxDepth,0,n.plugins,n.min))}(n,T)).indexOf("\n")&&(n=a("\n"+n,u)+"\n")):n="Function",a("\n"+t+"={"+n+"}",u)):"\n"+u+t+'="'+i(n)+'"'},jsx:!0,xml:!1,functions:!0,functionNames:!0,skipFalseAttributes:!0,pretty:" "};function J(t,n,e,r){return v(t,n,e=f(f({},R),e||{}))}export default J;export{J as render};
import{options as t,Fragment as e}from"preact";if("function"!=typeof Symbol){var n=0;Symbol=function(t){return"@@"+t+ ++n},Symbol.for=function(t){return"@@"+t}}var r=/^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,o=/[\s\n\\/='"\0<>]/,i=/^xlink:?./,a=/["&<]/;function c(t){if(0===t.length||!1===a.test(t))return t;for(var e=0,n=0,r="",o="";n<t.length;n++){switch(t.charCodeAt(n)){case 34:o="&quot;";break;case 38:o="&amp;";break;case 60:o="&lt;";break;default:continue}n!==e&&(r+=t.slice(e,n)),r+=o,e=n+1}return n!==e&&(r+=t.slice(e,n)),r}var l=function(t,e){return String(t).replace(/(\n+)/g,"$1"+(e||"\t"))},u=function(t,e,n){return String(t).length>(e||40)||!n&&-1!==String(t).indexOf("\n")||-1!==String(t).indexOf("<")},s={},f=new Set(["animation-iteration-count","border-image-outset","border-image-slice","border-image-width","box-flex","box-flex-group","box-ordinal-group","column-count","fill-opacity","flex","flex-grow","flex-negative","flex-order","flex-positive","flex-shrink","flood-opacity","font-weight","grid-column","grid-row","line-clamp","line-height","opacity","order","orphans","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","widows","z-index","zoom"]),p=/[A-Z]/g;function d(t){var e="";for(var n in t){var r=t[n];if(null!=r&&""!==r){var o="-"==n[0]?n:s[n]||(s[n]=n.replace(p,"-$&").toLowerCase()),i=";";"number"!=typeof r||o.startsWith("--")||f.has(o)||(i="px;"),e=e+o+":"+r+i}}return e||void 0}function g(t,e){return Array.isArray(e)?e.reduce(g,t):null!=e&&!1!==e&&t.push(e),t}function y(){this.__d=!0}function b(t,e){return{__v:t,context:e,props:t.props,setState:y,forceUpdate:y,__d:!0,__h:[]}}var m=[],h=[];function v(e,n,r,o){var i=t.__s;t.__s=!0;try{return _(e,n||{},r,o)}finally{t.__c&&t.__c(e,h),t.__s=i,h.length=0}}function _(n,a,s,f,p,y){if(null==n||"boolean"==typeof n)return"";if("object"!=typeof n)return"function"==typeof n?"":c(n+"");var m=s.pretty,h=m&&"string"==typeof m?m:"\t";if(Array.isArray(n)){for(var v="",j=0;j<n.length;j++)m&&j>0&&(v+="\n"),v+=_(n[j],a,s,f,p,y);return v}if(void 0!==n.constructor)return"";t.__b&&t.__b(n);var S,k=n.type,O=n.props,w=!1;if("function"==typeof k){if(w=!0,!s.shallow||!f&&!1!==s.renderRootComponent){if(k===e){var A=[];return g(A,n.props.children),_(A,a,s,!1!==s.shallowHighOrder,p,y)}var F,C=n.__c=b(n,a),E=t.__r,M=a,H=k.contextType;if(null!=H){var N=a[H.__c];M=N?N.props.value:H.__}if(k.prototype&&"function"==typeof k.prototype.render)(C=n.__c=new k(O,M)).__v=n,C._dirty=C.__d=!0,C.props=O,null==C.state&&(C.state={}),null==C._nextState&&null==C.__s&&(C._nextState=C.__s=C.state),C.context=M,k.getDerivedStateFromProps?C.state=Object.assign({},C.state,k.getDerivedStateFromProps(C.props,C.state)):C.componentWillMount&&(C.componentWillMount(),C.state=C._nextState!==C.state?C._nextState:C.__s!==C.state?C.__s:C.state),E&&E(n),F=C.render(C.props,C.state,C.context);else for(var D=0;C.__d&&D++<25;)C.__d=!1,E&&E(n),F=k.call(n.__c,O,M);C.getChildContext&&(a=Object.assign({},a,C.getChildContext()));var I=_(F,a,s,!1!==s.shallowHighOrder,p,y);return t.diffed&&t.diffed(n),I}k=(S=k).displayName||S!==Function&&S.name||x(S)}var W,$,U="<"+k;if(O){var L=Object.keys(O);s&&!0===s.sortAttributes&&L.sort();for(var P=0;P<L.length;P++){var T=L[P],z=O[T];if("children"!==T){if(!o.test(T)&&(s&&s.allAttributes||"key"!==T&&"ref"!==T&&"__self"!==T&&"__source"!==T)){if("defaultValue"===T)T="value";else if("defaultChecked"===T)T="checked";else if("defaultSelected"===T)T="selected";else if("className"===T){if(void 0!==O.class)continue;T="class"}else p&&i.test(T)&&(T=T.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===T){if(O.for)continue;T="for"}"style"===T&&z&&"object"==typeof z&&(z=d(z)),"a"===T[0]&&"r"===T[1]&&"boolean"==typeof z&&(z=String(z));var J=s.attributeHook&&s.attributeHook(T,z,a,s,w);if(J||""===J)U+=J;else if("dangerouslySetInnerHTML"===T)$=z&&z.__html;else if("textarea"===k&&"value"===T)W=z;else if((z||0===z||""===z)&&"function"!=typeof z){if(!(!0!==z&&""!==z||(z=T,s&&s.xml))){U=U+" "+T;continue}if("value"===T){if("select"===k){y=z;continue}"option"===k&&y==z&&void 0===O.selected&&(U+=" selected")}U=U+" "+T+'="'+c(z+"")+'"'}}}else W=z}}if(m){var R=U.replace(/\n\s*/," ");R===U||~R.indexOf("\n")?m&&~U.indexOf("\n")&&(U+="\n"):U=R}if(U+=">",o.test(k))throw new Error(k+" is not a valid HTML tag name in "+U);var V,q=r.test(k)||s.voidElements&&s.voidElements.test(k),B=[];if($)m&&u($)&&($="\n"+h+l($,h)),U+=$;else if(null!=W&&g(V=[],W).length){for(var G=m&&~U.indexOf("\n"),Z=!1,K=0;K<V.length;K++){var Q=V[K];if(null!=Q&&!1!==Q){var X=_(Q,a,s,!0,"svg"===k||"foreignObject"!==k&&p,y);if(m&&!G&&u(X)&&(G=!0),X)if(m){var Y=X.length>0&&"<"!=X[0];Z&&Y?B[B.length-1]+=X:B.push(X),Z=Y}else B.push(X)}}if(m&&G)for(var tt=B.length;tt--;)B[tt]="\n"+h+l(B[tt],h)}if(t.diffed&&t.diffed(n),B.length||$)U+=B.join("");else if(s&&s.xml)return U.substring(0,U.length-1)+" />";return!q||V||$?(m&&~U.indexOf("\n")&&(U+="\n"),U=U+"</"+k+">"):U=U.replace(/>$/," />"),U}function x(t){var e=(Function.prototype.toString.call(t).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!e){for(var n=-1,r=m.length;r--;)if(m[r]===t){n=r;break}n<0&&(n=m.push(t)-1),e="UnnamedComponent"+n}return e}const j=/(\\|\"|\')/g;var S=function(t){return t.replace(j,"\\$1")};const k=Object.prototype.toString,O=Date.prototype.toISOString,w=Error.prototype.toString,A=RegExp.prototype.toString,F=Symbol.prototype.toString,C=/^Symbol\((.*)\)(.*)$/,E=/\n/gi,M=Object.getOwnPropertySymbols||(t=>[]);function H(t){return"[object Array]"===t||"[object ArrayBuffer]"===t||"[object DataView]"===t||"[object Float32Array]"===t||"[object Float64Array]"===t||"[object Int8Array]"===t||"[object Int16Array]"===t||"[object Int32Array]"===t||"[object Uint8Array]"===t||"[object Uint8ClampedArray]"===t||"[object Uint16Array]"===t||"[object Uint32Array]"===t}function N(t){return t!=+t?"NaN":0===t&&1/t<0?"-0":""+t}function D(t){return""===t.name?"[Function anonymous]":"[Function "+t.name+"]"}function I(t){return F.call(t).replace(C,"Symbol($1)")}function W(t){return"["+w.call(t)+"]"}function $(t){if(!0===t||!1===t)return""+t;if(void 0===t)return"undefined";if(null===t)return"null";const e=typeof t;if("number"===e)return N(t);if("string"===e)return'"'+S(t)+'"';if("function"===e)return D(t);if("symbol"===e)return I(t);const n=k.call(t);return"[object WeakMap]"===n?"WeakMap {}":"[object WeakSet]"===n?"WeakSet {}":"[object Function]"===n||"[object GeneratorFunction]"===n?D(t,min):"[object Symbol]"===n?I(t):"[object Date]"===n?O.call(t):"[object Error]"===n?W(t):"[object RegExp]"===n?A.call(t):"[object Arguments]"===n&&0===t.length?"Arguments []":H(n)&&0===t.length?t.constructor.name+" []":t instanceof Error&&W(t)}function U(t,e,n,r,o,i,a,c,l,u){let s="";if(t.length){s+=o;const f=n+e;for(let n=0;n<t.length;n++)s+=f+q(t[n],e,f,r,o,i,a,c,l,u),n<t.length-1&&(s+=","+r);s+=o+n}return"["+s+"]"}function L(t,e,n,r,o,i,a,c,l,u){return(u?"":"Arguments ")+U(t,e,n,r,o,i,a,c,l,u)}function P(t,e,n,r,o,i,a,c,l,u){return(u?"":t.constructor.name+" ")+U(t,e,n,r,o,i,a,c,l,u)}function T(t,e,n,r,o,i,a,c,l,u){let s="Map {";const f=t.entries();let p=f.next();if(!p.done){s+=o;const t=n+e;for(;!p.done;)s+=t+q(p.value[0],e,t,r,o,i,a,c,l,u)+" => "+q(p.value[1],e,t,r,o,i,a,c,l,u),p=f.next(),p.done||(s+=","+r);s+=o+n}return s+"}"}function z(t,e,n,r,o,i,a,c,l,u){let s=(u?"":t.constructor?t.constructor.name+" ":"Object ")+"{",f=Object.keys(t).sort();const p=M(t);if(p.length&&(f=f.filter(t=>!("symbol"==typeof t||"[object Symbol]"===k.call(t))).concat(p)),f.length){s+=o;const p=n+e;for(let n=0;n<f.length;n++){const d=f[n];s+=p+q(d,e,p,r,o,i,a,c,l,u)+": "+q(t[d],e,p,r,o,i,a,c,l,u),n<f.length-1&&(s+=","+r)}s+=o+n}return s+"}"}function J(t,e,n,r,o,i,a,c,l,u){let s="Set {";const f=t.entries();let p=f.next();if(!p.done){s+=o;const t=n+e;for(;!p.done;)s+=t+q(p.value[1],e,t,r,o,i,a,c,l,u),p=f.next(),p.done||(s+=","+r);s+=o+n}return s+"}"}function R(t,e,n,r,o,i,a,c,l,u){if((i=i.slice()).indexOf(t)>-1)return"[Circular]";i.push(t);const s=++c>a;if(!s&&t.toJSON&&"function"==typeof t.toJSON)return q(t.toJSON(),e,n,r,o,i,a,c,l,u);const f=k.call(t);return"[object Arguments]"===f?s?"[Arguments]":L(t,e,n,r,o,i,a,c,l,u):H(f)?s?"[Array]":P(t,e,n,r,o,i,a,c,l,u):"[object Map]"===f?s?"[Map]":T(t,e,n,r,o,i,a,c,l,u):"[object Set]"===f?s?"[Set]":J(t,e,n,r,o,i,a,c,l,u):"object"==typeof t?s?"[Object]":z(t,e,n,r,o,i,a,c,l,u):void 0}function V(t,e,n,r,o,i,a,c,l,u){let s,f=!1;for(let e=0;e<l.length;e++)if(s=l[e],s.test(t)){f=!0;break}return!!f&&s.print(t,function(t){return q(t,e,n,r,o,i,a,c,l,u)},function(t){const r=n+e;return r+t.replace(E,"\n"+r)},{edgeSpacing:o,spacing:r})}function q(t,e,n,r,o,i,a,c,l,u){return $(t)||V(t,e,n,r,o,i,a,c,l,u)||R(t,e,n,r,o,i,a,c,l,u)}const B={indent:2,min:!1,maxDepth:Infinity,plugins:[]};function G(t){if(Object.keys(t).forEach(t=>{if(!B.hasOwnProperty(t))throw new Error("prettyFormat: Invalid option: "+t)}),t.min&&void 0!==t.indent&&0!==t.indent)throw new Error("prettyFormat: Cannot run with min option and indent")}function Z(t){const e={};return Object.keys(B).forEach(n=>e[n]=t.hasOwnProperty(n)?t[n]:B[n]),e.min&&(e.indent=0),e}function K(t){return new Array(t+1).join(" ")}var Q=function(t,e){let n,r;e?(G(e),e=Z(e)):e=B;const o=e.min?" ":"\n",i=e.min?"":"\n";if(e&&e.plugins.length){n=K(e.indent),r=[];var a=V(t,n,"",o,i,r,e.maxDepth,0,e.plugins,e.min);if(a)return a}return $(t)||(n||(n=K(e.indent)),r||(r=[]),R(t,n,"",o,i,r,e.maxDepth,0,e.plugins,e.min))},X={test:function(t){return t&&"object"==typeof t&&"type"in t&&"props"in t&&"key"in t},print:function(t,e,n){return v(t,X.context,X.opts,!0)}},Y={plugins:[X]},tt={attributeHook:function(t,e,n,r,o){var i=typeof e;if("dangerouslySetInnerHTML"===t)return!1;if(null==e||"function"===i&&!r.functions)return"";if(r.skipFalseAttributes&&!o&&(!1===e||("class"===t||"style"===t)&&""===e))return"";var a="string"==typeof r.pretty?r.pretty:"\t";return"string"!==i?("function"!==i||r.functionNames?(X.context=n,X.opts=r,~(e=Q(e,Y)).indexOf("\n")&&(e=l("\n"+e,a)+"\n")):e="Function",l("\n"+t+"={"+e+"}",a)):"\n"+a+t+'="'+c(e)+'"'},jsx:!0,xml:!1,functions:!0,functionNames:!0,skipFalseAttributes:!0,pretty:" "};function et(t,e,n){var r=Object.assign({},tt,n||{});return r.jsx||(r.attributeHook=null),v(t,e,r)}var nt={shallow:!0};function rt(t,e,n){return et(t,e,Object.assign({},nt,n||{}))}export default et;export{et as render,rt as shallowRender};
//# sourceMappingURL=jsx.module.js.map
module.exports = require('./dist/jsx'); // eslint-disable-line
{
"name": "preact-render-to-string",
"amdName": "preactRenderToString",
"version": "6.0.0-experimental.0",
"version": "6.0.0",
"description": "Render JSX to an HTML string, with support for Preact components.",
"main": "dist/index.js",
"umd:main": "dist/index.js",
"umd:main": "dist/index.umd.js",
"module": "dist/index.module.js",
"jsnext:main": "dist/index.module.js",
"types": "src/index.d.ts",
"exports": {
".": {
"types": "./src/index.d.ts",
"browser": "./dist/index.module.js",
"umd": "./dist/index.umd.js",
"import": "./dist/index.mjs",
"browser": "./dist/index.module.js",
"require": "./dist/index.js"
},
"./jsx": {
"types": "./jsx.d.ts",
"browser": "./dist/jsx.module.js",
"umd": "./dist/jsx.umd.js",
"import": "./dist/jsx.mjs",
"browser": "./dist/jsx.module.js",
"require": "./dist/jsx.js"
},
"./package.json": "./package.json",
"./": "./"
"./package.json": "./package.json"
},
"scripts": {
"bench": "BABEL_ENV=test node -r @babel/register benchmarks index.js",
"bench:v8": "BABEL_ENV=test microbundle benchmarks/index.js -f modern --alias benchmarkjs-pretty=benchmarks/lib/benchmark-lite.js --external none --target node --no-compress --no-sourcemap --raw -o benchmarks/.v8.js && v8 --module benchmarks/.v8.modern.js",
"bench:v8": "BABEL_ENV=test microbundle benchmarks/index.js -f modern --alias benchmarkjs-pretty=benchmarks/lib/benchmark-lite.js --external none --target node --no-compress --no-sourcemap --raw -o benchmarks/.v8.mjs && v8 --module benchmarks/.v8.mjs",
"build": "npm run -s transpile && npm run -s transpile:jsx && npm run -s copy-typescript-definition",
"postbuild": "node ./config/node-13-exports.js && node ./config/node-commonjs.js",
"transpile": "microbundle src/index.js -f es,umd --target web --external preact",
"transpile": "microbundle src/index.js -f es,cjs,umd --target web --external preact",
"transpile:jsx": "microbundle src/jsx.js -o dist/jsx.js --target web --external preact && microbundle dist/jsx.js -o dist/jsx.js -f cjs --external preact",
"copy-typescript-definition": "copyfiles -f src/*.d.ts dist",
"test": "eslint src test && tsc && npm run test:mocha && npm run bench",
"test:mocha": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js test/**/[!compat]*.test.js && npm run test:mocha:compat",
"test:mocha:compat": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js test/compat.test.js",
"test": "eslint src test && tsc && npm run test:mocha && npm run test:mocha:compat && npm run test:mocha:debug && npm run bench",
"test:mocha": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js test/*.test.js",
"test:mocha:compat": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js 'test/compat/index.test.js'",
"test:mocha:debug": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js 'test/debug/index.test.js'",
"format": "prettier src/**/*.{d.ts,js} test/**/*.js --write",

@@ -93,5 +98,9 @@ "prepublishOnly": "npm run build",

},
"minify": {
"compress": {
"reduce_funcs": false
}
},
"author": "Jason Miller <jason@developit.ca>",
"license": "MIT",
"typings": "src/index.d.ts",
"repository": "developit/preact-render-to-string",

@@ -101,3 +110,3 @@ "bugs": "https://github.com/developit/preact-render-to-string/issues",

"peerDependencies": {
"preact": ">=11"
"preact": ">=10"
},

@@ -108,4 +117,4 @@ "devDependencies": {

"@babel/register": "^7.12.10",
"@changesets/changelog-github": "^0.4.1",
"@changesets/cli": "^2.18.0",
"@changesets/changelog-github": "^0.4.1",
"benchmarkjs-pretty": "^2.0.1",

@@ -118,9 +127,10 @@ "chai": "^4.2.0",

"lint-staged": "^10.5.3",
"microbundle": "^0.13.0",
"microbundle": "^0.15.1",
"mocha": "^8.2.1",
"preact": "^11.0.0-experimental.0",
"baseline-rts": "npm:preact-render-to-string@latest",
"preact": "^10.13.0",
"prettier": "^2.2.1",
"sinon": "^9.2.2",
"sinon-chai": "^3.5.0",
"typescript": "^4.1.3"
"typescript": "^5.0.0"
},

@@ -127,0 +137,0 @@ "dependencies": {

@@ -6,3 +6,3 @@ # preact-render-to-string

Render JSX and [Preact] components to an HTML string.
Render JSX and [Preact](https://github.com/preactjs/preact) components to an HTML string.

@@ -13,10 +13,8 @@ Works in Node & the browser, making it useful for universal/isomorphic rendering.

---
### Render JSX/VDOM to HTML
```js
import render from 'preact-render-to-string';
import { render } from 'preact-render-to-string';
import { h } from 'preact';

@@ -32,7 +30,6 @@ /** @jsx h */

### Render Preact Components to HTML
```js
import render from 'preact-render-to-string';
import { render } from 'preact-render-to-string';
import { h, Component } from 'preact';

@@ -44,3 +41,3 @@ /** @jsx h */

render({ name }) {
return <span class="fox">{ name }</span>;
return <span class="fox">{name}</span>;
}

@@ -51,3 +48,3 @@ }

const Box = ({ type, children }) => (
<div class={`box box-${type}`}>{ children }</div>
<div class={`box box-${type}`}>{children}</div>
);

@@ -65,6 +62,4 @@

---
### Render JSX / Preact / Whatever via Express!

@@ -75,3 +70,3 @@

import { h } from 'preact';
import render from 'preact-render-to-string';
import { render } from 'preact-render-to-string';
/** @jsx h */

@@ -82,3 +77,3 @@

<div class="fox">
<h5>{ name }</h5>
<h5>{name}</h5>
<p>This page is all about {name}.</p>

@@ -100,12 +95,62 @@ </div>

---
### `Suspense` & `lazy` components with [`preact/compat`](https://www.npmjs.com/package/preact) & [`preact-ssr-prepass`](https://www.npmjs.com/package/preact-ssr-prepass)
### License
```bash
npm install preact preact-render-to-string preact-ssr-prepass
```
[MIT]
```jsx
export default () => {
return (
<h1>Home page</h1>
)
}
```
```jsx
import { Suspense, lazy } from "preact/compat"
[Preact]: https://github.com/developit/preact
[MIT]: http://choosealicense.com/licenses/mit/
// Creation of the lazy component
const HomePage = lazy(() => import("./pages/home"))
const Main = () => {
return (
<Suspense fallback={<p>Loading</p>}>
<HomePage />
</Suspense>
)
}
```
```jsx
import { render } from "preact-render-to-string"
import prepass from "preact-ssr-prepass"
import { Main } from "./main"
const main = async () => {
// Creation of the virtual DOM
const vdom = <Main />
// Pre-rendering of lazy components
await prepass(vdom)
// Rendering of components
const html = render(vdom)
console.log(html)
// <h1>Home page</h1>
}
// Execution & error handling
main().catch(error => {
console.error(error)
})
```
---
### License
[MIT](http://choosealicense.com/licenses/mit/)
import { VNode } from 'preact';
interface Options {
shallow?: boolean;
xml?: boolean;
pretty?: boolean | string;
}
export function render(vnode: VNode, context?: any, options?: Options): string;
export function renderToString(
vnode: VNode,
context?: any,
options?: Options
): string;
export function shallowRender(vnode: VNode, context?: any): string;
export default render;
export default function renderToString(vnode: VNode, context?: any): string;

@@ -0,52 +1,33 @@

import { encodeEntities, styleObjToCss, UNSAFE_NAME, XLINK } from './util';
import { options, h, Fragment } from 'preact';
import {
encodeEntities,
indent,
isLargeString,
styleObjToCss,
assign,
getChildren,
createInternalFromVnode
} from './util';
import { options, Fragment } from 'preact';
CHILDREN,
COMMIT,
COMPONENT,
DIFF,
DIFFED,
DIRTY,
NEXT_STATE,
PARENT,
RENDER,
SKIP_EFFECTS,
VNODE
} from './constants';
/** @typedef {import('preact').VNode} VNode */
const SHALLOW = { shallow: true };
const EMPTY_ARR = [];
const isArray = Array.isArray;
const assign = Object.assign;
// components without names, kept as a hash for later comparison to return consistent UnnamedComponentXX names.
const UNNAMED = [];
// Global state for the current render pass
let beforeDiff, afterDiff, renderHook, ummountHook;
const VOID_ELEMENTS = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;
const UNSAFE_NAME = /[\s\n\\/='"\0<>]/;
const noop = () => {};
/** Render Preact JSX + Components to an HTML string.
* @name render
* @function
* @param {VNode} vnode JSX VNode to render.
* @param {Object} [context={}] Optionally pass an initial context object through the render path.
* @param {Object} [options={}] Rendering options
* @param {Boolean} [options.shallow=false] If `true`, renders nested Components as HTML elements (`<Foo a="b" />`).
* @param {Boolean} [options.xml=false] If `true`, uses self-closing tags for elements without children.
* @param {Boolean} [options.pretty=false] If `true`, adds whitespace for readability
* @param {RegExp|undefined} [options.voidElements] RegeEx that matches elements that are considered void (self-closing)
/**
* Render Preact JSX + Components to an HTML string.
* @param {VNode} vnode JSX Element / VNode to render
* @param {Object} [context={}] Initial root context object
* @returns {string} serialized HTML
*/
renderToString.render = renderToString;
/** Only render elements, leaving Components inline as `<ComponentName ... />`.
* This method is just a convenience alias for `render(vnode, context, { shallow:true })`
* @name shallow
* @function
* @param {VNode} vnode JSX VNode to render.
* @param {Object} [context={}] Optionally pass an initial context object through the render path.
*/
let shallowRender = (vnode, context) => renderToString(vnode, context, SHALLOW);
const EMPTY_ARR = [];
function renderToString(vnode, context, opts) {
context = context || {};
opts = opts || {};
export default function renderToString(vnode, context) {
// Performance optimization: `renderToString` is synchronous and we

@@ -57,329 +38,293 @@ // therefore don't execute any effects. To do that we pass an empty

// `options._skipEffects` (`__s`) too.
const previousSkipEffects = options.__s;
options.__s = true;
const previousSkipEffects = options[SKIP_EFFECTS];
options[SKIP_EFFECTS] = true;
const res = _renderToString(vnode, context, opts);
// store options hooks once before each synchronous render call
beforeDiff = options[DIFF];
afterDiff = options[DIFFED];
renderHook = options[RENDER];
ummountHook = options.unmount;
// options._commit, we don't schedule any effects in this library right now,
// so we can pass an empty queue to this hook.
if (options.__c) options.__c(vnode, EMPTY_ARR);
EMPTY_ARR.length = 0;
options.__s = previousSkipEffects;
return res;
}
const parent = h(Fragment, null);
parent[CHILDREN] = [vnode];
/** The default export is an alias of `render()`. */
function _renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
if (vnode == null || typeof vnode === 'boolean') {
return '';
try {
return _renderToString(
vnode,
context || EMPTY_OBJ,
false,
undefined,
parent
);
} finally {
// options._commit, we don't schedule any effects in this library right now,
// so we can pass an empty queue to this hook.
if (options[COMMIT]) options[COMMIT](vnode, EMPTY_ARR);
options[SKIP_EFFECTS] = previousSkipEffects;
EMPTY_ARR.length = 0;
}
}
// #text nodes
if (typeof vnode !== 'object') {
return encodeEntities(vnode);
}
// Installed as setState/forceUpdate for function components
function markAsDirty() {
this.__d = true;
}
let pretty = opts.pretty,
indentChar = pretty && typeof pretty === 'string' ? pretty : '\t';
const EMPTY_OBJ = {};
if (Array.isArray(vnode)) {
let rendered = '';
for (let i = 0; i < vnode.length; i++) {
if (pretty && i > 0) rendered += '\n';
rendered += _renderToString(
vnode[i],
context,
opts,
inner,
isSvgMode,
selectValue
);
}
return rendered;
}
/**
* @param {VNode} vnode
* @param {Record<string, unknown>} context
*/
function renderClassComponent(vnode, context) {
let type = /** @type {import("preact").ComponentClass<typeof vnode.props>} */ (vnode.type);
let nodeName = vnode.type,
props = vnode.props,
isComponent = false;
let c = new type(vnode.props, context);
// components
if (typeof nodeName === 'function') {
isComponent = true;
if (opts.shallow && (inner || opts.renderRootComponent === false)) {
nodeName = getComponentName(nodeName);
} else if (nodeName === Fragment) {
const children = [];
getChildren(children, vnode.props.children);
return _renderToString(
children,
context,
opts,
opts.shallowHighOrder !== false,
isSvgMode,
selectValue
);
} else {
let rendered;
vnode[COMPONENT] = c;
c[VNODE] = vnode;
let c = (vnode.__c = {
__v: vnode,
context,
props: vnode.props,
// silently drop state updates
setState: noop,
forceUpdate: noop,
// hooks
data: {}
});
c.props = vnode.props;
c.context = context;
// turn off stateful re-rendering:
c[DIRTY] = true;
// options._diff
if (options.__b) options.__b(vnode);
if (c.state == null) c.state = EMPTY_OBJ;
const internal = createInternalFromVnode(vnode, context);
// options._render
if (options.__r) options.__r(internal);
if (c[NEXT_STATE] == null) {
c[NEXT_STATE] = c.state;
}
if (
!nodeName.prototype ||
typeof nodeName.prototype.render !== 'function'
) {
// Necessary for createContext api. Setting this property will pass
// the context value as `this.context` just for this component.
let cxType = nodeName.contextType;
let provider = cxType && context[cxType.__c];
let cctx =
cxType != null
? provider
? provider.props.value
: cxType.__
: context;
if (type.getDerivedStateFromProps) {
c.state = assign(
{},
c.state,
type.getDerivedStateFromProps(c.props, c.state)
);
} else if (c.componentWillMount) {
c.componentWillMount();
// stateless functional components
rendered = nodeName.call(vnode.__c, props, cctx);
} else {
// class-based components
let cxType = nodeName.contextType;
let provider = cxType && context[cxType.__c];
let cctx =
cxType != null
? provider
? provider.props.value
: cxType.__
: context;
// If the user called setState in cWM we need to flush pending,
// state updates. This is the same behaviour in React.
c.state = c[NEXT_STATE] !== c.state ? c[NEXT_STATE] : c.state;
}
// c = new nodeName(props, context);
c = vnode.__c = new nodeName(props, cctx);
c.__v = vnode;
// turn off stateful re-rendering:
c._dirty = c.__d = true;
c.props = props;
if (c.state == null) c.state = {};
if (renderHook) renderHook(vnode);
if (c._nextState == null && c.__s == null) {
c._nextState = c.__s = c.state;
}
return c.render(c.props, c.state, context);
}
c.context = cctx;
if (nodeName.getDerivedStateFromProps)
c.state = assign(
assign({}, c.state),
nodeName.getDerivedStateFromProps(c.props, c.state)
);
else if (c.componentWillMount) {
c.componentWillMount();
/**
* Recursively render VNodes to HTML.
* @param {VNode|any} vnode
* @param {any} context
* @param {boolean} isSvgMode
* @param {any} selectValue
* @param {VNode} parent
* @returns {string}
*/
function _renderToString(vnode, context, isSvgMode, selectValue, parent) {
// Ignore non-rendered VNodes/values
if (vnode == null || vnode === true || vnode === false || vnode === '') {
return '';
}
// If the user called setState in cWM we need to flush pending,
// state updates. This is the same behaviour in React.
c.state =
c._nextState !== c.state
? c._nextState
: c.__s !== c.state
? c.__s
: c.state;
}
// Text VNodes: escape as HTML
if (typeof vnode !== 'object') {
if (typeof vnode === 'function') return '';
return encodeEntities(vnode + '');
}
rendered = c.render(c.props, c.state, c.context);
}
// Recurse into children / Arrays
if (isArray(vnode)) {
let rendered = '';
parent[CHILDREN] = vnode;
for (let i = 0; i < vnode.length; i++) {
let child = vnode[i];
if (child == null || typeof child === 'boolean') continue;
if (c.getChildContext) {
context = assign(assign({}, context), c.getChildContext());
}
if (options.diffed) options.diffed(vnode);
return _renderToString(
rendered,
context,
opts,
opts.shallowHighOrder !== false,
isSvgMode,
selectValue
);
rendered =
rendered +
_renderToString(child, context, isSvgMode, selectValue, parent);
}
return rendered;
}
// render JSX to HTML
let s = '<' + nodeName,
propChildren,
html;
// VNodes have {constructor:undefined} to prevent JSON injection:
if (vnode.constructor !== undefined) return '';
if (props) {
let attrs = Object.keys(props);
vnode[PARENT] = parent;
if (beforeDiff) beforeDiff(vnode);
// allow sorting lexicographically for more determinism (useful for tests, such as via preact-jsx-chai)
if (opts && opts.sortAttributes === true) attrs.sort();
let type = vnode.type,
props = vnode.props,
cctx = context,
contextType,
rendered,
component;
for (let i = 0; i < attrs.length; i++) {
let name = attrs[i],
v = props[name];
if (name === 'children') {
propChildren = v;
continue;
// Invoke rendering on Components
if (typeof type === 'function') {
if (type === Fragment) {
rendered = props.children;
} else {
contextType = type.contextType;
if (contextType != null) {
let provider = context[contextType.__c];
cctx = provider ? provider.props.value : contextType.__;
}
if (UNSAFE_NAME.test(name)) continue;
if (type.prototype && typeof type.prototype.render === 'function') {
rendered = /**#__NOINLINE__**/ renderClassComponent(vnode, cctx);
component = vnode[COMPONENT];
} else {
component = {
__v: vnode,
props,
context: cctx,
// silently drop state updates
setState: markAsDirty,
forceUpdate: markAsDirty,
__d: true,
// hooks
__h: []
};
vnode[COMPONENT] = component;
if (
!(opts && opts.allAttributes) &&
(name === 'key' ||
name === 'ref' ||
name === '__self' ||
name === '__source')
)
continue;
// If a hook invokes setState() to invalidate the component during rendering,
// re-render it up to 25 times to allow "settling" of memoized states.
// Note:
// This will need to be updated for Preact 11 to use internal.flags rather than component._dirty:
// https://github.com/preactjs/preact/blob/d4ca6fdb19bc715e49fd144e69f7296b2f4daa40/src/diff/component.js#L35-L44
let count = 0;
while (component[DIRTY] && count++ < 25) {
component[DIRTY] = false;
if (name === 'defaultValue') {
name = 'value';
} else if (name === 'className') {
if (typeof props.class !== 'undefined') continue;
name = 'class';
} else if (isSvgMode && name.match(/^xlink:?./)) {
name = name.toLowerCase().replace(/^xlink:?/, 'xlink:');
}
if (renderHook) renderHook(vnode);
if (name === 'htmlFor') {
if (props.for) continue;
name = 'for';
rendered = type.call(component, props, cctx);
}
component[DIRTY] = true;
}
if (name === 'style' && v && typeof v === 'object') {
v = styleObjToCss(v);
if (component.getChildContext != null) {
context = assign({}, context, component.getChildContext());
}
}
// always use string values instead of booleans for aria attributes
// also see https://github.com/preactjs/preact/pull/2347/files
if (name[0] === 'a' && name['1'] === 'r' && typeof v === 'boolean') {
v = String(v);
}
// When a component returns a Fragment node we flatten it in core, so we
// need to mirror that logic here too
let isTopLevelFragment =
rendered != null && rendered.type === Fragment && rendered.key == null;
rendered = isTopLevelFragment ? rendered.props.children : rendered;
let hooked =
opts.attributeHook &&
opts.attributeHook(name, v, context, opts, isComponent);
if (hooked || hooked === '') {
s += hooked;
continue;
}
// Recurse into children before invoking the after-diff hook
const str = _renderToString(
rendered,
context,
isSvgMode,
selectValue,
vnode
);
if (afterDiff) afterDiff(vnode);
vnode[PARENT] = undefined;
if (name === 'dangerouslySetInnerHTML') {
html = v && v.__html;
} else if (nodeName === 'textarea' && name === 'value') {
// <textarea value="a&b"> --> <textarea>a&amp;b</textarea>
propChildren = v;
} else if ((v || v === 0 || v === '') && typeof v !== 'function') {
if (v === true || v === '') {
v = name;
// in non-xml mode, allow boolean attributes
if (!opts || !opts.xml) {
s += ' ' + name;
continue;
}
}
if (ummountHook) ummountHook(vnode);
if (name === 'value') {
if (nodeName === 'select') {
selectValue = v;
continue;
} else if (nodeName === 'option' && selectValue == v) {
s += ` selected`;
}
}
s += ` ${name}="${encodeEntities(v)}"`;
}
}
return str;
}
// account for >1 multiline attribute
if (pretty) {
let sub = s.replace(/\n\s*/, ' ');
if (sub !== s && !~sub.indexOf('\n')) s = sub;
else if (pretty && ~s.indexOf('\n')) s += '\n';
}
// Serialize Element VNodes to HTML
let s = '<' + type,
html = '',
children;
s += '>';
for (let name in props) {
let v = props[name];
if (UNSAFE_NAME.test(nodeName))
throw new Error(`${nodeName} is not a valid HTML tag name in ${s}`);
switch (name) {
case 'children':
children = v;
continue;
let isVoid =
VOID_ELEMENTS.test(nodeName) ||
(opts.voidElements && opts.voidElements.test(nodeName));
let pieces = [];
// VDOM-specific props
case 'key':
case 'ref':
case '__self':
case '__source':
continue;
let children;
if (html) {
// if multiline, indent.
if (pretty && isLargeString(html)) {
html = '\n' + indentChar + indent(html, indentChar);
}
s += html;
} else if (
propChildren != null &&
getChildren((children = []), propChildren).length
) {
let hasLarge = pretty && ~s.indexOf('\n');
let lastWasText = false;
// prefer for/class over htmlFor/className
case 'htmlFor':
if ('for' in props) continue;
name = 'for';
break;
case 'className':
if ('class' in props) continue;
name = 'class';
break;
for (let i = 0; i < children.length; i++) {
let child = children[i];
// Form element reflected properties
case 'defaultChecked':
name = 'checked';
break;
case 'defaultSelected':
name = 'selected';
break;
if (child != null && child !== false) {
let childSvgMode =
nodeName === 'svg'
? true
: nodeName === 'foreignObject'
? false
: isSvgMode,
ret = _renderToString(
child,
context,
opts,
true,
childSvgMode,
selectValue
);
// Special value attribute handling
case 'defaultValue':
case 'value':
name = 'value';
switch (type) {
// <textarea value="a&b"> --> <textarea>a&amp;b</textarea>
case 'textarea':
children = v;
continue;
if (pretty && !hasLarge && isLargeString(ret)) hasLarge = true;
// <select value> is serialized as a selected attribute on the matching option child
case 'select':
selectValue = v;
continue;
// Skip if we received an empty string
if (ret) {
if (pretty) {
let isText = ret.length > 0 && ret[0] != '<';
// We merge adjacent text nodes, otherwise each piece would be printed
// on a new line.
if (lastWasText && isText) {
pieces[pieces.length - 1] += ret;
} else {
pieces.push(ret);
// Add a selected attribute to <option> if its value matches the parent <select> value
case 'option':
if (selectValue == v && !('selected' in props)) {
s = s + ' selected';
}
break;
}
break;
lastWasText = isText;
} else {
pieces.push(ret);
}
case 'dangerouslySetInnerHTML':
html = v && v.__html;
continue;
// serialize object styles to a CSS string
case 'style':
if (typeof v === 'object') {
v = styleObjToCss(v);
}
break;
default: {
if (isSvgMode && XLINK.test(name)) {
name = name.toLowerCase().replace(XLINK_REPLACE_REGEX, 'xlink:');
} else if (UNSAFE_NAME.test(name)) {
continue;
} else if ((name[4] === '-' || name === 'draggable') && v != null) {
// serialize boolean aria-xyz or draggable attribute values as strings
// `draggable` is an enumerated attribute and not Boolean. A value of `true` or `false` is mandatory
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable
v += '';
}
}
}
if (pretty && hasLarge) {
for (let i = pieces.length; i--; ) {
pieces[i] = '\n' + indentChar + indent(pieces[i], indentChar);
// write this attribute to the buffer
if (v != null && v !== false && typeof v !== 'function') {
if (v === true || v === '') {
s = s + ' ' + name;
} else {
s = s + ' ' + name + '="' + encodeEntities(v + '') + '"';
}

@@ -389,55 +334,50 @@ }

if (pieces.length || html) {
s += pieces.join('');
} else if (opts && opts.xml) {
return s.substring(0, s.length - 1) + ' />';
if (UNSAFE_NAME.test(type)) {
// this seems to performs a lot better than throwing
// return '<!-- -->';
throw new Error(`${type} is not a valid HTML tag name in ${s}>`);
}
if (isVoid && !children && !html) {
s = s.replace(/>$/, ' />');
} else {
if (pretty && ~s.indexOf('\n')) s += '\n';
s += `</${nodeName}>`;
if (html) {
// dangerouslySetInnerHTML defined this node's contents
} else if (typeof children === 'string') {
// single text child
html = encodeEntities(children);
} else if (children != null && children !== false && children !== true) {
// recurse into this element VNode's children
let childSvgMode =
type === 'svg' || (type !== 'foreignObject' && isSvgMode);
html = _renderToString(children, context, childSvgMode, selectValue, vnode);
}
return s;
}
if (afterDiff) afterDiff(vnode);
vnode[PARENT] = undefined;
if (ummountHook) ummountHook(vnode);
function getComponentName(component) {
return (
component.displayName ||
(component !== Function && component.name) ||
getFallbackComponentName(component)
);
}
// Emit self-closing tag for empty void elements:
if (!html && SELF_CLOSING.has(type)) {
return s + '/>';
}
function getFallbackComponentName(component) {
let str = Function.prototype.toString.call(component),
name = (str.match(/^\s*function\s+([^( ]+)/) || '')[1];
if (!name) {
// search for an existing indexed name for the given component:
let index = -1;
for (let i = UNNAMED.length; i--; ) {
if (UNNAMED[i] === component) {
index = i;
break;
}
}
// not found, create a new indexed name:
if (index < 0) {
index = UNNAMED.push(component) - 1;
}
name = `UnnamedComponent${index}`;
}
return name;
return s + '>' + html + '</' + type + '>';
}
renderToString.shallowRender = shallowRender;
export default renderToString;
export {
renderToString as render,
renderToString as renderToStaticMarkup,
renderToString,
shallowRender
};
const XLINK_REPLACE_REGEX = /^xlink:?/;
const SELF_CLOSING = new Set([
'area',
'base',
'br',
'col',
'command',
'embed',
'hr',
'img',
'input',
'keygen',
'link',
'meta',
'param',
'source',
'track',
'wbr'
]);

@@ -6,9 +6,17 @@ import { VNode } from 'preact';

xml?: boolean;
pretty?: boolean | string;
shallow?: boolean;
functions?: boolean;
functionNames?: boolean;
skipFalseAttributes?: boolean;
pretty?: boolean | string;
}
export function render(vnode: VNode, context?: any, options?: Options): string;
export default function renderToStringPretty(
vnode: VNode,
context?: any,
options?: Options
): string;
export function shallowRender(vnode: VNode, context?: any): string;
export default render;
import './polyfills';
import renderToString from './index';
import { indent, encodeEntities, assign } from './util';
import renderToString from './pretty';
import { indent, encodeEntities } from './util';
import prettyFormat from 'pretty-format';
/** @typedef {import('preact').VNode} VNode */
// we have to patch in Array support, Possible issue in npm.im/pretty-format

@@ -70,8 +72,34 @@ let preactPlugin = {

function renderToJsxString(vnode, context, opts, inner) {
opts = assign(assign({}, defaultOpts), opts || {});
return renderToString(vnode, context, opts, inner);
/**
* Render Preact JSX + Components to a pretty-printed HTML-like string.
* @param {VNode} vnode JSX Element / VNode to render
* @param {Object} [context={}] Initial root context object
* @param {Object} [options={}] Rendering options
* @param {Boolean} [options.jsx=true] Generate JSX/XML output instead of HTML
* @param {Boolean} [options.xml=false] Use self-closing tags for elements without children
* @param {Boolean} [options.shallow=false] Serialize nested Components (`<Foo a="b" />`) instead of rendering
* @param {Boolean} [options.pretty=false] Add whitespace for readability
* @param {RegExp|undefined} [options.voidElements] RegeEx to define which element types are self-closing
* @returns {String} a pretty-printed HTML-like string
*/
export default function renderToStringPretty(vnode, context, options) {
const opts = Object.assign({}, defaultOpts, options || {});
if (!opts.jsx) opts.attributeHook = null;
return renderToString(vnode, context, opts);
}
export { renderToStringPretty as render };
export default renderToJsxString;
export { renderToJsxString as render };
const SHALLOW = { shallow: true };
/** Only render elements, leaving Components inline as `<ComponentName ... />`.
* This method is just a convenience alias for `render(vnode, context, { shallow:true })`
* @name shallow
* @function
* @param {VNode} vnode JSX VNode to render.
* @param {Object} [context={}] Optionally pass an initial context object through the render path.
* @param {Parameters<typeof renderToStringPretty>[2]} [options] Optionally pass an initial context object through the render path.
*/
export function shallowRender(vnode, context, options) {
const opts = Object.assign({}, SHALLOW, options || {});
return renderToStringPretty(vnode, context, opts);
}

@@ -0,0 +0,0 @@ if (typeof Symbol !== 'function') {

@@ -0,16 +1,41 @@

export const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;
export const UNSAFE_NAME = /[\s\n\\/='"\0<>]/;
export const XLINK = /^xlink:?./;
// DOM properties that should NOT have "px" added when numeric
export const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;
const ENCODED_ENTITIES = /["&<]/;
const ENCODED_ENTITIES = /[&<>"]/;
/** @param {string} str */
export function encodeEntities(str) {
// Skip all work for strings with no entities needing encoding:
if (str.length === 0 || ENCODED_ENTITIES.test(str) === false) return str;
export function encodeEntities(input) {
const s = String(input);
if (!ENCODED_ENTITIES.test(s)) {
return s;
let last = 0,
i = 0,
out = '',
ch = '';
// Seek forward in str until the next entity char:
for (; i < str.length; i++) {
switch (str.charCodeAt(i)) {
case 34:
ch = '&quot;';
break;
case 38:
ch = '&amp;';
break;
case 60:
ch = '&lt;';
break;
default:
continue;
}
// Append skipped/buffered characters and the encoded entity:
if (i !== last) out += str.slice(last, i);
out += ch;
// Start the next seek/buffer after the entity's offset:
last = i + 1;
}
return s
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
if (i !== last) out += str.slice(last, i);
return out;
}

@@ -28,2 +53,40 @@

const IS_NON_DIMENSIONAL = new Set([
'animation-iteration-count',
'border-image-outset',
'border-image-slice',
'border-image-width',
'box-flex',
'box-flex-group',
'box-ordinal-group',
'column-count',
'fill-opacity',
'flex',
'flex-grow',
'flex-negative',
'flex-order',
'flex-positive',
'flex-shrink',
'flood-opacity',
'font-weight',
'grid-column',
'grid-row',
'line-clamp',
'line-height',
'opacity',
'order',
'orphans',
'stop-opacity',
'stroke-dasharray',
'stroke-dashoffset',
'stroke-miterlimit',
'stroke-opacity',
'stroke-width',
'tab-size',
'widows',
'z-index',
'zoom'
]);
const CSS_REGEX = /[A-Z]/g;
// Convert an Object style to a CSSText string

@@ -35,15 +98,18 @@ export function styleObjToCss(s) {

if (val != null && val !== '') {
if (str) str += ' ';
// str += jsToCss(prop);
str +=
const name =
prop[0] == '-'
? prop
: JS_TO_CSS[prop] ||
(JS_TO_CSS[prop] = prop.replace(/([A-Z])/g, '-$1').toLowerCase());
str += ': ';
str += val;
if (typeof val === 'number' && IS_NON_DIMENSIONAL.test(prop) === false) {
str += 'px';
(JS_TO_CSS[prop] = prop.replace(CSS_REGEX, '-$&').toLowerCase());
let suffix = ';';
if (
typeof val === 'number' &&
// Exclude custom-attributes
!name.startsWith('--') &&
!IS_NON_DIMENSIONAL.has(name)
) {
suffix = 'px;';
}
str += ';';
str = str + name + ':' + val + suffix;
}

@@ -55,14 +121,2 @@ }

/**
* Copy all properties from `props` onto `obj`.
* @param {object} obj Object onto which properties should be copied.
* @param {object} props Object from which to copy properties.
* @returns {object}
* @private
*/
export function assign(obj, props) {
for (let i in props) obj[i] = props[i];
return obj;
}
/**
* Get flattened children from the children prop

@@ -83,9 +137,18 @@ * @param {Array} accumulator

export function createInternalFromVnode(vnode, context) {
function markAsDirty() {
this.__d = true;
}
export function createComponent(vnode, context) {
return {
type: vnode.type,
__v: vnode,
context,
props: vnode.props,
data: {},
c: context
// silently drop state updates
setState: markAsDirty,
forceUpdate: markAsDirty,
__d: true,
// hooks
__h: []
};
}

@@ -0,0 +0,0 @@ {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc