jsx-async-runtime
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -1,2 +0,2 @@ | ||
function $(t,e,...i){e??={};let n=[];for(let s of i)p(s,n);return e?.children&&p(e.children,n),e.children=n,Object.freeze(n),Object.freeze(e),{type:"tag",tag:t,props:e}}function p(t,e){switch(typeof t){case"string":e.push({type:"textNode",text:t});break;case"number":e.push({type:"textNode",text:t.toString()});break;case"object":if(Array.isArray(t))for(let i of t)p(i,e);else t!=null&&e.push(t);break}}function x(t){return typeof t=="string"?t.replace(J,e=>h[e]||e):t}var h={"&":"&","<":"<",">":">",'"':""","'":"'"},J=new RegExp(`[${Object.keys(h).join("")}]`,"g");function m(t){let e=[];for(let i of t){let n=T(i);n.length>0&&e.push(n)}return e.join(" ")}function T([t,e]){if(e===!0)return t;if(e===!1||e===null||e===void 0)return"";if(typeof e=="object")switch(t){case"style":let i=Object.entries(e).map(([s,r])=>`${s}: ${r}`);return`style="${f(i.join("; "))}"`;case"class":let n=Object.entries(e).filter(([s,r])=>r).map(([s,r])=>s);return`class="${f(n.join(" "))}"`;default:return`${t}="${f(JSON.stringify(e))}"`}return`${t}="${f(e.toString())}"`}function f(t){return t.replaceAll('"',""")}function S(t){return{tag:t.tag.toString(),attributes:X(t),children:E(t)}}function X(t){let e=[];for(let[i,n]of Object.entries(t.props))i!=="children"&&e.push([i,n]);return e}function E(t){return t.props.children?Array.isArray(t.props.children)?t.props.children:[t.props.children]:[]}var j=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);async function a(t,e){if(t===null)return"";switch(typeof t){case"string":return t;case"bigint":case"number":return String(t);case"boolean":case"function":case"symbol":case"undefined":return""}let{currentIndent:i=0,indent:n=2}=e??{},s=" ".repeat(i);if(t.type==="textNode")return`${s}${t.text}`;if(typeof t.tag=="string"){let r=S(t);if(r.tag===""){let c=[];for(let u of r.children){let o=await a(u,{indent:n,currentIndent:i});o.length>0&&c.push(o)}return c.join(` | ||
function $(t,e,...i){e??={};let n=[];for(let s of i)p(s,n);return e?.children&&p(e.children,n),e.children=n,Object.freeze(n),Object.freeze(e),{type:"tag",tag:t,props:e}}function p(t,e){switch(typeof t){case"string":e.push({type:"textNode",text:t});break;case"number":e.push({type:"textNode",text:t.toString()});break;case"object":if(Array.isArray(t))for(let i of t)p(i,e);else t!=null&&e.push(t);break}}function x(t){return typeof t=="string"?t.replace(J,e=>h[e]||e):t}var h={"&":"&","<":"<",">":">",'"':""","'":"'"},J=new RegExp(`[${Object.keys(h).join("")}]`,"g");function m(t){let e=[];for(let i of t){let n=T(i);n.length>0&&e.push(n)}return e.join(" ")}function T([t,e]){if(e===!0)return t;if(e===!1||e===null||e===void 0)return"";if(typeof e=="object")switch(t){case"style":let i=Object.entries(e).map(([s,r])=>`${s}: ${r}`);return`style="${f(i.join("; "))}"`;case"class":let n=Object.entries(e).filter(([s,r])=>r).map(([s,r])=>s);return`class="${f(n.join(" "))}"`;default:return`${t}="${f(JSON.stringify(e))}"`}return`${t}="${f(e.toString())}"`}function f(t){return t.replaceAll('"',""")}function S(t){return{tag:t.tag.toString(),attributes:X(t),children:E(t)}}function X(t){let e=[];for(let[i,n]of Object.entries(t.props))i!=="children"&&e.push([i,n]);return e}function E(t){return t.props.children?Array.isArray(t.props.children)?t.props.children:[t.props.children]:[]}var j=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);async function a(t,e){if(t===null)return"";switch(typeof t){case"string":return t;case"bigint":case"number":return String(t);case"boolean":case"function":case"symbol":case"undefined":return""}let{currentIndent:i=0,indent:n=0}=e??{},s=" ".repeat(i);if(t.type==="textNode")return`${s}${t.text}`;if(typeof t.tag=="string"){let r=S(t);if(r.tag===""){let c=[];for(let u of r.children){let o=await a(u,{indent:n,currentIndent:i});o.length>0&&c.push(o)}return c.join(` | ||
`)}else{let c=m(r.attributes),u=c.length?" ":"";if(r.children.length===0&&j.has(r.tag))return`${s}<${r.tag}${u}${c}>`;let o=r.children.length===0||r.children.every(A),l=`${s}<${r.tag}${u}${c}>`,d=`${o?"":s}</${r.tag}>`,g=[];for(let y of r.children){let b=await a(y,{indent:o?0:n,currentIndent:o?0:i+n});b.length>0&&g.push(b)}return o?`${l}${g.join("")}${d}`:`${l} | ||
@@ -3,0 +3,0 @@ ${g.join(` |
{ | ||
"name": "jsx-async-runtime", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "An asynchronous JSX runtime without dependencies to be used as server-side template engine.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -97,3 +97,3 @@ # jsx-async-runtime | ||
console.log(await renderToString(<App />, { indent: 1 })); | ||
console.log(await renderToString(<App />, { indent: 2 })); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package