@takumi-rs/helpers 0.68.16 → 0.69.0

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.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var y=(e,t)=>{for(var r in t)u(e,r,{get:t[r],enumerable:!0})},g=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of h(t))!l.call(e,i)&&i!==r&&u(e,i,{get:()=>t[i],enumerable:!(o=x(t,i))||o.enumerable});return e};var w=e=>g(u({},"__esModule",{value:!0}),e);var I={};y(I,{container:()=>p,em:()=>O,fetchResources:()=>v,fr:()=>A,image:()=>b,percentage:()=>T,rem:()=>C,rgba:()=>R,style:()=>S,text:()=>N,vh:()=>P,vw:()=>$});module.exports=w(I);function c(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function a(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function p(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),a(t,e.preset),c(t,e.style),t}function N(e,t){if(typeof e=="string"){let o={type:"text",text:e};return c(o,t),o}let r={type:"text",text:e.text};return e.tw&&(r.tw=e.tw),a(r,e.preset),c(r,t??e.style),r}function b(e){let t={type:"image",src:e.src,width:e.width,height:e.height};return e.tw&&(t.tw=e.tw),a(t,e.preset),c(t,e.style),t}function S(e){return e}function T(e){return`${e}%`}function $(e){return`${e}vw`}function P(e){return`${e}vh`}function O(e){return`${e}em`}function C(e){return`${e}rem`}function A(e){return`${e}fr`}function R(e,t,r,o=1){return`rgb(${e} ${t} ${r} / ${o})`}async function v(e,t){let r=AbortSignal.timeout(t?.timeout??5e3),o=t?.fetch??globalThis.fetch,i=t?.throwOnError??!0,f=[...new Set(e)].map(async n=>{if(t?.cache?.has(n)){let d=t.cache.get(n);if(d)return{src:n,data:d}}let s=await o(n,{signal:r});if(!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText} for ${n}`);let m=await s.arrayBuffer();return t?.cache?.set(n,m),{src:n,data:m}});return i?Promise.all(f):(await Promise.allSettled(f)).filter(n=>n.status==="fulfilled").map(n=>n.value)}0&&(module.exports={container,em,fetchResources,fr,image,percentage,rem,rgba,style,text,vh,vw});
1
+ "use strict";var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},N=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of y(t))!h.call(e,i)&&i!==n&&s(e,i,{get:()=>t[i],enumerable:!(o=l(t,i))||o.enumerable});return e};var w=e=>N(s({},"__esModule",{value:!0}),e);var E={};g(E,{container:()=>b,em:()=>A,fetchResources:()=>I,fr:()=>R,image:()=>T,percentage:()=>$,rem:()=>p,rgba:()=>v,style:()=>P,text:()=>S,vh:()=>C,vw:()=>O});module.exports=w(E);function c(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function u(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function f(e,t){t.tagName!==void 0&&(e.tagName=t.tagName),t.className!==void 0&&(e.className=t.className),t.id!==void 0&&(e.id=t.id)}function b(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),f(t,e),u(t,e.preset),c(t,e.style),t}function S(e,t){if(typeof e=="string"){let o={type:"text",text:e};return c(o,t),o}let n={type:"text",text:e.text};return e.tw&&(n.tw=e.tw),f(n,e),u(n,e.preset),c(n,t??e.style),n}function T(e){let t={type:"image",src:e.src,width:e.width,height:e.height};return e.tw&&(t.tw=e.tw),f(t,e),u(t,e.preset),c(t,e.style),t}function P(e){return e}function $(e){return`${e}%`}function O(e){return`${e}vw`}function C(e){return`${e}vh`}function A(e){return`${e}em`}function p(e){return`${e}rem`}function R(e){return`${e}fr`}function v(e,t,n,o=1){return`rgb(${e} ${t} ${n} / ${o})`}async function I(e,t){let n=AbortSignal.timeout(t?.timeout??5e3),o=t?.fetch??globalThis.fetch,i=t?.throwOnError??!0,m=[...new Set(e)].map(async r=>{if(t?.cache?.has(r)){let x=t.cache.get(r);if(x)return{src:r,data:x}}let a=await o(r,{signal:n});if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText} for ${r}`);let d=await a.arrayBuffer();return t?.cache?.set(r,d),{src:r,data:d}});return i?Promise.all(m):(await Promise.allSettled(m)).filter(r=>r.status==="fulfilled").map(r=>r.value)}0&&(module.exports={container,em,fetchResources,fr,image,percentage,rem,rgba,style,text,vh,vw});
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CSSProperties } from 'react';
2
- import { C as ContainerNode, T as TextNode, I as ImageNode } from './types-DgRXITo4.cjs';
3
- export { A as AnyNode, N as Node, P as PartialStyle } from './types-DgRXITo4.cjs';
2
+ import { C as ContainerNode, T as TextNode, I as ImageNode } from './types-DVfDlIZ1.cjs';
3
+ export { A as AnyNode, B as BaseNode, N as Node, P as PartialStyle } from './types-DVfDlIZ1.cjs';
4
4
 
5
5
  declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
6
6
  declare function text(text: string, style?: CSSProperties): TextNode;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CSSProperties } from 'react';
2
- import { C as ContainerNode, T as TextNode, I as ImageNode } from './types-DgRXITo4.js';
3
- export { A as AnyNode, N as Node, P as PartialStyle } from './types-DgRXITo4.js';
2
+ import { C as ContainerNode, T as TextNode, I as ImageNode } from './types-DVfDlIZ1.js';
3
+ export { A as AnyNode, B as BaseNode, N as Node, P as PartialStyle } from './types-DVfDlIZ1.js';
4
4
 
5
5
  declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
