able-baker/bundled/preact/ssr.mjs

9 lines
8.0 KiB
JavaScript

///<reference types="https://esm.sh/v135/preact-render-to-string@6.4.2/src/index.d.ts"/>
/* esm.sh - esbuild bundle(preact-render-to-string@6.4.2) denonext production */
import
{options as u,h as V,Fragment as E}
from"./compat.js";
var J=/[\s\n\\/='"\0<>]/,M=/^(xlink|xmlns|xml)([A-Z])/,oe=/^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]/,ae=/^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/,ie=/["&<]/;function H(e){if(e.length===0||ie.test(e)===!1)return e;for(var n=0,t=0,r="",a="";t<e.length;t++){switch(e.charCodeAt(t)){case 34:a="&quot;";break;case 38:a="&amp;";break;case 60:a="&lt;";break;default:continue}t!==n&&(r+=e.slice(n,t)),r+=a,n=t+1}return t!==n&&(r+=e.slice(n,t)),r}var Q={},se=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"]),ce=/[A-Z]/g;function le(e){var n="";for(var t in e){var r=e[t];if(r!=null&&r!==""){var a=t[0]=="-"?t:Q[t]||(Q[t]=t.replace(ce,"-$&").toLowerCase()),o=";";typeof r!="number"||a.startsWith("--")||se.has(a)||(o="px;"),n=n+a+":"+r+o}}return n||void 0}function y(e,n,t){if(!e.s){if(t instanceof W){if(!t.s)return void(t.o=y.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(y.bind(null,e,n),y.bind(null,e,2));e.s=n,e.v=t;let r=e.o;r&&r(e)}}var W=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,a=this.s;if(a){var o=1&a?n:t;if(o){try{y(r,1,o(this.v))}catch(i){y(r,2,i)}return r}return this}return this.o=function(i){try{var l=i.v;1&i.s?y(r,1,n?n(l):l):t?y(r,1,t(l)):y(r,2,l)}catch(_){y(r,2,_)}},r},e}();function D(e){return e instanceof W&&1&e.s}function ue(e,n,t){for(var r;;){var a=e();if(D(a)&&(a=a.v),!a)return o;if(a.then){r=0;break}var o=t();if(o&&o.then){if(!D(o)){r=1;break}o=o.s}if(n){var i=n();if(i&&i.then&&!D(i)){r=2;break}}}var l=new W,_=y.bind(null,l,2);return(r===0?a.then(g):r===1?o.then(m):i.then(v)).then(void 0,_),l;function m(S){o=S;do{if(n&&(i=n())&&i.then&&!D(i))return void i.then(v).then(void 0,_);if(!(a=e())||D(a)&&!a.v)return void y(l,1,o);if(a.then)return void a.then(g).then(void 0,_);D(o=t())&&(o=o.v)}while(!o||!o.then);o.then(m).then(void 0,_)}function g(S){S?(o=t())&&o.then?o.then(m).then(void 0,_):m(o):y(l,1,o)}function v(){(a=e())?a.then?a.then(g).then(void 0,_):g(a):y(l,1,o)}}function fe(e,n){try{var t=e()}catch(r){return n(!0,r)}return t&&t.then?t.then(n.bind(null,!1),n.bind(null,!0)):n(!1,t)}var N,A,P,C,de=function(e,n){try{var t,r=u.__s;u.__s=!0,N=u.__b,A=u.diffed,P=u.__r,C=u.unmount;var a=V(E,null);return a.__k=[e],Promise.resolve(fe(function(){var o=k(e,n||q,!1,void 0,a,!0),i=function(){if(Array.isArray(o)){var l=function(){var v=m.join("");return t=1,v},_=0,m=o,g=ue(function(){return!!m.some(function(v){return typeof v.then=="function"})&&_++<25},void 0,function(){return Promise.resolve(Promise.all(m)).then(function(v){m=v.flat()})});return g&&g.then?g.then(l):l()}}();return i&&i.then?i.then(function(l){return t?l:o}):t?i:o},function(o,i){if(u.__c&&u.__c(e,O),u.__s=r,O.length=0,o)throw i;return i}))}catch(o){return Promise.reject(o)}},O=[],X=Array.isArray,R=Object.assign;function $(e,n){var t=u.__s;u.__s=!0,N=u.__b,A=u.diffed,P=u.__r,C=u.unmount;var r=V(E,null);r.__k=[e];try{return k(e,n||q,!1,void 0,r,!1)}catch(a){throw a.then?new Error('Use "renderToStringAsync" for suspenseful rendering.'):a}finally{u.__c&&u.__c(e,O),u.__s=t,O.length=0}}function Y(){this.__d=!0}var q={};function K(e,n){var t,r=e.type,a=!0;return e.__c?(a=!1,(t=e.__c).state=t.__s):t=new r(e.props,n),e.__c=t,t.__v=e,t.props=e.props,t.context=n,t.__d=!0,t.state==null&&(t.state=q),t.__s==null&&(t.__s=t.state),r.getDerivedStateFromProps?t.state=R({},t.state,r.getDerivedStateFromProps(t.props,t.state)):a&&t.componentWillMount?(t.componentWillMount(),t.state=t.__s!==t.state?t.__s:t.state):!a&&t.componentWillUpdate&&t.componentWillUpdate(),P&&P(e),t.render(t.props,t.state,n)}function k(e,n,t,r,a,o){if(e==null||e===!0||e===!1||e==="")return"";if(typeof e!="object")return typeof e=="function"?"":H(e+"");if(X(e)){var i,l="";a.__k=e;for(var _=0;_<e.length;_++){var m=e[_];if(m!=null&&typeof m!="boolean"){var g,v=k(m,n,t,r,a,o);typeof v=="string"?l+=v:(i=i||[],l&&i.push(l),l="",Array.isArray(v)?(g=i).push.apply(g,v):i.push(v))}}return i?(l&&i.push(l),i):l}if(e.constructor!==void 0)return"";e.__=a,N&&N(e);var S,s,d,f=e.type,h=e.props,j=n;if(typeof f=="function"){if(f===E){if(h.tpl){for(var F="",U=0;U<h.tpl.length;U++)if(F+=h.tpl[U],h.exprs&&U<h.exprs.length){var T=h.exprs[U];if(T==null)continue;typeof T!="object"||T.constructor!==void 0&&!X(T)?F+=T:F+=k(T,n,t,r,e,o)}return F}if(h.UNSTABLE_comment)return"<!--"+H(h.UNSTABLE_comment||"")+"-->";s=h.children}else{if((S=f.contextType)!=null){var G=n[S.__c];j=G?G.props.value:S.__}if(f.prototype&&typeof f.prototype.render=="function")s=K(e,j),d=e.__c;else{e.__c=d={__v:e,props:h,context:j,setState:Y,forceUpdate:Y,__d:!0,__h:[]};for(var ee=0;d.__d&&ee++<25;)d.__d=!1,P&&P(e),s=f.call(d,h,j);d.__d=!0}if(d.getChildContext!=null&&(n=R({},n,d.getChildContext())),(f.getDerivedStateFromError||d.componentDidCatch)&&u.errorBoundaries){var z="";s=s!=null&&s.type===E&&s.key==null?s.props.children:s;try{return z=k(s,n,t,r,e,o)}catch(w){return f.getDerivedStateFromError&&(d.__s=f.getDerivedStateFromError(w)),d.componentDidCatch&&d.componentDidCatch(w,{}),d.__d&&(s=K(e,n),(d=e.__c).getChildContext!=null&&(n=R({},n,d.getChildContext())),z=k(s=s!=null&&s.type===E&&s.key==null?s.props.children:s,n,t,r,e,o)),z}finally{A&&A(e),e.__=null,C&&C(e)}}}s=s!=null&&s.type===E&&s.key==null&&s.props.tpl==null?s.props.children:s;try{var te=k(s,n,t,r,e,o);return A&&A(e),e.__=null,C&&C(e),te}catch(w){if(!o||!w||typeof w.then!="function")throw w;var ne=function re(){try{return k(s,n,t,r,e,o)}catch(Z){if(!Z||typeof Z.then!="function")throw Z;return Z.then(function(){return k(s,n,t,r,e,o)},function(){return re()})}};return w.then(function(){return ne()})}}var x,L="<"+f,b="";for(var c in h){var p=h[c];switch(c){case"children":x=p;continue;case"key":case"ref":case"__self":case"__source":continue;case"htmlFor":if("for"in h)continue;c="for";break;case"className":if("class"in h)continue;c="class";break;case"defaultChecked":c="checked";break;case"defaultSelected":c="selected";break;case"defaultValue":case"value":switch(c="value",f){case"textarea":x=p;continue;case"select":r=p;continue;case"option":r!=p||"selected"in h||(L+=" selected")}break;case"dangerouslySetInnerHTML":b=p&&p.__html;continue;case"style":typeof p=="object"&&(p=le(p));break;case"acceptCharset":c="accept-charset";break;case"httpEquiv":c="http-equiv";break;default:if(M.test(c))c=c.replace(M,"$1:$2").toLowerCase();else{if(J.test(c))continue;c[4]!=="-"&&c!=="draggable"||p==null?t?ae.test(c)&&(c=c==="panose1"?"panose-1":c.replace(/([A-Z])/g,"-$1").toLowerCase()):oe.test(c)&&(c=c.toLowerCase()):p+=""}}p!=null&&p!==!1&&typeof p!="function"&&(L=p===!0||p===""?L+" "+c:L+" "+c+'="'+H(p+"")+'"')}if(J.test(f))throw new Error(f+" is not a valid HTML tag name in "+L+">");if(b||(typeof x=="string"?b=H(x):x!=null&&x!==!1&&x!==!0&&(b=k(x,n,f==="svg"||f!=="foreignObject"&&t,r,e,o))),A&&A(e),e.__=null,C&&C(e),!b&&pe.has(f))return L+"/>";var B="</"+f+">",I=L+">";return Array.isArray(b)?[I].concat(b,[B]):typeof b!="string"?[I,b,B]:I+b+B}var pe=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),_e=$,ve=$,me=$;
export{me as default,_e as render,ve as renderToStaticMarkup,$ as renderToString,de as renderToStringAsync};