@takumi-rs/helpers 0.28.4 → 0.28.5

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 @@
1
- "use strict";var p=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var $=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},v=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of A(e))!T.call(t,i)&&i!==r&&p(t,i,{get:()=>e[i],enumerable:!(o=C(e,i))||o.enumerable});return t};var O=t=>v(p({},"__esModule",{value:!0}),t);var Z={};$(Z,{fromJsx:()=>Y});module.exports=O(Z);function l(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function s(t){let e={type:"container",children:t.children};return l(e,t.style),e}function h(t,e){let r={type:"text",text:t};return l(r,e),r}function f(t){let e={type:"image",src:t.src};return l(e,t.style),e}function u(t){return{percentage:t}}function n(t){return{em:t}}function S(t,e,r,o=1){return[t,e,r,o]}var m={p:{margin:[n(1),0]},blockquote:{margin:[n(1),40]},center:{textAlign:"center"},hr:{margin:[n(.5),"auto"],borderWidth:1},h1:{fontSize:n(2),margin:[n(.67),0],fontWeight:700},h2:{fontSize:n(1.5),margin:[n(.83),0],fontWeight:700},h3:{fontSize:n(1.17),margin:[n(1),0],fontWeight:700},h4:{margin:[n(1.33),0],fontWeight:700},h5:{fontSize:n(.83),margin:[n(1.67),0],fontWeight:700},h6:{fontSize:n(.67),margin:[n(2.33),0],fontWeight:700},strong:{fontWeight:700},b:{fontWeight:700},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{fontFamily:"monospace",margin:[n(1),0]},mark:{backgroundColor:S(255,255,0),color:0},big:{fontSize:n(1.2)},small:{fontSize:n(1/1.2)}};function y(t,e){return t.type===e}function R(t){return typeof t=="object"&&t!==null&&"type"in t&&typeof t.type=="string"}function E(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function I(t){return typeof t=="string"||typeof t=="number"}function b(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function j(t){return Object.keys(t).map(e=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(t[e]).trim()}`).join(";")}var z=["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 F(t,e){if(t==="children"||e==null)return;let r;if(t==="className"?r="class":z.includes(t)?r=E(t):r=t,typeof e=="boolean")return`${r}="${String(e)}"`;if(t==="style"&&typeof e=="object"){let o=j(e);if(o)return`style="${b(o)}"`}return`${r}="${b(String(e))}"`}function L(t){return Object.entries(t).map(([e,r])=>F(e,r)).filter(e=>e!==void 0)}var W=(t,e)=>{let r=t.props||{},o=L(r),i=r.children,d=Array.isArray(i)?i.map(x=>e(x)).join(""):e(i);return`<${t.type}${o.length>0?` ${o.join(" ")}`:""}>${d}</${t.type}>`},c=t=>t==null||t===!1?"":I(t)?String(t):Array.isArray(t)?t.map(c).join(""):R(t)?W(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)||""}var _=Symbol.for("react.transitional.element"),M=Symbol.for("react.element"),X=Symbol.for("react.forward_ref"),H=Symbol.for("react.memo");function J(t){return typeof t=="object"&&t!==null&&"$$typeof"in t&&(t.$$typeof===_||t.$$typeof===M)}async function Y(t){let e=await a(t);return e.length===0?s({}):e.length===1&&e[0]!==void 0?e[0]:s({children:e,style:{width:u(100),height:u(100)}})}async function a(t){if(t==null)return[];if(t instanceof Promise)return a(await t);if(typeof t=="object"&&Symbol.iterator in t)return q(t);if(J(t)){let e=await N(t);return Array.isArray(e)?e:e?[e]:[]}return[h(String(t))]}function k(t){return typeof t=="function"}function D(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof===X&&e.render)return a(e.render(t.props,null))}function B(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof!==H)return;let r=e.type;if(k(r))return a(r(t.props));let o={...t,type:r};return N(o)}async function N(t){if(k(t.type))return a(t.type(t.props));let e=D(t);if(e!==void 0)return e;let r=B(t);if(r!==void 0)return r;if(typeof t.type=="symbol"&&t.type===Symbol.for("react.fragment"))return await w(t)||[];if(y(t,"img"))return[K(t)];if(y(t,"svg"))return[V(t)];let o=await w(t),i=g(t.props);return typeof t.type=="string"&&t.type in m&&Object.assign(i,m[t.type]),[s({children:o,style:i})]}function K(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=g(t.props);return f({src:t.props.src,style:e})}function V(t){let e=g(t.props),r=P(t);return f({src:r,style:e})}function g(t){return typeof t!="object"||t===null?{}:"style"in t&&typeof t.style=="object"?t.style:{}}function w(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):a(t.props.children)}async function q(t){return(await Promise.all(Array.from(t).map(a))).flat()}0&&(module.exports={fromJsx});
1
+ "use strict";var p=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var A=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},$=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of L(e))!v.call(t,i)&&i!==r&&p(t,i,{get:()=>e[i],enumerable:!(o=C(e,i))||o.enumerable});return t};var O=t=>$(p({},"__esModule",{value:!0}),t);var V={};A(V,{fromJsx:()=>J});module.exports=O(V);function f(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function a(t){let e={type:"container",children:t.children};return f(e,t.style),e}function h(t,e){let r={type:"text",text:t};return f(r,e),r}function l(t){let e={type:"image",src:t.src};return f(e,t.style),e}function u(t){return{percentage:t}}function n(t){return{em:t}}function k(t,e,r,o=1){return[t,e,r,o]}var m={p:{margin:[n(1),0]},blockquote:{margin:[n(1),40]},center:{textAlign:"center"},hr:{margin:[n(.5),"auto"],borderWidth:1},h1:{fontSize:n(2),margin:[n(.67),0],fontWeight:700},h2:{fontSize:n(1.5),margin:[n(.83),0],fontWeight:700},h3:{fontSize:n(1.17),margin:[n(1),0],fontWeight:700},h4:{margin:[n(1.33),0],fontWeight:700},h5:{fontSize:n(.83),margin:[n(1.67),0],fontWeight:700},h6:{fontSize:n(.67),margin:[n(2.33),0],fontWeight:700},strong:{fontWeight:700},b:{fontWeight:700},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{fontFamily:"monospace",margin:[n(1),0]},mark:{backgroundColor:k(255,255,0),color:0},big:{fontSize:n(1.2)},small:{fontSize:n(1/1.2)}};function y(t,e){return t.type===e}function R(t){return typeof t=="object"&&t!==null&&"type"in t&&typeof t.type=="string"}function S(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function T(t){return typeof t=="string"||typeof t=="number"}function b(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function j(t){return Object.keys(t).map(e=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(t[e]).trim()}`).join(";")}var z=["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":z.includes(t)?r=S(t):r=t,typeof e=="boolean")return`${r}="${String(e)}"`;if(t==="style"&&typeof e=="object"){let o=j(e);if(o)return`style="${b(o)}"`}return`${r}="${b(String(e))}"`}function F(t){return Object.entries(t).map(([e,r])=>I(e,r)).filter(e=>e!==void 0)}var W=(t,e)=>{let r=t.props||{},o=F(r),i=r.children,d=Array.isArray(i)?i.map(N=>e(N)).join(""):e(i);return`<${t.type}${o.length>0?` ${o.join(" ")}`:""}>${d}</${t.type}>`},c=t=>t==null||t===!1?"":T(t)?String(t):Array.isArray(t)?t.map(c).join(""):R(t)?W(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)||""}var M=Symbol.for("react.forward_ref"),X=Symbol.for("react.memo");function H(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"type"in t}async function J(t){let e=await s(t);return e.length===0?a({}):e.length===1&&e[0]!==void 0?e[0]:a({children:e,style:{width:u(100),height:u(100)}})}async function s(t){if(t==null)return[];if(t instanceof Promise)return s(await t);if(typeof t=="object"&&Symbol.iterator in t)return B(t);if(H(t)){let e=await x(t);return Array.isArray(e)?e:e?[e]:[]}return[h(String(t))]}function w(t){return typeof t=="function"}function _(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof===M&&e.render)return s(e.render(t.props,null))}function K(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof!==X)return;let r=e.type;if(w(r))return s(r(t.props));let o={...t,type:r};return x(o)}async function x(t){if(w(t.type))return s(t.type(t.props));let e=_(t);if(e!==void 0)return e;let r=K(t);if(r!==void 0)return r;if(typeof t.type=="symbol"&&t.type===Symbol.for("react.fragment"))return await E(t)||[];if(y(t,"img"))return[D(t)];if(y(t,"svg"))return[Y(t)];let o=await E(t),i=g(t.props);return typeof t.type=="string"&&t.type in m&&Object.assign(i,m[t.type]),[a({children:o,style:i})]}function D(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=g(t.props);return l({src:t.props.src,style:e})}function Y(t){let e=g(t.props),r=P(t);return l({src:r,style:e})}function g(t){return typeof t!="object"||t===null?{}:"style"in t&&typeof t.style=="object"?t.style:{}}function E(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):s(t.props.children)}async function B(t){return(await Promise.all(Array.from(t).map(s))).flat()}0&&(module.exports={fromJsx});
@@ -1,6 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { N as Node } from '../types-8M7fRh4t.cjs';
3
3
 
