Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsx-async-runtime

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsx-async-runtime - npm Package Compare versions

Comparing version 0.1.8 to 0.2.0

6

dist/esm/index.js

@@ -1,5 +0,1 @@

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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},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('"',"&quot;")}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}
${g.join(`
`)}
${d}`}}else{let r=await t.tag(t.props);return await a(r,{indent:n,currentIndent:i})}}function A(t){return t!=null&&typeof t=="object"&&"type"in t&&t.type==="textNode"}async function w(t,e){return await a(await t,e)}export{$ as createElement,x as escapeEntities,w as renderToString};
function l(t,e,...r){e??={};let n=[];for(let s of r)a(s,n);return e?.children&&a(e.children,n),e.children=n,Object.freeze(n),Object.freeze(e),{type:"tag",tag:t,props:e}}function a(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 r of t)a(r,e);else t!=null&&e.push(t);break}}function b(t){return typeof t=="string"?t.replace(h,e=>u[e]||e):t}var u={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},h=new RegExp(`[${Object.keys(u).join("")}]`,"g");function g(t){let e=[];for(let r of t){let n=S(r);n.length>0&&e.push(n)}return e.join(" ")}function S([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 r=Object.entries(e).map(([s,i])=>`${s}: ${i}`);return`style="${c(r.join("; "))}"`;case"class":let n=Object.entries(e).filter(([s,i])=>i).map(([s,i])=>s);return`class="${c(n.join(" "))}"`;default:return`${t}="${c(JSON.stringify(e))}"`}return`${t}="${c(e.toString())}"`}function c(t){return t.replaceAll('"',"&quot;")}function p(t){return{tag:t.tag.toString(),attributes:d(t),children:m(t)}}function d(t){let e=[];for(let[r,n]of Object.entries(t.props))r!=="children"&&e.push([r,n]);return e}function m(t){return t.props.children?Array.isArray(t.props.children)?t.props.children:[t.props.children]:[]}var y=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);async function o(t){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""}if(t.type==="textNode")return t.text;if(typeof t.tag=="string"){let e=p(t);if(e.tag===""){let r=[];for(let n of e.children){let s=await o(n);s.length>0&&r.push(s)}return r.join("")}else{let r=g(e.attributes),n=r.length?" ":"";if(e.children.length===0&&y.has(e.tag))return`<${e.tag}${n}${r}>`;let s=[];for(let i of e.children){let f=await o(i);f.length>0&&s.push(f)}return`<${e.tag}${n}${r}>${s.join("")}</${e.tag}>`}}else{let e=await t.tag(t.props);return await o(e)}}async function x(t){return await o(await t)}export{l as createElement,b as escapeEntities,x as renderToString};

5

dist/types/render/jsx-to-string.d.ts

@@ -1,4 +0,1 @@

export declare function jsxToString(jsxElement: JSX.Element, options?: {
indent?: number;
currentIndent?: number;
}): Promise<string>;
export declare function jsxToString(jsxElement: JSX.Element): Promise<string>;

@@ -1,3 +0,1 @@

export declare function renderToString(component: JSX.Element | Promise<JSX.Element>, options?: {
indent?: number;
}): Promise<string>;
export declare function renderToString(component: JSX.Element | Promise<JSX.Element>): Promise<string>;
{
"name": "jsx-async-runtime",
"version": "0.1.8",
"version": "0.2.0",
"description": "An asynchronous JSX runtime without dependencies to be used as html template engine.",

@@ -51,4 +51,4 @@ "keywords": [

"nodemon": "3.1.0",
"typescript": "5.4.3"
"typescript": "5.4.5"
}
}

@@ -97,3 +97,3 @@ # jsx-async-runtime

console.log(await renderToString(<App />, { indent: 2 }));
console.log(await renderToString(<App />));
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc