@takumi-rs/helpers 0.43.0 → 0.43.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/jsx/jsx.cjs CHANGED
@@ -1 +1,2 @@
1
- "use strict";var m=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var A=(t,e)=>{for(var r in e)m(t,r,{get:e[r],enumerable:!0})},$=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of O(e))!F.call(t,o)&&o!==r&&m(t,o,{get:()=>e[o],enumerable:!(n=L(e,o))||n.enumerable});return t};var I=t=>$(m({},"__esModule",{value:!0}),t);var U={};A(U,{fromJsx:()=>D});module.exports=I(U);function u(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function l(t){let e={type:"container",children:t.children};return u(e,t.style),e}function y(t,e){let r={type:"text",text:t};return u(r,e),r}function g(t){let e={type:"image",src:t.src};return u(e,t.style),e}function d(t){return{percentage:t}}var f={p:{marginTop:"1em",marginBottom:"1em",display:"block"},blockquote:{marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40,display:"block"},center:{textAlign:"center",display:"inline"},hr:{marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1},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",marginTop:"1em",marginBottom:"1em",display:"inline"},mark:{backgroundColor:16776960,color:0,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"}};function R(t,e){return t.type===e&&"props"in t}function S(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function i(t){return typeof t=="object"&&t!==null&&"type"in t}function p(t){return typeof t=="function"}var W=Symbol.for("react.forward_ref"),j=Symbol.for("react.memo"),J=Symbol.for("react.fragment");function x(t){return t.$$typeof===W}function E(t){return t.$$typeof===j}function h(t){return t.type===J}function z(t){return typeof t=="string"||typeof t=="number"}function P(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function B(t){return Object.keys(t).map(e=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(t[e]).trim()}`).join(";")}var M=["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 _(t,e){if(t==="children"||e==null)return;let r;if(t==="className"?r="class":M.includes(t)?r=S(t):r=t,typeof e=="boolean")return`${r}="${String(e)}"`;if(t==="style"&&typeof e=="object"){let n=B(e);if(n)return`style="${P(n)}"`}return`${r}="${P(String(e))}"`}function H(t){return Object.entries(t).map(([e,r])=>_(e,r)).filter(e=>e!==void 0)}var X=(t,e)=>{let r=t.props||{};if(p(t.type))return c(t.type(t.props));if(typeof t.type=="symbol"||typeof t.type!="string")return"";let n=H(r),o=r.children,a=Array.isArray(o)?o.map(b=>e(b)).join(""):e(o);return`<${t.type}${n.length>0?` ${n.join(" ")}`:""}>${a}</${t.type}>`},c=t=>t==null||t===!1?"":z(t)?String(t):Array.isArray(t)?t.map(c).join(""):i(t)?X(t,c):"";function w(t){let e=t.props||{};if(!("xmlns"in e)){let r={...t,props:{...e,xmlns:"http://www.w3.org/2000/svg"}};return c(r)||""}return c(t)||""}async function D(t,e){let r=await s(t,e??{});return r.length===0?l({}):r.length===1&&r[0]!==void 0?r[0]:l({children:r,style:{width:d(100),height:d(100)}})}async function s(t,e){if(t==null||t===!1)return[];if(t instanceof Promise)return s(await t,e);if(typeof t=="object"&&Symbol.iterator in t)return G(t,e);if(i(t)){let r=await v(t,e);return Array.isArray(r)?r:r?[r]:[]}return[y(String(t),f.span)]}function V(t,e){if(!(typeof t.type!="object"||t.type===null)){if(x(t.type)&&"render"in t.type){let r=t.type;return s(r.render(t.props,null),e)}if(E(t.type)&&"type"in t.type){let n=t.type.type;if(p(n))return s(n(t.props),e);let o={...t,type:n};return v(o,e)}}}function N(t){if(!i(t))return Promise.resolve(void 0);let e=typeof t.props=="object"&&t.props!==null&&"children"in t.props?t.props.children:void 0;return typeof e=="string"?Promise.resolve(e):typeof e=="number"?Promise.resolve(String(e)):Array.isArray(e)?Promise.resolve(T(e)):typeof e=="object"&&e!==null&&Symbol.iterator in e?Promise.resolve(T(Array.from(e))):i(e)&&h(e)?N(e):Promise.resolve(void 0)}function T(t){if(!t.some(e=>i(e)))return t.map(e=>typeof e=="string"?e:typeof e=="number"?String(e):"").join("")}async function v(t,e){if(p(t.type))return s(t.type(t.props),e);let r=V(t,e);if(r!==void 0)return r;if(h(t))return await C(t,e)||[];if(R(t,"img"))return[Y(t,e)];if(R(t,"svg"))return[K(t,e)];let n=k(t,e),o=await N(t);if(o!==void 0)return[y(o,n)];let a=await C(t,e);return[l({children:a,style:n})]}function Y(t,e){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let r=k(t,e);return g({src:t.props.src,style:r})}function K(t,e){let r=k(t,e),n=w(t);return g({style:r,src:n})}var q={WebkitTextStroke:"textStroke",WebkitTextStrokeWidth:"textStrokeWidth",WebkitTextStrokeColor:"textStrokeColor"};function Z(t,e,r){if(!r.tailwindFn||typeof t.props!="object"||t.props===null)return;let n=[];"tw"in t.props&&typeof t.props.tw=="string"&&n.push(t.props.tw),"className"in t.props&&typeof t.props.className=="string"&&n.push(t.props.className),"class"in t.props&&typeof t.props.class=="string"&&n.push(t.props.class),Object.assign(e,r.tailwindFn(...n))}function k(t,e){let r={};typeof t.type=="string"&&t.type in f&&Object.assign(r,f[t.type]),Z(t,r,e);let n=typeof t.props=="object"&&t.props!==null&&"style"in t.props&&typeof t.props.style=="object"&&t.props.style!==null?t.props.style:void 0;if(n&&Object.keys(n).length>0){for(let[o,a]of Object.entries(q))o in n&&(r[a]=n[o],delete n[o]);Object.assign(r,n)}return r}function C(t,e){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):s(t.props.children,e)}function G(t,e){return Promise.all(Array.from(t).map(r=>s(r,e))).then(r=>r.flat())}0&&(module.exports={fromJsx});
1
+ "use strict";var y=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var $=(t,e)=>{for(var r in e)y(t,r,{get:e[r],enumerable:!0})},I=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of F(e))!A.call(t,o)&&o!==r&&y(t,o,{get:()=>e[o],enumerable:!(n=O(e,o))||n.enumerable});return t};var W=t=>I(y({},"__esModule",{value:!0}),t);var tt={};$(tt,{fromJsx:()=>Y});module.exports=W(tt);function g(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function f(t){let e={type:"container",children:t.children};return g(e,t.style),e}function m(t,e){let r={type:"text",text:t};return g(r,e),r}function d(t){let e={type:"image",src:t.src};return g(e,t.style),e}function k(t){return{percentage:t}}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:0,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 j=new Set(["head","meta","link","style","script"]);function S(t){return j.has(t.type)}function u(t,e){return t.type===e&&"props"in t}function x(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function i(t){return typeof t=="object"&&t!==null&&"type"in t}function c(t){return typeof t=="function"}var J=Symbol.for("react.forward_ref"),z=Symbol.for("react.memo"),B=Symbol.for("react.fragment");function E(t){return t.$$typeof===J}function P(t){return t.$$typeof===z}function R(t){return t.type===B}function M(t){return typeof t=="string"||typeof t=="number"}function w(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function H(t){return Object.keys(t).map(e=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(t[e]).trim()}`).join(";")}var _=["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 V(t,e){if(t==="children"||e==null)return;let r;if(t==="className"?r="class":_.includes(t)?r=x(t):r=t,typeof e=="boolean")return`${r}="${String(e)}"`;if(t==="style"&&typeof e=="object"){let n=H(e);if(n)return`style="${w(n)}"`}return`${r}="${w(String(e))}"`}function X(t){return Object.entries(t).map(([e,r])=>V(e,r)).filter(e=>e!==void 0)}var D=(t,e)=>{let r=t.props||{};if(c(t.type))return l(t.type(t.props));if(typeof t.type=="symbol"||typeof t.type!="string")return"";let n=X(r),o=r.children,a=Array.isArray(o)?o.map(b=>e(b)).join(""):e(o);return`<${t.type}${n.length>0?` ${n.join(" ")}`:""}>${a}</${t.type}>`},l=t=>t==null||t===!1?"":M(t)?String(t):Array.isArray(t)?t.map(l).join(""):i(t)?D(t,l):"";function T(t){let e=t.props||{};if(!("xmlns"in e)){let r={...t,props:{...e,xmlns:"http://www.w3.org/2000/svg"}};return l(r)||""}return l(t)||""}async function Y(t,e){let r=await s(t,e??{});return r.length===0?f({}):r.length===1&&r[0]!==void 0?r[0]:f({children:r,style:{width:k(100),height:k(100)}})}async function s(t,e){if(t==null||t===!1)return[];if(t instanceof Promise)return s(await t,e);if(typeof t=="object"&&Symbol.iterator in t)return Q(t,e);if(i(t)){let r=await L(t,e);return Array.isArray(r)?r:r?[r]:[]}return[m(String(t),p.span)]}function K(t,e){if(!(typeof t.type!="object"||t.type===null)){if(E(t.type)&&"render"in t.type){let r=t.type;return s(r.render(t.props,null),e)}if(P(t.type)&&"type"in t.type){let n=t.type.type;if(c(n))return s(n(t.props),e);let o={...t,type:n};return L(o,e)}}}function v(t){if(!i(t))return Promise.resolve(void 0);let e=typeof t.props=="object"&&t.props!==null&&"children"in t.props?t.props.children:void 0;return typeof e=="string"?Promise.resolve(e):typeof e=="number"?Promise.resolve(String(e)):Array.isArray(e)?Promise.resolve(C(e)):typeof e=="object"&&e!==null&&Symbol.iterator in e?Promise.resolve(C(Array.from(e))):i(e)&&R(e)?v(e):Promise.resolve(void 0)}function C(t){if(!t.some(e=>i(e)))return t.map(e=>typeof e=="string"?e:typeof e=="number"?String(e):"").join("")}async function L(t,e){if(c(t.type))return s(t.type(t.props),e);let r=K(t,e);if(r!==void 0)return r;if(R(t))return await N(t,e)||[];if(S(t))return[];if(u(t,"br"))return[m(`
2
+ `,p.span)];if(u(t,"img"))return[q(t,e)];if(u(t,"svg"))return[Z(t,e)];let n=h(t,e),o=await v(t);if(o!==void 0)return[m(o,n)];let a=await N(t,e);return[f({children:a,style:n})]}function q(t,e){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let r=h(t,e);return d({src:t.props.src,style:r})}function Z(t,e){let r=h(t,e),n=T(t);return d({style:r,src:n})}var G={WebkitTextStroke:"textStroke",WebkitTextStrokeWidth:"textStrokeWidth",WebkitTextStrokeColor:"textStrokeColor"};function U(t,e,r){if(!r.tailwindFn||typeof t.props!="object"||t.props===null)return;let n=[];"tw"in t.props&&typeof t.props.tw=="string"&&n.push(t.props.tw),"className"in t.props&&typeof t.props.className=="string"&&n.push(t.props.className),"class"in t.props&&typeof t.props.class=="string"&&n.push(t.props.class),Object.assign(e,r.tailwindFn(...n))}function h(t,e){let r={};typeof t.type=="string"&&t.type in p&&Object.assign(r,p[t.type]),U(t,r,e);let n=typeof t.props=="object"&&t.props!==null&&"style"in t.props&&typeof t.props.style=="object"&&t.props.style!==null?t.props.style:void 0;if(n&&Object.keys(n).length>0){for(let[o,a]of Object.entries(G))o in n&&(r[a]=n[o],delete n[o]);Object.assign(r,n)}return r}function N(t,e){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):s(t.props.children,e)}function Q(t,e){return Promise.all(Array.from(t).map(r=>s(r,e))).then(r=>r.flat())}0&&(module.exports={fromJsx});
package/dist/jsx/jsx.js CHANGED
@@ -1 +1,2 @@
1
- function m(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function l(t){let e={type:"container",children:t.children};return m(e,t.style),e}function u(t,e){let r={type:"text",text:t};return m(r,e),r}function y(t){let e={type:"image",src:t.src};return m(e,t.style),e}function g(t){return{percentage:t}}var f={p:{marginTop:"1em",marginBottom:"1em",display:"block"},blockquote:{marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40,display:"block"},center:{textAlign:"center",display:"inline"},hr:{marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1},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",marginTop:"1em",marginBottom:"1em",display:"inline"},mark:{backgroundColor:16776960,color:0,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"}};function d(t,e){return t.type===e&&"props"in t}function b(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function i(t){return typeof t=="object"&&t!==null&&"type"in t}function p(t){return typeof t=="function"}var v=Symbol.for("react.forward_ref"),L=Symbol.for("react.memo"),O=Symbol.for("react.fragment");function S(t){return t.$$typeof===v}function x(t){return t.$$typeof===L}function R(t){return t.type===O}function F(t){return typeof t=="string"||typeof t=="number"}function E(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function A(t){return Object.keys(t).map(e=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(t[e]).trim()}`).join(";")}var $=["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 I(t,e){if(t==="children"||e==null)return;let r;if(t==="className"?r="class":$.includes(t)?r=b(t):r=t,typeof e=="boolean")return`${r}="${String(e)}"`;if(t==="style"&&typeof e=="object"){let n=A(e);if(n)return`style="${E(n)}"`}return`${r}="${E(String(e))}"`}function W(t){return Object.entries(t).map(([e,r])=>I(e,r)).filter(e=>e!==void 0)}var j=(t,e)=>{let r=t.props||{};if(p(t.type))return c(t.type(t.props));if(typeof t.type=="symbol"||typeof t.type!="string")return"";let n=W(r),o=r.children,a=Array.isArray(o)?o.map(k=>e(k)).join(""):e(o);return`<${t.type}${n.length>0?` ${n.join(" ")}`:""}>${a}</${t.type}>`},c=t=>t==null||t===!1?"":F(t)?String(t):Array.isArray(t)?t.map(c).join(""):i(t)?j(t,c):"";function P(t){let e=t.props||{};if(!("xmlns"in e)){let r={...t,props:{...e,xmlns:"http://www.w3.org/2000/svg"}};return c(r)||""}return c(t)||""}async function Q(t,e){let r=await s(t,e??{});return r.length===0?l({}):r.length===1&&r[0]!==void 0?r[0]:l({children:r,style:{width:g(100),height:g(100)}})}async function s(t,e){if(t==null||t===!1)return[];if(t instanceof Promise)return s(await t,e);if(typeof t=="object"&&Symbol.iterator in t)return H(t,e);if(i(t)){let r=await N(t,e);return Array.isArray(r)?r:r?[r]:[]}return[u(String(t),f.span)]}function J(t,e){if(!(typeof t.type!="object"||t.type===null)){if(S(t.type)&&"render"in t.type){let r=t.type;return s(r.render(t.props,null),e)}if(x(t.type)&&"type"in t.type){let n=t.type.type;if(p(n))return s(n(t.props),e);let o={...t,type:n};return N(o,e)}}}function C(t){if(!i(t))return Promise.resolve(void 0);let e=typeof t.props=="object"&&t.props!==null&&"children"in t.props?t.props.children:void 0;return typeof e=="string"?Promise.resolve(e):typeof e=="number"?Promise.resolve(String(e)):Array.isArray(e)?Promise.resolve(w(e)):typeof e=="object"&&e!==null&&Symbol.iterator in e?Promise.resolve(w(Array.from(e))):i(e)&&R(e)?C(e):Promise.resolve(void 0)}function w(t){if(!t.some(e=>i(e)))return t.map(e=>typeof e=="string"?e:typeof e=="number"?String(e):"").join("")}async function N(t,e){if(p(t.type))return s(t.type(t.props),e);let r=J(t,e);if(r!==void 0)return r;if(R(t))return await T(t,e)||[];if(d(t,"img"))return[z(t,e)];if(d(t,"svg"))return[B(t,e)];let n=h(t,e),o=await C(t);if(o!==void 0)return[u(o,n)];let a=await T(t,e);return[l({children:a,style:n})]}function z(t,e){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let r=h(t,e);return y({src:t.props.src,style:r})}function B(t,e){let r=h(t,e),n=P(t);return y({style:r,src:n})}var M={WebkitTextStroke:"textStroke",WebkitTextStrokeWidth:"textStrokeWidth",WebkitTextStrokeColor:"textStrokeColor"};function _(t,e,r){if(!r.tailwindFn||typeof t.props!="object"||t.props===null)return;let n=[];"tw"in t.props&&typeof t.props.tw=="string"&&n.push(t.props.tw),"className"in t.props&&typeof t.props.className=="string"&&n.push(t.props.className),"class"in t.props&&typeof t.props.class=="string"&&n.push(t.props.class),Object.assign(e,r.tailwindFn(...n))}function h(t,e){let r={};typeof t.type=="string"&&t.type in f&&Object.assign(r,f[t.type]),_(t,r,e);let n=typeof t.props=="object"&&t.props!==null&&"style"in t.props&&typeof t.props.style=="object"&&t.props.style!==null?t.props.style:void 0;if(n&&Object.keys(n).length>0){for(let[o,a]of Object.entries(M))o in n&&(r[a]=n[o],delete n[o]);Object.assign(r,n)}return r}function T(t,e){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):s(t.props.children,e)}function H(t,e){return Promise.all(Array.from(t).map(r=>s(r,e))).then(r=>r.flat())}export{Q as fromJsx};
1
+ function y(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function f(t){let e={type:"container",children:t.children};return y(e,t.style),e}function m(t,e){let r={type:"text",text:t};return y(r,e),r}function g(t){let e={type:"image",src:t.src};return y(e,t.style),e}function d(t){return{percentage:t}}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:0,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 L=new Set(["head","meta","link","style","script"]);function b(t){return L.has(t.type)}function u(t,e){return t.type===e&&"props"in t}function S(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function i(t){return typeof t=="object"&&t!==null&&"type"in t}function c(t){return typeof t=="function"}var O=Symbol.for("react.forward_ref"),F=Symbol.for("react.memo"),A=Symbol.for("react.fragment");function x(t){return t.$$typeof===O}function E(t){return t.$$typeof===F}function k(t){return t.type===A}function $(t){return typeof t=="string"||typeof t=="number"}function P(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function I(t){return Object.keys(t).map(e=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(t[e]).trim()}`).join(";")}var W=["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 j(t,e){if(t==="children"||e==null)return;let r;if(t==="className"?r="class":W.includes(t)?r=S(t):r=t,typeof e=="boolean")return`${r}="${String(e)}"`;if(t==="style"&&typeof e=="object"){let n=I(e);if(n)return`style="${P(n)}"`}return`${r}="${P(String(e))}"`}function J(t){return Object.entries(t).map(([e,r])=>j(e,r)).filter(e=>e!==void 0)}var z=(t,e)=>{let r=t.props||{};if(c(t.type))return l(t.type(t.props));if(typeof t.type=="symbol"||typeof t.type!="string")return"";let n=J(r),o=r.children,a=Array.isArray(o)?o.map(h=>e(h)).join(""):e(o);return`<${t.type}${n.length>0?` ${n.join(" ")}`:""}>${a}</${t.type}>`},l=t=>t==null||t===!1?"":$(t)?String(t):Array.isArray(t)?t.map(l).join(""):i(t)?z(t,l):"";function w(t){let e=t.props||{};if(!("xmlns"in e)){let r={...t,props:{...e,xmlns:"http://www.w3.org/2000/svg"}};return l(r)||""}return l(t)||""}async function et(t,e){let r=await s(t,e??{});return r.length===0?f({}):r.length===1&&r[0]!==void 0?r[0]:f({children:r,style:{width:d(100),height:d(100)}})}async function s(t,e){if(t==null||t===!1)return[];if(t instanceof Promise)return s(await t,e);if(typeof t=="object"&&Symbol.iterator in t)return X(t,e);if(i(t)){let r=await v(t,e);return Array.isArray(r)?r:r?[r]:[]}return[m(String(t),p.span)]}function B(t,e){if(!(typeof t.type!="object"||t.type===null)){if(x(t.type)&&"render"in t.type){let r=t.type;return s(r.render(t.props,null),e)}if(E(t.type)&&"type"in t.type){let n=t.type.type;if(c(n))return s(n(t.props),e);let o={...t,type:n};return v(o,e)}}}function N(t){if(!i(t))return Promise.resolve(void 0);let e=typeof t.props=="object"&&t.props!==null&&"children"in t.props?t.props.children:void 0;return typeof e=="string"?Promise.resolve(e):typeof e=="number"?Promise.resolve(String(e)):Array.isArray(e)?Promise.resolve(T(e)):typeof e=="object"&&e!==null&&Symbol.iterator in e?Promise.resolve(T(Array.from(e))):i(e)&&k(e)?N(e):Promise.resolve(void 0)}function T(t){if(!t.some(e=>i(e)))return t.map(e=>typeof e=="string"?e:typeof e=="number"?String(e):"").join("")}async function v(t,e){if(c(t.type))return s(t.type(t.props),e);let r=B(t,e);if(r!==void 0)return r;if(k(t))return await C(t,e)||[];if(b(t))return[];if(u(t,"br"))return[m(`
2
+ `,p.span)];if(u(t,"img"))return[M(t,e)];if(u(t,"svg"))return[H(t,e)];let n=R(t,e),o=await N(t);if(o!==void 0)return[m(o,n)];let a=await C(t,e);return[f({children:a,style:n})]}function M(t,e){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let r=R(t,e);return g({src:t.props.src,style:r})}function H(t,e){let r=R(t,e),n=w(t);return g({style:r,src:n})}var _={WebkitTextStroke:"textStroke",WebkitTextStrokeWidth:"textStrokeWidth",WebkitTextStrokeColor:"textStrokeColor"};function V(t,e,r){if(!r.tailwindFn||typeof t.props!="object"||t.props===null)return;let n=[];"tw"in t.props&&typeof t.props.tw=="string"&&n.push(t.props.tw),"className"in t.props&&typeof t.props.className=="string"&&n.push(t.props.className),"class"in t.props&&typeof t.props.class=="string"&&n.push(t.props.class),Object.assign(e,r.tailwindFn(...n))}function R(t,e){let r={};typeof t.type=="string"&&t.type in p&&Object.assign(r,p[t.type]),V(t,r,e);let n=typeof t.props=="object"&&t.props!==null&&"style"in t.props&&typeof t.props.style=="object"&&t.props.style!==null?t.props.style:void 0;if(n&&Object.keys(n).length>0){for(let[o,a]of Object.entries(_))o in n&&(r[a]=n[o],delete n[o]);Object.assign(r,n)}return r}function C(t,e){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):s(t.props.children,e)}function X(t,e){return Promise.all(Array.from(t).map(r=>s(r,e))).then(r=>r.flat())}export{et as fromJsx};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takumi-rs/helpers",
3
- "version": "0.43.0",
3
+ "version": "0.43.1",
4
4
  "author": {
5
5
  "email": "me@kane.tw",
6
6
  "name": "Kane Wang",