@takumi-rs/helpers 0.72.0 → 0.73.1

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 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});
1
+ "use strict";var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},y=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of h(t))!N.call(e,o)&&o!==n&&u(e,o,{get:()=>t[o],enumerable:!(i=l(t,o))||i.enumerable});return e};var w=e=>y(u({},"__esModule",{value:!0}),e);var k={};g(k,{container:()=>b,em:()=>R,fetchResources:()=>M,fr:()=>I,image:()=>T,percentage:()=>$,rem:()=>v,rgba:()=>E,style:()=>P,text:()=>S,vh:()=>C,vw:()=>O});module.exports=w(k);function c(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 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),t.attributes!==void 0&&(e.attributes=t.attributes)}function b(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),f(t,e),s(t,e.preset),c(t,e.style),t}function S(e,t){if(typeof e=="string"){let i={type:"text",text:e};return c(i,t),i}let n={type:"text",text:e.text};return e.tw&&(n.tw=e.tw),f(n,e),s(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),s(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 R(e){return`${e}em`}function v(e){return`${e}rem`}function I(e){return`${e}fr`}function E(e,t,n,i=1){return`rgb(${e} ${t} ${n} / ${i})`}async function M(e,t){let n=AbortSignal.timeout(t?.timeout??5e3),i=t?.fetch??globalThis.fetch,o=t?.throwOnError??!0,d=[...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 i(r,{signal:n});if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText} for ${r}`);let m=await a.arrayBuffer();return t?.cache?.set(r,m),{src:r,data:m}});return o?Promise.all(d):(await Promise.allSettled(d)).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-DVfDlIZ1.cjs';
3
- export { A as AnyNode, B as BaseNode, N as Node, P as PartialStyle } from './types-DVfDlIZ1.cjs';
2
+ import { C as ContainerNode, T as TextNode, I as ImageNode } from './types-DS15vfPf.cjs';
3
+ export { b as Node, N as NodeAttributes, a as NodeMetadata, P as PartialStyle } from './types-DS15vfPf.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-DVfDlIZ1.js';
3
- export { A as AnyNode, B as BaseNode, N as Node, P as PartialStyle } from './types-DVfDlIZ1.js';
2
+ import { C as ContainerNode, T as TextNode, I as ImageNode } from './types-DS15vfPf.js';
3
+ export { b as Node, N as NodeAttributes, a as NodeMetadata, P as PartialStyle } from './types-DS15vfPf.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 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};
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 u(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),t.attributes!==void 0&&(e.attributes=t.attributes)}function h(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),u(t,e),c(t,e.preset),a(t,e.style),t}function N(e,t){if(typeof e=="string"){let i={type:"text",text:e};return a(i,t),i}let r={type:"text",text:e.text};return e.tw&&(r.tw=e.tw),u(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),u(t,e),c(t,e.preset),a(t,e.style),t}function y(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,i=1){return`rgb(${e} ${t} ${r} / ${i})`}async function R(e,t){let r=AbortSignal.timeout(t?.timeout??5e3),i=t?.fetch??globalThis.fetch,m=t?.throwOnError??!0,s=[...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 o=await i(n,{signal:r});if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText} for ${n}`);let f=await o.arrayBuffer();return t?.cache?.set(n,f),{src:n,data:f}});return m?Promise.all(s):(await Promise.allSettled(s)).filter(n=>n.status==="fulfilled").map(n=>n.value)}export{h as container,T as em,R as fetchResources,$ as fr,g as image,w as percentage,P as rem,O as rgba,y as style,N as text,S as vh,b as vw};
package/dist/jsx/jsx.cjs CHANGED
@@ -1,2 +1,2 @@
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
+ "use strict";var k=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var X=(e,t)=>{for(var r in t)k(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))!V.call(e,i)&&i!==r&&k(e,i,{get:()=>t[i],enumerable:!(n=B(t,i))||n.enumerable});return e};var Y=e=>D(k({},"__esModule",{value:!0}),e);var fe={};X(fe,{defaultStylePresets:()=>T,fromJsx:()=>ie});module.exports=Y(fe);function h(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 w(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),t.attributes!==void 0&&(e.attributes=t.attributes)}function R(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),w(t,e),N(t,e.preset),h(t,e.style),t}function b(e,t){if(typeof e=="string"){let n={type:"text",text:e};return h(n,t),n}let r={type:"text",text:e.text};return e.tw&&(r.tw=e.tw),w(r,e),N(r,e.preset),h(r,t??e.style),r}function E(e){let t={type:"image",src:e.src,width:e.width,height:e.height};return e.tw&&(t.tw=e.tw),w(t,e),N(t,e.preset),h(t,e.style),t}function P(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 K=new Set(["head","meta","link","style","script"]);function F(e){return K.has(e.type)}function u(e,t){return e.type===t&&"props"in e}function L(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function c(e){return typeof e=="object"&&e!==null&&"type"in e}function d(e){return typeof e=="function"}var U=Symbol.for("react.forward_ref"),q=Symbol.for("react.memo"),Z=Symbol.for("react.fragment");function $(e){return e.$$typeof===U}function A(e){return e.$$typeof===q}function x(e){return e.type===Z}function G(e){return typeof e=="string"||typeof e=="number"}function J(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Q(e){return Object.keys(e).map(t=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(e[t]).trim()}`).join(";")}var ee=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 te(e,t){if(e==="children"||t==null)return;let r;if(e==="className"?r="class":ee.has(e)?r=L(e):r=e,typeof t=="boolean")return`${r}="${String(t)}"`;if(e==="style"&&typeof t=="object"){let n=Q(t);if(n)return`style="${J(n)}"`}return`${r}="${J(String(t))}"`}function re(e){return Object.entries(e).map(([t,r])=>te(t,r)).filter(t=>t!==void 0)}var ne=(e,t)=>{let r=e.props||{};if(d(e.type))return m(e.type(e.props));if(typeof e.type=="symbol"||typeof e.type!="string")return"";let n=re(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}>`},m=e=>e==null||e===!1?"":G(e)?String(e):Array.isArray(e)?e.map(m).join(""):c(e)?ne(e,m):"";function I(e){let t=e.props||{};if(!("xmlns"in t)){let r={...e,props:{...t,xmlns:"http://www.w3.org/2000/svg"}};return m(r)||""}return m(e)||""}async function ie(e,t){let r=await l(e,{presets:oe(t),tailwindClassesProperty:t?.tailwindClassesProperty??"tw"}),n=r.nodes,i;return n.length===0?i=R({}):n.length===1&&n[0]!==void 0?i=n[0]:i=R({children:n,style:{width:P(100),height:P(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?pe(e,t):c(e)?await W(e,t):{nodes:[b({text:String(e),preset:t.presets?.span})],stylesheets:[]}}function C(e,t){let r={};for(let[n,i]of Object.entries(e))n==="children"||n==="className"||n==="id"||n==="style"||n===t||n==="ref"||n==="key"||n==="dangerouslySetInnerHTML"||n==="suppressHydrationWarning"||i==null||i===!1||typeof i=="function"||typeof i=="symbol"||typeof i!="object"&&(r[n]=i===!0?"":String(i));if(Object.keys(r).length!==0)return r}function oe(e){if(e?.defaultStyles!==!1)return e?.defaultStyles??T}function se(e,t){if(!(typeof e.type!="object"||e.type===null)){if($(e.type)&&"render"in e.type){let r=e.type;return l(r.render(e.props,null),t)}if(A(e.type)&&"type"in e.type){let n=e.type.type;if(d(n))return l(n(e.props),t);let i={...e,type:n};return W(i,t)}}}function y(e){if(typeof e.props=="object"&&e.props!==null&&"children"in e.props)return e.props.children}function M(e){if(!c(e))return;let t=y(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 z(t);if(c(t)&&x(t))return M(t)}function j(e){let t="";for(let r of e){let n=S(r);if(n===void 0)return;t+=n}return t}function S(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 S(y(e));let t=y(e);return t===void 0?"":typeof t=="object"&&t!==null&&Symbol.iterator in t?j(t):S(t)}function z(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 W(e,t){if(d(e.type))return l(e.type(e.props),t);let r=se(e,t);if(r!==void 0)return r;if(x(e))return H(e,t);if(u(e,"style")){let f=S(y(e));return{nodes:[],stylesheets:f&&f.length>0?[f]:[]}}if(typeof e.type!="string"||F(e))return{nodes:[],stylesheets:[]};let n=e.props,i=C(n,t.tailwindClassesProperty);if(u(e,"br"))return{nodes:[b({text:`
2
+ `,preset:t.presets?.span,tagName:"br",className:e.props.className,id:e.props.id,attributes:i})],stylesheets:[]};if(u(e,"img"))return{nodes:[ae(e,t)],stylesheets:[]};if(u(e,"svg"))return{nodes:[ce(e,t)],stylesheets:[]};let{preset:o,style:s}=v(e,t),a=O(e,t),g=M(e);if(g!==void 0)return{nodes:[b({text:g,preset:o,style:s,tw:a,className:n.className,id:n.id,attributes:i,tagName:e.type})],stylesheets:[]};let p=await H(e,t);return{nodes:[R({children:p.nodes,preset:o,style:s,tw:a,tagName:e.type,className:n.className,id:n.id,attributes:i})],stylesheets:p.stylesheets}}function ae(e,t){if(!e.props.src)throw new Error("Image element must have a 'src' prop.");let{preset:r,style:n}=v(e,t),i=O(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 E({src:e.props.src,width:o,height:s,preset:r,style:n,tw:i,className:e.props.className,id:e.props.id,attributes:C(e.props,t.tailwindClassesProperty),tagName:"img"})}function ce(e,t){let{preset:r,style:n}=v(e,t),i=O(e,t),o=I(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 E({preset:r,width:s,height:a,style:n,src:o,tw:i,className:e.props.className,id:e.props.id,attributes:C(e.props,t.tailwindClassesProperty),tagName:"svg"})}function v(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 O(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 H(e,t){let r=y(e);return r===void 0?Promise.resolve({nodes:[],stylesheets:[]}):l(r,t)}var le=8;async function pe(e,t){let r=[],n=new Set,i=0;for(let a of e){let g=i;i+=1;let p=l(a,t).then(f=>{r[g]=f}).finally(()=>n.delete(p));n.add(p),n.size>=le&&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-DVfDlIZ1.cjs';
2
+ import { b as Node } from '../types-DS15vfPf.cjs';
3
3
 
4
4
  declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
5
5
 
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-DVfDlIZ1.js';
2
+ import { b as Node } from '../types-DS15vfPf.js';
3
3
 
4
4
  declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
5
5
 
package/dist/jsx/jsx.js CHANGED
@@ -1,2 +1,2 @@
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
+ function h(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function k(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),t.attributes!==void 0&&(e.attributes=t.attributes)}function R(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),N(t,e),k(t,e.preset),h(t,e.style),t}function b(e,t){if(typeof e=="string"){let n={type:"text",text:e};return h(n,t),n}let r={type:"text",text:e.text};return e.tw&&(r.tw=e.tw),N(r,e),k(r,e.preset),h(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),N(t,e),k(t,e.preset),h(t,e.style),t}function E(e){return`${e}%`}var v={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 O(e){return W.has(e.type)}function u(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 d(e){return typeof e=="function"}var B=Symbol.for("react.forward_ref"),_=Symbol.for("react.memo"),V=Symbol.for("react.fragment");function L(e){return e.$$typeof===B}function $(e){return e.$$typeof===_}function x(e){return e.type===V}function X(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 D(e){return Object.keys(e).map(t=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(e[t]).trim()}`).join(";")}var Y=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 K(e,t){if(e==="children"||t==null)return;let r;if(e==="className"?r="class":Y.has(e)?r=F(e):r=e,typeof t=="boolean")return`${r}="${String(t)}"`;if(e==="style"&&typeof t=="object"){let n=D(t);if(n)return`style="${A(n)}"`}return`${r}="${A(String(t))}"`}function U(e){return Object.entries(e).map(([t,r])=>K(t,r)).filter(t=>t!==void 0)}var q=(e,t)=>{let r=e.props||{};if(d(e.type))return m(e.type(e.props));if(typeof e.type=="symbol"||typeof e.type!="string")return"";let n=U(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}>`},m=e=>e==null||e===!1?"":X(e)?String(e):Array.isArray(e)?e.map(m).join(""):c(e)?q(e,m):"";function J(e){let t=e.props||{};if(!("xmlns"in t)){let r={...e,props:{...t,xmlns:"http://www.w3.org/2000/svg"}};return m(r)||""}return m(e)||""}async function ue(e,t){let r=await l(e,{presets:Z(t),tailwindClassesProperty:t?.tailwindClassesProperty??"tw"}),n=r.nodes,i;return n.length===0?i=R({}):n.length===1&&n[0]!==void 0?i=n[0]:i=R({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?re(e,t):c(e)?await M(e,t):{nodes:[b({text:String(e),preset:t.presets?.span})],stylesheets:[]}}function P(e,t){let r={};for(let[n,i]of Object.entries(e))n==="children"||n==="className"||n==="id"||n==="style"||n===t||n==="ref"||n==="key"||n==="dangerouslySetInnerHTML"||n==="suppressHydrationWarning"||i==null||i===!1||typeof i=="function"||typeof i=="symbol"||typeof i!="object"&&(r[n]=i===!0?"":String(i));if(Object.keys(r).length!==0)return r}function Z(e){if(e?.defaultStyles!==!1)return e?.defaultStyles??v}function G(e,t){if(!(typeof e.type!="object"||e.type===null)){if(L(e.type)&&"render"in e.type){let r=e.type;return l(r.render(e.props,null),t)}if($(e.type)&&"type"in e.type){let n=e.type.type;if(d(n))return l(n(e.props),t);let i={...e,type:n};return M(i,t)}}}function y(e){if(typeof e.props=="object"&&e.props!==null&&"children"in e.props)return e.props.children}function H(e){if(!c(e))return;let t=y(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 H(t)}function I(e){let t="";for(let r of e){let n=S(r);if(n===void 0)return;t+=n}return t}function S(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 I(e);if(!c(e))return;if(x(e))return S(y(e));let t=y(e);return t===void 0?"":typeof t=="object"&&t!==null&&Symbol.iterator in t?I(t):S(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 M(e,t){if(d(e.type))return l(e.type(e.props),t);let r=G(e,t);if(r!==void 0)return r;if(x(e))return z(e,t);if(u(e,"style")){let f=S(y(e));return{nodes:[],stylesheets:f&&f.length>0?[f]:[]}}if(typeof e.type!="string"||O(e))return{nodes:[],stylesheets:[]};let n=e.props,i=P(n,t.tailwindClassesProperty);if(u(e,"br"))return{nodes:[b({text:`
2
+ `,preset:t.presets?.span,tagName:"br",className:e.props.className,id:e.props.id,attributes:i})],stylesheets:[]};if(u(e,"img"))return{nodes:[Q(e,t)],stylesheets:[]};if(u(e,"svg"))return{nodes:[ee(e,t)],stylesheets:[]};let{preset:o,style:s}=T(e,t),a=C(e,t),g=H(e);if(g!==void 0)return{nodes:[b({text:g,preset:o,style:s,tw:a,className:n.className,id:n.id,attributes:i,tagName:e.type})],stylesheets:[]};let p=await z(e,t);return{nodes:[R({children:p.nodes,preset:o,style:s,tw:a,tagName:e.type,className:n.className,id:n.id,attributes:i})],stylesheets:p.stylesheets}}function Q(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,attributes:P(e.props,t.tailwindClassesProperty),tagName:"img"})}function ee(e,t){let{preset:r,style:n}=T(e,t),i=C(e,t),o=J(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,attributes:P(e.props,t.tailwindClassesProperty),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=y(e);return r===void 0?Promise.resolve({nodes:[],stylesheets:[]}):l(r,t)}var te=8;async function re(e,t){let r=[],n=new Set,i=0;for(let a of e){let g=i;i+=1;let p=l(a,t).then(f=>{r[g]=f}).finally(()=>n.delete(p));n.add(p),n.size>=te&&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{v as defaultStylePresets,ue as fromJsx};
@@ -1,35 +1,33 @@
1
1
  import { CSSProperties } from 'react';
2
2
 
3
- type BaseNode = {
3
+ type NodeAttributes = Record<string, string>;
4
+ type NodeMetadata = {
4
5
  tagName?: string;
5
6
  className?: string;
6
7
  id?: string;
8
+ attributes?: NodeAttributes;
7
9
  tw?: string;
8
10
  style?: CSSProperties;
9
11
  preset?: CSSProperties;
10
12
  };
11
- type AnyNode = BaseNode & {
12
- type: string;
13
- [key: string]: unknown;
14
- };
15
13
  /**
16
14
  * @deprecated Use {import("csstype").Properties} or {import("react").CSSProperties} instead
17
15
  */
18
16
  type PartialStyle = CSSProperties;
19
- type Node = ContainerNode | TextNode | ImageNode | AnyNode;
20
- type ContainerNode = BaseNode & {
17
+ type Node = ContainerNode | TextNode | ImageNode;
18
+ type ContainerNode = NodeMetadata & {
21
19
  type: "container";
22
20
  children?: Node[];
23
21
  };
24
- type TextNode = BaseNode & {
22
+ type TextNode = NodeMetadata & {
25
23
  type: "text";
26
24
  text: string;
27
25
  };
28
- type ImageNode = BaseNode & {
26
+ type ImageNode = NodeMetadata & {
29
27
  type: "image";
30
28
  src: string;
31
29
  width?: number;
32
30
  height?: number;
33
31
  };
34
32
 
35
- export type { AnyNode as A, BaseNode as B, ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, TextNode as T };
33
+ export type { ContainerNode as C, ImageNode as I, NodeAttributes as N, PartialStyle as P, TextNode as T, NodeMetadata as a, Node as b };
@@ -1,35 +1,33 @@
1
1
  import { CSSProperties } from 'react';
2
2
 
3
- type BaseNode = {
3
+ type NodeAttributes = Record<string, string>;
4
+ type NodeMetadata = {
4
5
  tagName?: string;
5
6
  className?: string;
6
7
  id?: string;
8
+ attributes?: NodeAttributes;
7
9
  tw?: string;
8
10
  style?: CSSProperties;
9
11
  preset?: CSSProperties;
10
12
  };
11
- type AnyNode = BaseNode & {
12
- type: string;
13
- [key: string]: unknown;
14
- };
15
13
  /**
16
14
  * @deprecated Use {import("csstype").Properties} or {import("react").CSSProperties} instead
17
15
  */
18
16
  type PartialStyle = CSSProperties;
19
- type Node = ContainerNode | TextNode | ImageNode | AnyNode;
20
- type ContainerNode = BaseNode & {
17
+ type Node = ContainerNode | TextNode | ImageNode;
18
+ type ContainerNode = NodeMetadata & {
21
19
  type: "container";
22
20
  children?: Node[];
23
21
  };
24
- type TextNode = BaseNode & {
22
+ type TextNode = NodeMetadata & {
25
23
  type: "text";
26
24
  text: string;
27
25
  };
28
- type ImageNode = BaseNode & {
26
+ type ImageNode = NodeMetadata & {
29
27
  type: "image";
30
28
  src: string;
31
29
  width?: number;
32
30
  height?: number;
33
31
  };
34
32
 
35
- export type { AnyNode as A, BaseNode as B, ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, TextNode as T };
33
+ export type { ContainerNode as C, ImageNode as I, NodeAttributes as N, PartialStyle as P, TextNode as T, NodeMetadata as a, Node as b };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takumi-rs/helpers",
3
- "version": "0.72.0",
3
+ "version": "0.73.1",
4
4
  "author": {
5
5
  "email": "me@kane.tw",
6
6
  "name": "Kane Wang",