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

3 lines
11 KiB
JavaScript

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|xmlns|xml)([A-Z])/,a=/^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]/,c=/^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/,l=/["&<]/;function s(t){if(0===t.length||!1===l.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"))},f=function(t,e,n){return String(t).length>(e||40)||!n&&-1!==String(t).indexOf("\n")||-1!==String(t).indexOf("<")},p={},d=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"]),g=/[A-Z]/g;function y(t){var e="";for(var n in t){var r=t[n];if(null!=r&&""!==r){var o="-"==n[0]?n:p[n]||(p[n]=n.replace(g,"-$&").toLowerCase()),i=";";"number"!=typeof r||o.startsWith("--")||d.has(o)||(i="px;"),e=e+o+":"+r+i}}return e||void 0}function b(t,e){return Array.isArray(e)?e.reduce(b,t):null!=e&&!1!==e&&t.push(e),t}function m(){this.__d=!0}function h(t,e){return{__v:t,context:e,props:t.props,setState:m,forceUpdate:m,__d:!0,__h:[]}}var v=[],_=[];function x(e,n,r,o){var i=t.__s;t.__s=!0;try{return j(e,n||{},r,o)}finally{t.__c&&t.__c(e,_),t.__s=i,_.length=0}}function j(n,l,p,d,g,m){if(null==n||"boolean"==typeof n)return"";if("object"!=typeof n)return"function"==typeof n?"":s(n+"");var v=p.pretty,_=v&&"string"==typeof v?v:"\t";if(Array.isArray(n)){for(var x="",k=0;k<n.length;k++)v&&k>0&&(x+="\n"),x+=j(n[k],l,p,d,g,m);return x}if(void 0!==n.constructor)return"";t.__b&&t.__b(n);var A,w=n.type,O=n.props,C=!1;if("function"==typeof w){if(C=!0,!p.shallow||!d&&!1!==p.renderRootComponent){if(w===e){var F=[];return b(F,n.props.children),j(F,l,p,!1!==p.shallowHighOrder,g,m)}var E,$=n.__c=h(n,l),H=t.__r,L=l,M=w.contextType;if(null!=M){var I=l[M.__c];L=I?I.props.value:M.__}if(w.prototype&&"function"==typeof w.prototype.render)($=n.__c=new w(O,L)).__v=n,$._dirty=$.__d=!0,$.props=O,null==$.state&&($.state={}),null==$._nextState&&null==$.__s&&($._nextState=$.__s=$.state),$.context=L,w.getDerivedStateFromProps?$.state=Object.assign({},$.state,w.getDerivedStateFromProps($.props,$.state)):$.componentWillMount&&($.componentWillMount(),$.state=$._nextState!==$.state?$._nextState:$.__s!==$.state?$.__s:$.state),H&&H(n),E=$.render($.props,$.state,$.context);else for(var N=0;$.__d&&N++<25;)$.__d=!1,H&&H(n),E=w.call(n.__c,O,L);$.getChildContext&&(l=Object.assign({},l,$.getChildContext()));var D=j(E,l,p,!1!==p.shallowHighOrder,g,m);return t.diffed&&t.diffed(n),D}w=(A=w).displayName||A!==Function&&A.name||S(A)}var W,U,Z="<"+w;if(O){var P=Object.keys(O);p&&!0===p.sortAttributes&&P.sort();for(var T=0;T<P.length;T++){var R=P[T],z=O[R];if("children"!==R){if(!o.test(R)&&(p&&p.allAttributes||"key"!==R&&"ref"!==R&&"__self"!==R&&"__source"!==R)){if("defaultValue"===R)R="value";else if("defaultChecked"===R)R="checked";else if("defaultSelected"===R)R="selected";else if("className"===R){if(void 0!==O.class)continue;R="class"}else"acceptCharset"===R?R="accept-charset":"httpEquiv"===R?R="http-equiv":i.test(R)?R=R.replace(i,"$1:$2").toLowerCase():g?c.test(R)&&(R="panose1"===R?"panose-1":R.replace(/([A-Z])/g,"-$1").toLowerCase()):a.test(R)&&(R=R.toLowerCase());if("htmlFor"===R){if(O.for)continue;R="for"}"style"===R&&z&&"object"==typeof z&&(z=y(z)),"a"===R[0]&&"r"===R[1]&&"boolean"==typeof z&&(z=String(z));var q=p.attributeHook&&p.attributeHook(R,z,l,p,C);if(q||""===q)Z+=q;else if("dangerouslySetInnerHTML"===R)U=z&&z.__html;else if("textarea"===w&&"value"===R)W=z;else if((z||0===z||""===z)&&"function"!=typeof z){if(!(!0!==z&&""!==z||(z=R,p&&p.xml))){Z=Z+" "+R;continue}if("value"===R){if("select"===w){m=z;continue}"option"===w&&m==z&&void 0===O.selected&&(Z+=" selected")}Z=Z+" "+R+'="'+s(z+"")+'"'}}}else W=z}}if(v){var J=Z.replace(/\n\s*/," ");J===Z||~J.indexOf("\n")?v&&~Z.indexOf("\n")&&(Z+="\n"):Z=J}if(Z+=">",o.test(w))throw new Error(w+" is not a valid HTML tag name in "+Z);var V,B=r.test(w)||p.voidElements&&p.voidElements.test(w),G=[];if(U)v&&f(U)&&(U="\n"+_+u(U,_)),Z+=U;else if(null!=W&&b(V=[],W).length){for(var K=v&&~Z.indexOf("\n"),Q=!1,X=0;X<V.length;X++){var Y=V[X];if(null!=Y&&!1!==Y){var tt=j(Y,l,p,!0,"svg"===w||"foreignObject"!==w&&g,m);if(v&&!K&&f(tt)&&(K=!0),tt)if(v){var et=tt.length>0&&"<"!=tt[0];Q&&et?G[G.length-1]+=tt:G.push(tt),Q=et}else G.push(tt)}}if(v&&K)for(var nt=G.length;nt--;)G[nt]="\n"+_+u(G[nt],_)}if(t.diffed&&t.diffed(n),G.length||U)Z+=G.join("");else if(p&&p.xml)return Z.substring(0,Z.length-1)+" />";return!B||V||U?(v&&~Z.indexOf("\n")&&(Z+="\n"),Z=Z+"</"+w+">"):Z=Z.replace(/>$/," />"),Z}function S(t){var e=(Function.prototype.toString.call(t).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!e){for(var n=-1,r=v.length;r--;)if(v[r]===t){n=r;break}n<0&&(n=v.push(t)-1),e="UnnamedComponent"+n}return e}const k=/(\\|\"|\')/g;var A=function(t){return t.replace(k,"\\$1")};const w=Object.prototype.toString,O=Date.prototype.toISOString,C=Error.prototype.toString,F=RegExp.prototype.toString,E=Symbol.prototype.toString,$=/^Symbol\((.*)\)(.*)$/,H=/\n/gi,L=Object.getOwnPropertySymbols||(t=>[]);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 I(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 E.call(t).replace($,"Symbol($1)")}function W(t){return"["+C.call(t)+"]"}function U(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 I(t);if("string"===e)return'"'+A(t)+'"';if("function"===e)return N(t);if("symbol"===e)return D(t);const n=w.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?O.call(t):"[object Error]"===n?W(t):"[object RegExp]"===n?F.call(t):"[object Arguments]"===n&&0===t.length?"Arguments []":M(n)&&0===t.length?t.constructor.name+" []":t instanceof Error&&W(t)}function Z(t,e,n,r,o,i,a,c,l,s){let u="";if(t.length){u+=o;const f=n+e;for(let n=0;n<t.length;n++)u+=f+B(t[n],e,f,r,o,i,a,c,l,s),n<t.length-1&&(u+=","+r);u+=o+n}return"["+u+"]"}function P(t,e,n,r,o,i,a,c,l,s){return(s?"":"Arguments ")+Z(t,e,n,r,o,i,a,c,l,s)}function T(t,e,n,r,o,i,a,c,l,s){return(s?"":t.constructor.name+" ")+Z(t,e,n,r,o,i,a,c,l,s)}function R(t,e,n,r,o,i,a,c,l,s){let u="Map {";const f=t.entries();let p=f.next();if(!p.done){u+=o;const t=n+e;for(;!p.done;)u+=t+B(p.value[0],e,t,r,o,i,a,c,l,s)+" => "+B(p.value[1],e,t,r,o,i,a,c,l,s),p=f.next(),p.done||(u+=","+r);u+=o+n}return u+"}"}function z(t,e,n,r,o,i,a,c,l,s){let u=(s?"":t.constructor?t.constructor.name+" ":"Object ")+"{",f=Object.keys(t).sort();const p=L(t);if(p.length&&(f=f.filter(t=>!("symbol"==typeof t||"[object Symbol]"===w.call(t))).concat(p)),f.length){u+=o;const p=n+e;for(let n=0;n<f.length;n++){const d=f[n];u+=p+B(d,e,p,r,o,i,a,c,l,s)+": "+B(t[d],e,p,r,o,i,a,c,l,s),n<f.length-1&&(u+=","+r)}u+=o+n}return u+"}"}function q(t,e,n,r,o,i,a,c,l,s){let u="Set {";const f=t.entries();let p=f.next();if(!p.done){u+=o;const t=n+e;for(;!p.done;)u+=t+B(p.value[1],e,t,r,o,i,a,c,l,s),p=f.next(),p.done||(u+=","+r);u+=o+n}return u+"}"}function J(t,e,n,r,o,i,a,c,l,s){if((i=i.slice()).indexOf(t)>-1)return"[Circular]";i.push(t);const u=++c>a;if(!u&&t.toJSON&&"function"==typeof t.toJSON)return B(t.toJSON(),e,n,r,o,i,a,c,l,s);const f=w.call(t);return"[object Arguments]"===f?u?"[Arguments]":P(t,e,n,r,o,i,a,c,l,s):M(f)?u?"[Array]":T(t,e,n,r,o,i,a,c,l,s):"[object Map]"===f?u?"[Map]":R(t,e,n,r,o,i,a,c,l,s):"[object Set]"===f?u?"[Set]":q(t,e,n,r,o,i,a,c,l,s):"object"==typeof t?u?"[Object]":z(t,e,n,r,o,i,a,c,l,s):void 0}function V(t,e,n,r,o,i,a,c,l,s){let u,f=!1;for(let e=0;e<l.length;e++)if(u=l[e],u.test(t)){f=!0;break}return!!f&&u.print(t,function(t){return B(t,e,n,r,o,i,a,c,l,s)},function(t){const r=n+e;return r+t.replace(H,"\n"+r)},{edgeSpacing:o,spacing:r})}function B(t,e,n,r,o,i,a,c,l,s){return U(t)||V(t,e,n,r,o,i,a,c,l,s)||J(t,e,n,r,o,i,a,c,l,s)}const G={indent:2,min:!1,maxDepth:Infinity,plugins:[]};function K(t){if(Object.keys(t).forEach(t=>{if(!G.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 Q(t){const e={};return Object.keys(G).forEach(n=>e[n]=t.hasOwnProperty(n)?t[n]:G[n]),e.min&&(e.indent=0),e}function X(t){return new Array(t+1).join(" ")}var Y=function(t,e){let n,r;e?(K(e),e=Q(e)):e=G;const o=e.min?" ":"\n",i=e.min?"":"\n";if(e&&e.plugins.length){n=X(e.indent),r=[];var a=V(t,n,"",o,i,r,e.maxDepth,0,e.plugins,e.min);if(a)return a}return U(t)||(n||(n=X(e.indent)),r||(r=[]),J(t,n,"",o,i,r,e.maxDepth,0,e.plugins,e.min))},tt={test:function(t){return t&&"object"==typeof t&&"type"in t&&"props"in t&&"key"in t},print:function(t,e,n){return x(t,tt.context,tt.opts,!0)}},et={plugins:[tt]},nt={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?(tt.context=n,tt.opts=r,~(e=Y(e,et)).indexOf("\n")&&(e=u("\n"+e,a)+"\n")):e="Function",u("\n"+t+"={"+e+"}",a)):"\n"+a+t+'="'+s(e)+'"'},jsx:!0,xml:!1,functions:!0,functionNames:!0,skipFalseAttributes:!0,pretty:" "};function rt(t,e,n){var r=Object.assign({},nt,n||{});return r.jsx||(r.attributeHook=null),x(t,e,r)}var ot={shallow:!0};function it(t,e,n){return rt(t,e,Object.assign({},ot,n||{}))}export default rt;export{rt as render,it as shallowRender};
//# sourceMappingURL=jsx.module.js.map