6
6
  declare function text(text: string, style?: CSSProperties): TextNode;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- function s(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function c(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function h(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),c(t,e.preset),s(t,e.style),t}function l(e,t){if(typeof e=="string"){let o={type:"text",text:e};return s(o,t),o}let n={type:"text",text:e.text};return e.tw&&(n.tw=e.tw),c(n,e.preset),s(n,t??e.style),n}function y(e){let t={type:"image",src:e.src,width:e.width,height:e.height};return e.tw&&(t.tw=e.tw),c(t,e.preset),s(t,e.style),t}function g(e){return e}function w(e){return`${e}%`}function p(e){return`${e}vw`}function N(e){return`${e}vh`}function b(e){return`${e}em`}function S(e){return`${e}rem`}function T(e){return`${e}fr`}function $(e,t,n,o=1){return`rgb(${e} ${t} ${n} / ${o})`}async function O(e,t){let n=AbortSignal.timeout(t?.timeout??5e3),o=t?.fetch??globalThis.fetch,m=t?.throwOnError??!0,u=[...new Set(e)].map(async r=>{if(t?.cache?.has(r)){let f=t.cache.get(r);if(f)return{src:r,data:f}}let i=await o(r,{signal:n});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText} for ${r}`);let a=await i.arrayBuffer();return t?.cache?.set(r,a),{src:r,data:a}});return m?Promise.all(u):(await Promise.allSettled(u)).filter(r=>r.status==="fulfilled").map(r=>r.value)}export{h as container,b as em,O as fetchResources,T as fr,y as image,w as percentage,S as rem,$ as rgba,g as style,l as text,N as vh,p as vw};
1
+ function a(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function c(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function s(e,t){t.tagName!==void 0&&(e.tagName=t.tagName),t.className!==void 0&&(e.className=t.className),t.id!==void 0&&(e.id=t.id)}function y(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),s(t,e),c(t,e.preset),a(t,e.style),t}function h(e,t){if(typeof e=="string"){let o={type:"text",text:e};return a(o,t),o}let r={type:"text",text:e.text};return e.tw&&(r.tw=e.tw),s(r,e),c(r,e.preset),a(r,t??e.style),r}function g(e){let t={type:"image",src:e.src,width:e.width,height:e.height};return e.tw&&(t.tw=e.tw),s(t,e),c(t,e.preset),a(t,e.style),t}function N(e){return e}function w(e){return`${e}%`}function b(e){return`${e}vw`}function S(e){return`${e}vh`}function T(e){return`${e}em`}function P(e){return`${e}rem`}function $(e){return`${e}fr`}function O(e,t,r,o=1){return`rgb(${e} ${t} ${r} / ${o})`}async function A(e,t){let r=AbortSignal.timeout(t?.timeout??5e3),o=t?.fetch??globalThis.fetch,d=t?.throwOnError??!0,u=[...new Set(e)].map(async n=>{if(t?.cache?.has(n)){let m=t.cache.get(n);if(m)return{src:n,data:m}}let i=await o(n,{signal:r});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText} for ${n}`);let f=await i.arrayBuffer();return t?.cache?.set(n,f),{src:n,data:f}});return d?Promise.all(u):(await Promise.allSettled(u)).filter(n=>n.status==="fulfilled").map(n=>n.value)}export{y as container,T as em,A as fetchResources,$ as fr,g as image,w as percentage,P as rem,O as rgba,N as style,h as text,S as vh,b as vw};
package/dist/jsx/jsx.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var h=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var B=(e,t)=>{for(var r in t)h(e,r,{get:t[r],enumerable:!0})},W=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of z(t))!j.call(e,i)&&i!==r&&h(e,i,{get:()=>t[i],enumerable:!(n=J(t,i))||n.enumerable});return e};var M=e=>W(h({},"__esModule",{value:!0}),e);var oe={};B(oe,{defaultStylePresets:()=>S,fromJsx:()=>G});module.exports=M(oe);function u(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function R(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function d(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),R(t,e.preset),u(t,e.style),t}function m(e,t){if(typeof e=="string"){let n={type:"text",text:e};return u(n,t),n}let r={type:"text",text:e.text};return e.tw&&(r.tw=e.tw),R(r,e.preset),u(r,t??e.style),r}function b(e){let t={type:"image",src:e.src,width:e.width,height:e.height};return e.tw&&(t.tw=e.tw),R(t,e.preset),u(t,e.style),t}function x(e){return`${e}%`}var S={body:{margin:8},p:{marginTop:"1em",marginBottom:"1em",display:"block"},blockquote:{marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40,display:"block"},center:{textAlign:"center",display:"block"},hr:{marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,display:"block"},h1:{fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h2:{fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h3:{fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h4:{marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h5:{fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h6:{fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},u:{textDecoration:"underline",display:"inline"},strong:{fontWeight:"bold",display:"inline"},b:{fontWeight:"bold",display:"inline"},i:{fontStyle:"italic",display:"inline"},em:{fontStyle:"italic",display:"inline"},code:{fontFamily:"monospace",display:"inline"},kbd:{fontFamily:"monospace",display:"inline"},pre:{fontFamily:"monospace",margin:"1em 0",display:"block"},mark:{backgroundColor:"yellow",color:"black",display:"inline"},big:{fontSize:"1.2em",display:"inline"},small:{fontSize:"0.8em",display:"inline"},s:{textDecoration:"line-through",display:"inline"},span:{display:"inline"},img:{display:"inline"},svg:{display:"inline"}};var _=new Set(["head","meta","link","style","script"]);function P(e){return _.has(e.type)}function g(e,t){return e.type===t&&"props"in e}function N(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function a(e){return typeof e=="object"&&e!==null&&"type"in e}function l(e){return typeof e=="function"}var H=Symbol.for("react.forward_ref"),X=Symbol.for("react.memo"),D=Symbol.for("react.fragment");function C(e){return e.$$typeof===H}function T(e){return e.$$typeof===X}function w(e){return e.type===D}function V(e){return typeof e=="string"||typeof e=="number"}function v(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Y(e){return Object.keys(e).map(t=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(e[t]).trim()}`).join(";")}var K=new Set(["stopColor","stopOpacity","strokeWidth","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","fillRule","clipRule","colorInterpolationFilters","floodColor","floodOpacity","accentHeight","alignmentBaseline","arabicForm","baselineShift","capHeight","clipPath","clipPathUnits","colorInterpolation","colorProfile","colorRendering","enableBackground","fillOpacity","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","horizAdvX","horizOriginX","imageRendering","letterSpacing","lightingColor","markerEnd","markerMid","markerStart","overlinePosition","overlineThickness","paintOrder","preserveAspectRatio","pointerEvents","shapeRendering","strokeMiterlimit","strokeOpacity","textAnchor","textDecoration","textRendering","transformOrigin","underlinePosition","underlineThickness","unicodeBidi","unicodeRange","unitsPerEm","vectorEffect","vertAdvY","vertOriginX","vertOriginY","vAlphabetic","vHanging","vIdeographic","vMathematical","wordSpacing","writingMode"]);function U(e,t){if(e==="children"||t==null)return;let r;if(e==="className"?r="class":K.has(e)?r=N(e):r=e,typeof t=="boolean")return`${r}="${String(t)}"`;if(e==="style"&&typeof t=="object"){let n=Y(t);if(n)return`style="${v(n)}"`}return`${r}="${v(String(t))}"`}function q(e){return Object.entries(e).map(([t,r])=>U(t,r)).filter(t=>t!==void 0)}var Z=(e,t)=>{let r=e.props||{};if(l(e.type))return f(e.type(e.props));if(typeof e.type=="symbol"||typeof e.type!="string")return"";let n=q(r),i=r.children,o=Array.isArray(i)?i.map(s=>t(s)).join(""):t(i);return`<${e.type}${n.length>0?` ${n.join(" ")}`:""}>${o}</${e.type}>`},f=e=>e==null||e===!1?"":V(e)?String(e):Array.isArray(e)?e.map(f).join(""):a(e)?Z(e,f):"";function O(e){let t=e.props||{};if(!("xmlns"in t)){let r={...e,props:{...t,xmlns:"http://www.w3.org/2000/svg"}};return f(r)||""}return f(e)||""}async function G(e,t){let r=await p(e,{presets:Q(t),tailwindClassesProperty:t?.tailwindClassesProperty??"tw"});return r.length===0?d({}):r.length===1&&r[0]!==void 0?r[0]:d({children:r,style:{width:x(100),height:x(100)}})}async function p(e,t){if(e==null||e===!1)return[];if(e instanceof Promise)return p(await e,t);if(typeof e=="object"&&Symbol.iterator in e)return ie(e,t);if(a(e)){let r=await $(e,t);return Array.isArray(r)?r:r?[r]:[]}return[m({text:String(e),preset:t.presets?.span})]}function Q(e){if(e?.defaultStyles!==!1)return e?.defaultStyles??S}function ee(e,t){if(!(typeof e.type!="object"||e.type===null)){if(C(e.type)&&"render"in e.type){let r=e.type;return p(r.render(e.props,null),t)}if(T(e.type)&&"type"in e.type){let n=e.type.type;if(l(n))return p(n(e.props),t);let i={...e,type:n};return $(i,t)}}}function F(e){if(!a(e))return;let t=typeof e.props=="object"&&e.props!==null&&"children"in e.props?e.props.children:void 0;if(typeof t=="string")return t;if(typeof t=="number")return String(t);if(Array.isArray(t)||typeof t=="object"&&t!==null&&Symbol.iterator in t)return L(t);if(a(t)&&w(t))return F(t)}function L(e){let t="";for(let r of e){if(a(r))return;if(typeof r=="string"){t+=r;continue}if(typeof r=="number"){t+=String(r);continue}return}return t}async function $(e,t){if(l(e.type))return p(e.type(e.props),t);let r=ee(e,t);if(r!==void 0)return r;if(w(e))return await A(e,t)||[];if(P(e))return[];if(g(e,"br"))return[m({text:`
2
- `,preset:t.presets?.span})];if(g(e,"img"))return[te(e,t)];if(g(e,"svg"))return[re(e,t)];let{preset:n,style:i}=k(e,t),o=E(e,t),s=F(e);if(s!==void 0)return[m({text:s,preset:n,style:i,tw:o})];let c=await A(e,t);return[d({children:c,preset:n,style:i,tw:o})]}function te(e,t){if(!e.props.src)throw new Error("Image element must have a 'src' prop.");let{preset:r,style:n}=k(e,t),i=E(e,t),o=e.props.width!==void 0?Number(e.props.width):void 0,s=e.props.height!==void 0?Number(e.props.height):void 0;return b({src:e.props.src,width:o,height:s,preset:r,style:n,tw:i})}function re(e,t){let{preset:r,style:n}=k(e,t),i=E(e,t),o=O(e),s=e.props.width!==void 0?Number(e.props.width):void 0,c=e.props.height!==void 0?Number(e.props.height):void 0;return b({preset:r,width:s,height:c,style:n,src:o,tw:i})}function k(e,t){let r,n,i=t.presets;i&&typeof e.type=="string"&&e.type in i&&(r=i[e.type]);let o=typeof e.props=="object"&&e.props!==null&&"style"in e.props&&typeof e.props.style=="object"&&e.props.style!==null?e.props.style:void 0;if(o){for(let s in o)if(Object.hasOwn(o,s)){n=o;break}}return{preset:r,style:n}}function E(e,t){let r=t.tailwindClassesProperty;if(typeof e.props!="object"||e.props===null||!(r in e.props))return;let n=e.props[r];if(typeof n=="string")return n}function A(e,t){return typeof e.props!="object"||e.props===null||!("children"in e.props)?Promise.resolve([]):p(e.props.children,t)}var ne=8;async function ie(e,t){let r=[],n=new Set,i=0;for(let s of e){let c=i;i+=1;let y=p(s,t).then(I=>{r[c]=I}).finally(()=>n.delete(y));n.add(y),n.size>=ne&&await Promise.race(n)}await Promise.all(n);let o=[];for(let s of r)s&&o.push(...s);return o}0&&(module.exports={defaultStylePresets,fromJsx});
1
+ "use strict";var S=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var X=(e,t)=>{for(var r in t)S(e,r,{get:t[r],enumerable:!0})},D=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of _(t))!H.call(e,i)&&i!==r&&S(e,i,{get:()=>t[i],enumerable:!(n=M(t,i))||n.enumerable});return e};var V=e=>D(S({},"__esModule",{value:!0}),e);var pe={};X(pe,{defaultStylePresets:()=>P,fromJsx:()=>ne});module.exports=V(pe);function g(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function N(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function k(e,t){t.tagName!==void 0&&(e.tagName=t.tagName),t.className!==void 0&&(e.className=t.className),t.id!==void 0&&(e.id=t.id)}function h(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),k(t,e),N(t,e.preset),g(t,e.style),t}function R(e,t){if(typeof e=="string"){let n={type:"text",text:e};return g(n,t),n}let r={type:"text",text:e.text};return e.tw&&(r.tw=e.tw),k(r,e),N(r,e.preset),g(r,t??e.style),r}function w(e){let t={type:"image",src:e.src,width:e.width,height:e.height};return e.tw&&(t.tw=e.tw),k(t,e),N(t,e.preset),g(t,e.style),t}function E(e){return`${e}%`}var P={body:{margin:8},p:{marginTop:"1em",marginBottom:"1em",display:"block"},blockquote:{marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40,display:"block"},center:{textAlign:"center",display:"block"},hr:{marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,display:"block"},h1:{fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h2:{fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h3:{fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h4:{marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h5:{fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h6:{fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},u:{textDecoration:"underline",display:"inline"},strong:{fontWeight:"bold",display:"inline"},b:{fontWeight:"bold",display:"inline"},i:{fontStyle:"italic",display:"inline"},em:{fontStyle:"italic",display:"inline"},code:{fontFamily:"monospace",display:"inline"},kbd:{fontFamily:"monospace",display:"inline"},pre:{fontFamily:"monospace",margin:"1em 0",display:"block"},mark:{backgroundColor:"yellow",color:"black",display:"inline"},big:{fontSize:"1.2em",display:"inline"},small:{fontSize:"0.8em",display:"inline"},s:{textDecoration:"line-through",display:"inline"},span:{display:"inline"},img:{display:"inline"},svg:{display:"inline"}};var Y=new Set(["head","meta","link","style","script"]);function v(e){return Y.has(e.type)}function f(e,t){return e.type===t&&"props"in e}function F(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function c(e){return typeof e=="object"&&e!==null&&"type"in e}function u(e){return typeof e=="function"}var K=Symbol.for("react.forward_ref"),U=Symbol.for("react.memo"),q=Symbol.for("react.fragment");function O(e){return e.$$typeof===K}function L(e){return e.$$typeof===U}function x(e){return e.type===q}function Z(e){return typeof e=="string"||typeof e=="number"}function A(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function G(e){return Object.keys(e).map(t=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(e[t]).trim()}`).join(";")}var Q=new Set(["stopColor","stopOpacity","strokeWidth","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","fillRule","clipRule","colorInterpolationFilters","floodColor","floodOpacity","accentHeight","alignmentBaseline","arabicForm","baselineShift","capHeight","clipPath","clipPathUnits","colorInterpolation","colorProfile","colorRendering","enableBackground","fillOpacity","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","horizAdvX","horizOriginX","imageRendering","letterSpacing","lightingColor","markerEnd","markerMid","markerStart","overlinePosition","overlineThickness","paintOrder","preserveAspectRatio","pointerEvents","shapeRendering","strokeMiterlimit","strokeOpacity","textAnchor","textDecoration","textRendering","transformOrigin","underlinePosition","underlineThickness","unicodeBidi","unicodeRange","unitsPerEm","vectorEffect","vertAdvY","vertOriginX","vertOriginY","vAlphabetic","vHanging","vIdeographic","vMathematical","wordSpacing","writingMode"]);function ee(e,t){if(e==="children"||t==null)return;let r;if(e==="className"?r="class":Q.has(e)?r=F(e):r=e,typeof t=="boolean")return`${r}="${String(t)}"`;if(e==="style"&&typeof t=="object"){let n=G(t);if(n)return`style="${A(n)}"`}return`${r}="${A(String(t))}"`}function te(e){return Object.entries(e).map(([t,r])=>ee(t,r)).filter(t=>t!==void 0)}var re=(e,t)=>{let r=e.props||{};if(u(e.type))return d(e.type(e.props));if(typeof e.type=="symbol"||typeof e.type!="string")return"";let n=te(r),i=r.children,o=Array.isArray(i)?i.map(s=>t(s)).join(""):t(i);return`<${e.type}${n.length>0?` ${n.join(" ")}`:""}>${o}</${e.type}>`},d=e=>e==null||e===!1?"":Z(e)?String(e):Array.isArray(e)?e.map(d).join(""):c(e)?re(e,d):"";function $(e){let t=e.props||{};if(!("xmlns"in t)){let r={...e,props:{...t,xmlns:"http://www.w3.org/2000/svg"}};return d(r)||""}return d(e)||""}async function ne(e,t){let r=await l(e,{presets:ie(t),tailwindClassesProperty:t?.tailwindClassesProperty??"tw"}),n=r.nodes,i;return n.length===0?i=h({}):n.length===1&&n[0]!==void 0?i=n[0]:i=h({children:n,style:{width:E(100),height:E(100)}}),{node:i,stylesheets:r.stylesheets}}async function l(e,t){return e==null||e===!1?{nodes:[],stylesheets:[]}:e instanceof Promise?l(await e,t):typeof e=="object"&&Symbol.iterator in e?le(e,t):c(e)?await B(e,t):{nodes:[R({text:String(e),preset:t.presets?.span})],stylesheets:[]}}function ie(e){if(e?.defaultStyles!==!1)return e?.defaultStyles??P}function oe(e,t){if(!(typeof e.type!="object"||e.type===null)){if(O(e.type)&&"render"in e.type){let r=e.type;return l(r.render(e.props,null),t)}if(L(e.type)&&"type"in e.type){let n=e.type.type;if(u(n))return l(n(e.props),t);let i={...e,type:n};return B(i,t)}}}function m(e){if(typeof e.props=="object"&&e.props!==null&&"children"in e.props)return e.props.children}function j(e){if(!c(e))return;let t=m(e);if(typeof t=="string")return t;if(typeof t=="number")return String(t);if(Array.isArray(t)||typeof t=="object"&&t!==null&&Symbol.iterator in t)return I(t);if(c(t)&&x(t))return j(t)}function J(e){let t="";for(let r of e){let n=b(r);if(n===void 0)return;t+=n}return t}function b(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(e==null||typeof e=="boolean"||typeof e=="symbol")return"";if(typeof e=="object"&&Symbol.iterator in e)return J(e);if(!c(e))return;if(x(e))return b(m(e));let t=m(e);return t===void 0?"":typeof t=="object"&&t!==null&&Symbol.iterator in t?J(t):b(t)}function I(e){let t="";for(let r of e){if(c(r))return;if(typeof r=="string"){t+=r;continue}if(typeof r=="number"){t+=String(r);continue}return}return t}async function B(e,t){if(u(e.type))return l(e.type(e.props),t);let r=oe(e,t);if(r!==void 0)return r;if(x(e))return z(e,t);if(f(e,"style")){let p=b(m(e));return{nodes:[],stylesheets:p&&p.length>0?[p]:[]}}if(typeof e.type!="string"||v(e))return{nodes:[],stylesheets:[]};let n=e.props;if(f(e,"br"))return{nodes:[R({text:`
2
+ `,preset:t.presets?.span,tagName:"br",className:e.props.className,id:e.props.id})],stylesheets:[]};if(f(e,"img"))return{nodes:[se(e,t)],stylesheets:[]};if(f(e,"svg"))return{nodes:[ae(e,t)],stylesheets:[]};let{preset:i,style:o}=T(e,t),s=C(e,t),a=j(e);if(a!==void 0)return{nodes:[R({text:a,preset:i,style:o,tw:s,className:n.className,id:n.id,tagName:e.type})],stylesheets:[]};let y=await z(e,t);return{nodes:[h({children:y.nodes,preset:i,style:o,tw:s,tagName:e.type,className:n.className,id:n.id})],stylesheets:y.stylesheets}}function se(e,t){if(!e.props.src)throw new Error("Image element must have a 'src' prop.");let{preset:r,style:n}=T(e,t),i=C(e,t),o=e.props.width!==void 0?Number(e.props.width):void 0,s=e.props.height!==void 0?Number(e.props.height):void 0;return w({src:e.props.src,width:o,height:s,preset:r,style:n,tw:i,className:e.props.className,id:e.props.id,tagName:"img"})}function ae(e,t){let{preset:r,style:n}=T(e,t),i=C(e,t),o=$(e),s=e.props.width!==void 0?Number(e.props.width):void 0,a=e.props.height!==void 0?Number(e.props.height):void 0;return w({preset:r,width:s,height:a,style:n,src:o,tw:i,className:e.props.className,id:e.props.id,tagName:"svg"})}function T(e,t){let r,n,i=t.presets;i&&typeof e.type=="string"&&e.type in i&&(r=i[e.type]);let o=typeof e.props=="object"&&e.props!==null&&"style"in e.props&&typeof e.props.style=="object"&&e.props.style!==null?e.props.style:void 0;if(o){for(let s in o)if(Object.hasOwn(o,s)){n=o;break}}return{preset:r,style:n}}function C(e,t){let r=t.tailwindClassesProperty;if(typeof e.props!="object"||e.props===null||!(r in e.props))return;let n=e.props[r];if(typeof n=="string")return n}function z(e,t){let r=m(e);return r===void 0?Promise.resolve({nodes:[],stylesheets:[]}):l(r,t)}var ce=8;async function le(e,t){let r=[],n=new Set,i=0;for(let a of e){let y=i;i+=1;let p=l(a,t).then(W=>{r[y]=W}).finally(()=>n.delete(p));n.add(p),n.size>=ce&&await Promise.race(n)}await Promise.all(n);let o=[],s=[];for(let a of r)a&&(o.push(...a.nodes),s.push(...a.stylesheets));return{nodes:o,stylesheets:s}}0&&(module.exports={defaultStylePresets,fromJsx});
@@ -1,5 +1,5 @@
1
1
  import { JSX, CSSProperties, ReactNode } from 'react';
2
- import { N as Node } from '../types-DgRXITo4.cjs';
2
+ import { N as Node } from '../types-DVfDlIZ1.cjs';
3
3
 
4
4
  declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
5
5
 
@@ -30,6 +30,10 @@ interface FromJsxOptions {
30
30
  */
31
31
  tailwindClassesProperty?: string;
32
32
  }
33
- declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<Node>;
33
+ interface FromJsxResult {
34
+ node: Node;
35
+ stylesheets: string[];
36
+ }
37
+ declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<FromJsxResult>;
34
38
 
35
- export { type FromJsxOptions, defaultStylePresets, fromJsx };
39
+ export { type FromJsxOptions, type FromJsxResult, defaultStylePresets, fromJsx };
package/dist/jsx/jsx.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { JSX, CSSProperties, ReactNode } from 'react';
2
- import { N as Node } from '../types-DgRXITo4.js';
2
+ import { N as Node } from '../types-DVfDlIZ1.js';
3
3
 
4
4
  declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
5
5
 
@@ -30,6 +30,10 @@ interface FromJsxOptions {
30
30
  */
31
31
  tailwindClassesProperty?: string;
32
32
  }
33
- declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<Node>;
33
+ interface FromJsxResult {
34
+ node: Node;
35
+ stylesheets: string[];
36
+ }
37
+ declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<FromJsxResult>;
34
38
 
35
- export { type FromJsxOptions, defaultStylePresets, fromJsx };
39
+ export { type FromJsxOptions, type FromJsxResult, defaultStylePresets, fromJsx };
package/dist/jsx/jsx.js CHANGED
@@ -1,2 +1,2 @@
1
- function u(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function h(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function d(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),h(t,e.preset),u(t,e.style),t}function m(e,t){if(typeof e=="string"){let n={type:"text",text:e};return u(n,t),n}let r={type:"text",text:e.text};return e.tw&&(r.tw=e.tw),h(r,e.preset),u(r,t??e.style),r}function R(e){let t={type:"image",src:e.src,width:e.width,height:e.height};return e.tw&&(t.tw=e.tw),h(t,e.preset),u(t,e.style),t}function b(e){return`${e}%`}var k={body:{margin:8},p:{marginTop:"1em",marginBottom:"1em",display:"block"},blockquote:{marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40,display:"block"},center:{textAlign:"center",display:"block"},hr:{marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,display:"block"},h1:{fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h2:{fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h3:{fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h4:{marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h5:{fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h6:{fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},u:{textDecoration:"underline",display:"inline"},strong:{fontWeight:"bold",display:"inline"},b:{fontWeight:"bold",display:"inline"},i:{fontStyle:"italic",display:"inline"},em:{fontStyle:"italic",display:"inline"},code:{fontFamily:"monospace",display:"inline"},kbd:{fontFamily:"monospace",display:"inline"},pre:{fontFamily:"monospace",margin:"1em 0",display:"block"},mark:{backgroundColor:"yellow",color:"black",display:"inline"},big:{fontSize:"1.2em",display:"inline"},small:{fontSize:"0.8em",display:"inline"},s:{textDecoration:"line-through",display:"inline"},span:{display:"inline"},img:{display:"inline"},svg:{display:"inline"}};var I=new Set(["head","meta","link","style","script"]);function E(e){return I.has(e.type)}function g(e,t){return e.type===t&&"props"in e}function P(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function a(e){return typeof e=="object"&&e!==null&&"type"in e}function l(e){return typeof e=="function"}var J=Symbol.for("react.forward_ref"),z=Symbol.for("react.memo"),j=Symbol.for("react.fragment");function N(e){return e.$$typeof===J}function C(e){return e.$$typeof===z}function x(e){return e.type===j}function B(e){return typeof e=="string"||typeof e=="number"}function T(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function W(e){return Object.keys(e).map(t=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(e[t]).trim()}`).join(";")}var M=new Set(["stopColor","stopOpacity","strokeWidth","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","fillRule","clipRule","colorInterpolationFilters","floodColor","floodOpacity","accentHeight","alignmentBaseline","arabicForm","baselineShift","capHeight","clipPath","clipPathUnits","colorInterpolation","colorProfile","colorRendering","enableBackground","fillOpacity","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","horizAdvX","horizOriginX","imageRendering","letterSpacing","lightingColor","markerEnd","markerMid","markerStart","overlinePosition","overlineThickness","paintOrder","preserveAspectRatio","pointerEvents","shapeRendering","strokeMiterlimit","strokeOpacity","textAnchor","textDecoration","textRendering","transformOrigin","underlinePosition","underlineThickness","unicodeBidi","unicodeRange","unitsPerEm","vectorEffect","vertAdvY","vertOriginX","vertOriginY","vAlphabetic","vHanging","vIdeographic","vMathematical","wordSpacing","writingMode"]);function _(e,t){if(e==="children"||t==null)return;let r;if(e==="className"?r="class":M.has(e)?r=P(e):r=e,typeof t=="boolean")return`${r}="${String(t)}"`;if(e==="style"&&typeof t=="object"){let n=W(t);if(n)return`style="${T(n)}"`}return`${r}="${T(String(t))}"`}function H(e){return Object.entries(e).map(([t,r])=>_(t,r)).filter(t=>t!==void 0)}var X=(e,t)=>{let r=e.props||{};if(l(e.type))return f(e.type(e.props));if(typeof e.type=="symbol"||typeof e.type!="string")return"";let n=H(r),i=r.children,o=Array.isArray(i)?i.map(s=>t(s)).join(""):t(i);return`<${e.type}${n.length>0?` ${n.join(" ")}`:""}>${o}</${e.type}>`},f=e=>e==null||e===!1?"":B(e)?String(e):Array.isArray(e)?e.map(f).join(""):a(e)?X(e,f):"";function v(e){let t=e.props||{};if(!("xmlns"in t)){let r={...e,props:{...t,xmlns:"http://www.w3.org/2000/svg"}};return f(r)||""}return f(e)||""}async function se(e,t){let r=await p(e,{presets:D(t),tailwindClassesProperty:t?.tailwindClassesProperty??"tw"});return r.length===0?d({}):r.length===1&&r[0]!==void 0?r[0]:d({children:r,style:{width:b(100),height:b(100)}})}async function p(e,t){if(e==null||e===!1)return[];if(e instanceof Promise)return p(await e,t);if(typeof e=="object"&&Symbol.iterator in e)return q(e,t);if(a(e)){let r=await F(e,t);return Array.isArray(r)?r:r?[r]:[]}return[m({text:String(e),preset:t.presets?.span})]}function D(e){if(e?.defaultStyles!==!1)return e?.defaultStyles??k}function V(e,t){if(!(typeof e.type!="object"||e.type===null)){if(N(e.type)&&"render"in e.type){let r=e.type;return p(r.render(e.props,null),t)}if(C(e.type)&&"type"in e.type){let n=e.type.type;if(l(n))return p(n(e.props),t);let i={...e,type:n};return F(i,t)}}}function A(e){if(!a(e))return;let t=typeof e.props=="object"&&e.props!==null&&"children"in e.props?e.props.children:void 0;if(typeof t=="string")return t;if(typeof t=="number")return String(t);if(Array.isArray(t)||typeof t=="object"&&t!==null&&Symbol.iterator in t)return O(t);if(a(t)&&x(t))return A(t)}function O(e){let t="";for(let r of e){if(a(r))return;if(typeof r=="string"){t+=r;continue}if(typeof r=="number"){t+=String(r);continue}return}return t}async function F(e,t){if(l(e.type))return p(e.type(e.props),t);let r=V(e,t);if(r!==void 0)return r;if(x(e))return await L(e,t)||[];if(E(e))return[];if(g(e,"br"))return[m({text:`
2
- `,preset:t.presets?.span})];if(g(e,"img"))return[Y(e,t)];if(g(e,"svg"))return[K(e,t)];let{preset:n,style:i}=S(e,t),o=w(e,t),s=A(e);if(s!==void 0)return[m({text:s,preset:n,style:i,tw:o})];let c=await L(e,t);return[d({children:c,preset:n,style:i,tw:o})]}function Y(e,t){if(!e.props.src)throw new Error("Image element must have a 'src' prop.");let{preset:r,style:n}=S(e,t),i=w(e,t),o=e.props.width!==void 0?Number(e.props.width):void 0,s=e.props.height!==void 0?Number(e.props.height):void 0;return R({src:e.props.src,width:o,height:s,preset:r,style:n,tw:i})}function K(e,t){let{preset:r,style:n}=S(e,t),i=w(e,t),o=v(e),s=e.props.width!==void 0?Number(e.props.width):void 0,c=e.props.height!==void 0?Number(e.props.height):void 0;return R({preset:r,width:s,height:c,style:n,src:o,tw:i})}function S(e,t){let r,n,i=t.presets;i&&typeof e.type=="string"&&e.type in i&&(r=i[e.type]);let o=typeof e.props=="object"&&e.props!==null&&"style"in e.props&&typeof e.props.style=="object"&&e.props.style!==null?e.props.style:void 0;if(o){for(let s in o)if(Object.hasOwn(o,s)){n=o;break}}return{preset:r,style:n}}function w(e,t){let r=t.tailwindClassesProperty;if(typeof e.props!="object"||e.props===null||!(r in e.props))return;let n=e.props[r];if(typeof n=="string")return n}function L(e,t){return typeof e.props!="object"||e.props===null||!("children"in e.props)?Promise.resolve([]):p(e.props.children,t)}var U=8;async function q(e,t){let r=[],n=new Set,i=0;for(let s of e){let c=i;i+=1;let y=p(s,t).then($=>{r[c]=$}).finally(()=>n.delete(y));n.add(y),n.size>=U&&await Promise.race(n)}await Promise.all(n);let o=[];for(let s of r)s&&o.push(...s);return o}export{k as defaultStylePresets,se as fromJsx};
1
+ function g(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function S(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function N(e,t){t.tagName!==void 0&&(e.tagName=t.tagName),t.className!==void 0&&(e.className=t.className),t.id!==void 0&&(e.id=t.id)}function h(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),N(t,e),S(t,e.preset),g(t,e.style),t}function R(e,t){if(typeof e=="string"){let n={type:"text",text:e};return g(n,t),n}let r={type:"text",text:e.text};return e.tw&&(r.tw=e.tw),N(r,e),S(r,e.preset),g(r,t??e.style),r}function k(e){let t={type:"image",src:e.src,width:e.width,height:e.height};return e.tw&&(t.tw=e.tw),N(t,e),S(t,e.preset),g(t,e.style),t}function w(e){return`${e}%`}var T={body:{margin:8},p:{marginTop:"1em",marginBottom:"1em",display:"block"},blockquote:{marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40,display:"block"},center:{textAlign:"center",display:"block"},hr:{marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,display:"block"},h1:{fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h2:{fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h3:{fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h4:{marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h5:{fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},h6:{fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold",display:"block"},u:{textDecoration:"underline",display:"inline"},strong:{fontWeight:"bold",display:"inline"},b:{fontWeight:"bold",display:"inline"},i:{fontStyle:"italic",display:"inline"},em:{fontStyle:"italic",display:"inline"},code:{fontFamily:"monospace",display:"inline"},kbd:{fontFamily:"monospace",display:"inline"},pre:{fontFamily:"monospace",margin:"1em 0",display:"block"},mark:{backgroundColor:"yellow",color:"black",display:"inline"},big:{fontSize:"1.2em",display:"inline"},small:{fontSize:"0.8em",display:"inline"},s:{textDecoration:"line-through",display:"inline"},span:{display:"inline"},img:{display:"inline"},svg:{display:"inline"}};var W=new Set(["head","meta","link","style","script"]);function C(e){return W.has(e.type)}function f(e,t){return e.type===t&&"props"in e}function v(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function c(e){return typeof e=="object"&&e!==null&&"type"in e}function u(e){return typeof e=="function"}var M=Symbol.for("react.forward_ref"),_=Symbol.for("react.memo"),H=Symbol.for("react.fragment");function F(e){return e.$$typeof===M}function O(e){return e.$$typeof===_}function x(e){return e.type===H}function X(e){return typeof e=="string"||typeof e=="number"}function L(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function D(e){return Object.keys(e).map(t=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(e[t]).trim()}`).join(";")}var V=new Set(["stopColor","stopOpacity","strokeWidth","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","fillRule","clipRule","colorInterpolationFilters","floodColor","floodOpacity","accentHeight","alignmentBaseline","arabicForm","baselineShift","capHeight","clipPath","clipPathUnits","colorInterpolation","colorProfile","colorRendering","enableBackground","fillOpacity","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","horizAdvX","horizOriginX","imageRendering","letterSpacing","lightingColor","markerEnd","markerMid","markerStart","overlinePosition","overlineThickness","paintOrder","preserveAspectRatio","pointerEvents","shapeRendering","strokeMiterlimit","strokeOpacity","textAnchor","textDecoration","textRendering","transformOrigin","underlinePosition","underlineThickness","unicodeBidi","unicodeRange","unitsPerEm","vectorEffect","vertAdvY","vertOriginX","vertOriginY","vAlphabetic","vHanging","vIdeographic","vMathematical","wordSpacing","writingMode"]);function Y(e,t){if(e==="children"||t==null)return;let r;if(e==="className"?r="class":V.has(e)?r=v(e):r=e,typeof t=="boolean")return`${r}="${String(t)}"`;if(e==="style"&&typeof t=="object"){let n=D(t);if(n)return`style="${L(n)}"`}return`${r}="${L(String(t))}"`}function K(e){return Object.entries(e).map(([t,r])=>Y(t,r)).filter(t=>t!==void 0)}var U=(e,t)=>{let r=e.props||{};if(u(e.type))return d(e.type(e.props));if(typeof e.type=="symbol"||typeof e.type!="string")return"";let n=K(r),i=r.children,o=Array.isArray(i)?i.map(s=>t(s)).join(""):t(i);return`<${e.type}${n.length>0?` ${n.join(" ")}`:""}>${o}</${e.type}>`},d=e=>e==null||e===!1?"":X(e)?String(e):Array.isArray(e)?e.map(d).join(""):c(e)?U(e,d):"";function A(e){let t=e.props||{};if(!("xmlns"in t)){let r={...e,props:{...t,xmlns:"http://www.w3.org/2000/svg"}};return d(r)||""}return d(e)||""}async function fe(e,t){let r=await l(e,{presets:q(t),tailwindClassesProperty:t?.tailwindClassesProperty??"tw"}),n=r.nodes,i;return n.length===0?i=h({}):n.length===1&&n[0]!==void 0?i=n[0]:i=h({children:n,style:{width:w(100),height:w(100)}}),{node:i,stylesheets:r.stylesheets}}async function l(e,t){return e==null||e===!1?{nodes:[],stylesheets:[]}:e instanceof Promise?l(await e,t):typeof e=="object"&&Symbol.iterator in e?te(e,t):c(e)?await j(e,t):{nodes:[R({text:String(e),preset:t.presets?.span})],stylesheets:[]}}function q(e){if(e?.defaultStyles!==!1)return e?.defaultStyles??T}function Z(e,t){if(!(typeof e.type!="object"||e.type===null)){if(F(e.type)&&"render"in e.type){let r=e.type;return l(r.render(e.props,null),t)}if(O(e.type)&&"type"in e.type){let n=e.type.type;if(u(n))return l(n(e.props),t);let i={...e,type:n};return j(i,t)}}}function m(e){if(typeof e.props=="object"&&e.props!==null&&"children"in e.props)return e.props.children}function z(e){if(!c(e))return;let t=m(e);if(typeof t=="string")return t;if(typeof t=="number")return String(t);if(Array.isArray(t)||typeof t=="object"&&t!==null&&Symbol.iterator in t)return J(t);if(c(t)&&x(t))return z(t)}function $(e){let t="";for(let r of e){let n=b(r);if(n===void 0)return;t+=n}return t}function b(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(e==null||typeof e=="boolean"||typeof e=="symbol")return"";if(typeof e=="object"&&Symbol.iterator in e)return $(e);if(!c(e))return;if(x(e))return b(m(e));let t=m(e);return t===void 0?"":typeof t=="object"&&t!==null&&Symbol.iterator in t?$(t):b(t)}function J(e){let t="";for(let r of e){if(c(r))return;if(typeof r=="string"){t+=r;continue}if(typeof r=="number"){t+=String(r);continue}return}return t}async function j(e,t){if(u(e.type))return l(e.type(e.props),t);let r=Z(e,t);if(r!==void 0)return r;if(x(e))return I(e,t);if(f(e,"style")){let p=b(m(e));return{nodes:[],stylesheets:p&&p.length>0?[p]:[]}}if(typeof e.type!="string"||C(e))return{nodes:[],stylesheets:[]};let n=e.props;if(f(e,"br"))return{nodes:[R({text:`
2
+ `,preset:t.presets?.span,tagName:"br",className:e.props.className,id:e.props.id})],stylesheets:[]};if(f(e,"img"))return{nodes:[G(e,t)],stylesheets:[]};if(f(e,"svg"))return{nodes:[Q(e,t)],stylesheets:[]};let{preset:i,style:o}=E(e,t),s=P(e,t),a=z(e);if(a!==void 0)return{nodes:[R({text:a,preset:i,style:o,tw:s,className:n.className,id:n.id,tagName:e.type})],stylesheets:[]};let y=await I(e,t);return{nodes:[h({children:y.nodes,preset:i,style:o,tw:s,tagName:e.type,className:n.className,id:n.id})],stylesheets:y.stylesheets}}function G(e,t){if(!e.props.src)throw new Error("Image element must have a 'src' prop.");let{preset:r,style:n}=E(e,t),i=P(e,t),o=e.props.width!==void 0?Number(e.props.width):void 0,s=e.props.height!==void 0?Number(e.props.height):void 0;return k({src:e.props.src,width:o,height:s,preset:r,style:n,tw:i,className:e.props.className,id:e.props.id,tagName:"img"})}function Q(e,t){let{preset:r,style:n}=E(e,t),i=P(e,t),o=A(e),s=e.props.width!==void 0?Number(e.props.width):void 0,a=e.props.height!==void 0?Number(e.props.height):void 0;return k({preset:r,width:s,height:a,style:n,src:o,tw:i,className:e.props.className,id:e.props.id,tagName:"svg"})}function E(e,t){let r,n,i=t.presets;i&&typeof e.type=="string"&&e.type in i&&(r=i[e.type]);let o=typeof e.props=="object"&&e.props!==null&&"style"in e.props&&typeof e.props.style=="object"&&e.props.style!==null?e.props.style:void 0;if(o){for(let s in o)if(Object.hasOwn(o,s)){n=o;break}}return{preset:r,style:n}}function P(e,t){let r=t.tailwindClassesProperty;if(typeof e.props!="object"||e.props===null||!(r in e.props))return;let n=e.props[r];if(typeof n=="string")return n}function I(e,t){let r=m(e);return r===void 0?Promise.resolve({nodes:[],stylesheets:[]}):l(r,t)}var ee=8;async function te(e,t){let r=[],n=new Set,i=0;for(let a of e){let y=i;i+=1;let p=l(a,t).then(B=>{r[y]=B}).finally(()=>n.delete(p));n.add(p),n.size>=ee&&await Promise.race(n)}await Promise.all(n);let o=[],s=[];for(let a of r)a&&(o.push(...a.nodes),s.push(...a.stylesheets));return{nodes:o,stylesheets:s}}export{T as defaultStylePresets,fe as fromJsx};
@@ -1,9 +1,15 @@
1
1
  import { CSSProperties } from 'react';
2
2
 
3
- type AnyNode = {
4
- type: string;
5
- style?: CSSProperties;
3
+ type BaseNode = {
4
+ tagName?: string;
5
+ className?: string;
6
+ id?: string;
6
7
  tw?: string;
8
+ style?: CSSProperties;
9
+ preset?: CSSProperties;
10
+ };
11
+ type AnyNode = BaseNode & {
12
+ type: string;
7
13
  [key: string]: unknown;
8
14
  };
9
15
  /**
@@ -11,28 +17,19 @@ type AnyNode = {
11
17
  */
12
18
  type PartialStyle = CSSProperties;
13
19
  type Node = ContainerNode | TextNode | ImageNode | AnyNode;
14
- type ContainerNode = {
20
+ type ContainerNode = BaseNode & {
15
21
  type: "container";
16
- preset?: CSSProperties;
17
- style?: CSSProperties;
18
22
  children?: Node[];
19
- tw?: string;
20
23
  };
21
- type TextNode = {
24
+ type TextNode = BaseNode & {
22
25
  type: "text";
23
26
  text: string;
24
- preset?: CSSProperties;
25
- style?: CSSProperties;
26
- tw?: string;
27
27
  };
28
- type ImageNode = {
28
+ type ImageNode = BaseNode & {
29
29
  type: "image";
30
30
  src: string;
31
31
  width?: number;
32
32
  height?: number;
33
- preset?: CSSProperties;
34
- style?: CSSProperties;
35
- tw?: string;
36
33
  };
37
34
 
38
- export type { AnyNode as A, ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, TextNode as T };
35
+ export type { AnyNode as A, BaseNode as B, ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, TextNode as T };
@@ -1,9 +1,15 @@
1
1
  import { CSSProperties } from 'react';
2
2
 
3
- type AnyNode = {
4
- type: string;
5
- style?: CSSProperties;
3
+ type BaseNode = {
4
+ tagName?: string;
5
+ className?: string;
6
+ id?: string;
6
7
  tw?: string;
8
+ style?: CSSProperties;
9
+ preset?: CSSProperties;
10
+ };
11
+ type AnyNode = BaseNode & {
12
+ type: string;
7
13
  [key: string]: unknown;
8
14
  };
9
15
  /**
@@ -11,28 +17,19 @@ type AnyNode = {
11
17
  */
12
18
  type PartialStyle = CSSProperties;
13
19
  type Node = ContainerNode | TextNode | ImageNode | AnyNode;
14
- type ContainerNode = {
20
+ type ContainerNode = BaseNode & {
15
21
  type: "container";
16
- preset?: CSSProperties;
17
- style?: CSSProperties;
18
22
  children?: Node[];
19
- tw?: string;
20
23
  };
21
- type TextNode = {
24
+ type TextNode = BaseNode & {
22
25
  type: "text";
23
26
  text: string;
24
- preset?: CSSProperties;
25
- style?: CSSProperties;
26
- tw?: string;
27
27
  };
28
- type ImageNode = {
28
+ type ImageNode = BaseNode & {
29
29
  type: "image";
30
30
  src: string;
31
31
  width?: number;
32
32
  height?: number;
33
- preset?: CSSProperties;
34
- style?: CSSProperties;
35
- tw?: string;
36
33
  };
37
34
 
38
- export type { AnyNode as A, ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, TextNode as T };
35
+ export type { AnyNode as A, BaseNode as B, ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, TextNode as T };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takumi-rs/helpers",
3
- "version": "0.68.16",
3
+ "version": "0.69.0",
4
4
  "author": {
5
5
  "email": "me@kane.tw",
6
6
  "name": "Kane Wang",