@takumi-rs/helpers 0.52.2 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +13 -29
- package/dist/index.d.ts +13 -29
- package/dist/index.js +1 -1
- package/dist/jsx/jsx.cjs +2 -2
- package/dist/jsx/jsx.d.cts +1 -1
- package/dist/jsx/jsx.d.ts +1 -1
- package/dist/jsx/jsx.js +2 -2
- package/dist/types-D4Tf1iTw.d.cts +35 -0
- package/dist/types-D4Tf1iTw.d.ts +35 -0
- package/package.json +1 -1
- package/dist/types-Dm5SijB6.d.cts +0 -985
- package/dist/types-Dm5SijB6.d.ts +0 -985
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var d=(e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},s=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of x(t))!m.call(e,o)&&o!==n&&u(e,o,{get:()=>t[o],enumerable:!(r=c(t,o))||r.enumerable});return e};var a=e=>s(u({},"__esModule",{value:!0}),e);var l={};d(l,{container:()=>f,em:()=>S,fr:()=>$,image:()=>p,percentage:()=>g,rem:()=>w,rgba:()=>C,style:()=>N,text:()=>y,vh:()=>h,vw:()=>b});module.exports=a(l);function i(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function f(e){let t={type:"container",children:e.children,tw:e.tw};return i(t,e.style),t}function y(e,t){if(typeof e=="string"){let r={type:"text",text:e};return i(r,t),r}let n={type:"text",text:e.text,tw:e.tw};return i(n,t??e.style),n}function p(e){let t={type:"image",src:e.src,width:e.width,height:e.height,tw:e.tw};return i(t,e.style),t}function N(e){return e}function g(e){return`${e}%`}function b(e){return`${e}vw`}function h(e){return`${e}vh`}function S(e){return`${e}em`}function w(e){return`${e}rem`}function $(e){return`${e}fr`}function C(e,t,n,r=1){return`rgb(${e} ${t} ${n} / ${r})`}0&&(module.exports={container,em,fr,image,percentage,rem,rgba,style,text,vh,vw});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,34 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { C as ContainerNode, T as TextNode, I as ImageNode } from './types-D4Tf1iTw.cjs';
|
|
3
|
+
export { A as AnyNode, N as Node, P as PartialStyle } from './types-D4Tf1iTw.cjs';
|
|
3
4
|
|
|
4
5
|
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
5
|
-
declare function text(text: string, style?:
|
|
6
|
+
declare function text(text: string, style?: CSSProperties): TextNode;
|
|
6
7
|
declare function text(props: Omit<TextNode, "type">): TextNode;
|
|
7
8
|
declare function image(props: Omit<ImageNode, "type">): ImageNode;
|
|
8
|
-
declare function style(style:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
declare function
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
declare function vw(vw: number): {
|
|
18
|
-
vw: number;
|
|
19
|
-
};
|
|
20
|
-
declare function vh(vh: number): {
|
|
21
|
-
vh: number;
|
|
22
|
-
};
|
|
23
|
-
declare function em(em: number): {
|
|
24
|
-
em: number;
|
|
25
|
-
};
|
|
26
|
-
declare function rem(rem: number): {
|
|
27
|
-
rem: number;
|
|
28
|
-
};
|
|
29
|
-
declare function fr(fr: number): {
|
|
30
|
-
fr: number;
|
|
31
|
-
};
|
|
32
|
-
declare function rgba(r: number, g: number, b: number, a?: number): ColorInput;
|
|
9
|
+
declare function style(style: CSSProperties): CSSProperties;
|
|
10
|
+
declare function percentage(percentage: number): `${number}%`;
|
|
11
|
+
declare function vw(vw: number): `${number}vw`;
|
|
12
|
+
declare function vh(vh: number): `${number}vh`;
|
|
13
|
+
declare function em(em: number): `${number}em`;
|
|
14
|
+
declare function rem(rem: number): `${number}rem`;
|
|
15
|
+
declare function fr(fr: number): `${number}fr`;
|
|
16
|
+
declare function rgba(r: number, g: number, b: number, a?: number): `rgb(${number} ${number} ${number} / ${number})`;
|
|
33
17
|
|
|
34
|
-
export { ContainerNode, ImageNode,
|
|
18
|
+
export { ContainerNode, ImageNode, TextNode, container, em, fr, image, percentage, rem, rgba, style, text, vh, vw };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,34 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { C as ContainerNode, T as TextNode, I as ImageNode } from './types-D4Tf1iTw.js';
|
|
3
|
+
export { A as AnyNode, N as Node, P as PartialStyle } from './types-D4Tf1iTw.js';
|
|
3
4
|
|
|
4
5
|
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
5
|
-
declare function text(text: string, style?:
|
|
6
|
+
declare function text(text: string, style?: CSSProperties): TextNode;
|
|
6
7
|
declare function text(props: Omit<TextNode, "type">): TextNode;
|
|
7
8
|
declare function image(props: Omit<ImageNode, "type">): ImageNode;
|
|
8
|
-
declare function style(style:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
declare function
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
declare function vw(vw: number): {
|
|
18
|
-
vw: number;
|
|
19
|
-
};
|
|
20
|
-
declare function vh(vh: number): {
|
|
21
|
-
vh: number;
|
|
22
|
-
};
|
|
23
|
-
declare function em(em: number): {
|
|
24
|
-
em: number;
|
|
25
|
-
};
|
|
26
|
-
declare function rem(rem: number): {
|
|
27
|
-
rem: number;
|
|
28
|
-
};
|
|
29
|
-
declare function fr(fr: number): {
|
|
30
|
-
fr: number;
|
|
31
|
-
};
|
|
32
|
-
declare function rgba(r: number, g: number, b: number, a?: number): ColorInput;
|
|
9
|
+
declare function style(style: CSSProperties): CSSProperties;
|
|
10
|
+
declare function percentage(percentage: number): `${number}%`;
|
|
11
|
+
declare function vw(vw: number): `${number}vw`;
|
|
12
|
+
declare function vh(vh: number): `${number}vh`;
|
|
13
|
+
declare function em(em: number): `${number}em`;
|
|
14
|
+
declare function rem(rem: number): `${number}rem`;
|
|
15
|
+
declare function fr(fr: number): `${number}fr`;
|
|
16
|
+
declare function rgba(r: number, g: number, b: number, a?: number): `rgb(${number} ${number} ${number} / ${number})`;
|
|
33
17
|
|
|
34
|
-
export { ContainerNode, ImageNode,
|
|
18
|
+
export { ContainerNode, ImageNode, TextNode, container, em, fr, image, percentage, rem, rgba, style, text, vh, vw };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function o(t
|
|
1
|
+
function o(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function i(e){let t={type:"container",children:e.children,tw:e.tw};return o(t,e.style),t}function u(e,t){if(typeof e=="string"){let r={type:"text",text:e};return o(r,t),r}let n={type:"text",text:e.text,tw:e.tw};return o(n,t??e.style),n}function c(e){let t={type:"image",src:e.src,width:e.width,height:e.height,tw:e.tw};return o(t,e.style),t}function x(e){return e}function m(e){return`${e}%`}function d(e){return`${e}vw`}function s(e){return`${e}vh`}function a(e){return`${e}em`}function f(e){return`${e}rem`}function y(e){return`${e}fr`}function p(e,t,n,r=1){return`rgb(${e} ${t} ${n} / ${r})`}export{i as container,a as em,y as fr,c as image,m as percentage,f as rem,p as rgba,x as style,u as text,s as vh,d as vw};
|
package/dist/jsx/jsx.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`,a.span)];if(u(t,"img"))return[Z(t)];if(u(t,"svg"))return[G(t)];let n=
|
|
1
|
+
"use strict";var d=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var F=(t,e)=>{for(var n in e)d(t,n,{get:e[n],enumerable:!0})},j=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of O(e))!z.call(t,o)&&o!==n&&d(t,o,{get:()=>e[o],enumerable:!(r=$(e,o))||r.enumerable});return t};var I=t=>j(d({},"__esModule",{value:!0}),t);var Q={};F(Q,{fromJsx:()=>K});module.exports=I(Q);function l(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function f(t){let e={type:"container",children:t.children,tw:t.tw};return l(e,t.style),e}function m(t,e){if(typeof t=="string"){let r={type:"text",text:t};return l(r,e),r}let n={type:"text",text:t.text,tw:t.tw};return l(n,e??t.style),n}function y(t){let e={type:"image",src:t.src,width:t.width,height:t.height,tw:t.tw};return l(e,t.style),e}function h(t){return`${t}%`}var a={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 S(t){return W.has(t.type)}function u(t,e){return t.type===e&&"props"in t}function E(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 B=Symbol.for("react.forward_ref"),M=Symbol.for("react.memo"),H=Symbol.for("react.fragment");function w(t){return t.$$typeof===B}function P(t){return t.$$typeof===M}function R(t){return t.type===H}function _(t){return typeof t=="string"||typeof t=="number"}function T(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function D(t){return Object.keys(t).map(e=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(t[e]).trim()}`).join(";")}var V=["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 X(t,e){if(t==="children"||e==null)return;let n;if(t==="className"?n="class":V.includes(t)?n=E(t):n=t,typeof e=="boolean")return`${n}="${String(e)}"`;if(t==="style"&&typeof e=="object"){let r=D(e);if(r)return`style="${T(r)}"`}return`${n}="${T(String(e))}"`}function J(t){return Object.entries(t).map(([e,n])=>X(e,n)).filter(e=>e!==void 0)}var Y=(t,e)=>{let n=t.props||{};if(p(t.type))return c(t.type(t.props));if(typeof t.type=="symbol"||typeof t.type!="string")return"";let r=J(n),o=n.children,g=Array.isArray(o)?o.map(x=>e(x)).join(""):e(o);return`<${t.type}${r.length>0?` ${r.join(" ")}`:""}>${g}</${t.type}>`},c=t=>t==null||t===!1?"":_(t)?String(t):Array.isArray(t)?t.map(c).join(""):i(t)?Y(t,c):"";function C(t){let e=t.props||{};if(!("xmlns"in e)){let n={...t,props:{...e,xmlns:"http://www.w3.org/2000/svg"}};return c(n)||""}return c(t)||""}async function K(t){let e=await s(t);return e.length===0?f({}):e.length===1&&e[0]!==void 0?e[0]:f({children:e,style:{width:h(100),height:h(100)}})}async function s(t){if(t==null||t===!1)return[];if(t instanceof Promise)return s(await t);if(typeof t=="object"&&Symbol.iterator in t)return U(t);if(i(t)){let e=await A(t);return Array.isArray(e)?e:e?[e]:[]}return[m(String(t),a.span)]}function q(t){if(!(typeof t.type!="object"||t.type===null)){if(w(t.type)&&"render"in t.type){let e=t.type;return s(e.render(t.props,null))}if(P(t.type)&&"type"in t.type){let n=t.type.type;if(p(n))return s(n(t.props));let r={...t,type:n};return A(r)}}}function L(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(N(e)):typeof e=="object"&&e!==null&&Symbol.iterator in e?Promise.resolve(N(Array.from(e))):i(e)&&R(e)?L(e):Promise.resolve(void 0)}function N(t){if(!t.some(e=>i(e)))return t.map(e=>typeof e=="string"?e:typeof e=="number"?String(e):"").join("")}async function A(t){if(p(t.type))return s(t.type(t.props));let e=q(t);if(e!==void 0)return e;if(R(t))return await v(t)||[];if(S(t))return[];if(u(t,"br"))return[m(`
|
|
2
|
+
`,a.span)];if(u(t,"img"))return[Z(t)];if(u(t,"svg"))return[G(t)];let n=b(t),r=k(t),o=await L(t);if(o!==void 0)return[m({text:o,style:n,tw:r})];let g=await v(t);return[f({children:g,style:n,tw:r})]}function Z(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=b(t),n=k(t);return y({src:t.props.src,style:e,tw:n})}function G(t){let e=b(t),n=k(t),r=C(t);return y({style:e,src:r,tw:n})}function b(t){let e={};typeof t.type=="string"&&t.type in a&&Object.assign(e,a[t.type]);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;return n&&Object.keys(n).length>0&&Object.assign(e,n),e}function k(t){if(!(typeof t.props!="object"||t.props===null||!("tw"in t.props)))return t.props.tw}function v(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):s(t.props.children)}function U(t){return Promise.all(Array.from(t).map(e=>s(e))).then(e=>e.flat())}0&&(module.exports={fromJsx});
|
package/dist/jsx/jsx.d.cts
CHANGED
package/dist/jsx/jsx.d.ts
CHANGED
package/dist/jsx/jsx.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function l(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function f(t){let e={type:"container",children:t.children,tw:t.tw};return l(e,t.style),e}function m(t,e){if(typeof t=="string"){let r={type:"text",text:t};return l(r,e),r}let n={type:"text",text:t.text,tw:t.tw};return l(n,e??t.style),n}function
|
|
2
|
-
`,a.span)];if(u(t,"img"))return[_(t)];if(u(t,"svg"))return[D(t)];let n=
|
|
1
|
+
function l(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function f(t){let e={type:"container",children:t.children,tw:t.tw};return l(e,t.style),e}function m(t,e){if(typeof t=="string"){let r={type:"text",text:t};return l(r,e),r}let n={type:"text",text:t.text,tw:t.tw};return l(n,e??t.style),n}function d(t){let e={type:"image",src:t.src,width:t.width,height:t.height,tw:t.tw};return l(e,t.style),e}function y(t){return`${t}%`}var a={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 A=new Set(["head","meta","link","style","script"]);function x(t){return A.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 o(t){return typeof t=="object"&&t!==null&&"type"in t}function p(t){return typeof t=="function"}var $=Symbol.for("react.forward_ref"),O=Symbol.for("react.memo"),z=Symbol.for("react.fragment");function E(t){return t.$$typeof===$}function w(t){return t.$$typeof===O}function h(t){return t.type===z}function F(t){return typeof t=="string"||typeof t=="number"}function P(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function j(t){return Object.keys(t).map(e=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(t[e]).trim()}`).join(";")}var I=["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 W(t,e){if(t==="children"||e==null)return;let n;if(t==="className"?n="class":I.includes(t)?n=S(t):n=t,typeof e=="boolean")return`${n}="${String(e)}"`;if(t==="style"&&typeof e=="object"){let r=j(e);if(r)return`style="${P(r)}"`}return`${n}="${P(String(e))}"`}function B(t){return Object.entries(t).map(([e,n])=>W(e,n)).filter(e=>e!==void 0)}var M=(t,e)=>{let n=t.props||{};if(p(t.type))return c(t.type(t.props));if(typeof t.type=="symbol"||typeof t.type!="string")return"";let r=B(n),s=n.children,g=Array.isArray(s)?s.map(k=>e(k)).join(""):e(s);return`<${t.type}${r.length>0?` ${r.join(" ")}`:""}>${g}</${t.type}>`},c=t=>t==null||t===!1?"":F(t)?String(t):Array.isArray(t)?t.map(c).join(""):o(t)?M(t,c):"";function T(t){let e=t.props||{};if(!("xmlns"in e)){let n={...t,props:{...e,xmlns:"http://www.w3.org/2000/svg"}};return c(n)||""}return c(t)||""}async function tt(t){let e=await i(t);return e.length===0?f({}):e.length===1&&e[0]!==void 0?e[0]:f({children:e,style:{width:y(100),height:y(100)}})}async function i(t){if(t==null||t===!1)return[];if(t instanceof Promise)return i(await t);if(typeof t=="object"&&Symbol.iterator in t)return V(t);if(o(t)){let e=await L(t);return Array.isArray(e)?e:e?[e]:[]}return[m(String(t),a.span)]}function H(t){if(!(typeof t.type!="object"||t.type===null)){if(E(t.type)&&"render"in t.type){let e=t.type;return i(e.render(t.props,null))}if(w(t.type)&&"type"in t.type){let n=t.type.type;if(p(n))return i(n(t.props));let r={...t,type:n};return L(r)}}}function v(t){if(!o(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))):o(e)&&h(e)?v(e):Promise.resolve(void 0)}function C(t){if(!t.some(e=>o(e)))return t.map(e=>typeof e=="string"?e:typeof e=="number"?String(e):"").join("")}async function L(t){if(p(t.type))return i(t.type(t.props));let e=H(t);if(e!==void 0)return e;if(h(t))return await N(t)||[];if(x(t))return[];if(u(t,"br"))return[m(`
|
|
2
|
+
`,a.span)];if(u(t,"img"))return[_(t)];if(u(t,"svg"))return[D(t)];let n=R(t),r=b(t),s=await v(t);if(s!==void 0)return[m({text:s,style:n,tw:r})];let g=await N(t);return[f({children:g,style:n,tw:r})]}function _(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=R(t),n=b(t);return d({src:t.props.src,style:e,tw:n})}function D(t){let e=R(t),n=b(t),r=T(t);return d({style:e,src:r,tw:n})}function R(t){let e={};typeof t.type=="string"&&t.type in a&&Object.assign(e,a[t.type]);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;return n&&Object.keys(n).length>0&&Object.assign(e,n),e}function b(t){if(!(typeof t.props!="object"||t.props===null||!("tw"in t.props)))return t.props.tw}function N(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):i(t.props.children)}function V(t){return Promise.all(Array.from(t).map(e=>i(e))).then(e=>e.flat())}export{tt as fromJsx};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
type AnyNode = {
|
|
4
|
+
type: string;
|
|
5
|
+
style?: CSSProperties;
|
|
6
|
+
tw?: string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use {import("csstype").Properties} or {import("react").CSSProperties} instead
|
|
11
|
+
*/
|
|
12
|
+
type PartialStyle = CSSProperties;
|
|
13
|
+
type Node = ContainerNode | TextNode | ImageNode | AnyNode;
|
|
14
|
+
type ContainerNode = {
|
|
15
|
+
type: "container";
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
children?: Node[];
|
|
18
|
+
tw?: string;
|
|
19
|
+
};
|
|
20
|
+
type TextNode = {
|
|
21
|
+
type: "text";
|
|
22
|
+
text: string;
|
|
23
|
+
style?: CSSProperties;
|
|
24
|
+
tw?: string;
|
|
25
|
+
};
|
|
26
|
+
type ImageNode = {
|
|
27
|
+
type: "image";
|
|
28
|
+
src: string;
|
|
29
|
+
width?: number;
|
|
30
|
+
height?: number;
|
|
31
|
+
style?: CSSProperties;
|
|
32
|
+
tw?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type { AnyNode as A, ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, TextNode as T };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
type AnyNode = {
|
|
4
|
+
type: string;
|
|
5
|
+
style?: CSSProperties;
|
|
6
|
+
tw?: string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use {import("csstype").Properties} or {import("react").CSSProperties} instead
|
|
11
|
+
*/
|
|
12
|
+
type PartialStyle = CSSProperties;
|
|
13
|
+
type Node = ContainerNode | TextNode | ImageNode | AnyNode;
|
|
14
|
+
type ContainerNode = {
|
|
15
|
+
type: "container";
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
children?: Node[];
|
|
18
|
+
tw?: string;
|
|
19
|
+
};
|
|
20
|
+
type TextNode = {
|
|
21
|
+
type: "text";
|
|
22
|
+
text: string;
|
|
23
|
+
style?: CSSProperties;
|
|
24
|
+
tw?: string;
|
|
25
|
+
};
|
|
26
|
+
type ImageNode = {
|
|
27
|
+
type: "image";
|
|
28
|
+
src: string;
|
|
29
|
+
width?: number;
|
|
30
|
+
height?: number;
|
|
31
|
+
style?: CSSProperties;
|
|
32
|
+
tw?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type { AnyNode as A, ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, TextNode as T };
|