site/node_modules/preact-render-to-string/dist/index.mjs
2024-10-14 08:09:33 +02:00

3 lines
7.9 KiB
JavaScript

import{options as e,h as t,Fragment as r}from"preact";var n=/[\s\n\\/='"\0<>]/,o=/^(xlink|xmlns|xml)([A-Z])/,i=/^accessK|^auto[A-Z]|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|readO|rowS|spellC|src[A-Z]|tabI|item[A-Z]/,a=/^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/,c=/["&<]/;function s(e){if(0===e.length||!1===c.test(e))return e;for(var t=0,r=0,n="",o="";r<e.length;r++){switch(e.charCodeAt(r)){case 34:o="&quot;";break;case 38:o="&amp;";break;case 60:o="&lt;";break;default:continue}r!==t&&(n+=e.slice(t,r)),n+=o,t=r+1}return r!==t&&(n+=e.slice(t,r)),n}var l={},u=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"]),f=/[A-Z]/g;function p(e){var t="";for(var r in e){var n=e[r];if(null!=n&&""!==n){var o="-"==r[0]?r:l[r]||(l[r]=r.replace(f,"-$&").toLowerCase()),i=";";"number"!=typeof n||o.startsWith("--")||u.has(o)||(i="px;"),t=t+o+":"+n+i}}return t||void 0}function h(e,t,r){if(!e.s){if(r instanceof d){if(!r.s)return void(r.o=h.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(h.bind(null,e,t),h.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var d=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var i=1&o?t:r;if(i){try{h(n,1,i(this.v))}catch(e){h(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?h(n,1,t?t(o):o):r?h(n,1,r(o)):h(n,2,o)}catch(e){h(n,2,e)}},n},e}();function _(e){return e instanceof d&&1&e.s}function v(e,t,r){for(var n;;){var o=e();if(_(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(!_(i)){n=1;break}i=i.s}if(t){var a=t();if(a&&a.then&&!_(a)){n=2;break}}}var c=new d,s=h.bind(null,c,2);return(0===n?o.then(u):1===n?i.then(l):a.then(f)).then(void 0,s),c;function l(n){i=n;do{if(t&&(a=t())&&a.then&&!_(a))return void a.then(f).then(void 0,s);if(!(o=e())||_(o)&&!o.v)return void h(c,1,i);if(o.then)return void o.then(u).then(void 0,s);_(i=r())&&(i=i.v)}while(!i||!i.then);i.then(l).then(void 0,s)}function u(e){e?(i=r())&&i.then?i.then(l).then(void 0,s):l(i):h(c,1,i)}function f(){(o=e())?o.then?o.then(u).then(void 0,s):u(o):h(c,1,i)}}function y(e,t){try{var r=e()}catch(e){return t(!0,e)}return r&&r.then?r.then(t.bind(null,!1),t.bind(null,!0)):t(!1,r)}var m,g,b,k,x=function(n,o){try{var i,a=e.__s;e.__s=!0,m=e.__b,g=e.diffed,b=e.__r,k=e.unmount;var c=t(r,null);return c.__k=[n],Promise.resolve(y(function(){var e=T(n,o||D,!1,void 0,c,!0),t=function(){if(Array.isArray(e)){var t=function(){var e=n.join("");return i=1,e},r=0,n=e,o=v(function(){return!!n.some(function(e){return"function"==typeof e.then})&&r++<25},void 0,function(){return Promise.resolve(Promise.all(n)).then(function(e){n=e.flat()})});return o&&o.then?o.then(t):t()}}();return t&&t.then?t.then(function(t){return i?t:e}):i?t:e},function(t,r){if(e.__c&&e.__c(n,w),e.__s=a,w.length=0,t)throw r;return r}))}catch(e){return Promise.reject(e)}},w=[],A=Array.isArray,C=Object.assign;function S(n,o){var i=e.__s;e.__s=!0,m=e.__b,g=e.diffed,b=e.__r,k=e.unmount;var a=t(r,null);a.__k=[n];try{return T(n,o||D,!1,void 0,a,!1)}catch(e){if(e.then)throw new Error('Use "renderToStringAsync" for suspenseful rendering.');throw e}finally{e.__c&&e.__c(n,w),e.__s=i,w.length=0}}function L(){this.__d=!0}var D={};function E(e,t){var r,n=e.type,o=!0;return e.__c?(o=!1,(r=e.__c).state=r.__s):r=new n(e.props,t),e.__c=r,r.__v=e,r.props=e.props,r.context=t,r.__d=!0,null==r.state&&(r.state=D),null==r.__s&&(r.__s=r.state),n.getDerivedStateFromProps?r.state=C({},r.state,n.getDerivedStateFromProps(r.props,r.state)):o&&r.componentWillMount?(r.componentWillMount(),r.state=r.__s!==r.state?r.__s:r.state):!o&&r.componentWillUpdate&&r.componentWillUpdate(),b&&b(e),r.render(r.props,r.state,t)}function T(t,c,l,u,f,h){if(null==t||!0===t||!1===t||""===t)return"";if("object"!=typeof t)return"function"==typeof t?"":s(t+"");if(A(t)){var d,_="";f.__k=t;for(var v=0;v<t.length;v++){var y=t[v];if(null!=y&&"boolean"!=typeof y){var x,w=T(y,c,l,u,f,h);"string"==typeof w?_+=w:(d=d||[],_&&d.push(_),_="",Array.isArray(w)?(x=d).push.apply(x,w):d.push(w))}}return d?(_&&d.push(_),d):_}if(void 0!==t.constructor)return"";t.__=f,m&&m(t);var S,D,P,U=t.type,Z=t.props,F=c;if("function"==typeof U){if(U===r){if(Z.tpl){for(var W="",$=0;$<Z.tpl.length;$++)if(W+=Z.tpl[$],Z.exprs&&$<Z.exprs.length){var M=Z.exprs[$];if(null==M)continue;"object"!=typeof M||void 0!==M.constructor&&!A(M)?W+=M:W+=T(M,c,l,u,t,h)}return W}if(Z.UNSTABLE_comment)return"\x3c!--"+s(Z.UNSTABLE_comment||"")+"--\x3e";D=Z.children}else{if(null!=(S=U.contextType)){var z=c[S.__c];F=z?z.props.value:S.__}if(U.prototype&&"function"==typeof U.prototype.render)D=E(t,F),P=t.__c;else{t.__c=P={__v:t,props:Z,context:F,setState:L,forceUpdate:L,__d:!0,__h:[]};for(var H=0;P.__d&&H++<25;)P.__d=!1,b&&b(t),D=U.call(P,Z,F);P.__d=!0}if(null!=P.getChildContext&&(c=C({},c,P.getChildContext())),(U.getDerivedStateFromError||P.componentDidCatch)&&e.errorBoundaries){var q="";D=null!=D&&D.type===r&&null==D.key?D.props.children:D;try{return q=T(D,c,l,u,t,h)}catch(e){return U.getDerivedStateFromError&&(P.__s=U.getDerivedStateFromError(e)),P.componentDidCatch&&P.componentDidCatch(e,{}),P.__d&&(D=E(t,c),null!=(P=t.__c).getChildContext&&(c=C({},c,P.getChildContext())),q=T(D=null!=D&&D.type===r&&null==D.key?D.props.children:D,c,l,u,t,h)),q}finally{g&&g(t),t.__=null,k&&k(t)}}}D=null!=D&&D.type===r&&null==D.key&&null==D.props.tpl?D.props.children:D;try{var B=T(D,c,l,u,t,h);return g&&g(t),t.__=null,k&&k(t),B}catch(e){if(!h)throw e;if(!e||"function"!=typeof e.then)throw e;var I=function e(){try{return T(D,c,l,u,t,h)}catch(r){if(!r||"function"!=typeof r.then)throw r;return r.then(function(){return T(D,c,l,u,t,h)},function(){return e()})}};return e.then(function(){return I()})}}var N,O="<"+U,R="";for(var V in Z){var K=Z[V];switch(V){case"children":N=K;continue;case"key":case"ref":case"__self":case"__source":continue;case"htmlFor":if("for"in Z)continue;V="for";break;case"className":if("class"in Z)continue;V="class";break;case"defaultChecked":V="checked";break;case"defaultSelected":V="selected";break;case"defaultValue":case"value":switch(V="value",U){case"textarea":N=K;continue;case"select":u=K;continue;case"option":u!=K||"selected"in Z||(O+=" selected")}break;case"dangerouslySetInnerHTML":R=K&&K.__html;continue;case"style":"object"==typeof K&&(K=p(K));break;case"acceptCharset":V="accept-charset";break;case"httpEquiv":V="http-equiv";break;default:if(o.test(V))V=V.replace(o,"$1:$2").toLowerCase();else{if(n.test(V))continue;"-"!==V[4]&&"draggable"!==V||null==K?l?a.test(V)&&(V="panose1"===V?"panose-1":V.replace(/([A-Z])/g,"-$1").toLowerCase()):i.test(V)&&(V=V.toLowerCase()):K+=""}}null!=K&&!1!==K&&"function"!=typeof K&&(O=!0===K||""===K?O+" "+V:O+" "+V+'="'+s(K+"")+'"')}if(n.test(U))throw new Error(U+" is not a valid HTML tag name in "+O+">");if(R||("string"==typeof N?R=s(N):null!=N&&!1!==N&&!0!==N&&(R=T(N,c,"svg"===U||"foreignObject"!==U&&l,u,t,h))),g&&g(t),t.__=null,k&&k(t),!R&&j.has(U))return O+"/>";var G="</"+U+">",J=O+">";return Array.isArray(R)?[J].concat(R,[G]):"string"!=typeof R?[J,R,G]:J+R+G}var j=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),P=S,U=S;export default S;export{P as render,U as renderToStaticMarkup,S as renderToString,x as renderToStringAsync};
//# sourceMappingURL=index.module.js.map