4
- declare function fromJsx(element: ReactNode): Promise<Node>;
4
+ type ReactElementLike<K extends string = string, P = unknown> = {
5
+ type: K;
6
+ props: P;
7
+ };
8
+ declare function fromJsx(element: ReactNode | ReactElementLike): Promise<Node>;
5
9
 
6
- export { fromJsx };
10
+ export { type ReactElementLike, fromJsx };
package/dist/jsx/jsx.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { N as Node } from '../types-8M7fRh4t.js';
3
3
 
4
- declare function fromJsx(element: ReactNode): Promise<Node>;
4
+ type ReactElementLike<K extends string = string, P = unknown> = {
5
+ type: K;
6
+ props: P;
7
+ };
8
+ declare function fromJsx(element: ReactNode | ReactElementLike): Promise<Node>;
5
9
 
6
- export { fromJsx };
10
+ export { type ReactElementLike, fromJsx };
package/dist/jsx/jsx.js CHANGED
@@ -1 +1 @@
1
- function p(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function s(t){let e={type:"container",children:t.children};return p(e,t.style),e}function d(t,e){let r={type:"text",text:t};return p(r,e),r}function l(t){let e={type:"image",src:t.src};return p(e,t.style),e}function f(t){return{percentage:t}}function n(t){return{em:t}}function h(t,e,r,o=1){return[t,e,r,o]}var u={p:{margin:[n(1),0]},blockquote:{margin:[n(1),40]},center:{textAlign:"center"},hr:{margin:[n(.5),"auto"],borderWidth:1},h1:{fontSize:n(2),margin:[n(.67),0],fontWeight:700},h2:{fontSize:n(1.5),margin:[n(.83),0],fontWeight:700},h3:{fontSize:n(1.17),margin:[n(1),0],fontWeight:700},h4:{margin:[n(1.33),0],fontWeight:700},h5:{fontSize:n(.83),margin:[n(1.67),0],fontWeight:700},h6:{fontSize:n(.67),margin:[n(2.33),0],fontWeight:700},strong:{fontWeight:700},b:{fontWeight:700},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{fontFamily:"monospace",margin:[n(1),0]},mark:{backgroundColor:h(255,255,0),color:0},big:{fontSize:n(1.2)},small:{fontSize:n(1/1.2)}};function m(t,e){return t.type===e}function S(t){return typeof t=="object"&&t!==null&&"type"in t&&typeof t.type=="string"}function R(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function x(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 C(t){return Object.keys(t).map(e=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(t[e]).trim()}`).join(";")}var A=["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(t,e){if(t==="children"||e==null)return;let r;if(t==="className"?r="class":A.includes(t)?r=R(t):r=t,typeof e=="boolean")return`${r}="${String(e)}"`;if(t==="style"&&typeof e=="object"){let o=C(e);if(o)return`style="${E(o)}"`}return`${r}="${E(String(e))}"`}function $(t){return Object.entries(t).map(([e,r])=>T(e,r)).filter(e=>e!==void 0)}var v=(t,e)=>{let r=t.props||{},o=$(r),a=r.children,g=Array.isArray(a)?a.map(N=>e(N)).join(""):e(a);return`<${t.type}${o.length>0?` ${o.join(" ")}`:""}>${g}</${t.type}>`},c=t=>t==null||t===!1?"":x(t)?String(t):Array.isArray(t)?t.map(c).join(""):S(t)?v(t,c):"";function b(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)||""}var O=Symbol.for("react.transitional.element"),I=Symbol.for("react.element"),j=Symbol.for("react.forward_ref"),z=Symbol.for("react.memo");function F(t){return typeof t=="object"&&t!==null&&"$$typeof"in t&&(t.$$typeof===O||t.$$typeof===I)}async function U(t){let e=await i(t);return e.length===0?s({}):e.length===1&&e[0]!==void 0?e[0]:s({children:e,style:{width:f(100),height:f(100)}})}async function i(t){if(t==null)return[];if(t instanceof Promise)return i(await t);if(typeof t=="object"&&Symbol.iterator in t)return X(t);if(F(t)){let e=await k(t);return Array.isArray(e)?e:e?[e]:[]}return[d(String(t))]}function w(t){return typeof t=="function"}function L(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof===j&&e.render)return i(e.render(t.props,null))}function W(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof!==z)return;let r=e.type;if(w(r))return i(r(t.props));let o={...t,type:r};return k(o)}async function k(t){if(w(t.type))return i(t.type(t.props));let e=L(t);if(e!==void 0)return e;let r=W(t);if(r!==void 0)return r;if(typeof t.type=="symbol"&&t.type===Symbol.for("react.fragment"))return await P(t)||[];if(m(t,"img"))return[_(t)];if(m(t,"svg"))return[M(t)];let o=await P(t),a=y(t.props);return typeof t.type=="string"&&t.type in u&&Object.assign(a,u[t.type]),[s({children:o,style:a})]}function _(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=y(t.props);return l({src:t.props.src,style:e})}function M(t){let e=y(t.props),r=b(t);return l({src:r,style:e})}function y(t){return typeof t!="object"||t===null?{}:"style"in t&&typeof t.style=="object"?t.style:{}}function P(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):i(t.props.children)}async function X(t){return(await Promise.all(Array.from(t).map(i))).flat()}export{U as fromJsx};
1
+ function p(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function a(t){let e={type:"container",children:t.children};return p(e,t.style),e}function d(t,e){let r={type:"text",text:t};return p(r,e),r}function f(t){let e={type:"image",src:t.src};return p(e,t.style),e}function l(t){return{percentage:t}}function n(t){return{em:t}}function h(t,e,r,o=1){return[t,e,r,o]}var u={p:{margin:[n(1),0]},blockquote:{margin:[n(1),40]},center:{textAlign:"center"},hr:{margin:[n(.5),"auto"],borderWidth:1},h1:{fontSize:n(2),margin:[n(.67),0],fontWeight:700},h2:{fontSize:n(1.5),margin:[n(.83),0],fontWeight:700},h3:{fontSize:n(1.17),margin:[n(1),0],fontWeight:700},h4:{margin:[n(1.33),0],fontWeight:700},h5:{fontSize:n(.83),margin:[n(1.67),0],fontWeight:700},h6:{fontSize:n(.67),margin:[n(2.33),0],fontWeight:700},strong:{fontWeight:700},b:{fontWeight:700},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{fontFamily:"monospace",margin:[n(1),0]},mark:{backgroundColor:h(255,255,0),color:0},big:{fontSize:n(1.2)},small:{fontSize:n(1/1.2)}};function m(t,e){return t.type===e}function k(t){return typeof t=="object"&&t!==null&&"type"in t&&typeof t.type=="string"}function R(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function N(t){return typeof t=="string"||typeof t=="number"}function S(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function C(t){return Object.keys(t).map(e=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(t[e]).trim()}`).join(";")}var L=["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":L.includes(t)?r=R(t):r=t,typeof e=="boolean")return`${r}="${String(e)}"`;if(t==="style"&&typeof e=="object"){let o=C(e);if(o)return`style="${S(o)}"`}return`${r}="${S(String(e))}"`}function A(t){return Object.entries(t).map(([e,r])=>v(e,r)).filter(e=>e!==void 0)}var $=(t,e)=>{let r=t.props||{},o=A(r),s=r.children,g=Array.isArray(s)?s.map(x=>e(x)).join(""):e(s);return`<${t.type}${o.length>0?` ${o.join(" ")}`:""}>${g}</${t.type}>`},c=t=>t==null||t===!1?"":N(t)?String(t):Array.isArray(t)?t.map(c).join(""):k(t)?$(t,c):"";function b(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)||""}var O=Symbol.for("react.forward_ref"),T=Symbol.for("react.memo");function j(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"type"in t}async function Z(t){let e=await i(t);return e.length===0?a({}):e.length===1&&e[0]!==void 0?e[0]:a({children:e,style:{width:l(100),height:l(100)}})}async function i(t){if(t==null)return[];if(t instanceof Promise)return i(await t);if(typeof t=="object"&&Symbol.iterator in t)return M(t);if(j(t)){let e=await w(t);return Array.isArray(e)?e:e?[e]:[]}return[d(String(t))]}function E(t){return typeof t=="function"}function z(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof===O&&e.render)return i(e.render(t.props,null))}function I(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof!==T)return;let r=e.type;if(E(r))return i(r(t.props));let o={...t,type:r};return w(o)}async function w(t){if(E(t.type))return i(t.type(t.props));let e=z(t);if(e!==void 0)return e;let r=I(t);if(r!==void 0)return r;if(typeof t.type=="symbol"&&t.type===Symbol.for("react.fragment"))return await P(t)||[];if(m(t,"img"))return[F(t)];if(m(t,"svg"))return[W(t)];let o=await P(t),s=y(t.props);return typeof t.type=="string"&&t.type in u&&Object.assign(s,u[t.type]),[a({children:o,style:s})]}function F(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=y(t.props);return f({src:t.props.src,style:e})}function W(t){let e=y(t.props),r=b(t);return f({src:r,style:e})}function y(t){return typeof t!="object"||t===null?{}:"style"in t&&typeof t.style=="object"?t.style:{}}function P(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):i(t.props.children)}async function M(t){return(await Promise.all(Array.from(t).map(i))).flat()}export{Z as fromJsx};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takumi-rs/helpers",
3
- "version": "0.28.4",
3
+ "version": "0.28.5",
4
4
  "author": {
5
5
  "email": "me@kane.tw",
6
6
  "name": "Kane Wang",