preact-render-to-string 5.1.10 → 5.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +10 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/jsx.d.ts +7 -7
- package/dist/jsx.js +1 -1
- package/dist/jsx.js.map +1 -1
- package/dist/jsx.mjs +1 -1
- package/dist/jsx.module.js +1 -1
- package/dist/jsx.module.js.map +1 -1
- package/package.json +126 -102
- package/src/index.d.ts +10 -6
- package/src/index.js +143 -77
- package/src/jsx.d.ts +7 -7
- package/src/jsx.js +22 -16
- package/src/polyfills.js +4 -3
- package/src/util.js +30 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { VNode } from 'preact';
|
|
2
2
|
|
|
3
3
|
interface Options {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
shallow?: boolean;
|
|
5
|
+
xml?: boolean;
|
|
6
|
+
pretty?: boolean | string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export function render(vnode: VNode, context?: any, options?: Options):string;
|
|
10
|
-
export function renderToString(
|
|
11
|
-
|
|
9
|
+
export function render(vnode: VNode, context?: any, options?: Options): string;
|
|
10
|
+
export function renderToString(
|
|
11
|
+
vnode: VNode,
|
|
12
|
+
context?: any,
|
|
13
|
+
options?: Options
|
|
14
|
+
): string;
|
|
15
|
+
export function shallowRender(vnode: VNode, context?: any): string;
|
|
12
16
|
export default render;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("preact")):"function"==typeof define&&define.amd?define(["preact"],t):e.preactRenderToString=t(e.preact)}(this,function(e){var t=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("preact")):"function"==typeof define&&define.amd?define(["preact"],t):e.preactRenderToString=t(e.preact)}(this,function(e){var t=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;function n(e){"string"!=typeof e&&(e=String(e));for(var t="",n=0;n<e.length;n++){var r=e[n];switch(r){case"<":t+="<";break;case">":t+=">";break;case'"':t+=""";break;case"&":t+="&";break;default:t+=r}}return t}var r=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},o=function(e,t,n){return String(e).length>(t||40)||!n&&-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},a={};function i(e){var n="";for(var r in e){var o=e[r];null!=o&&(n&&(n+=" "),n+="-"==r[0]?r:a[r]||(a[r]=r.replace(/([A-Z])/g,"-$1").toLowerCase()),n+=": ",n+=o,"number"==typeof o&&!1===t.test(r)&&(n+="px"),n+=";")}return n||void 0}function l(e,t){for(var n in t)e[n]=t[n];return e}function s(e,t){return Array.isArray(t)?t.reduce(s,e):null!=t&&!1!==t&&e.push(t),e}var f={shallow:!0},c=[],u=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,p=function(){};_.render=_;function _(t,a,f,d,g,v){if(null==t||"boolean"==typeof t)return"";Array.isArray(t)&&(t=e.createElement(e.Fragment,null,t));var h=t.type,m=t.props,y=!1;a=a||{};var x,b=(f=f||{}).pretty,S=b&&"string"==typeof b?b:"\t";if("object"!=typeof t&&!h)return n(t);if("function"==typeof h){if(y=!0,!f.shallow||!d&&!1!==f.renderRootComponent){if(h===e.Fragment){var k="",w=[];s(w,t.props.children);for(var O=0;O<w.length;O++)k+=(O>0&&b?"\n":"")+_(w[O],a,f,!1!==f.shallowHighOrder,g,v);return k}var C,A=t.__c={__v:t,context:a,props:t.props,setState:p,forceUpdate:p,__h:[]};if(e.options.__b&&e.options.__b(t),e.options.__r&&e.options.__r(t),h.prototype&&"function"==typeof h.prototype.render){var F=h.contextType,j=F&&a[F.__c],H=null!=F?j?j.props.value:F.__:a;(A=t.__c=new h(m,H)).__v=t,A._dirty=A.__d=!0,A.props=m,null==A.state&&(A.state={}),null==A._nextState&&null==A.__s&&(A._nextState=A.__s=A.state),A.context=H,h.getDerivedStateFromProps?A.state=l(l({},A.state),h.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 T=h.contextType,$=T&&a[T.__c];C=h.call(t.__c,m,null!=T?$?$.props.value:T.__:a)}return A.getChildContext&&(a=l(l({},a),A.getChildContext())),_(C,a,f,!1!==f.shallowHighOrder,g,v)}h=(x=h).displayName||x!==Function&&x.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}(x)}var E,L,M="";if(m){var R=Object.keys(m);f&&!0===f.sortAttributes&&R.sort();for(var q=0;q<R.length;q++){var D=R[q],N=m[D];if("children"!==D){if(!D.match(/[\s\n\\/='"\0<>]/)&&(f&&f.allAttributes||"key"!==D&&"ref"!==D&&"__self"!==D&&"__source"!==D&&"defaultValue"!==D)){if("className"===D){if(m.class)continue;D="class"}else g&&D.match(/^xlink:?./)&&(D=D.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===D){if(m.for)continue;D="for"}"style"===D&&N&&"object"==typeof N&&(N=i(N)),"a"===D[0]&&"r"===D[1]&&"boolean"==typeof N&&(N=String(N));var P=f.attributeHook&&f.attributeHook(D,N,a,f,y);if(P||""===P)M+=P;else if("dangerouslySetInnerHTML"===D)L=N&&N.__html;else if("textarea"===h&&"value"===D)E=N;else if((N||0===N||""===N)&&"function"!=typeof N){if(!(!0!==N&&""!==N||(N=D,f&&f.xml))){M+=" "+D;continue}if("value"===D){if("select"===h){v=N;continue}"option"===h&&v==N&&(M+=" selected")}M+=" "+D+'="'+n(N)+'"'}}}else E=N}}if(b){var U=M.replace(/^\n\s*/," ");U===M||~U.indexOf("\n")?b&&~M.indexOf("\n")&&(M+="\n"):M=U}if(M="<"+h+M+">",String(h).match(/[\s\n\\/='"\0<>]/))throw new Error(h+" is not a valid HTML tag name in "+M);var W,z=String(h).match(u)||f.voidElements&&String(h).match(f.voidElements),I=[];if(L)b&&o(L)&&(L="\n"+S+r(L,S)),M+=L;else if(null!=E&&s(W=[],E).length){for(var V=b&&~M.indexOf("\n"),Z=!1,B=0;B<W.length;B++){var G=W[B];if(null!=G&&!1!==G){var J=_(G,a,f,!0,"svg"===h||"foreignObject"!==h&&g,v);if(b&&!V&&o(J)&&(V=!0),J)if(b){var K=J.length>0&&"<"!=J[0];Z&&K?I[I.length-1]+=J:I.push(J),Z=K}else I.push(J)}}if(b&&V)for(var Q=I.length;Q--;)I[Q]="\n"+S+r(I[Q],S)}if(I.length)M+=I.join("");else if(f&&f.xml)return M.substring(0,M.length-1)+" />";return z&&!W?M=M.replace(/>$/," />"):(b&&~M.indexOf("\n")&&(M+="\n"),M+="</"+h+">"),M}return _.shallowRender=function(e,t){return _(e,t,f)},_});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/util.js","../src/index.js"],"sourcesContent":["// DOM properties that should NOT have \"px\" added when numeric\nexport const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;\n\nexport let encodeEntities = s => String(s)\n\t.replace(/&/g, '&')\n\t.replace(/</g, '<')\n\t.replace(/>/g, '>')\n\t.replace(/\"/g, '"');\n\nexport let indent = (s, char) => String(s).replace(/(\\n+)/g, '$1' + (char || '\\t'));\n\nexport let isLargeString = (s, length, ignoreLines) => (String(s).length>(length || 40) || (!ignoreLines && String(s).indexOf('\\n')!==-1) || String(s).indexOf('<')!==-1);\n\nconst JS_TO_CSS = {};\n\n// Convert an Object style to a CSSText string\nexport function styleObjToCss(s) {\n\tlet str = '';\n\tfor (let prop in s) {\n\t\tlet val = s[prop];\n\t\tif (val!=null) {\n\t\t\tif (str) str += ' ';\n\t\t\t// str += jsToCss(prop);\n\t\t\tstr += prop[0]=='-' ? prop : (JS_TO_CSS[prop] || (JS_TO_CSS[prop] = prop.replace(/([A-Z])/g,'-$1').toLowerCase()));\n\t\t\tstr += ': ';\n\t\t\tstr += val;\n\t\t\tif (typeof val==='number' && IS_NON_DIMENSIONAL.test(prop)===false) {\n\t\t\t\tstr += 'px';\n\t\t\t}\n\t\t\tstr += ';';\n\t\t}\n\t}\n\treturn str || undefined;\n}\n\n/**\n * Copy all properties from `props` onto `obj`.\n * @param {object} obj Object onto which properties should be copied.\n * @param {object} props Object from which to copy properties.\n * @returns {object}\n * @private\n */\nexport function assign(obj, props) {\n\tfor (let i in props) obj[i] = props[i];\n\treturn obj;\n}\n\n/**\n * Get flattened children from the children prop\n * @param {Array} accumulator\n * @param {any} children A `props.children` opaque object.\n * @returns {Array} accumulator\n * @private\n */\nexport function getChildren(accumulator, children) {\n\tif (Array.isArray(children)) {\n\t\tchildren.reduce(getChildren, accumulator);\n\t}\n\telse if (children!=null && children!==false) {\n\t\taccumulator.push(children);\n\t}\n\treturn accumulator;\n}\n","import { encodeEntities, indent, isLargeString, styleObjToCss, assign, getChildren } from './util';\nimport { options, Fragment, createElement } from 'preact';\n\nconst SHALLOW = { shallow: true };\n\n// components without names, kept as a hash for later comparison to return consistent UnnamedComponentXX names.\nconst UNNAMED = [];\n\nconst VOID_ELEMENTS = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;\n\nconst noop = () => {};\n\n\n/** Render Preact JSX + Components to an HTML string.\n *\t@name render\n *\t@function\n *\t@param {VNode} vnode\tJSX VNode to render.\n *\t@param {Object} [context={}]\tOptionally pass an initial context object through the render path.\n *\t@param {Object} [options={}]\tRendering options\n *\t@param {Boolean} [options.shallow=false]\tIf `true`, renders nested Components as HTML elements (`<Foo a=\"b\" />`).\n *\t@param {Boolean} [options.xml=false]\t\tIf `true`, uses self-closing tags for elements without children.\n *\t@param {Boolean} [options.pretty=false]\t\tIf `true`, adds whitespace for readability\n *\t@param {RegEx|undefined} [options.voidElements] RegeEx that matches elements that are considered void (self-closing)\n */\nrenderToString.render = renderToString;\n\n\n/** Only render elements, leaving Components inline as `<ComponentName ... />`.\n *\tThis method is just a convenience alias for `render(vnode, context, { shallow:true })`\n *\t@name shallow\n *\t@function\n *\t@param {VNode} vnode\tJSX VNode to render.\n *\t@param {Object} [context={}]\tOptionally pass an initial context object through the render path.\n */\nlet shallowRender = (vnode, context) => renderToString(vnode, context, SHALLOW);\n\n\n/** The default export is an alias of `render()`. */\nfunction renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {\n\tif (vnode==null || typeof vnode==='boolean') {\n\t\treturn '';\n\t}\n\n\t// wrap array nodes in Fragment\n\tif (Array.isArray(vnode)) {\n\t\tvnode = createElement(Fragment, null, vnode);\n\t}\n\n\tlet nodeName = vnode.type,\n\t\tprops = vnode.props,\n\t\tisComponent = false;\n\tcontext = context || {};\n\topts = opts || {};\n\n\tlet pretty = opts.pretty,\n\t\tindentChar = pretty && typeof pretty==='string' ? pretty : '\\t';\n\n\t// #text nodes\n\tif (typeof vnode!=='object' && !nodeName) {\n\t\treturn encodeEntities(vnode);\n\t}\n\n\t// components\n\tif (typeof nodeName==='function') {\n\t\tisComponent = true;\n\t\tif (opts.shallow && (inner || opts.renderRootComponent===false)) {\n\t\t\tnodeName = getComponentName(nodeName);\n\t\t}\n\t\telse if (nodeName===Fragment) {\n\t\t\tlet rendered = '';\n\t\t\tlet children = [];\n\t\t\tgetChildren(children, vnode.props.children);\n\n\t\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\t\trendered += (i > 0 && pretty ? '\\n' : '') + renderToString(children[i], context, opts, opts.shallowHighOrder!==false, isSvgMode, selectValue);\n\t\t\t}\n\t\t\treturn rendered;\n\t\t}\n\t\telse {\n\t\t\tlet rendered;\n\n\t\t\tlet c = vnode.__c = {\n\t\t\t\t__v: vnode,\n\t\t\t\tcontext,\n\t\t\t\tprops: vnode.props,\n\t\t\t\t// silently drop state updates\n\t\t\t\tsetState: noop,\n\t\t\t\tforceUpdate: noop,\n\t\t\t\t// hooks\n\t\t\t\t__h: []\n\t\t\t};\n\n\t\t\t// options.render\n\t\t\tif (options.__r) options.__r(vnode);\n\n\t\t\tif (!nodeName.prototype || typeof nodeName.prototype.render!=='function') {\n\t\t\t\t// Necessary for createContext api. Setting this property will pass\n\t\t\t\t// the context value as `this.context` just for this component.\n\t\t\t\tlet cxType = nodeName.contextType;\n\t\t\t\tlet provider = cxType && context[cxType.__c];\n\t\t\t\tlet cctx = cxType != null ? (provider ? provider.props.value : cxType.__) : context;\n\n\t\t\t\t// stateless functional components\n\t\t\t\trendered = nodeName.call(vnode.__c, props, cctx);\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// class-based components\n\t\t\t\tlet cxType = nodeName.contextType;\n\t\t\t\tlet provider = cxType && context[cxType.__c];\n\t\t\t\tlet cctx = cxType != null ? (provider ? provider.props.value : cxType.__) : context;\n\n\t\t\t\t// c = new nodeName(props, context);\n\t\t\t\tc = vnode.__c = new nodeName(props, cctx);\n\t\t\t\tc.__v = vnode;\n\t\t\t\t// turn off stateful re-rendering:\n\t\t\t\tc._dirty = c.__d = true;\n\t\t\t\tc.props = props;\n\t\t\t\tif (c.state==null) c.state = {};\n\n\t\t\t\tif (c._nextState==null && c.__s==null) {\n\t\t\t\t\tc._nextState = c.__s = c.state;\n\t\t\t\t}\n\n\t\t\t\tc.context = cctx;\n\t\t\t\tif (nodeName.getDerivedStateFromProps) c.state = assign(assign({}, c.state), nodeName.getDerivedStateFromProps(c.props, c.state));\n\t\t\t\telse if (c.componentWillMount) {\n\t\t\t\t\tc.componentWillMount();\n\n\t\t\t\t\t// If the user called setState in cWM we need to flush pending,\n\t\t\t\t\t// state updates. This is the same behaviour in React.\n\t\t\t\t\tc.state = c._nextState !== c.state\n\t\t\t\t\t\t? c._nextState : c.__s!==c.state\n\t\t\t\t\t\t\t? c.__s : c.state;\n\t\t\t\t}\n\n\t\t\t\trendered = c.render(c.props, c.state, c.context);\n\t\t\t}\n\n\t\t\tif (c.getChildContext) {\n\t\t\t\tcontext = assign(assign({}, context), c.getChildContext());\n\t\t\t}\n\n\t\t\treturn renderToString(rendered, context, opts, opts.shallowHighOrder!==false, isSvgMode, selectValue);\n\t\t}\n\t}\n\n\t// render JSX to HTML\n\tlet s = '', propChildren, html;\n\n\tif (props) {\n\t\tlet attrs = Object.keys(props);\n\n\t\t// allow sorting lexicographically for more determinism (useful for tests, such as via preact-jsx-chai)\n\t\tif (opts && opts.sortAttributes===true) attrs.sort();\n\n\t\tfor (let i=0; i<attrs.length; i++) {\n\t\t\tlet name = attrs[i],\n\t\t\t\tv = props[name];\n\t\t\tif (name==='children') {\n\t\t\t\tpropChildren = v;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (name.match(/[\\s\\n\\\\/='\"\\0<>]/)) continue;\n\n\t\t\tif (!(opts && opts.allAttributes) && (name==='key' || name==='ref' || name==='__self' || name==='__source')) continue;\n\n\t\t\tif (name==='className') {\n\t\t\t\tif (props.class) continue;\n\t\t\t\tname = 'class';\n\t\t\t}\n\t\t\telse if (isSvgMode && name.match(/^xlink:?./)) {\n\t\t\t\tname = name.toLowerCase().replace(/^xlink:?/, 'xlink:');\n\t\t\t}\n\n\t\t\tif (name==='htmlFor') {\n\t\t\t\tif (props.for) continue;\n\t\t\t\tname = 'for';\n\t\t\t}\n\n\t\t\tif (name==='style' && v && typeof v==='object') {\n\t\t\t\tv = styleObjToCss(v);\n\t\t\t}\n\n\t\t\t// always use string values instead of booleans for aria attributes\n\t\t\t// also see https://github.com/preactjs/preact/pull/2347/files\n\t\t\tif (name[0] === 'a' && name['1'] === 'r' && typeof v === 'boolean') {\n\t\t\t\tv = String(v);\n\t\t\t}\n\n\t\t\tlet hooked = opts.attributeHook && opts.attributeHook(name, v, context, opts, isComponent);\n\t\t\tif (hooked || hooked==='') {\n\t\t\t\ts += hooked;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (name==='dangerouslySetInnerHTML') {\n\t\t\t\thtml = v && v.__html;\n\t\t\t}\n\t\t\telse if (nodeName === 'textarea' && name === 'value') {\n\t\t\t\t// <textarea value=\"a&b\"> --> <textarea>a&b</textarea>\n\t\t\t\tpropChildren = v;\n\t\t\t}\n\t\t\telse if ((v || v===0 || v==='') && typeof v!=='function') {\n\t\t\t\tif (v===true || v==='') {\n\t\t\t\t\tv = name;\n\t\t\t\t\t// in non-xml mode, allow boolean attributes\n\t\t\t\t\tif (!opts || !opts.xml) {\n\t\t\t\t\t\ts += ' ' + name;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (name==='value') {\n\t\t\t\t\tif (nodeName==='select') {\n\t\t\t\t\t\tselectValue = v;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\telse if (nodeName==='option' && selectValue==v) {\n\t\t\t\t\t\ts += ` selected`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ts += ` ${name}=\"${encodeEntities(v)}\"`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// account for >1 multiline attribute\n\tif (pretty) {\n\t\tlet sub = s.replace(/^\\n\\s*/, ' ');\n\t\tif (sub!==s && !~sub.indexOf('\\n')) s = sub;\n\t\telse if (pretty && ~s.indexOf('\\n')) s += '\\n';\n\t}\n\n\ts = `<${nodeName}${s}>`;\n\tif (String(nodeName).match(/[\\s\\n\\\\/='\"\\0<>]/)) throw new Error(`${nodeName} is not a valid HTML tag name in ${s}`);\n\n\tlet isVoid = String(nodeName).match(VOID_ELEMENTS) || (opts.voidElements && String(nodeName).match(opts.voidElements));\n\tif (isVoid) s = s.replace(/>$/, ' />');\n\n\tlet pieces = [];\n\n\tlet children;\n\tif (html) {\n\t\t// if multiline, indent.\n\t\tif (pretty && isLargeString(html)) {\n\t\t\thtml = '\\n' + indentChar + indent(html, indentChar);\n\t\t}\n\t\ts += html;\n\t}\n\telse if (propChildren != null && getChildren(children = [], propChildren).length) {\n\t\tlet hasLarge = pretty && ~s.indexOf('\\n');\n\t\tlet lastWasText = false;\n\n\t\tfor (let i=0; i<children.length; i++) {\n\t\t\tlet child = children[i];\n\n\t\t\tif (child!=null && child!==false) {\n\t\t\t\tlet childSvgMode = nodeName==='svg' ? true : nodeName==='foreignObject' ? false : isSvgMode,\n\t\t\t\t\tret = renderToString(child, context, opts, true, childSvgMode, selectValue);\n\n\t\t\t\tif (pretty && !hasLarge && isLargeString(ret)) hasLarge = true;\n\n\t\t\t\t// Skip if we received an empty string\n\t\t\t\tif (ret) {\n\t\t\t\t\tif (pretty) {\n\t\t\t\t\t\tlet isText = ret.length > 0 && ret[0]!='<';\n\n\t\t\t\t\t\t// We merge adjacent text nodes, otherwise each piece would be printed\n\t\t\t\t\t\t// on a new line.\n\t\t\t\t\t\tif (lastWasText && isText) {\n\t\t\t\t\t\t\tpieces[pieces.length -1] += ret;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tpieces.push(ret);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlastWasText = isText;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tpieces.push(ret);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (pretty && hasLarge) {\n\t\t\tfor (let i=pieces.length; i--; ) {\n\t\t\t\tpieces[i] = '\\n' + indentChar + indent(pieces[i], indentChar);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (pieces.length) {\n\t\ts += pieces.join('');\n\t}\n\telse if (opts && opts.xml) {\n\t\treturn s.substring(0, s.length-1) + ' />';\n\t}\n\n\tif (!isVoid) {\n\t\tif (pretty && ~s.indexOf('\\n')) s += '\\n';\n\t\ts += `</${nodeName}>`;\n\t}\n\n\treturn s;\n}\n\nfunction getComponentName(component) {\n\treturn component.displayName || component!==Function && component.name || getFallbackComponentName(component);\n}\n\nfunction getFallbackComponentName(component) {\n\tlet str = Function.prototype.toString.call(component),\n\t\tname = (str.match(/^\\s*function\\s+([^( ]+)/) || '')[1];\n\tif (!name) {\n\t\t// search for an existing indexed name for the given component:\n\t\tlet index = -1;\n\t\tfor (let i=UNNAMED.length; i--; ) {\n\t\t\tif (UNNAMED[i]===component) {\n\t\t\t\tindex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// not found, create a new indexed name:\n\t\tif (index<0) {\n\t\t\tindex = UNNAMED.push(component) - 1;\n\t\t}\n\t\tname = `UnnamedComponent${index}`;\n\t}\n\treturn name;\n}\nrenderToString.shallowRender = shallowRender;\n\nexport default renderToString;\n\nexport {\n\trenderToString as render,\n\trenderToString as renderToStaticMarkup,\n\trenderToString,\n\tshallowRender\n};\n"],"names":["const","IS_NON_DIMENSIONAL","encodeEntities","s","String","replace","indent","char","isLargeString","length","ignoreLines","indexOf","JS_TO_CSS","styleObjToCss","let","str","prop","val","toLowerCase","test","undefined","assign","obj","props","i","getChildren","accumulator","children","Array","isArray","reduce","push","SHALLOW","shallow","UNNAMED","VOID_ELEMENTS","noop","renderToString","render","vnode","context","opts","inner","isSvgMode","selectValue","createElement","Fragment","nodeName","type","isComponent","component","pretty","indentChar","renderRootComponent","rendered","shallowHighOrder","c","__c","__v","setState","forceUpdate","__h","options","__r","prototype","cxType","contextType","provider","cctx","value","__","_dirty","__d","state","_nextState","__s","getDerivedStateFromProps","componentWillMount","call","getChildContext","displayName","Function","name","toString","match","index","getFallbackComponentName","propChildren","html","attrs","Object","keys","sortAttributes","sort","v","allAttributes","class","for","hooked","attributeHook","__html","xml","sub","Error","isVoid","voidElements","pieces","hasLarge","lastWasText","child","ret","isText","join","substring","shallowRender"],"mappings":"wNACOA,IAAMC,EAAqB,kEAEvBC,WAAiBC,UAAKC,OAAOD,GACtCE,QAAQ,KAAM,SACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,WAELC,WAAUH,EAAGI,UAASH,OAAOD,GAAGE,QAAQ,SAAU,MAAQE,GAAQ,QAElEC,WAAiBL,EAAGM,EAAQC,UAAiBN,OAAOD,GAAGM,QAAQA,GAAU,MAASC,IAA0C,IAA3BN,OAAOD,GAAGQ,QAAQ,QAAyC,IAA1BP,OAAOD,GAAGQ,QAAQ,MAEzJC,KAGC,SAASC,EAAcV,GAC7BW,IAAIC,EAAM,GACV,IAAKD,IAAIE,KAAQb,EAAG,CACnBW,IAAIG,EAAMd,EAAEa,GACH,MAALC,IACCF,IAAKA,GAAO,KAEhBA,GAAgB,KAATC,EAAK,GAAUA,EAAQJ,EAAUI,KAAUJ,EAAUI,GAAQA,EAAKX,QAAQ,WAAW,OAAOa,eACnGH,GAAO,KACPA,GAAOE,EACU,iBAANA,IAAkD,IAAhChB,EAAmBkB,KAAKH,KACpDD,GAAO,MAERA,GAAO,KAGT,OAAOA,QAAOK,EAUR,SAASC,EAAOC,EAAKC,GAC3B,IAAKT,IAAIU,KAAKD,EAAOD,EAAIE,GAAKD,EAAMC,GACpC,OAAOF,EAUD,SAASG,EAAYC,EAAaC,GAOxC,OANIC,MAAMC,QAAQF,GACjBA,EAASG,OAAOL,EAAaC,GAEX,MAAVC,IAA6B,IAAXA,GAC1BD,EAAYK,KAAKJ,GAEXD,EC1DR1B,IAAMgC,GAAYC,SAAS,GAGrBC,KAEAC,EAAgB,2EAEhBC,eAcNC,EAAeC,OAASD,EAcxB,SAASA,EAAeE,EAAOC,EAASC,EAAMC,EAAOC,EAAWC,GAC/D,GAAW,MAAPL,GAA8B,kBAARA,EACzB,MAAO,GAIJX,MAAM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E,KAAK+E,IAKhB,GAAI3D,GAAUwD,EACb,IAAK7F,IAAIU,EAAEkF,EAAOjG,OAAQe,KACzBkF,EAAOlF,GAAK,KAAO4B,EAAa9C,EAAOoG,EAAOlF,GAAI4B,GAKrD,GAAIsD,EAAOjG,OACVN,GAAKuG,EAAOM,KAAK,SAEb,GAAIvE,GAAQA,EAAK4D,IACrB,OAAOlG,EAAE8G,UAAU,EAAG9G,EAAEM,OAAO,GAAK,MAQrC,OALK+F,IACArD,IAAWhD,EAAEQ,QAAQ,QAAOR,GAAK,MACrCA,GAAK,KAAK4C,OAGJ5C,SA2BRkC,EAAe6E,uBAzSM3E,EAAOC,UAAYH,EAAeE,EAAOC,EAASR"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/util.js","../src/index.js"],"sourcesContent":["// DOM properties that should NOT have \"px\" added when numeric\nexport const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;\n\nexport function encodeEntities(s) {\n\tif (typeof s !== 'string') s = String(s);\n\tlet out = '';\n\tfor (let i = 0; i < s.length; i++) {\n\t\tlet ch = s[i];\n\t\t// prettier-ignore\n\t\tswitch (ch) {\n\t\t\tcase '<': out += '<'; break;\n\t\t\tcase '>': out += '>'; break;\n\t\t\tcase '\"': out += '"'; break;\n\t\t\tcase '&': out += '&'; break;\n\t\t\tdefault: out += ch;\n\t\t}\n\t}\n\treturn out;\n}\n\nexport let indent = (s, char) =>\n\tString(s).replace(/(\\n+)/g, '$1' + (char || '\\t'));\n\nexport let isLargeString = (s, length, ignoreLines) =>\n\tString(s).length > (length || 40) ||\n\t(!ignoreLines && String(s).indexOf('\\n') !== -1) ||\n\tString(s).indexOf('<') !== -1;\n\nconst JS_TO_CSS = {};\n\n// Convert an Object style to a CSSText string\nexport function styleObjToCss(s) {\n\tlet str = '';\n\tfor (let prop in s) {\n\t\tlet val = s[prop];\n\t\tif (val != null) {\n\t\t\tif (str) str += ' ';\n\t\t\t// str += jsToCss(prop);\n\t\t\tstr +=\n\t\t\t\tprop[0] == '-'\n\t\t\t\t\t? prop\n\t\t\t\t\t: JS_TO_CSS[prop] ||\n\t\t\t\t\t (JS_TO_CSS[prop] = prop.replace(/([A-Z])/g, '-$1').toLowerCase());\n\t\t\tstr += ': ';\n\t\t\tstr += val;\n\t\t\tif (typeof val === 'number' && IS_NON_DIMENSIONAL.test(prop) === false) {\n\t\t\t\tstr += 'px';\n\t\t\t}\n\t\t\tstr += ';';\n\t\t}\n\t}\n\treturn str || undefined;\n}\n\n/**\n * Copy all properties from `props` onto `obj`.\n * @param {object} obj Object onto which properties should be copied.\n * @param {object} props Object from which to copy properties.\n * @returns {object}\n * @private\n */\nexport function assign(obj, props) {\n\tfor (let i in props) obj[i] = props[i];\n\treturn obj;\n}\n\n/**\n * Get flattened children from the children prop\n * @param {Array} accumulator\n * @param {any} children A `props.children` opaque object.\n * @returns {Array} accumulator\n * @private\n */\nexport function getChildren(accumulator, children) {\n\tif (Array.isArray(children)) {\n\t\tchildren.reduce(getChildren, accumulator);\n\t} else if (children != null && children !== false) {\n\t\taccumulator.push(children);\n\t}\n\treturn accumulator;\n}\n","import {\n\tencodeEntities,\n\tindent,\n\tisLargeString,\n\tstyleObjToCss,\n\tassign,\n\tgetChildren\n} from './util';\nimport { options, Fragment, createElement } from 'preact';\n\nconst SHALLOW = { shallow: true };\n\n// components without names, kept as a hash for later comparison to return consistent UnnamedComponentXX names.\nconst UNNAMED = [];\n\nconst VOID_ELEMENTS = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;\n\nconst noop = () => {};\n\n/** Render Preact JSX + Components to an HTML string.\n *\t@name render\n *\t@function\n *\t@param {VNode} vnode\tJSX VNode to render.\n *\t@param {Object} [context={}]\tOptionally pass an initial context object through the render path.\n *\t@param {Object} [options={}]\tRendering options\n *\t@param {Boolean} [options.shallow=false]\tIf `true`, renders nested Components as HTML elements (`<Foo a=\"b\" />`).\n *\t@param {Boolean} [options.xml=false]\t\tIf `true`, uses self-closing tags for elements without children.\n *\t@param {Boolean} [options.pretty=false]\t\tIf `true`, adds whitespace for readability\n *\t@param {RegEx|undefined} [options.voidElements] RegeEx that matches elements that are considered void (self-closing)\n */\nrenderToString.render = renderToString;\n\n/** Only render elements, leaving Components inline as `<ComponentName ... />`.\n *\tThis method is just a convenience alias for `render(vnode, context, { shallow:true })`\n *\t@name shallow\n *\t@function\n *\t@param {VNode} vnode\tJSX VNode to render.\n *\t@param {Object} [context={}]\tOptionally pass an initial context object through the render path.\n */\nlet shallowRender = (vnode, context) => renderToString(vnode, context, SHALLOW);\n\n/** The default export is an alias of `render()`. */\nfunction renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {\n\tif (vnode == null || typeof vnode === 'boolean') {\n\t\treturn '';\n\t}\n\n\t// wrap array nodes in Fragment\n\tif (Array.isArray(vnode)) {\n\t\tvnode = createElement(Fragment, null, vnode);\n\t}\n\n\tlet nodeName = vnode.type,\n\t\tprops = vnode.props,\n\t\tisComponent = false;\n\tcontext = context || {};\n\topts = opts || {};\n\n\tlet pretty = opts.pretty,\n\t\tindentChar = pretty && typeof pretty === 'string' ? pretty : '\\t';\n\n\t// #text nodes\n\tif (typeof vnode !== 'object' && !nodeName) {\n\t\treturn encodeEntities(vnode);\n\t}\n\n\t// components\n\tif (typeof nodeName === 'function') {\n\t\tisComponent = true;\n\t\tif (opts.shallow && (inner || opts.renderRootComponent === false)) {\n\t\t\tnodeName = getComponentName(nodeName);\n\t\t} else if (nodeName === Fragment) {\n\t\t\tlet rendered = '';\n\t\t\tlet children = [];\n\t\t\tgetChildren(children, vnode.props.children);\n\n\t\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\t\trendered +=\n\t\t\t\t\t(i > 0 && pretty ? '\\n' : '') +\n\t\t\t\t\trenderToString(\n\t\t\t\t\t\tchildren[i],\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\topts,\n\t\t\t\t\t\topts.shallowHighOrder !== false,\n\t\t\t\t\t\tisSvgMode,\n\t\t\t\t\t\tselectValue\n\t\t\t\t\t);\n\t\t\t}\n\t\t\treturn rendered;\n\t\t} else {\n\t\t\tlet rendered;\n\n\t\t\tlet c = (vnode.__c = {\n\t\t\t\t__v: vnode,\n\t\t\t\tcontext,\n\t\t\t\tprops: vnode.props,\n\t\t\t\t// silently drop state updates\n\t\t\t\tsetState: noop,\n\t\t\t\tforceUpdate: noop,\n\t\t\t\t// hooks\n\t\t\t\t__h: []\n\t\t\t});\n\n\t\t\t// options._diff\n\t\t\tif (options.__b) options.__b(vnode);\n\n\t\t\t// options._render\n\t\t\tif (options.__r) options.__r(vnode);\n\n\t\t\tif (\n\t\t\t\t!nodeName.prototype ||\n\t\t\t\ttypeof nodeName.prototype.render !== 'function'\n\t\t\t) {\n\t\t\t\t// Necessary for createContext api. Setting this property will pass\n\t\t\t\t// the context value as `this.context` just for this component.\n\t\t\t\tlet cxType = nodeName.contextType;\n\t\t\t\tlet provider = cxType && context[cxType.__c];\n\t\t\t\tlet cctx =\n\t\t\t\t\tcxType != null\n\t\t\t\t\t\t? provider\n\t\t\t\t\t\t\t? provider.props.value\n\t\t\t\t\t\t\t: cxType.__\n\t\t\t\t\t\t: context;\n\n\t\t\t\t// stateless functional components\n\t\t\t\trendered = nodeName.call(vnode.__c, props, cctx);\n\t\t\t} else {\n\t\t\t\t// class-based components\n\t\t\t\tlet cxType = nodeName.contextType;\n\t\t\t\tlet provider = cxType && context[cxType.__c];\n\t\t\t\tlet cctx =\n\t\t\t\t\tcxType != null\n\t\t\t\t\t\t? provider\n\t\t\t\t\t\t\t? provider.props.value\n\t\t\t\t\t\t\t: cxType.__\n\t\t\t\t\t\t: context;\n\n\t\t\t\t// c = new nodeName(props, context);\n\t\t\t\tc = vnode.__c = new nodeName(props, cctx);\n\t\t\t\tc.__v = vnode;\n\t\t\t\t// turn off stateful re-rendering:\n\t\t\t\tc._dirty = c.__d = true;\n\t\t\t\tc.props = props;\n\t\t\t\tif (c.state == null) c.state = {};\n\n\t\t\t\tif (c._nextState == null && c.__s == null) {\n\t\t\t\t\tc._nextState = c.__s = c.state;\n\t\t\t\t}\n\n\t\t\t\tc.context = cctx;\n\t\t\t\tif (nodeName.getDerivedStateFromProps)\n\t\t\t\t\tc.state = assign(\n\t\t\t\t\t\tassign({}, c.state),\n\t\t\t\t\t\tnodeName.getDerivedStateFromProps(c.props, c.state)\n\t\t\t\t\t);\n\t\t\t\telse if (c.componentWillMount) {\n\t\t\t\t\tc.componentWillMount();\n\n\t\t\t\t\t// If the user called setState in cWM we need to flush pending,\n\t\t\t\t\t// state updates. This is the same behaviour in React.\n\t\t\t\t\tc.state =\n\t\t\t\t\t\tc._nextState !== c.state\n\t\t\t\t\t\t\t? c._nextState\n\t\t\t\t\t\t\t: c.__s !== c.state\n\t\t\t\t\t\t\t? c.__s\n\t\t\t\t\t\t\t: c.state;\n\t\t\t\t}\n\n\t\t\t\trendered = c.render(c.props, c.state, c.context);\n\t\t\t}\n\n\t\t\tif (c.getChildContext) {\n\t\t\t\tcontext = assign(assign({}, context), c.getChildContext());\n\t\t\t}\n\n\t\t\treturn renderToString(\n\t\t\t\trendered,\n\t\t\t\tcontext,\n\t\t\t\topts,\n\t\t\t\topts.shallowHighOrder !== false,\n\t\t\t\tisSvgMode,\n\t\t\t\tselectValue\n\t\t\t);\n\t\t}\n\t}\n\n\t// render JSX to HTML\n\tlet s = '',\n\t\tpropChildren,\n\t\thtml;\n\n\tif (props) {\n\t\tlet attrs = Object.keys(props);\n\n\t\t// allow sorting lexicographically for more determinism (useful for tests, such as via preact-jsx-chai)\n\t\tif (opts && opts.sortAttributes === true) attrs.sort();\n\n\t\tfor (let i = 0; i < attrs.length; i++) {\n\t\t\tlet name = attrs[i],\n\t\t\t\tv = props[name];\n\t\t\tif (name === 'children') {\n\t\t\t\tpropChildren = v;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (name.match(/[\\s\\n\\\\/='\"\\0<>]/)) continue;\n\n\t\t\tif (\n\t\t\t\t!(opts && opts.allAttributes) &&\n\t\t\t\t(name === 'key' ||\n\t\t\t\t\tname === 'ref' ||\n\t\t\t\t\tname === '__self' ||\n\t\t\t\t\tname === '__source' ||\n\t\t\t\t\tname === 'defaultValue')\n\t\t\t)\n\t\t\t\tcontinue;\n\n\t\t\tif (name === 'className') {\n\t\t\t\tif (props.class) continue;\n\t\t\t\tname = 'class';\n\t\t\t} else if (isSvgMode && name.match(/^xlink:?./)) {\n\t\t\t\tname = name.toLowerCase().replace(/^xlink:?/, 'xlink:');\n\t\t\t}\n\n\t\t\tif (name === 'htmlFor') {\n\t\t\t\tif (props.for) continue;\n\t\t\t\tname = 'for';\n\t\t\t}\n\n\t\t\tif (name === 'style' && v && typeof v === 'object') {\n\t\t\t\tv = styleObjToCss(v);\n\t\t\t}\n\n\t\t\t// always use string values instead of booleans for aria attributes\n\t\t\t// also see https://github.com/preactjs/preact/pull/2347/files\n\t\t\tif (name[0] === 'a' && name['1'] === 'r' && typeof v === 'boolean') {\n\t\t\t\tv = String(v);\n\t\t\t}\n\n\t\t\tlet hooked =\n\t\t\t\topts.attributeHook &&\n\t\t\t\topts.attributeHook(name, v, context, opts, isComponent);\n\t\t\tif (hooked || hooked === '') {\n\t\t\t\ts += hooked;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (name === 'dangerouslySetInnerHTML') {\n\t\t\t\thtml = v && v.__html;\n\t\t\t} else if (nodeName === 'textarea' && name === 'value') {\n\t\t\t\t// <textarea value=\"a&b\"> --> <textarea>a&b</textarea>\n\t\t\t\tpropChildren = v;\n\t\t\t} else if ((v || v === 0 || v === '') && typeof v !== 'function') {\n\t\t\t\tif (v === true || v === '') {\n\t\t\t\t\tv = name;\n\t\t\t\t\t// in non-xml mode, allow boolean attributes\n\t\t\t\t\tif (!opts || !opts.xml) {\n\t\t\t\t\t\ts += ' ' + name;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (name === 'value') {\n\t\t\t\t\tif (nodeName === 'select') {\n\t\t\t\t\t\tselectValue = v;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else if (nodeName === 'option' && selectValue == v) {\n\t\t\t\t\t\ts += ` selected`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ts += ` ${name}=\"${encodeEntities(v)}\"`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// account for >1 multiline attribute\n\tif (pretty) {\n\t\tlet sub = s.replace(/^\\n\\s*/, ' ');\n\t\tif (sub !== s && !~sub.indexOf('\\n')) s = sub;\n\t\telse if (pretty && ~s.indexOf('\\n')) s += '\\n';\n\t}\n\n\ts = `<${nodeName}${s}>`;\n\tif (String(nodeName).match(/[\\s\\n\\\\/='\"\\0<>]/))\n\t\tthrow new Error(`${nodeName} is not a valid HTML tag name in ${s}`);\n\n\tlet isVoid =\n\t\tString(nodeName).match(VOID_ELEMENTS) ||\n\t\t(opts.voidElements && String(nodeName).match(opts.voidElements));\n\tlet pieces = [];\n\n\tlet children;\n\tif (html) {\n\t\t// if multiline, indent.\n\t\tif (pretty && isLargeString(html)) {\n\t\t\thtml = '\\n' + indentChar + indent(html, indentChar);\n\t\t}\n\t\ts += html;\n\t} else if (\n\t\tpropChildren != null &&\n\t\tgetChildren((children = []), propChildren).length\n\t) {\n\t\tlet hasLarge = pretty && ~s.indexOf('\\n');\n\t\tlet lastWasText = false;\n\n\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\tlet child = children[i];\n\n\t\t\tif (child != null && child !== false) {\n\t\t\t\tlet childSvgMode =\n\t\t\t\t\t\tnodeName === 'svg'\n\t\t\t\t\t\t\t? true\n\t\t\t\t\t\t\t: nodeName === 'foreignObject'\n\t\t\t\t\t\t\t? false\n\t\t\t\t\t\t\t: isSvgMode,\n\t\t\t\t\tret = renderToString(\n\t\t\t\t\t\tchild,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\topts,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tchildSvgMode,\n\t\t\t\t\t\tselectValue\n\t\t\t\t\t);\n\n\t\t\t\tif (pretty && !hasLarge && isLargeString(ret)) hasLarge = true;\n\n\t\t\t\t// Skip if we received an empty string\n\t\t\t\tif (ret) {\n\t\t\t\t\tif (pretty) {\n\t\t\t\t\t\tlet isText = ret.length > 0 && ret[0] != '<';\n\n\t\t\t\t\t\t// We merge adjacent text nodes, otherwise each piece would be printed\n\t\t\t\t\t\t// on a new line.\n\t\t\t\t\t\tif (lastWasText && isText) {\n\t\t\t\t\t\t\tpieces[pieces.length - 1] += ret;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpieces.push(ret);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlastWasText = isText;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpieces.push(ret);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (pretty && hasLarge) {\n\t\t\tfor (let i = pieces.length; i--; ) {\n\t\t\t\tpieces[i] = '\\n' + indentChar + indent(pieces[i], indentChar);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (pieces.length) {\n\t\ts += pieces.join('');\n\t} else if (opts && opts.xml) {\n\t\treturn s.substring(0, s.length - 1) + ' />';\n\t}\n\n\tif (isVoid && !children) {\n\t\ts = s.replace(/>$/, ' />');\n\t} else {\n\t\tif (pretty && ~s.indexOf('\\n')) s += '\\n';\n\t\ts += `</${nodeName}>`;\n\t}\n\n\treturn s;\n}\n\nfunction getComponentName(component) {\n\treturn (\n\t\tcomponent.displayName ||\n\t\t(component !== Function && component.name) ||\n\t\tgetFallbackComponentName(component)\n\t);\n}\n\nfunction getFallbackComponentName(component) {\n\tlet str = Function.prototype.toString.call(component),\n\t\tname = (str.match(/^\\s*function\\s+([^( ]+)/) || '')[1];\n\tif (!name) {\n\t\t// search for an existing indexed name for the given component:\n\t\tlet index = -1;\n\t\tfor (let i = UNNAMED.length; i--; ) {\n\t\t\tif (UNNAMED[i] === component) {\n\t\t\t\tindex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// not found, create a new indexed name:\n\t\tif (index < 0) {\n\t\t\tindex = UNNAMED.push(component) - 1;\n\t\t}\n\t\tname = `UnnamedComponent${index}`;\n\t}\n\treturn name;\n}\nrenderToString.shallowRender = shallowRender;\n\nexport default renderToString;\n\nexport {\n\trenderToString as render,\n\trenderToString as renderToStaticMarkup,\n\trenderToString,\n\tshallowRender\n};\n"],"names":["const","IS_NON_DIMENSIONAL","encodeEntities","s","String","let","out","i","length","ch","indent","char","replace","isLargeString","ignoreLines","indexOf","JS_TO_CSS","styleObjToCss","str","prop","val","toLowerCase","test","undefined","assign","obj","props","getChildren","accumulator","children","Array","isArray","reduce","push","SHALLOW","shallow","UNNAMED","VOID_ELEMENTS","noop","renderToString","render","vnode","context","opts","inner","isSvgMode","selectValue","createElement","Fragment","nodeName","type","isComponent","component","pretty","indentChar","renderRootComponent","rendered","shallowHighOrder","c","__c","__v","setState","forceUpdate","__h","options","__b","__r","prototype","cxType","contextType","provider","cctx","value","__","_dirty","__d","state","_nextState","__s","getDerivedStateFromProps","componentWillMount","call","getChildContext","displayName","Function","name","toString","match","index","getFallbackComponentName","propChildren","html","attrs","Object","keys","sortAttributes","sort","v","allAttributes","class","for","hooked","attributeHook","__html","xml","sub","Error","isVoid","voidElements","pieces","hasLarge","lastWasText","child","ret","isText","join","substring","shallowRender"],"mappings":"wNACOA,IAAMC,EAAqB,kEAE3B,SAASC,EAAeC,GACb,iBAANA,IAAgBA,EAAIC,OAAOD,IAEtC,IADAE,IAAIC,EAAM,GACDC,EAAI,EAAGA,EAAIJ,EAAEK,OAAQD,IAAK,CAClCF,IAAII,EAAKN,EAAEI,GAEX,OAAQE,GACP,IAAK,IAAKH,GAAO,OAAQ,MACzB,IAAK,IAAKA,GAAO,OAAQ,MACzB,IAAK,IAAKA,GAAO,SAAU,MAC3B,IAAK,IAAKA,GAAO,QAAS,MAC1B,Q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AAGjH,EAAEK,OAAS,GAAK,MAUvC,OAPImG,IAAW9E,EACd1B,EAAIA,EAAES,QAAQ,KAAM,QAEhByC,IAAWlD,EAAEY,QAAQ,QAAOZ,GAAK,MACrCA,GAAK,KAAK8C,OAGJ9C,SA+BRoC,EAAe8E,uBAtWM5E,EAAOC,UAAYH,EAAeE,EAAOC,EAASR"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{options as e,Fragment as t,createElement as r}from"preact";var n=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i
|
|
1
|
+
import{options as e,Fragment as t,createElement as r}from"preact";var n=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;function a(e){"string"!=typeof e&&(e=String(e));for(var t="",r=0;r<e.length;r++){var n=e[r];switch(n){case"<":t+="<";break;case">":t+=">";break;case'"':t+=""";break;case"&":t+="&";break;default:t+=n}}return t}var o=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 r in e){var a=e[r];null!=a&&(t&&(t+=" "),t+="-"==r[0]?r:l[r]||(l[r]=r.replace(/([A-Z])/g,"-$1").toLowerCase()),t+=": ",t+=a,"number"==typeof a&&!1===n.test(r)&&(t+="px"),t+=";")}return t||void 0}function f(e,t){for(var r in t)e[r]=t[r];return e}function c(e,t){return Array.isArray(t)?t.reduce(c,e):null!=t&&!1!==t&&e.push(t),e}var u={shallow:!0},p=[],_=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,v=function(){};h.render=h;var g=function(e,t){return h(e,t,u)};function h(n,l,u,g,d,m){if(null==n||"boolean"==typeof n)return"";Array.isArray(n)&&(n=r(t,null,n));var x=n.type,y=n.props,b=!1;l=l||{};var S,k=(u=u||{}).pretty,w=k&&"string"==typeof k?k:"\t";if("object"!=typeof n&&!x)return a(n);if("function"==typeof x){if(b=!0,!u.shallow||!g&&!1!==u.renderRootComponent){if(x===t){var O="",C=[];c(C,n.props.children);for(var A=0;A<C.length;A++)O+=(A>0&&k?"\n":"")+h(C[A],l,u,!1!==u.shallowHighOrder,d,m);return O}var H,j=n.__c={__v:n,context:l,props:n.props,setState:v,forceUpdate:v,__h:[]};if(e.__b&&e.__b(n),e.__r&&e.__r(n),x.prototype&&"function"==typeof x.prototype.render){var F=x.contextType,M=F&&l[F.__c],T=null!=F?M?M.props.value:F.__:l;(j=n.__c=new x(y,T)).__v=n,j._dirty=j.__d=!0,j.props=y,null==j.state&&(j.state={}),null==j._nextState&&null==j.__s&&(j._nextState=j.__s=j.state),j.context=T,x.getDerivedStateFromProps?j.state=f(f({},j.state),x.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 $=x.contextType,L=$&&l[$.__c];H=x.call(n.__c,y,null!=$?L?L.props.value:$.__:l)}return j.getChildContext&&(l=f(f({},l),j.getChildContext())),h(H,l,u,!1!==u.shallowHighOrder,d,m)}x=(S=x).displayName||S!==Function&&S.name||function(e){var t=(Function.prototype.toString.call(e).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!t){for(var r=-1,n=p.length;n--;)if(p[n]===e){r=n;break}r<0&&(r=p.push(e)-1),t="UnnamedComponent"+r}return t}(S)}var E,D,N="";if(y){var P=Object.keys(y);u&&!0===u.sortAttributes&&P.sort();for(var R=0;R<P.length;R++){var U=P[R],W=y[U];if("children"!==U){if(!U.match(/[\s\n\\/='"\0<>]/)&&(u&&u.allAttributes||"key"!==U&&"ref"!==U&&"__self"!==U&&"__source"!==U&&"defaultValue"!==U)){if("className"===U){if(y.class)continue;U="class"}else d&&U.match(/^xlink:?./)&&(U=U.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===U){if(y.for)continue;U="for"}"style"===U&&W&&"object"==typeof W&&(W=s(W)),"a"===U[0]&&"r"===U[1]&&"boolean"==typeof W&&(W=String(W));var q=u.attributeHook&&u.attributeHook(U,W,l,u,b);if(q||""===q)N+=q;else if("dangerouslySetInnerHTML"===U)D=W&&W.__html;else if("textarea"===x&&"value"===U)E=W;else if((W||0===W||""===W)&&"function"!=typeof W){if(!(!0!==W&&""!==W||(W=U,u&&u.xml))){N+=" "+U;continue}if("value"===U){if("select"===x){m=W;continue}"option"===x&&m==W&&(N+=" selected")}N+=" "+U+'="'+a(W)+'"'}}}else E=W}}if(k){var z=N.replace(/^\n\s*/," ");z===N||~z.indexOf("\n")?k&&~N.indexOf("\n")&&(N+="\n"):N=z}if(N="<"+x+N+">",String(x).match(/[\s\n\\/='"\0<>]/))throw new Error(x+" is not a valid HTML tag name in "+N);var I,V=String(x).match(_)||u.voidElements&&String(x).match(u.voidElements),Z=[];if(D)k&&i(D)&&(D="\n"+w+o(D,w)),N+=D;else if(null!=E&&c(I=[],E).length){for(var B=k&&~N.indexOf("\n"),G=!1,J=0;J<I.length;J++){var K=I[J];if(null!=K&&!1!==K){var Q=h(K,l,u,!0,"svg"===x||"foreignObject"!==x&&d,m);if(k&&!B&&i(Q)&&(B=!0),Q)if(k){var X=Q.length>0&&"<"!=Q[0];G&&X?Z[Z.length-1]+=Q:Z.push(Q),G=X}else Z.push(Q)}}if(k&&B)for(var Y=Z.length;Y--;)Z[Y]="\n"+w+o(Z[Y],w)}if(Z.length)N+=Z.join("");else if(u&&u.xml)return N.substring(0,N.length-1)+" />";return V&&!I?N=N.replace(/>$/," />"):(k&&~N.indexOf("\n")&&(N+="\n"),N+="</"+x+">"),N}h.shallowRender=g;export default h;export{h as render,h as renderToStaticMarkup,h as renderToString,g as shallowRender};
|
|
2
2
|
//# sourceMappingURL=index.module.js.map
|
package/dist/index.module.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{options as e,Fragment as t,createElement as r}from"preact";var n=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i
|
|
1
|
+
import{options as e,Fragment as t,createElement as r}from"preact";var n=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;function a(e){"string"!=typeof e&&(e=String(e));for(var t="",r=0;r<e.length;r++){var n=e[r];switch(n){case"<":t+="<";break;case">":t+=">";break;case'"':t+=""";break;case"&":t+="&";break;default:t+=n}}return t}var o=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 r in e){var a=e[r];null!=a&&(t&&(t+=" "),t+="-"==r[0]?r:l[r]||(l[r]=r.replace(/([A-Z])/g,"-$1").toLowerCase()),t+=": ",t+=a,"number"==typeof a&&!1===n.test(r)&&(t+="px"),t+=";")}return t||void 0}function f(e,t){for(var r in t)e[r]=t[r];return e}function c(e,t){return Array.isArray(t)?t.reduce(c,e):null!=t&&!1!==t&&e.push(t),e}var u={shallow:!0},p=[],_=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,v=function(){};h.render=h;var g=function(e,t){return h(e,t,u)};function h(n,l,u,g,d,m){if(null==n||"boolean"==typeof n)return"";Array.isArray(n)&&(n=r(t,null,n));var x=n.type,y=n.props,b=!1;l=l||{};var S,k=(u=u||{}).pretty,w=k&&"string"==typeof k?k:"\t";if("object"!=typeof n&&!x)return a(n);if("function"==typeof x){if(b=!0,!u.shallow||!g&&!1!==u.renderRootComponent){if(x===t){var O="",C=[];c(C,n.props.children);for(var A=0;A<C.length;A++)O+=(A>0&&k?"\n":"")+h(C[A],l,u,!1!==u.shallowHighOrder,d,m);return O}var H,j=n.__c={__v:n,context:l,props:n.props,setState:v,forceUpdate:v,__h:[]};if(e.__b&&e.__b(n),e.__r&&e.__r(n),x.prototype&&"function"==typeof x.prototype.render){var F=x.contextType,M=F&&l[F.__c],T=null!=F?M?M.props.value:F.__:l;(j=n.__c=new x(y,T)).__v=n,j._dirty=j.__d=!0,j.props=y,null==j.state&&(j.state={}),null==j._nextState&&null==j.__s&&(j._nextState=j.__s=j.state),j.context=T,x.getDerivedStateFromProps?j.state=f(f({},j.state),x.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 $=x.contextType,L=$&&l[$.__c];H=x.call(n.__c,y,null!=$?L?L.props.value:$.__:l)}return j.getChildContext&&(l=f(f({},l),j.getChildContext())),h(H,l,u,!1!==u.shallowHighOrder,d,m)}x=(S=x).displayName||S!==Function&&S.name||function(e){var t=(Function.prototype.toString.call(e).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!t){for(var r=-1,n=p.length;n--;)if(p[n]===e){r=n;break}r<0&&(r=p.push(e)-1),t="UnnamedComponent"+r}return t}(S)}var E,D,N="";if(y){var P=Object.keys(y);u&&!0===u.sortAttributes&&P.sort();for(var R=0;R<P.length;R++){var U=P[R],W=y[U];if("children"!==U){if(!U.match(/[\s\n\\/='"\0<>]/)&&(u&&u.allAttributes||"key"!==U&&"ref"!==U&&"__self"!==U&&"__source"!==U&&"defaultValue"!==U)){if("className"===U){if(y.class)continue;U="class"}else d&&U.match(/^xlink:?./)&&(U=U.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===U){if(y.for)continue;U="for"}"style"===U&&W&&"object"==typeof W&&(W=s(W)),"a"===U[0]&&"r"===U[1]&&"boolean"==typeof W&&(W=String(W));var q=u.attributeHook&&u.attributeHook(U,W,l,u,b);if(q||""===q)N+=q;else if("dangerouslySetInnerHTML"===U)D=W&&W.__html;else if("textarea"===x&&"value"===U)E=W;else if((W||0===W||""===W)&&"function"!=typeof W){if(!(!0!==W&&""!==W||(W=U,u&&u.xml))){N+=" "+U;continue}if("value"===U){if("select"===x){m=W;continue}"option"===x&&m==W&&(N+=" selected")}N+=" "+U+'="'+a(W)+'"'}}}else E=W}}if(k){var z=N.replace(/^\n\s*/," ");z===N||~z.indexOf("\n")?k&&~N.indexOf("\n")&&(N+="\n"):N=z}if(N="<"+x+N+">",String(x).match(/[\s\n\\/='"\0<>]/))throw new Error(x+" is not a valid HTML tag name in "+N);var I,V=String(x).match(_)||u.voidElements&&String(x).match(u.voidElements),Z=[];if(D)k&&i(D)&&(D="\n"+w+o(D,w)),N+=D;else if(null!=E&&c(I=[],E).length){for(var B=k&&~N.indexOf("\n"),G=!1,J=0;J<I.length;J++){var K=I[J];if(null!=K&&!1!==K){var Q=h(K,l,u,!0,"svg"===x||"foreignObject"!==x&&d,m);if(k&&!B&&i(Q)&&(B=!0),Q)if(k){var X=Q.length>0&&"<"!=Q[0];G&&X?Z[Z.length-1]+=Q:Z.push(Q),G=X}else Z.push(Q)}}if(k&&B)for(var Y=Z.length;Y--;)Z[Y]="\n"+w+o(Z[Y],w)}if(Z.length)N+=Z.join("");else if(u&&u.xml)return N.substring(0,N.length-1)+" />";return V&&!I?N=N.replace(/>$/," />"):(k&&~N.indexOf("\n")&&(N+="\n"),N+="</"+x+">"),N}h.shallowRender=g;export default h;export{h as render,h as renderToStaticMarkup,h as renderToString,g as shallowRender};
|
|
2
2
|
//# sourceMappingURL=index.module.js.map
|
package/dist/index.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.js","sources":["../src/util.js","../src/index.js"],"sourcesContent":["// DOM properties that should NOT have \"px\" added when numeric\nexport const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;\n\nexport let encodeEntities = s => String(s)\n\t.replace(/&/g, '&')\n\t.replace(/</g, '<')\n\t.replace(/>/g, '>')\n\t.replace(/\"/g, '"');\n\nexport let indent = (s, char) => String(s).replace(/(\\n+)/g, '$1' + (char || '\\t'));\n\nexport let isLargeString = (s, length, ignoreLines) => (String(s).length>(length || 40) || (!ignoreLines && String(s).indexOf('\\n')!==-1) || String(s).indexOf('<')!==-1);\n\nconst JS_TO_CSS = {};\n\n// Convert an Object style to a CSSText string\nexport function styleObjToCss(s) {\n\tlet str = '';\n\tfor (let prop in s) {\n\t\tlet val = s[prop];\n\t\tif (val!=null) {\n\t\t\tif (str) str += ' ';\n\t\t\t// str += jsToCss(prop);\n\t\t\tstr += prop[0]=='-' ? prop : (JS_TO_CSS[prop] || (JS_TO_CSS[prop] = prop.replace(/([A-Z])/g,'-$1').toLowerCase()));\n\t\t\tstr += ': ';\n\t\t\tstr += val;\n\t\t\tif (typeof val==='number' && IS_NON_DIMENSIONAL.test(prop)===false) {\n\t\t\t\tstr += 'px';\n\t\t\t}\n\t\t\tstr += ';';\n\t\t}\n\t}\n\treturn str || undefined;\n}\n\n/**\n * Copy all properties from `props` onto `obj`.\n * @param {object} obj Object onto which properties should be copied.\n * @param {object} props Object from which to copy properties.\n * @returns {object}\n * @private\n */\nexport function assign(obj, props) {\n\tfor (let i in props) obj[i] = props[i];\n\treturn obj;\n}\n\n/**\n * Get flattened children from the children prop\n * @param {Array} accumulator\n * @param {any} children A `props.children` opaque object.\n * @returns {Array} accumulator\n * @private\n */\nexport function getChildren(accumulator, children) {\n\tif (Array.isArray(children)) {\n\t\tchildren.reduce(getChildren, accumulator);\n\t}\n\telse if (children!=null && children!==false) {\n\t\taccumulator.push(children);\n\t}\n\treturn accumulator;\n}\n","import { encodeEntities, indent, isLargeString, styleObjToCss, assign, getChildren } from './util';\nimport { options, Fragment, createElement } from 'preact';\n\nconst SHALLOW = { shallow: true };\n\n// components without names, kept as a hash for later comparison to return consistent UnnamedComponentXX names.\nconst UNNAMED = [];\n\nconst VOID_ELEMENTS = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;\n\nconst noop = () => {};\n\n\n/** Render Preact JSX + Components to an HTML string.\n *\t@name render\n *\t@function\n *\t@param {VNode} vnode\tJSX VNode to render.\n *\t@param {Object} [context={}]\tOptionally pass an initial context object through the render path.\n *\t@param {Object} [options={}]\tRendering options\n *\t@param {Boolean} [options.shallow=false]\tIf `true`, renders nested Components as HTML elements (`<Foo a=\"b\" />`).\n *\t@param {Boolean} [options.xml=false]\t\tIf `true`, uses self-closing tags for elements without children.\n *\t@param {Boolean} [options.pretty=false]\t\tIf `true`, adds whitespace for readability\n *\t@param {RegEx|undefined} [options.voidElements] RegeEx that matches elements that are considered void (self-closing)\n */\nrenderToString.render = renderToString;\n\n\n/** Only render elements, leaving Components inline as `<ComponentName ... />`.\n *\tThis method is just a convenience alias for `render(vnode, context, { shallow:true })`\n *\t@name shallow\n *\t@function\n *\t@param {VNode} vnode\tJSX VNode to render.\n *\t@param {Object} [context={}]\tOptionally pass an initial context object through the render path.\n */\nlet shallowRender = (vnode, context) => renderToString(vnode, context, SHALLOW);\n\n\n/** The default export is an alias of `render()`. */\nfunction renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {\n\tif (vnode==null || typeof vnode==='boolean') {\n\t\treturn '';\n\t}\n\n\t// wrap array nodes in Fragment\n\tif (Array.isArray(vnode)) {\n\t\tvnode = createElement(Fragment, null, vnode);\n\t}\n\n\tlet nodeName = vnode.type,\n\t\tprops = vnode.props,\n\t\tisComponent = false;\n\tcontext = context || {};\n\topts = opts || {};\n\n\tlet pretty = opts.pretty,\n\t\tindentChar = pretty && typeof pretty==='string' ? pretty : '\\t';\n\n\t// #text nodes\n\tif (typeof vnode!=='object' && !nodeName) {\n\t\treturn encodeEntities(vnode);\n\t}\n\n\t// components\n\tif (typeof nodeName==='function') {\n\t\tisComponent = true;\n\t\tif (opts.shallow && (inner || opts.renderRootComponent===false)) {\n\t\t\tnodeName = getComponentName(nodeName);\n\t\t}\n\t\telse if (nodeName===Fragment) {\n\t\t\tlet rendered = '';\n\t\t\tlet children = [];\n\t\t\tgetChildren(children, vnode.props.children);\n\n\t\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\t\trendered += (i > 0 && pretty ? '\\n' : '') + renderToString(children[i], context, opts, opts.shallowHighOrder!==false, isSvgMode, selectValue);\n\t\t\t}\n\t\t\treturn rendered;\n\t\t}\n\t\telse {\n\t\t\tlet rendered;\n\n\t\t\tlet c = vnode.__c = {\n\t\t\t\t__v: vnode,\n\t\t\t\tcontext,\n\t\t\t\tprops: vnode.props,\n\t\t\t\t// silently drop state updates\n\t\t\t\tsetState: noop,\n\t\t\t\tforceUpdate: noop,\n\t\t\t\t// hooks\n\t\t\t\t__h: []\n\t\t\t};\n\n\t\t\t// options.render\n\t\t\tif (options.__r) options.__r(vnode);\n\n\t\t\tif (!nodeName.prototype || typeof nodeName.prototype.render!=='function') {\n\t\t\t\t// Necessary for createContext api. Setting this property will pass\n\t\t\t\t// the context value as `this.context` just for this component.\n\t\t\t\tlet cxType = nodeName.contextType;\n\t\t\t\tlet provider = cxType && context[cxType.__c];\n\t\t\t\tlet cctx = cxType != null ? (provider ? provider.props.value : cxType.__) : context;\n\n\t\t\t\t// stateless functional components\n\t\t\t\trendered = nodeName.call(vnode.__c, props, cctx);\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// class-based components\n\t\t\t\tlet cxType = nodeName.contextType;\n\t\t\t\tlet provider = cxType && context[cxType.__c];\n\t\t\t\tlet cctx = cxType != null ? (provider ? provider.props.value : cxType.__) : context;\n\n\t\t\t\t// c = new nodeName(props, context);\n\t\t\t\tc = vnode.__c = new nodeName(props, cctx);\n\t\t\t\tc.__v = vnode;\n\t\t\t\t// turn off stateful re-rendering:\n\t\t\t\tc._dirty = c.__d = true;\n\t\t\t\tc.props = props;\n\t\t\t\tif (c.state==null) c.state = {};\n\n\t\t\t\tif (c._nextState==null && c.__s==null) {\n\t\t\t\t\tc._nextState = c.__s = c.state;\n\t\t\t\t}\n\n\t\t\t\tc.context = cctx;\n\t\t\t\tif (nodeName.getDerivedStateFromProps) c.state = assign(assign({}, c.state), nodeName.getDerivedStateFromProps(c.props, c.state));\n\t\t\t\telse if (c.componentWillMount) {\n\t\t\t\t\tc.componentWillMount();\n\n\t\t\t\t\t// If the user called setState in cWM we need to flush pending,\n\t\t\t\t\t// state updates. This is the same behaviour in React.\n\t\t\t\t\tc.state = c._nextState !== c.state\n\t\t\t\t\t\t? c._nextState : c.__s!==c.state\n\t\t\t\t\t\t\t? c.__s : c.state;\n\t\t\t\t}\n\n\t\t\t\trendered = c.render(c.props, c.state, c.context);\n\t\t\t}\n\n\t\t\tif (c.getChildContext) {\n\t\t\t\tcontext = assign(assign({}, context), c.getChildContext());\n\t\t\t}\n\n\t\t\treturn renderToString(rendered, context, opts, opts.shallowHighOrder!==false, isSvgMode, selectValue);\n\t\t}\n\t}\n\n\t// render JSX to HTML\n\tlet s = '', propChildren, html;\n\n\tif (props) {\n\t\tlet attrs = Object.keys(props);\n\n\t\t// allow sorting lexicographically for more determinism (useful for tests, such as via preact-jsx-chai)\n\t\tif (opts && opts.sortAttributes===true) attrs.sort();\n\n\t\tfor (let i=0; i<attrs.length; i++) {\n\t\t\tlet name = attrs[i],\n\t\t\t\tv = props[name];\n\t\t\tif (name==='children') {\n\t\t\t\tpropChildren = v;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (name.match(/[\\s\\n\\\\/='\"\\0<>]/)) continue;\n\n\t\t\tif (!(opts && opts.allAttributes) && (name==='key' || name==='ref' || name==='__self' || name==='__source')) continue;\n\n\t\t\tif (name==='className') {\n\t\t\t\tif (props.class) continue;\n\t\t\t\tname = 'class';\n\t\t\t}\n\t\t\telse if (isSvgMode && name.match(/^xlink:?./)) {\n\t\t\t\tname = name.toLowerCase().replace(/^xlink:?/, 'xlink:');\n\t\t\t}\n\n\t\t\tif (name==='htmlFor') {\n\t\t\t\tif (props.for) continue;\n\t\t\t\tname = 'for';\n\t\t\t}\n\n\t\t\tif (name==='style' && v && typeof v==='object') {\n\t\t\t\tv = styleObjToCss(v);\n\t\t\t}\n\n\t\t\t// always use string values instead of booleans for aria attributes\n\t\t\t// also see https://github.com/preactjs/preact/pull/2347/files\n\t\t\tif (name[0] === 'a' && name['1'] === 'r' && typeof v === 'boolean') {\n\t\t\t\tv = String(v);\n\t\t\t}\n\n\t\t\tlet hooked = opts.attributeHook && opts.attributeHook(name, v, context, opts, isComponent);\n\t\t\tif (hooked || hooked==='') {\n\t\t\t\ts += hooked;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (name==='dangerouslySetInnerHTML') {\n\t\t\t\thtml = v && v.__html;\n\t\t\t}\n\t\t\telse if (nodeName === 'textarea' && name === 'value') {\n\t\t\t\t// <textarea value=\"a&b\"> --> <textarea>a&b</textarea>\n\t\t\t\tpropChildren = v;\n\t\t\t}\n\t\t\telse if ((v || v===0 || v==='') && typeof v!=='function') {\n\t\t\t\tif (v===true || v==='') {\n\t\t\t\t\tv = name;\n\t\t\t\t\t// in non-xml mode, allow boolean attributes\n\t\t\t\t\tif (!opts || !opts.xml) {\n\t\t\t\t\t\ts += ' ' + name;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (name==='value') {\n\t\t\t\t\tif (nodeName==='select') {\n\t\t\t\t\t\tselectValue = v;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\telse if (nodeName==='option' && selectValue==v) {\n\t\t\t\t\t\ts += ` selected`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ts += ` ${name}=\"${encodeEntities(v)}\"`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// account for >1 multiline attribute\n\tif (pretty) {\n\t\tlet sub = s.replace(/^\\n\\s*/, ' ');\n\t\tif (sub!==s && !~sub.indexOf('\\n')) s = sub;\n\t\telse if (pretty && ~s.indexOf('\\n')) s += '\\n';\n\t}\n\n\ts = `<${nodeName}${s}>`;\n\tif (String(nodeName).match(/[\\s\\n\\\\/='\"\\0<>]/)) throw new Error(`${nodeName} is not a valid HTML tag name in ${s}`);\n\n\tlet isVoid = String(nodeName).match(VOID_ELEMENTS) || (opts.voidElements && String(nodeName).match(opts.voidElements));\n\tif (isVoid) s = s.replace(/>$/, ' />');\n\n\tlet pieces = [];\n\n\tlet children;\n\tif (html) {\n\t\t// if multiline, indent.\n\t\tif (pretty && isLargeString(html)) {\n\t\t\thtml = '\\n' + indentChar + indent(html, indentChar);\n\t\t}\n\t\ts += html;\n\t}\n\telse if (propChildren != null && getChildren(children = [], propChildren).length) {\n\t\tlet hasLarge = pretty && ~s.indexOf('\\n');\n\t\tlet lastWasText = false;\n\n\t\tfor (let i=0; i<children.length; i++) {\n\t\t\tlet child = children[i];\n\n\t\t\tif (child!=null && child!==false) {\n\t\t\t\tlet childSvgMode = nodeName==='svg' ? true : nodeName==='foreignObject' ? false : isSvgMode,\n\t\t\t\t\tret = renderToString(child, context, opts, true, childSvgMode, selectValue);\n\n\t\t\t\tif (pretty && !hasLarge && isLargeString(ret)) hasLarge = true;\n\n\t\t\t\t// Skip if we received an empty string\n\t\t\t\tif (ret) {\n\t\t\t\t\tif (pretty) {\n\t\t\t\t\t\tlet isText = ret.length > 0 && ret[0]!='<';\n\n\t\t\t\t\t\t// We merge adjacent text nodes, otherwise each piece would be printed\n\t\t\t\t\t\t// on a new line.\n\t\t\t\t\t\tif (lastWasText && isText) {\n\t\t\t\t\t\t\tpieces[pieces.length -1] += ret;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tpieces.push(ret);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlastWasText = isText;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tpieces.push(ret);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (pretty && hasLarge) {\n\t\t\tfor (let i=pieces.length; i--; ) {\n\t\t\t\tpieces[i] = '\\n' + indentChar + indent(pieces[i], indentChar);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (pieces.length) {\n\t\ts += pieces.join('');\n\t}\n\telse if (opts && opts.xml) {\n\t\treturn s.substring(0, s.length-1) + ' />';\n\t}\n\n\tif (!isVoid) {\n\t\tif (pretty && ~s.indexOf('\\n')) s += '\\n';\n\t\ts += `</${nodeName}>`;\n\t}\n\n\treturn s;\n}\n\nfunction getComponentName(component) {\n\treturn component.displayName || component!==Function && component.name || getFallbackComponentName(component);\n}\n\nfunction getFallbackComponentName(component) {\n\tlet str = Function.prototype.toString.call(component),\n\t\tname = (str.match(/^\\s*function\\s+([^( ]+)/) || '')[1];\n\tif (!name) {\n\t\t// search for an existing indexed name for the given component:\n\t\tlet index = -1;\n\t\tfor (let i=UNNAMED.length; i--; ) {\n\t\t\tif (UNNAMED[i]===component) {\n\t\t\t\tindex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// not found, create a new indexed name:\n\t\tif (index<0) {\n\t\t\tindex = UNNAMED.push(component) - 1;\n\t\t}\n\t\tname = `UnnamedComponent${index}`;\n\t}\n\treturn name;\n}\nrenderToString.shallowRender = shallowRender;\n\nexport default renderToString;\n\nexport {\n\trenderToString as render,\n\trenderToString as renderToStaticMarkup,\n\trenderToString,\n\tshallowRender\n};\n"],"names":["const","IS_NON_DIMENSIONAL","encodeEntities","s","String","replace","indent","char","isLargeString","length","ignoreLines","indexOf","JS_TO_CSS","styleObjToCss","let","str","prop","val","toLowerCase","test","undefined","assign","obj","props","i","getChildren","accumulator","children","Array","isArray","reduce","push","SHALLOW","shallow","UNNAMED","VOID_ELEMENTS","noop","renderToString","render","shallowRender","vnode","context","opts","inner","isSvgMode","selectValue","createElement","Fragment","nodeName","type","isComponent","component","pretty","indentChar","renderRootComponent","rendered","shallowHighOrder","c","__c","__v","setState","forceUpdate","__h","options","__r","prototype","cxType","contextType","provider","cctx","value","__","_dirty","__d","state","_nextState","__s","getDerivedStateFromProps","componentWillMount","call","getChildContext","displayName","Function","name","toString","match","index","getFallbackComponentName","propChildren","html","attrs","Object","keys","sortAttributes","sort","v","allAttributes","class","for","hooked","attributeHook","__html","xml","sub","Error","isVoid","voidElements","pieces","hasLarge","lastWasText","child","ret","isText","join","substring"],"mappings":"kEACOA,IAAMC,EAAqB,kEAEvBC,WAAiBC,UAAKC,OAAOD,GACtCE,QAAQ,KAAM,SACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,WAELC,WAAUH,EAAGI,UAASH,OAAOD,GAAGE,QAAQ,SAAU,MAAQE,GAAQ,QAElEC,WAAiBL,EAAGM,EAAQC,UAAiBN,OAAOD,GAAGM,QAAQA,GAAU,MAASC,IAA0C,IAA3BN,OAAOD,GAAGQ,QAAQ,QAAyC,IAA1BP,OAAOD,GAAGQ,QAAQ,MAEzJC,KAGC,SAASC,EAAcV,GAC7BW,IAAIC,EAAM,GACV,IAAKD,IAAIE,KAAQb,EAAG,CACnBW,IAAIG,EAAMd,EAAEa,GACH,MAALC,IACCF,IAAKA,GAAO,KAEhBA,GAAgB,KAATC,EAAK,GAAUA,EAAQJ,EAAUI,KAAUJ,EAAUI,GAAQA,EAAKX,QAAQ,WAAW,OAAOa,eACnGH,GAAO,KACPA,GAAOE,EACU,iBAANA,IAAkD,IAAhChB,EAAmBkB,KAAKH,KACpDD,GAAO,MAERA,GAAO,KAGT,OAAOA,QAAOK,EAUR,SAASC,EAAOC,EAAKC,GAC3B,IAAKT,IAAIU,KAAKD,EAAOD,EAAIE,GAAKD,EAAMC,GACpC,OAAOF,EAUD,SAASG,EAAYC,EAAaC,GAOxC,OANIC,MAAMC,QAAQF,GACjBA,EAASG,OAAOL,EAAaC,GAEX,MAAVC,IAA6B,IAAXA,GAC1BD,EAAYK,KAAKJ,GAEXD,EC1DR1B,IAAMgC,GAAYC,SAAS,GAGrBC,KAEAC,EAAgB,2EAEhBC,eAcNC,EAAeC,OAASD,EAUxBvB,IAAIyB,WAAiBC,EAAOC,UAAYJ,EAAeG,EAAOC,EAAST,IAIvE,SAASK,EA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AClBL,EAAOA,EAAOlG,OAAQ,IAAMsG,EAG5BJ,EAAO5E,KAAKgF,GAGbF,EAAcG,OAGdL,EAAO5E,KAAKgF,IAKhB,GAAI3D,GAAUwD,EACb,IAAK9F,IAAIU,EAAEmF,EAAOlG,OAAQe,KACzBmF,EAAOnF,GAAK,KAAO6B,EAAa/C,EAAOqG,EAAOnF,GAAI6B,GAKrD,GAAIsD,EAAOlG,OACVN,GAAKwG,EAAOM,KAAK,SAEb,GAAIvE,GAAQA,EAAK4D,IACrB,OAAOnG,EAAE+G,UAAU,EAAG/G,EAAEM,OAAO,GAAK,MAQrC,OALKgG,IACArD,IAAWjD,EAAEQ,QAAQ,QAAOR,GAAK,MACrCA,GAAK,KAAK6C,OAGJ7C,EA2BRkC,EAAeE,cAAgBA"}
|
|
1
|
+
{"version":3,"file":"index.module.js","sources":["../src/util.js","../src/index.js"],"sourcesContent":["// DOM properties that should NOT have \"px\" added when numeric\nexport const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;\n\nexport function encodeEntities(s) {\n\tif (typeof s !== 'string') s = String(s);\n\tlet out = '';\n\tfor (let i = 0; i < s.length; i++) {\n\t\tlet ch = s[i];\n\t\t// prettier-ignore\n\t\tswitch (ch) {\n\t\t\tcase '<': out += '<'; break;\n\t\t\tcase '>': out += '>'; break;\n\t\t\tcase '\"': out += '"'; break;\n\t\t\tcase '&': out += '&'; break;\n\t\t\tdefault: out += ch;\n\t\t}\n\t}\n\treturn out;\n}\n\nexport let indent = (s, char) =>\n\tString(s).replace(/(\\n+)/g, '$1' + (char || '\\t'));\n\nexport let isLargeString = (s, length, ignoreLines) =>\n\tString(s).length > (length || 40) ||\n\t(!ignoreLines && String(s).indexOf('\\n') !== -1) ||\n\tString(s).indexOf('<') !== -1;\n\nconst JS_TO_CSS = {};\n\n// Convert an Object style to a CSSText string\nexport function styleObjToCss(s) {\n\tlet str = '';\n\tfor (let prop in s) {\n\t\tlet val = s[prop];\n\t\tif (val != null) {\n\t\t\tif (str) str += ' ';\n\t\t\t// str += jsToCss(prop);\n\t\t\tstr +=\n\t\t\t\tprop[0] == '-'\n\t\t\t\t\t? prop\n\t\t\t\t\t: JS_TO_CSS[prop] ||\n\t\t\t\t\t (JS_TO_CSS[prop] = prop.replace(/([A-Z])/g, '-$1').toLowerCase());\n\t\t\tstr += ': ';\n\t\t\tstr += val;\n\t\t\tif (typeof val === 'number' && IS_NON_DIMENSIONAL.test(prop) === false) {\n\t\t\t\tstr += 'px';\n\t\t\t}\n\t\t\tstr += ';';\n\t\t}\n\t}\n\treturn str || undefined;\n}\n\n/**\n * Copy all properties from `props` onto `obj`.\n * @param {object} obj Object onto which properties should be copied.\n * @param {object} props Object from which to copy properties.\n * @returns {object}\n * @private\n */\nexport function assign(obj, props) {\n\tfor (let i in props) obj[i] = props[i];\n\treturn obj;\n}\n\n/**\n * Get flattened children from the children prop\n * @param {Array} accumulator\n * @param {any} children A `props.children` opaque object.\n * @returns {Array} accumulator\n * @private\n */\nexport function getChildren(accumulator, children) {\n\tif (Array.isArray(children)) {\n\t\tchildren.reduce(getChildren, accumulator);\n\t} else if (children != null && children !== false) {\n\t\taccumulator.push(children);\n\t}\n\treturn accumulator;\n}\n","import {\n\tencodeEntities,\n\tindent,\n\tisLargeString,\n\tstyleObjToCss,\n\tassign,\n\tgetChildren\n} from './util';\nimport { options, Fragment, createElement } from 'preact';\n\nconst SHALLOW = { shallow: true };\n\n// components without names, kept as a hash for later comparison to return consistent UnnamedComponentXX names.\nconst UNNAMED = [];\n\nconst VOID_ELEMENTS = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;\n\nconst noop = () => {};\n\n/** Render Preact JSX + Components to an HTML string.\n *\t@name render\n *\t@function\n *\t@param {VNode} vnode\tJSX VNode to render.\n *\t@param {Object} [context={}]\tOptionally pass an initial context object through the render path.\n *\t@param {Object} [options={}]\tRendering options\n *\t@param {Boolean} [options.shallow=false]\tIf `true`, renders nested Components as HTML elements (`<Foo a=\"b\" />`).\n *\t@param {Boolean} [options.xml=false]\t\tIf `true`, uses self-closing tags for elements without children.\n *\t@param {Boolean} [options.pretty=false]\t\tIf `true`, adds whitespace for readability\n *\t@param {RegEx|undefined} [options.voidElements] RegeEx that matches elements that are considered void (self-closing)\n */\nrenderToString.render = renderToString;\n\n/** Only render elements, leaving Components inline as `<ComponentName ... />`.\n *\tThis method is just a convenience alias for `render(vnode, context, { shallow:true })`\n *\t@name shallow\n *\t@function\n *\t@param {VNode} vnode\tJSX VNode to render.\n *\t@param {Object} [context={}]\tOptionally pass an initial context object through the render path.\n */\nlet shallowRender = (vnode, context) => renderToString(vnode, context, SHALLOW);\n\n/** The default export is an alias of `render()`. */\nfunction renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {\n\tif (vnode == null || typeof vnode === 'boolean') {\n\t\treturn '';\n\t}\n\n\t// wrap array nodes in Fragment\n\tif (Array.isArray(vnode)) {\n\t\tvnode = createElement(Fragment, null, vnode);\n\t}\n\n\tlet nodeName = vnode.type,\n\t\tprops = vnode.props,\n\t\tisComponent = false;\n\tcontext = context || {};\n\topts = opts || {};\n\n\tlet pretty = opts.pretty,\n\t\tindentChar = pretty && typeof pretty === 'string' ? pretty : '\\t';\n\n\t// #text nodes\n\tif (typeof vnode !== 'object' && !nodeName) {\n\t\treturn encodeEntities(vnode);\n\t}\n\n\t// components\n\tif (typeof nodeName === 'function') {\n\t\tisComponent = true;\n\t\tif (opts.shallow && (inner || opts.renderRootComponent === false)) {\n\t\t\tnodeName = getComponentName(nodeName);\n\t\t} else if (nodeName === Fragment) {\n\t\t\tlet rendered = '';\n\t\t\tlet children = [];\n\t\t\tgetChildren(children, vnode.props.children);\n\n\t\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\t\trendered +=\n\t\t\t\t\t(i > 0 && pretty ? '\\n' : '') +\n\t\t\t\t\trenderToString(\n\t\t\t\t\t\tchildren[i],\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\topts,\n\t\t\t\t\t\topts.shallowHighOrder !== false,\n\t\t\t\t\t\tisSvgMode,\n\t\t\t\t\t\tselectValue\n\t\t\t\t\t);\n\t\t\t}\n\t\t\treturn rendered;\n\t\t} else {\n\t\t\tlet rendered;\n\n\t\t\tlet c = (vnode.__c = {\n\t\t\t\t__v: vnode,\n\t\t\t\tcontext,\n\t\t\t\tprops: vnode.props,\n\t\t\t\t// silently drop state updates\n\t\t\t\tsetState: noop,\n\t\t\t\tforceUpdate: noop,\n\t\t\t\t// hooks\n\t\t\t\t__h: []\n\t\t\t});\n\n\t\t\t// options._diff\n\t\t\tif (options.__b) options.__b(vnode);\n\n\t\t\t// options._render\n\t\t\tif (options.__r) options.__r(vnode);\n\n\t\t\tif (\n\t\t\t\t!nodeName.prototype ||\n\t\t\t\ttypeof nodeName.prototype.render !== 'function'\n\t\t\t) {\n\t\t\t\t// Necessary for createContext api. Setting this property will pass\n\t\t\t\t// the context value as `this.context` just for this component.\n\t\t\t\tlet cxType = nodeName.contextType;\n\t\t\t\tlet provider = cxType && context[cxType.__c];\n\t\t\t\tlet cctx =\n\t\t\t\t\tcxType != null\n\t\t\t\t\t\t? provider\n\t\t\t\t\t\t\t? provider.props.value\n\t\t\t\t\t\t\t: cxType.__\n\t\t\t\t\t\t: context;\n\n\t\t\t\t// stateless functional components\n\t\t\t\trendered = nodeName.call(vnode.__c, props, cctx);\n\t\t\t} else {\n\t\t\t\t// class-based components\n\t\t\t\tlet cxType = nodeName.contextType;\n\t\t\t\tlet provider = cxType && context[cxType.__c];\n\t\t\t\tlet cctx =\n\t\t\t\t\tcxType != null\n\t\t\t\t\t\t? provider\n\t\t\t\t\t\t\t? provider.props.value\n\t\t\t\t\t\t\t: cxType.__\n\t\t\t\t\t\t: context;\n\n\t\t\t\t// c = new nodeName(props, context);\n\t\t\t\tc = vnode.__c = new nodeName(props, cctx);\n\t\t\t\tc.__v = vnode;\n\t\t\t\t// turn off stateful re-rendering:\n\t\t\t\tc._dirty = c.__d = true;\n\t\t\t\tc.props = props;\n\t\t\t\tif (c.state == null) c.state = {};\n\n\t\t\t\tif (c._nextState == null && c.__s == null) {\n\t\t\t\t\tc._nextState = c.__s = c.state;\n\t\t\t\t}\n\n\t\t\t\tc.context = cctx;\n\t\t\t\tif (nodeName.getDerivedStateFromProps)\n\t\t\t\t\tc.state = assign(\n\t\t\t\t\t\tassign({}, c.state),\n\t\t\t\t\t\tnodeName.getDerivedStateFromProps(c.props, c.state)\n\t\t\t\t\t);\n\t\t\t\telse if (c.componentWillMount) {\n\t\t\t\t\tc.componentWillMount();\n\n\t\t\t\t\t// If the user called setState in cWM we need to flush pending,\n\t\t\t\t\t// state updates. This is the same behaviour in React.\n\t\t\t\t\tc.state =\n\t\t\t\t\t\tc._nextState !== c.state\n\t\t\t\t\t\t\t? c._nextState\n\t\t\t\t\t\t\t: c.__s !== c.state\n\t\t\t\t\t\t\t? c.__s\n\t\t\t\t\t\t\t: c.state;\n\t\t\t\t}\n\n\t\t\t\trendered = c.render(c.props, c.state, c.context);\n\t\t\t}\n\n\t\t\tif (c.getChildContext) {\n\t\t\t\tcontext = assign(assign({}, context), c.getChildContext());\n\t\t\t}\n\n\t\t\treturn renderToString(\n\t\t\t\trendered,\n\t\t\t\tcontext,\n\t\t\t\topts,\n\t\t\t\topts.shallowHighOrder !== false,\n\t\t\t\tisSvgMode,\n\t\t\t\tselectValue\n\t\t\t);\n\t\t}\n\t}\n\n\t// render JSX to HTML\n\tlet s = '',\n\t\tpropChildren,\n\t\thtml;\n\n\tif (props) {\n\t\tlet attrs = Object.keys(props);\n\n\t\t// allow sorting lexicographically for more determinism (useful for tests, such as via preact-jsx-chai)\n\t\tif (opts && opts.sortAttributes === true) attrs.sort();\n\n\t\tfor (let i = 0; i < attrs.length; i++) {\n\t\t\tlet name = attrs[i],\n\t\t\t\tv = props[name];\n\t\t\tif (name === 'children') {\n\t\t\t\tpropChildren = v;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (name.match(/[\\s\\n\\\\/='\"\\0<>]/)) continue;\n\n\t\t\tif (\n\t\t\t\t!(opts && opts.allAttributes) &&\n\t\t\t\t(name === 'key' ||\n\t\t\t\t\tname === 'ref' ||\n\t\t\t\t\tname === '__self' ||\n\t\t\t\t\tname === '__source' ||\n\t\t\t\t\tname === 'defaultValue')\n\t\t\t)\n\t\t\t\tcontinue;\n\n\t\t\tif (name === 'className') {\n\t\t\t\tif (props.class) continue;\n\t\t\t\tname = 'class';\n\t\t\t} else if (isSvgMode && name.match(/^xlink:?./)) {\n\t\t\t\tname = name.toLowerCase().replace(/^xlink:?/, 'xlink:');\n\t\t\t}\n\n\t\t\tif (name === 'htmlFor') {\n\t\t\t\tif (props.for) continue;\n\t\t\t\tname = 'for';\n\t\t\t}\n\n\t\t\tif (name === 'style' && v && typeof v === 'object') {\n\t\t\t\tv = styleObjToCss(v);\n\t\t\t}\n\n\t\t\t// always use string values instead of booleans for aria attributes\n\t\t\t// also see https://github.com/preactjs/preact/pull/2347/files\n\t\t\tif (name[0] === 'a' && name['1'] === 'r' && typeof v === 'boolean') {\n\t\t\t\tv = String(v);\n\t\t\t}\n\n\t\t\tlet hooked =\n\t\t\t\topts.attributeHook &&\n\t\t\t\topts.attributeHook(name, v, context, opts, isComponent);\n\t\t\tif (hooked || hooked === '') {\n\t\t\t\ts += hooked;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (name === 'dangerouslySetInnerHTML') {\n\t\t\t\thtml = v && v.__html;\n\t\t\t} else if (nodeName === 'textarea' && name === 'value') {\n\t\t\t\t// <textarea value=\"a&b\"> --> <textarea>a&b</textarea>\n\t\t\t\tpropChildren = v;\n\t\t\t} else if ((v || v === 0 || v === '') && typeof v !== 'function') {\n\t\t\t\tif (v === true || v === '') {\n\t\t\t\t\tv = name;\n\t\t\t\t\t// in non-xml mode, allow boolean attributes\n\t\t\t\t\tif (!opts || !opts.xml) {\n\t\t\t\t\t\ts += ' ' + name;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (name === 'value') {\n\t\t\t\t\tif (nodeName === 'select') {\n\t\t\t\t\t\tselectValue = v;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else if (nodeName === 'option' && selectValue == v) {\n\t\t\t\t\t\ts += ` selected`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ts += ` ${name}=\"${encodeEntities(v)}\"`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// account for >1 multiline attribute\n\tif (pretty) {\n\t\tlet sub = s.replace(/^\\n\\s*/, ' ');\n\t\tif (sub !== s && !~sub.indexOf('\\n')) s = sub;\n\t\telse if (pretty && ~s.indexOf('\\n')) s += '\\n';\n\t}\n\n\ts = `<${nodeName}${s}>`;\n\tif (String(nodeName).match(/[\\s\\n\\\\/='\"\\0<>]/))\n\t\tthrow new Error(`${nodeName} is not a valid HTML tag name in ${s}`);\n\n\tlet isVoid =\n\t\tString(nodeName).match(VOID_ELEMENTS) ||\n\t\t(opts.voidElements && String(nodeName).match(opts.voidElements));\n\tlet pieces = [];\n\n\tlet children;\n\tif (html) {\n\t\t// if multiline, indent.\n\t\tif (pretty && isLargeString(html)) {\n\t\t\thtml = '\\n' + indentChar + indent(html, indentChar);\n\t\t}\n\t\ts += html;\n\t} else if (\n\t\tpropChildren != null &&\n\t\tgetChildren((children = []), propChildren).length\n\t) {\n\t\tlet hasLarge = pretty && ~s.indexOf('\\n');\n\t\tlet lastWasText = false;\n\n\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\tlet child = children[i];\n\n\t\t\tif (child != null && child !== false) {\n\t\t\t\tlet childSvgMode =\n\t\t\t\t\t\tnodeName === 'svg'\n\t\t\t\t\t\t\t? true\n\t\t\t\t\t\t\t: nodeName === 'foreignObject'\n\t\t\t\t\t\t\t? false\n\t\t\t\t\t\t\t: isSvgMode,\n\t\t\t\t\tret = renderToString(\n\t\t\t\t\t\tchild,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\topts,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tchildSvgMode,\n\t\t\t\t\t\tselectValue\n\t\t\t\t\t);\n\n\t\t\t\tif (pretty && !hasLarge && isLargeString(ret)) hasLarge = true;\n\n\t\t\t\t// Skip if we received an empty string\n\t\t\t\tif (ret) {\n\t\t\t\t\tif (pretty) {\n\t\t\t\t\t\tlet isText = ret.length > 0 && ret[0] != '<';\n\n\t\t\t\t\t\t// We merge adjacent text nodes, otherwise each piece would be printed\n\t\t\t\t\t\t// on a new line.\n\t\t\t\t\t\tif (lastWasText && isText) {\n\t\t\t\t\t\t\tpieces[pieces.length - 1] += ret;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpieces.push(ret);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlastWasText = isText;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpieces.push(ret);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (pretty && hasLarge) {\n\t\t\tfor (let i = pieces.length; i--; ) {\n\t\t\t\tpieces[i] = '\\n' + indentChar + indent(pieces[i], indentChar);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (pieces.length) {\n\t\ts += pieces.join('');\n\t} else if (opts && opts.xml) {\n\t\treturn s.substring(0, s.length - 1) + ' />';\n\t}\n\n\tif (isVoid && !children) {\n\t\ts = s.replace(/>$/, ' />');\n\t} else {\n\t\tif (pretty && ~s.indexOf('\\n')) s += '\\n';\n\t\ts += `</${nodeName}>`;\n\t}\n\n\treturn s;\n}\n\nfunction getComponentName(component) {\n\treturn (\n\t\tcomponent.displayName ||\n\t\t(component !== Function && component.name) ||\n\t\tgetFallbackComponentName(component)\n\t);\n}\n\nfunction getFallbackComponentName(component) {\n\tlet str = Function.prototype.toString.call(component),\n\t\tname = (str.match(/^\\s*function\\s+([^( ]+)/) || '')[1];\n\tif (!name) {\n\t\t// search for an existing indexed name for the given component:\n\t\tlet index = -1;\n\t\tfor (let i = UNNAMED.length; i--; ) {\n\t\t\tif (UNNAMED[i] === component) {\n\t\t\t\tindex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// not found, create a new indexed name:\n\t\tif (index < 0) {\n\t\t\tindex = UNNAMED.push(component) - 1;\n\t\t}\n\t\tname = `UnnamedComponent${index}`;\n\t}\n\treturn name;\n}\nrenderToString.shallowRender = shallowRender;\n\nexport default renderToString;\n\nexport {\n\trenderToString as render,\n\trenderToString as renderToStaticMarkup,\n\trenderToString,\n\tshallowRender\n};\n"],"names":["const","IS_NON_DIMENSIONAL","encodeEntities","s","String","let","out","i","length","ch","indent","char","replace","isLargeString","ignoreLines","indexOf","JS_TO_CSS","styleObjToCss","str","prop","val","toLowerCase","test","undefined","assign","obj","props","getChildren","accumulator","children","Array","isArray","reduce","push","SHALLOW","shallow","UNNAMED","VOID_ELEMENTS","noop","renderToString","render","shallowRender","vnode","context","opts","inner","isSvgMode","selectValue","createElement","Fragment","nodeName","type","isComponent","component","pretty","indentChar","renderRootComponent","rendered","shallowHighOrder","c","__c","__v","setState","forceUpdate","__h","options","__b","__r","prototype","cxType","contextType","provider","cctx","value","__","_dirty","__d","state","_nextState","__s","getDerivedStateFromProps","componentWillMount","call","getChildContext","displayName","Function","name","toString","match","index","getFallbackComponentName","propChildren","html","attrs","Object","keys","sortAttributes","sort","v","allAttributes","class","for","hooked","attributeHook","__html","xml","sub","Error","isVoid","voidElements","pieces","hasLarge","lastWasText","child","ret","isText","join","substring"],"mappings":"kEACOA,IAAMC,EAAqB,kEAE3B,SAASC,EAAeC,GACb,iBAANA,IAAgBA,EAAIC,OAAOD,IAEtC,IADAE,IAAIC,EAAM,GACDC,EAAI,EAAGA,EAAIJ,EAAEK,OAAQD,IAAK,CAClCF,IAAII,EAAKN,EAAEI,GAEX,OAAQE,GACP,IAAK,IAAKH,GAAO,OAAQ,MACzB,IAAK,IAAKA,GAAO,OAAQ,MACzB,IAAK,IAAK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G,GAAIgD,GAKrD,GAAIuD,EAAOtG,OACVL,GAAK2G,EAAOM,KAAK,SACX,GAAIxE,GAAQA,EAAK6D,IACvB,OAAOtG,EAAEkH,UAAU,EAAGlH,EAAEK,OAAS,GAAK,MAUvC,OAPIoG,IAAW/E,EACd1B,EAAIA,EAAES,QAAQ,KAAM,QAEhB0C,IAAWnD,EAAEY,QAAQ,QAAOZ,GAAK,MACrCA,GAAK,KAAK+C,OAGJ/C,EA+BRoC,EAAeE,cAAgBA"}
|
package/dist/jsx.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { VNode } from 'preact';
|
|
2
2
|
|
|
3
3
|
interface Options {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
jsx?: boolean;
|
|
5
|
+
xml?: boolean;
|
|
6
|
+
functions?: boolean;
|
|
7
|
+
functionNames?: boolean;
|
|
8
|
+
skipFalseAttributes?: boolean;
|
|
9
|
+
pretty?: boolean | string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export function render(vnode: VNode, context?: any, options?: Options):string;
|
|
12
|
+
export function render(vnode: VNode, context?: any, options?: Options): string;
|
|
13
13
|
export default render;
|
package/dist/jsx.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e,t;e=void 0,t=function(){if("function"!=typeof Symbol){var e=0;Symbol=function(t){return"@@"+t+ ++e},Symbol.for=function(e){return"@@"+e}}var t=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,n=function(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},r=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},o=function(e,t,n){return String(e).length>(t||40)||!n&&-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},l={};function i(e){var n="";for(var r in e){var o=e[r];null!=o&&(n&&(n+=" "),n+="-"==r[0]?r:l[r]||(l[r]=r.replace(/([A-Z])/g,"-$1").toLowerCase()),n+=": ",n+=o,"number"==typeof o&&!1===t.test(r)&&(n+="px"),n+=";")}return n||void 0}function u(e,t){for(var n in t)e[n]=t[n];return e}function c(e,t){return Array.isArray(t)?t.reduce(c,e):null!=t&&!1!==t&&e.push(t),e}var a,_,f,s,p={},d=[],y=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i;function h(e,t){for(var n in t)e[n]=t[n];return e}function v(e){var t=e.parentNode;t&&t.removeChild(e)}function m(e,t,n){var r,o=arguments,l={};for(r in t)"key"!==r&&"ref"!==r&&(l[r]=t[r]);if(arguments.length>3)for(n=[n],r=3;r<arguments.length;r++)n.push(o[r]);if(null!=n&&(l.children=n),"function"==typeof e&&null!=e.defaultProps)for(r in e.defaultProps)void 0===l[r]&&(l[r]=e.defaultProps[r]);return g(e,l,t&&t.key,t&&t.ref)}function g(e,t,n,r){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:null,__c:null,constructor:void 0};return a.vnode&&a.vnode(o),o}function b(e){return e.children}function k(e,t){this.props=e,this.context=t}function S(e,t){if(null==t)return e.__?S(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?S(e):null}function x(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return x(e)}}function w(e){(!e.__d&&(e.__d=!0)&&1===_.push(e)||s!==a.debounceRendering)&&((s=a.debounceRendering)||f)(j)}function j(){var e,t,n,r,o,l,i;for(_.sort(function(e,t){return t.__v.__b-e.__v.__b});e=_.pop();)e.__d&&(n=void 0,r=void 0,l=(o=(t=e).__v).__e,(i=t.__P)&&(n=[],r=N(i,o,h({},o),t.__n,void 0!==i.ownerSVGElement,null,n,null==l?S(o):l),P(n,o),r!=l&&x(o)))}function A(e,t,n,r,o,l,i,u,c){var a,_,f,s,y,h,m,g=n&&n.__k||d,b=g.length;if(u==p&&(u=null!=l?l[0]:b?S(n,0):null),a=0,t.__k=O(t.__k,function(n){if(null!=n){if(n.__=t,n.__b=t.__b+1,null===(f=g[a])||f&&n.key==f.key&&n.type===f.type)g[a]=void 0;else for(_=0;_<b;_++){if((f=g[_])&&n.key==f.key&&n.type===f.type){g[_]=void 0;break}f=null}if(s=N(e,n,f=f||p,r,o,l,i,u,c),(_=n.ref)&&f.ref!=_&&(m||(m=[]),f.ref&&m.push(f.ref,null,n),m.push(_,n.__c||s,n)),null!=s){if(null==h&&(h=s),null!=n.__d)s=n.__d,n.__d=null;else if(l==f||s!=u||null==s.parentNode){e:if(null==u||u.parentNode!==e)e.appendChild(s);else{for(y=u,_=0;(y=y.nextSibling)&&_<b;_+=2)if(y==s)break e;e.insertBefore(s,u)}"option"==t.type&&(e.value="")}u=s.nextSibling,"function"==typeof t.type&&(t.__d=s)}}return a++,n}),t.__e=h,null!=l&&"function"!=typeof t.type)for(a=l.length;a--;)null!=l[a]&&v(l[a]);for(a=b;a--;)null!=g[a]&&U(g[a],g[a]);if(m)for(a=0;a<m.length;a++)M(m[a],m[++a],m[++a])}function O(e,t,n){if(null==n&&(n=[]),null==e||"boolean"==typeof e)t&&n.push(t(null));else if(Array.isArray(e))for(var r=0;r<e.length;r++)O(e[r],t,n);else n.push(t?t("string"==typeof e||"number"==typeof e?g(null,e,null,null):null!=e.__e||null!=e.__c?g(e.type,e.props,e.key,null):e):e);return n}function C(e,t,n){"-"===t[0]?e.setProperty(t,n):e[t]="number"==typeof n&&!1===y.test(t)?n+"px":null==n?"":n}function E(e,t,n,r,o){var l,i,u,c,a;if(o?"className"===t&&(t="class"):"class"===t&&(t="className"),"key"===t||"children"===t);else if("style"===t)if(l=e.style,"string"==typeof n)l.cssText=n;else{if("string"==typeof r&&(l.cssText="",r=null),r)for(i in r)n&&i in n||C(l,i,"");if(n)for(u in n)r&&n[u]===r[u]||C(l,u,n[u])}else"o"===t[0]&&"n"===t[1]?(c=t!==(t=t.replace(/Capture$/,"")),t=((a=t.toLowerCase())in e?a:t).slice(2),n?(r||e.addEventListener(t,F,c),(e.l||(e.l={}))[t]=n):e.removeEventListener(t,F,c)):"list"!==t&&"tagName"!==t&&"form"!==t&&"type"!==t&&!o&&t in e?e[t]=null==n?"":n:"function"!=typeof n&&"dangerouslySetInnerHTML"!==t&&(t!==(t=t.replace(/^xlink:?/,""))?null==n||!1===n?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),n):null==n||!1===n?e.removeAttribute(t):e.setAttribute(t,n))}function F(e){this.l[e.type](a.event?a.event(e):e)}function N(e,t,n,r,o,l,i,u,c){var _,f,s,p,d,y,v,m,g,S,x=t.type;if(void 0!==t.constructor)return null;(_=a.__b)&&_(t);try{e:if("function"==typeof x){if(m=t.props,g=(_=x.contextType)&&r[_.__c],S=_?g?g.props.value:_.__:r,n.__c?v=(f=t.__c=n.__c).__=f.__E:("prototype"in x&&x.prototype.render?t.__c=f=new x(m,S):(t.__c=f=new k(m,S),f.constructor=x,f.render=T),g&&g.sub(f),f.props=m,f.state||(f.state={}),f.context=S,f.__n=r,s=f.__d=!0,f.__h=[]),null==f.__s&&(f.__s=f.state),null!=x.getDerivedStateFromProps&&(f.__s==f.state&&(f.__s=h({},f.__s)),h(f.__s,x.getDerivedStateFromProps(m,f.__s))),p=f.props,d=f.state,s)null==x.getDerivedStateFromProps&&null!=f.componentWillMount&&f.componentWillMount(),null!=f.componentDidMount&&f.__h.push(f.componentDidMount);else{if(null==x.getDerivedStateFromProps&&m!==p&&null!=f.componentWillReceiveProps&&f.componentWillReceiveProps(m,S),!f.__e&&null!=f.shouldComponentUpdate&&!1===f.shouldComponentUpdate(m,f.__s,S)){for(f.props=m,f.state=f.__s,f.__d=!1,f.__v=t,t.__e=n.__e,t.__k=n.__k,f.__h.length&&i.push(f),_=0;_<t.__k.length;_++)t.__k[_]&&(t.__k[_].__=t);break e}null!=f.componentWillUpdate&&f.componentWillUpdate(m,f.__s,S),null!=f.componentDidUpdate&&f.__h.push(function(){f.componentDidUpdate(p,d,y)})}f.context=S,f.props=m,f.state=f.__s,(_=a.__r)&&_(t),f.__d=!1,f.__v=t,f.__P=e,_=f.render(f.props,f.state,f.context),t.__k=O(null!=_&&_.type==b&&null==_.key?_.props.children:_),null!=f.getChildContext&&(r=h(h({},r),f.getChildContext())),s||null==f.getSnapshotBeforeUpdate||(y=f.getSnapshotBeforeUpdate(p,d)),A(e,t,n,r,o,l,i,u,c),f.base=t.__e,f.__h.length&&i.push(f),v&&(f.__E=f.__=null),f.__e=null}else t.__e=D(n.__e,t,n,r,o,l,i,c);(_=a.diffed)&&_(t)}catch(e){a.__e(e,t,n)}return t.__e}function P(e,t){a.__c&&a.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){a.__e(e,t.__v)}})}function D(e,t,n,r,o,l,i,u){var c,a,_,f,s,y=n.props,h=t.props;if(o="svg"===t.type||o,null==e&&null!=l)for(c=0;c<l.length;c++)if(null!=(a=l[c])&&(null===t.type?3===a.nodeType:a.localName===t.type)){e=a,l[c]=null;break}if(null==e){if(null===t.type)return document.createTextNode(h);e=o?document.createElementNS("http://www.w3.org/2000/svg",t.type):document.createElement(t.type),l=null}if(null===t.type)null!=l&&(l[l.indexOf(e)]=null),y!==h&&e.data!=h&&(e.data=h);else if(t!==n){if(null!=l&&(l=d.slice.call(e.childNodes)),_=(y=n.props||p).dangerouslySetInnerHTML,f=h.dangerouslySetInnerHTML,!u){if(y===p)for(y={},s=0;s<e.attributes.length;s++)y[e.attributes[s].name]=e.attributes[s].value;(f||_)&&(f&&_&&f.__html==_.__html||(e.innerHTML=f&&f.__html||""))}(function(e,t,n,r,o){var l;for(l in n)l in t||E(e,l,null,n[l],r);for(l in t)o&&"function"!=typeof t[l]||"value"===l||"checked"===l||n[l]===t[l]||E(e,l,t[l],n[l],r)})(e,h,y,o,u),t.__k=t.props.children,f||A(e,t,n,r,"foreignObject"!==t.type&&o,l,i,p,u),u||("value"in h&&void 0!==h.value&&h.value!==e.value&&(e.value=null==h.value?"":h.value),"checked"in h&&void 0!==h.checked&&h.checked!==e.checked&&(e.checked=h.checked))}return e}function M(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(e){a.__e(e,n)}}function U(e,t,n){var r,o,l;if(a.unmount&&a.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||M(r,null,t)),n||"function"==typeof e.type||(n=null!=(o=e.__e)),e.__e=e.__d=null,null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){a.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(l=0;l<r.length;l++)r[l]&&U(r[l],t,n);null!=o&&v(o)}function T(e,t,n){return this.constructor(e,n)}a={__e:function(e,t){for(var n,r;t=t.__;)if((n=t.__c)&&!n.__)try{if(n.constructor&&null!=n.constructor.getDerivedStateFromError&&(r=!0,n.setState(n.constructor.getDerivedStateFromError(e))),null!=n.componentDidCatch&&(r=!0,n.componentDidCatch(e)),r)return w(n.__E=n)}catch(t){e=t}throw e}},k.prototype.setState=function(e,t){var n;n=this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof e&&(e=e(n,this.props)),e&&h(n,e),null!=e&&this.__v&&(this.__e=!1,t&&this.__h.push(t),w(this))},k.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),w(this))},k.prototype.render=b,_=[],f="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout;var L={shallow:!0},W=[],H=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,I=function(){};function $(e,t,l,_,f,s){if(null==e||"boolean"==typeof e)return"";Array.isArray(e)&&(e=m(b,null,e));var p=e.type,d=e.props,y=!1;t=t||{};var h,v=(l=l||{}).pretty,g=v&&"string"==typeof v?v:"\t";if("object"!=typeof e&&!p)return n(e);if("function"==typeof p){if(y=!0,!l.shallow||!_&&!1!==l.renderRootComponent){if(p===b){var k="",S=[];c(S,e.props.children);for(var x=0;x<S.length;x++)k+=(x>0&&v?"\n":"")+$(S[x],t,l,!1!==l.shallowHighOrder,f,s);return k}var w,j=e.__c={__v:e,context:t,props:e.props,setState:I,forceUpdate:I,__h:[]};if(a.__r&&a.__r(e),p.prototype&&"function"==typeof p.prototype.render){var A=p.contextType,O=A&&t[A.__c],C=null!=A?O?O.props.value:A.__:t;(j=e.__c=new p(d,C)).__v=e,j._dirty=j.__d=!0,j.props=d,null==j.state&&(j.state={}),null==j._nextState&&null==j.__s&&(j._nextState=j.__s=j.state),j.context=C,p.getDerivedStateFromProps?j.state=u(u({},j.state),p.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),w=j.render(j.props,j.state,j.context)}else{var E=p.contextType,F=E&&t[E.__c];w=p.call(e.__c,d,null!=E?F?F.props.value:E.__:t)}return j.getChildContext&&(t=u(u({},t),j.getChildContext())),$(w,t,l,!1!==l.shallowHighOrder,f,s)}p=(h=p).displayName||h!==Function&&h.name||function(e){var t=(Function.prototype.toString.call(e).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!t){for(var n=-1,r=W.length;r--;)if(W[r]===e){n=r;break}n<0&&(n=W.push(e)-1),t="UnnamedComponent"+n}return t}(h)}var N,P,D="";if(d){var M=Object.keys(d);l&&!0===l.sortAttributes&&M.sort();for(var U=0;U<M.length;U++){var T=M[U],L=d[T];if("children"!==T){if(!T.match(/[\s\n\\/='"\0<>]/)&&(l&&l.allAttributes||"key"!==T&&"ref"!==T&&"__self"!==T&&"__source"!==T)){if("className"===T){if(d.class)continue;T="class"}else f&&T.match(/^xlink:?./)&&(T=T.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===T){if(d.for)continue;T="for"}"style"===T&&L&&"object"==typeof L&&(L=i(L)),"a"===T[0]&&"r"===T[1]&&"boolean"==typeof L&&(L=String(L));var R=l.attributeHook&&l.attributeHook(T,L,t,l,y);if(R||""===R)D+=R;else if("dangerouslySetInnerHTML"===T)P=L&&L.__html;else if("textarea"===p&&"value"===T)N=L;else if((L||0===L||""===L)&&"function"!=typeof L){if(!(!0!==L&&""!==L||(L=T,l&&l.xml))){D+=" "+T;continue}if("value"===T){if("select"===p){s=L;continue}"option"===p&&s==L&&(D+=" selected")}D+=" "+T+'="'+n(L)+'"'}}}else N=L}}if(v){var B=D.replace(/^\n\s*/," ");B===D||~B.indexOf("\n")?v&&~D.indexOf("\n")&&(D+="\n"):D=B}if(D="<"+p+D+">",String(p).match(/[\s\n\\/='"\0<>]/))throw new Error(p+" is not a valid HTML tag name in "+D);var J=String(p).match(H)||l.voidElements&&String(p).match(l.voidElements);J&&(D=D.replace(/>$/," />"));var z,G=[];if(P)v&&o(P)&&(P="\n"+g+r(P,g)),D+=P;else if(null!=N&&c(z=[],N).length){for(var V=v&&~D.indexOf("\n"),q=!1,Z=0;Z<z.length;Z++){var K=z[Z];if(null!=K&&!1!==K){var Q=$(K,t,l,!0,"svg"===p||"foreignObject"!==p&&f,s);if(v&&!V&&o(Q)&&(V=!0),Q)if(v){var X=Q.length>0&&"<"!=Q[0];q&&X?G[G.length-1]+=Q:G.push(Q),q=X}else G.push(Q)}}if(v&&V)for(var Y=G.length;Y--;)G[Y]="\n"+g+r(G[Y],g)}if(G.length)D+=G.join("");else if(l&&l.xml)return D.substring(0,D.length-1)+" />";return J||(v&&~D.indexOf("\n")&&(D+="\n"),D+="</"+p+">"),D}$.render=$,$.shallowRender=function(e,t){return $(e,t,L)};var R=/(\\|\"|\')/g,B=function(e){return e.replace(R,"\\$1")},J=Object.prototype.toString,z=Date.prototype.toISOString,G=Error.prototype.toString,V=RegExp.prototype.toString,q=Symbol.prototype.toString,Z=/^Symbol\((.*)\)(.*)$/,K=/\n/gi,Q=Object.getOwnPropertySymbols||function(e){return[]};function X(e){return"[object Array]"===e||"[object ArrayBuffer]"===e||"[object DataView]"===e||"[object Float32Array]"===e||"[object Float64Array]"===e||"[object Int8Array]"===e||"[object Int16Array]"===e||"[object Int32Array]"===e||"[object Uint8Array]"===e||"[object Uint8ClampedArray]"===e||"[object Uint16Array]"===e||"[object Uint32Array]"===e}function Y(e){return""===e.name?"[Function anonymous]":"[Function "+e.name+"]"}function ee(e){return q.call(e).replace(Z,"Symbol($1)")}function te(e){return"["+G.call(e)+"]"}function ne(e){if(!0===e||!1===e)return""+e;if(void 0===e)return"undefined";if(null===e)return"null";var t=typeof e;if("number"===t)return function(e){return e!=+e?"NaN":0===e&&1/e<0?"-0":""+e}(e);if("string"===t)return'"'+B(e)+'"';if("function"===t)return Y(e);if("symbol"===t)return ee(e);var n=J.call(e);return"[object WeakMap]"===n?"WeakMap {}":"[object WeakSet]"===n?"WeakSet {}":"[object Function]"===n||"[object GeneratorFunction]"===n?Y(e,min):"[object Symbol]"===n?ee(e):"[object Date]"===n?z.call(e):"[object Error]"===n?te(e):"[object RegExp]"===n?V.call(e):"[object Arguments]"===n&&0===e.length?"Arguments []":X(n)&&0===e.length?e.constructor.name+" []":e instanceof Error&&te(e)}function re(e,t,n,r,o,l,i,u,c,a){var _="";if(e.length){_+=o;for(var f=n+t,s=0;s<e.length;s++)_+=f+ie(e[s],t,f,r,o,l,i,u,c,a),s<e.length-1&&(_+=","+r);_+=o+n}return"["+_+"]"}function oe(e,t,n,r,o,l,i,u,c,a){if((l=l.slice()).indexOf(e)>-1)return"[Circular]";l.push(e);var _=++u>i;if(!_&&e.toJSON&&"function"==typeof e.toJSON)return ie(e.toJSON(),t,n,r,o,l,i,u,c,a);var f=J.call(e);return"[object Arguments]"===f?_?"[Arguments]":function(e,t,n,r,o,l,i,u,c,a){return(a?"":"Arguments ")+re(e,t,n,r,o,l,i,u,c,a)}(e,t,n,r,o,l,i,u,c,a):X(f)?_?"[Array]":function(e,t,n,r,o,l,i,u,c,a){return(a?"":e.constructor.name+" ")+re(e,t,n,r,o,l,i,u,c,a)}(e,t,n,r,o,l,i,u,c,a):"[object Map]"===f?_?"[Map]":function(e,t,n,r,o,l,i,u,c,a){var _="Map {",f=e.entries(),s=f.next();if(!s.done){_+=o;for(var p=n+t;!s.done;)_+=p+ie(s.value[0],t,p,r,o,l,i,u,c,a)+" => "+ie(s.value[1],t,p,r,o,l,i,u,c,a),(s=f.next()).done||(_+=","+r);_+=o+n}return _+"}"}(e,t,n,r,o,l,i,u,c,a):"[object Set]"===f?_?"[Set]":function(e,t,n,r,o,l,i,u,c,a){var _="Set {",f=e.entries(),s=f.next();if(!s.done){_+=o;for(var p=n+t;!s.done;)_+=p+ie(s.value[1],t,p,r,o,l,i,u,c,a),(s=f.next()).done||(_+=","+r);_+=o+n}return _+"}"}(e,t,n,r,o,l,i,u,c,a):"object"==typeof e?_?"[Object]":function(e,t,n,r,o,l,i,u,c,a){var _=(a?"":e.constructor?e.constructor.name+" ":"Object ")+"{",f=Object.keys(e).sort(),s=Q(e);if(s.length&&(f=f.filter(function(e){return!("symbol"==typeof e||"[object Symbol]"===J.call(e))}).concat(s)),f.length){_+=o;for(var p=n+t,d=0;d<f.length;d++){var y=f[d];_+=p+ie(y,t,p,r,o,l,i,u,c,a)+": "+ie(e[y],t,p,r,o,l,i,u,c,a),d<f.length-1&&(_+=","+r)}_+=o+n}return _+"}"}(e,t,n,r,o,l,i,u,c,a):void 0}function le(e,t,n,r,o,l,i,u,c,a){for(var _,f=!1,s=0;s<c.length;s++)if((_=c[s]).test(e)){f=!0;break}return!!f&&_.print(e,function(e){return ie(e,t,n,r,o,l,i,u,c,a)},function(e){var r=n+t;return r+e.replace(K,"\n"+r)},{edgeSpacing:o,spacing:r})}function ie(e,t,n,r,o,l,i,u,c,a){var _=ne(e);return _||(le(e,t,n,r,o,l,i,u,c,a)||oe(e,t,n,r,o,l,i,u,c,a))}var ue={indent:2,min:!1,maxDepth:Infinity,plugins:[]};function ce(e){return new Array(e+1).join(" ")}var ae={test:function(e){return e&&"object"==typeof e&&"type"in e&&"props"in e&&"key"in e},print:function(e,t,n){return $(e,ae.context,ae.opts,!0)}},_e={plugins:[ae]},fe={attributeHook:function(e,t,o,l,i){var u=typeof t;if("dangerouslySetInnerHTML"===e)return!1;if(null==t||"function"===u&&!l.functions)return"";if(l.skipFalseAttributes&&!i&&(!1===t||("class"===e||"style"===e)&&""===t))return"";var c="string"==typeof l.pretty?l.pretty:"\t";return"string"!==u?("function"!==u||l.functionNames?(ae.context=o,ae.opts=l,~(t=function(e,t){var n,r;t?(function(e){if(Object.keys(e).forEach(function(e){if(!ue.hasOwnProperty(e))throw new Error("prettyFormat: Invalid option: "+e)}),e.min&&void 0!==e.indent&&0!==e.indent)throw new Error("prettyFormat: Cannot run with min option and indent")}(t),t=function(e){var t={};return Object.keys(ue).forEach(function(n){return t[n]=e.hasOwnProperty(n)?e[n]:ue[n]}),t.min&&(t.indent=0),t}(t)):t=ue;var o=t.min?" ":"\n",l=t.min?"":"\n";if(t&&t.plugins.length){var i=le(e,n=ce(t.indent),"",o,l,r=[],t.maxDepth,0,t.plugins,t.min);if(i)return i}return ne(e)||(n||(n=ce(t.indent)),r||(r=[]),oe(e,n,"",o,l,r,t.maxDepth,0,t.plugins,t.min))}(t,_e)).indexOf("\n")&&(t=r("\n"+t,c)+"\n")):t="Function",r("\n"+e+"={"+t+"}",c)):"\n"+c+e+'="'+n(t)+'"'},jsx:!0,xml:!1,functions:!0,functionNames:!0,skipFalseAttributes:!0,pretty:" "};return function(e,t,n,r){return $(e,t,n=u(u({},fe),n||{}),r)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.preactRenderToString=t();
|
|
1
|
+
var e,t;e=void 0,t=function(){if("function"!=typeof Symbol){var e=0;Symbol=function(t){return"@@"+t+ ++e},Symbol.for=function(e){return"@@"+e}}var t=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;function n(e){"string"!=typeof e&&(e=String(e));for(var t="",n=0;n<e.length;n++){var r=e[n];switch(r){case"<":t+="<";break;case">":t+=">";break;case'"':t+=""";break;case"&":t+="&";break;default:t+=r}}return t}var r=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},o=function(e,t,n){return String(e).length>(t||40)||!n&&-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},l={};function i(e){var n="";for(var r in e){var o=e[r];null!=o&&(n&&(n+=" "),n+="-"==r[0]?r:l[r]||(l[r]=r.replace(/([A-Z])/g,"-$1").toLowerCase()),n+=": ",n+=o,"number"==typeof o&&!1===t.test(r)&&(n+="px"),n+=";")}return n||void 0}function u(e,t){for(var n in t)e[n]=t[n];return e}function a(e,t){return Array.isArray(t)?t.reduce(a,e):null!=t&&!1!==t&&e.push(t),e}var c,_,f,s,p={},d=[],y=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i;function h(e,t){for(var n in t)e[n]=t[n];return e}function v(e){var t=e.parentNode;t&&t.removeChild(e)}function m(e,t,n){var r,o=arguments,l={};for(r in t)"key"!==r&&"ref"!==r&&(l[r]=t[r]);if(arguments.length>3)for(n=[n],r=3;r<arguments.length;r++)n.push(o[r]);if(null!=n&&(l.children=n),"function"==typeof e&&null!=e.defaultProps)for(r in e.defaultProps)void 0===l[r]&&(l[r]=e.defaultProps[r]);return g(e,l,t&&t.key,t&&t.ref)}function g(e,t,n,r){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:null,__c:null,constructor:void 0};return c.vnode&&c.vnode(o),o}function b(e){return e.children}function k(e,t){this.props=e,this.context=t}function S(e,t){if(null==t)return e.__?S(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?S(e):null}function x(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return x(e)}}function w(e){(!e.__d&&(e.__d=!0)&&1===_.push(e)||s!==c.debounceRendering)&&((s=c.debounceRendering)||f)(j)}function j(){var e,t,n,r,o,l,i;for(_.sort(function(e,t){return t.__v.__b-e.__v.__b});e=_.pop();)e.__d&&(n=void 0,r=void 0,l=(o=(t=e).__v).__e,(i=t.__P)&&(n=[],r=N(i,o,h({},o),t.__n,void 0!==i.ownerSVGElement,null,n,null==l?S(o):l),P(n,o),r!=l&&x(o)))}function A(e,t,n,r,o,l,i,u,a){var c,_,f,s,y,h,m,g=n&&n.__k||d,b=g.length;if(u==p&&(u=null!=l?l[0]:b?S(n,0):null),c=0,t.__k=O(t.__k,function(n){if(null!=n){if(n.__=t,n.__b=t.__b+1,null===(f=g[c])||f&&n.key==f.key&&n.type===f.type)g[c]=void 0;else for(_=0;_<b;_++){if((f=g[_])&&n.key==f.key&&n.type===f.type){g[_]=void 0;break}f=null}if(s=N(e,n,f=f||p,r,o,l,i,u,a),(_=n.ref)&&f.ref!=_&&(m||(m=[]),f.ref&&m.push(f.ref,null,n),m.push(_,n.__c||s,n)),null!=s){if(null==h&&(h=s),null!=n.__d)s=n.__d,n.__d=null;else if(l==f||s!=u||null==s.parentNode){e:if(null==u||u.parentNode!==e)e.appendChild(s);else{for(y=u,_=0;(y=y.nextSibling)&&_<b;_+=2)if(y==s)break e;e.insertBefore(s,u)}"option"==t.type&&(e.value="")}u=s.nextSibling,"function"==typeof t.type&&(t.__d=s)}}return c++,n}),t.__e=h,null!=l&&"function"!=typeof t.type)for(c=l.length;c--;)null!=l[c]&&v(l[c]);for(c=b;c--;)null!=g[c]&&U(g[c],g[c]);if(m)for(c=0;c<m.length;c++)M(m[c],m[++c],m[++c])}function O(e,t,n){if(null==n&&(n=[]),null==e||"boolean"==typeof e)t&&n.push(t(null));else if(Array.isArray(e))for(var r=0;r<e.length;r++)O(e[r],t,n);else n.push(t?t("string"==typeof e||"number"==typeof e?g(null,e,null,null):null!=e.__e||null!=e.__c?g(e.type,e.props,e.key,null):e):e);return n}function C(e,t,n){"-"===t[0]?e.setProperty(t,n):e[t]="number"==typeof n&&!1===y.test(t)?n+"px":null==n?"":n}function E(e,t,n,r,o){var l,i,u,a,c;if(o?"className"===t&&(t="class"):"class"===t&&(t="className"),"key"===t||"children"===t);else if("style"===t)if(l=e.style,"string"==typeof n)l.cssText=n;else{if("string"==typeof r&&(l.cssText="",r=null),r)for(i in r)n&&i in n||C(l,i,"");if(n)for(u in n)r&&n[u]===r[u]||C(l,u,n[u])}else"o"===t[0]&&"n"===t[1]?(a=t!==(t=t.replace(/Capture$/,"")),t=((c=t.toLowerCase())in e?c:t).slice(2),n?(r||e.addEventListener(t,F,a),(e.l||(e.l={}))[t]=n):e.removeEventListener(t,F,a)):"list"!==t&&"tagName"!==t&&"form"!==t&&"type"!==t&&!o&&t in e?e[t]=null==n?"":n:"function"!=typeof n&&"dangerouslySetInnerHTML"!==t&&(t!==(t=t.replace(/^xlink:?/,""))?null==n||!1===n?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),n):null==n||!1===n?e.removeAttribute(t):e.setAttribute(t,n))}function F(e){this.l[e.type](c.event?c.event(e):e)}function N(e,t,n,r,o,l,i,u,a){var _,f,s,p,d,y,v,m,g,S,x=t.type;if(void 0!==t.constructor)return null;(_=c.__b)&&_(t);try{e:if("function"==typeof x){if(m=t.props,g=(_=x.contextType)&&r[_.__c],S=_?g?g.props.value:_.__:r,n.__c?v=(f=t.__c=n.__c).__=f.__E:("prototype"in x&&x.prototype.render?t.__c=f=new x(m,S):(t.__c=f=new k(m,S),f.constructor=x,f.render=T),g&&g.sub(f),f.props=m,f.state||(f.state={}),f.context=S,f.__n=r,s=f.__d=!0,f.__h=[]),null==f.__s&&(f.__s=f.state),null!=x.getDerivedStateFromProps&&(f.__s==f.state&&(f.__s=h({},f.__s)),h(f.__s,x.getDerivedStateFromProps(m,f.__s))),p=f.props,d=f.state,s)null==x.getDerivedStateFromProps&&null!=f.componentWillMount&&f.componentWillMount(),null!=f.componentDidMount&&f.__h.push(f.componentDidMount);else{if(null==x.getDerivedStateFromProps&&m!==p&&null!=f.componentWillReceiveProps&&f.componentWillReceiveProps(m,S),!f.__e&&null!=f.shouldComponentUpdate&&!1===f.shouldComponentUpdate(m,f.__s,S)){for(f.props=m,f.state=f.__s,f.__d=!1,f.__v=t,t.__e=n.__e,t.__k=n.__k,f.__h.length&&i.push(f),_=0;_<t.__k.length;_++)t.__k[_]&&(t.__k[_].__=t);break e}null!=f.componentWillUpdate&&f.componentWillUpdate(m,f.__s,S),null!=f.componentDidUpdate&&f.__h.push(function(){f.componentDidUpdate(p,d,y)})}f.context=S,f.props=m,f.state=f.__s,(_=c.__r)&&_(t),f.__d=!1,f.__v=t,f.__P=e,_=f.render(f.props,f.state,f.context),t.__k=O(null!=_&&_.type==b&&null==_.key?_.props.children:_),null!=f.getChildContext&&(r=h(h({},r),f.getChildContext())),s||null==f.getSnapshotBeforeUpdate||(y=f.getSnapshotBeforeUpdate(p,d)),A(e,t,n,r,o,l,i,u,a),f.base=t.__e,f.__h.length&&i.push(f),v&&(f.__E=f.__=null),f.__e=null}else t.__e=D(n.__e,t,n,r,o,l,i,a);(_=c.diffed)&&_(t)}catch(e){c.__e(e,t,n)}return t.__e}function P(e,t){c.__c&&c.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){c.__e(e,t.__v)}})}function D(e,t,n,r,o,l,i,u){var a,c,_,f,s,y=n.props,h=t.props;if(o="svg"===t.type||o,null==e&&null!=l)for(a=0;a<l.length;a++)if(null!=(c=l[a])&&(null===t.type?3===c.nodeType:c.localName===t.type)){e=c,l[a]=null;break}if(null==e){if(null===t.type)return document.createTextNode(h);e=o?document.createElementNS("http://www.w3.org/2000/svg",t.type):document.createElement(t.type),l=null}if(null===t.type)null!=l&&(l[l.indexOf(e)]=null),y!==h&&e.data!=h&&(e.data=h);else if(t!==n){if(null!=l&&(l=d.slice.call(e.childNodes)),_=(y=n.props||p).dangerouslySetInnerHTML,f=h.dangerouslySetInnerHTML,!u){if(y===p)for(y={},s=0;s<e.attributes.length;s++)y[e.attributes[s].name]=e.attributes[s].value;(f||_)&&(f&&_&&f.__html==_.__html||(e.innerHTML=f&&f.__html||""))}(function(e,t,n,r,o){var l;for(l in n)l in t||E(e,l,null,n[l],r);for(l in t)o&&"function"!=typeof t[l]||"value"===l||"checked"===l||n[l]===t[l]||E(e,l,t[l],n[l],r)})(e,h,y,o,u),t.__k=t.props.children,f||A(e,t,n,r,"foreignObject"!==t.type&&o,l,i,p,u),u||("value"in h&&void 0!==h.value&&h.value!==e.value&&(e.value=null==h.value?"":h.value),"checked"in h&&void 0!==h.checked&&h.checked!==e.checked&&(e.checked=h.checked))}return e}function M(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(e){c.__e(e,n)}}function U(e,t,n){var r,o,l;if(c.unmount&&c.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||M(r,null,t)),n||"function"==typeof e.type||(n=null!=(o=e.__e)),e.__e=e.__d=null,null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){c.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(l=0;l<r.length;l++)r[l]&&U(r[l],t,n);null!=o&&v(o)}function T(e,t,n){return this.constructor(e,n)}c={__e:function(e,t){for(var n,r;t=t.__;)if((n=t.__c)&&!n.__)try{if(n.constructor&&null!=n.constructor.getDerivedStateFromError&&(r=!0,n.setState(n.constructor.getDerivedStateFromError(e))),null!=n.componentDidCatch&&(r=!0,n.componentDidCatch(e)),r)return w(n.__E=n)}catch(t){e=t}throw e}},k.prototype.setState=function(e,t){var n;n=this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof e&&(e=e(n,this.props)),e&&h(n,e),null!=e&&this.__v&&(this.__e=!1,t&&this.__h.push(t),w(this))},k.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),w(this))},k.prototype.render=b,_=[],f="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout;var L={shallow:!0},W=[],H=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,I=function(){};function $(e,t,l,_,f,s){if(null==e||"boolean"==typeof e)return"";Array.isArray(e)&&(e=m(b,null,e));var p=e.type,d=e.props,y=!1;t=t||{};var h,v=(l=l||{}).pretty,g=v&&"string"==typeof v?v:"\t";if("object"!=typeof e&&!p)return n(e);if("function"==typeof p){if(y=!0,!l.shallow||!_&&!1!==l.renderRootComponent){if(p===b){var k="",S=[];a(S,e.props.children);for(var x=0;x<S.length;x++)k+=(x>0&&v?"\n":"")+$(S[x],t,l,!1!==l.shallowHighOrder,f,s);return k}var w,j=e.__c={__v:e,context:t,props:e.props,setState:I,forceUpdate:I,__h:[]};if(c.__b&&c.__b(e),c.__r&&c.__r(e),p.prototype&&"function"==typeof p.prototype.render){var A=p.contextType,O=A&&t[A.__c],C=null!=A?O?O.props.value:A.__:t;(j=e.__c=new p(d,C)).__v=e,j._dirty=j.__d=!0,j.props=d,null==j.state&&(j.state={}),null==j._nextState&&null==j.__s&&(j._nextState=j.__s=j.state),j.context=C,p.getDerivedStateFromProps?j.state=u(u({},j.state),p.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),w=j.render(j.props,j.state,j.context)}else{var E=p.contextType,F=E&&t[E.__c];w=p.call(e.__c,d,null!=E?F?F.props.value:E.__:t)}return j.getChildContext&&(t=u(u({},t),j.getChildContext())),$(w,t,l,!1!==l.shallowHighOrder,f,s)}p=(h=p).displayName||h!==Function&&h.name||function(e){var t=(Function.prototype.toString.call(e).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!t){for(var n=-1,r=W.length;r--;)if(W[r]===e){n=r;break}n<0&&(n=W.push(e)-1),t="UnnamedComponent"+n}return t}(h)}var N,P,D="";if(d){var M=Object.keys(d);l&&!0===l.sortAttributes&&M.sort();for(var U=0;U<M.length;U++){var T=M[U],L=d[T];if("children"!==T){if(!T.match(/[\s\n\\/='"\0<>]/)&&(l&&l.allAttributes||"key"!==T&&"ref"!==T&&"__self"!==T&&"__source"!==T&&"defaultValue"!==T)){if("className"===T){if(d.class)continue;T="class"}else f&&T.match(/^xlink:?./)&&(T=T.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===T){if(d.for)continue;T="for"}"style"===T&&L&&"object"==typeof L&&(L=i(L)),"a"===T[0]&&"r"===T[1]&&"boolean"==typeof L&&(L=String(L));var R=l.attributeHook&&l.attributeHook(T,L,t,l,y);if(R||""===R)D+=R;else if("dangerouslySetInnerHTML"===T)P=L&&L.__html;else if("textarea"===p&&"value"===T)N=L;else if((L||0===L||""===L)&&"function"!=typeof L){if(!(!0!==L&&""!==L||(L=T,l&&l.xml))){D+=" "+T;continue}if("value"===T){if("select"===p){s=L;continue}"option"===p&&s==L&&(D+=" selected")}D+=" "+T+'="'+n(L)+'"'}}}else N=L}}if(v){var B=D.replace(/^\n\s*/," ");B===D||~B.indexOf("\n")?v&&~D.indexOf("\n")&&(D+="\n"):D=B}if(D="<"+p+D+">",String(p).match(/[\s\n\\/='"\0<>]/))throw new Error(p+" is not a valid HTML tag name in "+D);var J,V=String(p).match(H)||l.voidElements&&String(p).match(l.voidElements),z=[];if(P)v&&o(P)&&(P="\n"+g+r(P,g)),D+=P;else if(null!=N&&a(J=[],N).length){for(var G=v&&~D.indexOf("\n"),q=!1,Z=0;Z<J.length;Z++){var K=J[Z];if(null!=K&&!1!==K){var Q=$(K,t,l,!0,"svg"===p||"foreignObject"!==p&&f,s);if(v&&!G&&o(Q)&&(G=!0),Q)if(v){var X=Q.length>0&&"<"!=Q[0];q&&X?z[z.length-1]+=Q:z.push(Q),q=X}else z.push(Q)}}if(v&&G)for(var Y=z.length;Y--;)z[Y]="\n"+g+r(z[Y],g)}if(z.length)D+=z.join("");else if(l&&l.xml)return D.substring(0,D.length-1)+" />";return V&&!J?D=D.replace(/>$/," />"):(v&&~D.indexOf("\n")&&(D+="\n"),D+="</"+p+">"),D}$.render=$,$.shallowRender=function(e,t){return $(e,t,L)};var R=/(\\|\"|\')/g,B=function(e){return e.replace(R,"\\$1")},J=Object.prototype.toString,V=Date.prototype.toISOString,z=Error.prototype.toString,G=RegExp.prototype.toString,q=Symbol.prototype.toString,Z=/^Symbol\((.*)\)(.*)$/,K=/\n/gi,Q=Object.getOwnPropertySymbols||function(e){return[]};function X(e){return"[object Array]"===e||"[object ArrayBuffer]"===e||"[object DataView]"===e||"[object Float32Array]"===e||"[object Float64Array]"===e||"[object Int8Array]"===e||"[object Int16Array]"===e||"[object Int32Array]"===e||"[object Uint8Array]"===e||"[object Uint8ClampedArray]"===e||"[object Uint16Array]"===e||"[object Uint32Array]"===e}function Y(e){return""===e.name?"[Function anonymous]":"[Function "+e.name+"]"}function ee(e){return q.call(e).replace(Z,"Symbol($1)")}function te(e){return"["+z.call(e)+"]"}function ne(e){if(!0===e||!1===e)return""+e;if(void 0===e)return"undefined";if(null===e)return"null";var t=typeof e;if("number"===t)return function(e){return e!=+e?"NaN":0===e&&1/e<0?"-0":""+e}(e);if("string"===t)return'"'+B(e)+'"';if("function"===t)return Y(e);if("symbol"===t)return ee(e);var n=J.call(e);return"[object WeakMap]"===n?"WeakMap {}":"[object WeakSet]"===n?"WeakSet {}":"[object Function]"===n||"[object GeneratorFunction]"===n?Y(e,min):"[object Symbol]"===n?ee(e):"[object Date]"===n?V.call(e):"[object Error]"===n?te(e):"[object RegExp]"===n?G.call(e):"[object Arguments]"===n&&0===e.length?"Arguments []":X(n)&&0===e.length?e.constructor.name+" []":e instanceof Error&&te(e)}function re(e,t,n,r,o,l,i,u,a,c){var _="";if(e.length){_+=o;for(var f=n+t,s=0;s<e.length;s++)_+=f+ie(e[s],t,f,r,o,l,i,u,a,c),s<e.length-1&&(_+=","+r);_+=o+n}return"["+_+"]"}function oe(e,t,n,r,o,l,i,u,a,c){if((l=l.slice()).indexOf(e)>-1)return"[Circular]";l.push(e);var _=++u>i;if(!_&&e.toJSON&&"function"==typeof e.toJSON)return ie(e.toJSON(),t,n,r,o,l,i,u,a,c);var f=J.call(e);return"[object Arguments]"===f?_?"[Arguments]":function(e,t,n,r,o,l,i,u,a,c){return(c?"":"Arguments ")+re(e,t,n,r,o,l,i,u,a,c)}(e,t,n,r,o,l,i,u,a,c):X(f)?_?"[Array]":function(e,t,n,r,o,l,i,u,a,c){return(c?"":e.constructor.name+" ")+re(e,t,n,r,o,l,i,u,a,c)}(e,t,n,r,o,l,i,u,a,c):"[object Map]"===f?_?"[Map]":function(e,t,n,r,o,l,i,u,a,c){var _="Map {",f=e.entries(),s=f.next();if(!s.done){_+=o;for(var p=n+t;!s.done;)_+=p+ie(s.value[0],t,p,r,o,l,i,u,a,c)+" => "+ie(s.value[1],t,p,r,o,l,i,u,a,c),(s=f.next()).done||(_+=","+r);_+=o+n}return _+"}"}(e,t,n,r,o,l,i,u,a,c):"[object Set]"===f?_?"[Set]":function(e,t,n,r,o,l,i,u,a,c){var _="Set {",f=e.entries(),s=f.next();if(!s.done){_+=o;for(var p=n+t;!s.done;)_+=p+ie(s.value[1],t,p,r,o,l,i,u,a,c),(s=f.next()).done||(_+=","+r);_+=o+n}return _+"}"}(e,t,n,r,o,l,i,u,a,c):"object"==typeof e?_?"[Object]":function(e,t,n,r,o,l,i,u,a,c){var _=(c?"":e.constructor?e.constructor.name+" ":"Object ")+"{",f=Object.keys(e).sort(),s=Q(e);if(s.length&&(f=f.filter(function(e){return!("symbol"==typeof e||"[object Symbol]"===J.call(e))}).concat(s)),f.length){_+=o;for(var p=n+t,d=0;d<f.length;d++){var y=f[d];_+=p+ie(y,t,p,r,o,l,i,u,a,c)+": "+ie(e[y],t,p,r,o,l,i,u,a,c),d<f.length-1&&(_+=","+r)}_+=o+n}return _+"}"}(e,t,n,r,o,l,i,u,a,c):void 0}function le(e,t,n,r,o,l,i,u,a,c){for(var _,f=!1,s=0;s<a.length;s++)if((_=a[s]).test(e)){f=!0;break}return!!f&&_.print(e,function(e){return ie(e,t,n,r,o,l,i,u,a,c)},function(e){var r=n+t;return r+e.replace(K,"\n"+r)},{edgeSpacing:o,spacing:r})}function ie(e,t,n,r,o,l,i,u,a,c){var _=ne(e);return _||(le(e,t,n,r,o,l,i,u,a,c)||oe(e,t,n,r,o,l,i,u,a,c))}var ue={indent:2,min:!1,maxDepth:Infinity,plugins:[]};function ae(e){return new Array(e+1).join(" ")}var ce={test:function(e){return e&&"object"==typeof e&&"type"in e&&"props"in e&&"key"in e},print:function(e,t,n){return $(e,ce.context,ce.opts,!0)}},_e={plugins:[ce]},fe={attributeHook:function(e,t,o,l,i){var u=typeof t;if("dangerouslySetInnerHTML"===e)return!1;if(null==t||"function"===u&&!l.functions)return"";if(l.skipFalseAttributes&&!i&&(!1===t||("class"===e||"style"===e)&&""===t))return"";var a="string"==typeof l.pretty?l.pretty:"\t";return"string"!==u?("function"!==u||l.functionNames?(ce.context=o,ce.opts=l,~(t=function(e,t){var n,r;t?(function(e){if(Object.keys(e).forEach(function(e){if(!ue.hasOwnProperty(e))throw new Error("prettyFormat: Invalid option: "+e)}),e.min&&void 0!==e.indent&&0!==e.indent)throw new Error("prettyFormat: Cannot run with min option and indent")}(t),t=function(e){var t={};return Object.keys(ue).forEach(function(n){return t[n]=e.hasOwnProperty(n)?e[n]:ue[n]}),t.min&&(t.indent=0),t}(t)):t=ue;var o=t.min?" ":"\n",l=t.min?"":"\n";if(t&&t.plugins.length){var i=le(e,n=ae(t.indent),"",o,l,r=[],t.maxDepth,0,t.plugins,t.min);if(i)return i}return ne(e)||(n||(n=ae(t.indent)),r||(r=[]),oe(e,n,"",o,l,r,t.maxDepth,0,t.plugins,t.min))}(t,_e)).indexOf("\n")&&(t=r("\n"+t,a)+"\n")):t="Function",r("\n"+e+"={"+t+"}",a)):"\n"+a+e+'="'+n(t)+'"'},jsx:!0,xml:!1,functions:!0,functionNames:!0,skipFalseAttributes:!0,pretty:" "};return function(e,t,n,r){return $(e,t,n=u(u({},fe),n||{}),r)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.preactRenderToString=t();
|
|
2
2
|
//# sourceMappingURL=jsx.js.map
|