@takumi-rs/helpers 0.68.16 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/jsx/jsx.cjs +2 -2
- package/dist/jsx/jsx.d.cts +7 -3
- package/dist/jsx/jsx.d.ts +7 -3
- package/dist/jsx/jsx.js +2 -2
- package/dist/{types-DgRXITo4.d.cts → types-DVfDlIZ1.d.cts} +13 -16
- package/dist/{types-DgRXITo4.d.ts → types-DVfDlIZ1.d.ts} +13 -16
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},N=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of y(t))!h.call(e,i)&&i!==n&&s(e,i,{get:()=>t[i],enumerable:!(o=l(t,i))||o.enumerable});return e};var w=e=>N(s({},"__esModule",{value:!0}),e);var E={};g(E,{container:()=>b,em:()=>A,fetchResources:()=>I,fr:()=>R,image:()=>T,percentage:()=>$,rem:()=>p,rgba:()=>v,style:()=>P,text:()=>S,vh:()=>C,vw:()=>O});module.exports=w(E);function c(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function u(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function f(e,t){t.tagName!==void 0&&(e.tagName=t.tagName),t.className!==void 0&&(e.className=t.className),t.id!==void 0&&(e.id=t.id)}function b(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),f(t,e),u(t,e.preset),c(t,e.style),t}function S(e,t){if(typeof e=="string"){let o={type:"text",text:e};return c(o,t),o}let n={type:"text",text:e.text};return e.tw&&(n.tw=e.tw),f(n,e),u(n,e.preset),c(n,t??e.style),n}function T(e){let t={type:"image",src:e.src,width:e.width,height:e.height};return e.tw&&(t.tw=e.tw),f(t,e),u(t,e.preset),c(t,e.style),t}function P(e){return e}function $(e){return`${e}%`}function O(e){return`${e}vw`}function C(e){return`${e}vh`}function A(e){return`${e}em`}function p(e){return`${e}rem`}function R(e){return`${e}fr`}function v(e,t,n,o=1){return`rgb(${e} ${t} ${n} / ${o})`}async function I(e,t){let n=AbortSignal.timeout(t?.timeout??5e3),o=t?.fetch??globalThis.fetch,i=t?.throwOnError??!0,m=[...new Set(e)].map(async r=>{if(t?.cache?.has(r)){let x=t.cache.get(r);if(x)return{src:r,data:x}}let a=await o(r,{signal:n});if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText} for ${r}`);let d=await a.arrayBuffer();return t?.cache?.set(r,d),{src:r,data:d}});return i?Promise.all(m):(await Promise.allSettled(m)).filter(r=>r.status==="fulfilled").map(r=>r.value)}0&&(module.exports={container,em,fetchResources,fr,image,percentage,rem,rgba,style,text,vh,vw});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
|
-
import { C as ContainerNode, T as TextNode, I as ImageNode } from './types-
|
|
3
|
-
export { A as AnyNode, N as Node, P as PartialStyle } from './types-
|
|
2
|
+
import { C as ContainerNode, T as TextNode, I as ImageNode } from './types-DVfDlIZ1.cjs';
|
|
3
|
+
export { A as AnyNode, B as BaseNode, N as Node, P as PartialStyle } from './types-DVfDlIZ1.cjs';
|
|
4
4
|
|
|
5
5
|
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
6
6
|
declare function text(text: string, style?: CSSProperties): TextNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
|
-
import { C as ContainerNode, T as TextNode, I as ImageNode } from './types-
|
|
3
|
-
export { A as AnyNode, N as Node, P as PartialStyle } from './types-
|
|
2
|
+
import { C as ContainerNode, T as TextNode, I as ImageNode } from './types-DVfDlIZ1.js';
|
|
3
|
+
export { A as AnyNode, B as BaseNode, N as Node, P as PartialStyle } from './types-DVfDlIZ1.js';
|
|
4
4
|
|
|
5
5
|
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
6
6
|
declare function text(text: string, style?: CSSProperties): TextNode;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function c(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function s(e,t){t.tagName!==void 0&&(e.tagName=t.tagName),t.className!==void 0&&(e.className=t.className),t.id!==void 0&&(e.id=t.id)}function y(e){let t={type:"container",children:e.children};return e.tw&&(t.tw=e.tw),s(t,e),c(t,e.preset),a(t,e.style),t}function h(e,t){if(typeof e=="string"){let o={type:"text",text:e};return a(o,t),o}let r={type:"text",text:e.text};return e.tw&&(r.tw=e.tw),s(r,e),c(r,e.preset),a(r,t??e.style),r}function g(e){let t={type:"image",src:e.src,width:e.width,height:e.height};return e.tw&&(t.tw=e.tw),s(t,e),c(t,e.preset),a(t,e.style),t}function N(e){return e}function w(e){return`${e}%`}function b(e){return`${e}vw`}function S(e){return`${e}vh`}function T(e){return`${e}em`}function P(e){return`${e}rem`}function $(e){return`${e}fr`}function O(e,t,r,o=1){return`rgb(${e} ${t} ${r} / ${o})`}async function A(e,t){let r=AbortSignal.timeout(t?.timeout??5e3),o=t?.fetch??globalThis.fetch,d=t?.throwOnError??!0,u=[...new Set(e)].map(async n=>{if(t?.cache?.has(n)){let m=t.cache.get(n);if(m)return{src:n,data:m}}let i=await o(n,{signal:r});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText} for ${n}`);let f=await i.arrayBuffer();return t?.cache?.set(n,f),{src:n,data:f}});return d?Promise.all(u):(await Promise.allSettled(u)).filter(n=>n.status==="fulfilled").map(n=>n.value)}export{y as container,T as em,A as fetchResources,$ as fr,g as image,w as percentage,P as rem,O as rgba,N as style,h as text,S as vh,b as vw};
|
package/dist/jsx/jsx.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`,preset:t.presets?.span})];if(
|
|
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,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}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});
|
package/dist/jsx/jsx.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSX, CSSProperties, ReactNode } from 'react';
|
|
2
|
-
import { N as Node } from '../types-
|
|
2
|
+
import { N as Node } from '../types-DVfDlIZ1.cjs';
|
|
3
3
|
|
|
4
4
|
declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
|
|
5
5
|
|
|
@@ -30,6 +30,10 @@ interface FromJsxOptions {
|
|
|
30
30
|
*/
|
|
31
31
|
tailwindClassesProperty?: string;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
interface FromJsxResult {
|
|
34
|
+
node: Node;
|
|
35
|
+
stylesheets: string[];
|
|
36
|
+
}
|
|
37
|
+
declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<FromJsxResult>;
|
|
34
38
|
|
|
35
|
-
export { type FromJsxOptions, defaultStylePresets, fromJsx };
|
|
39
|
+
export { type FromJsxOptions, type FromJsxResult, defaultStylePresets, fromJsx };
|
package/dist/jsx/jsx.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSX, CSSProperties, ReactNode } from 'react';
|
|
2
|
-
import { N as Node } from '../types-
|
|
2
|
+
import { N as Node } from '../types-DVfDlIZ1.js';
|
|
3
3
|
|
|
4
4
|
declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
|
|
5
5
|
|
|
@@ -30,6 +30,10 @@ interface FromJsxOptions {
|
|
|
30
30
|
*/
|
|
31
31
|
tailwindClassesProperty?: string;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
interface FromJsxResult {
|
|
34
|
+
node: Node;
|
|
35
|
+
stylesheets: string[];
|
|
36
|
+
}
|
|
37
|
+
declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<FromJsxResult>;
|
|
34
38
|
|
|
35
|
-
export { type FromJsxOptions, defaultStylePresets, fromJsx };
|
|
39
|
+
export { type FromJsxOptions, type FromJsxResult, defaultStylePresets, fromJsx };
|
package/dist/jsx/jsx.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
2
|
-
`,preset:t.presets?.span})];if(
|
|
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,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function D(e){return Object.keys(e).map(t=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(e[t]).trim()}`).join(";")}var V=new Set(["stopColor","stopOpacity","strokeWidth","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","fillRule","clipRule","colorInterpolationFilters","floodColor","floodOpacity","accentHeight","alignmentBaseline","arabicForm","baselineShift","capHeight","clipPath","clipPathUnits","colorInterpolation","colorProfile","colorRendering","enableBackground","fillOpacity","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","horizAdvX","horizOriginX","imageRendering","letterSpacing","lightingColor","markerEnd","markerMid","markerStart","overlinePosition","overlineThickness","paintOrder","preserveAspectRatio","pointerEvents","shapeRendering","strokeMiterlimit","strokeOpacity","textAnchor","textDecoration","textRendering","transformOrigin","underlinePosition","underlineThickness","unicodeBidi","unicodeRange","unitsPerEm","vectorEffect","vertAdvY","vertOriginX","vertOriginY","vAlphabetic","vHanging","vIdeographic","vMathematical","wordSpacing","writingMode"]);function Y(e,t){if(e==="children"||t==null)return;let r;if(e==="className"?r="class":V.has(e)?r=v(e):r=e,typeof t=="boolean")return`${r}="${String(t)}"`;if(e==="style"&&typeof t=="object"){let n=D(t);if(n)return`style="${L(n)}"`}return`${r}="${L(String(t))}"`}function K(e){return Object.entries(e).map(([t,r])=>Y(t,r)).filter(t=>t!==void 0)}var U=(e,t)=>{let r=e.props||{};if(u(e.type))return d(e.type(e.props));if(typeof e.type=="symbol"||typeof e.type!="string")return"";let n=K(r),i=r.children,o=Array.isArray(i)?i.map(s=>t(s)).join(""):t(i);return`<${e.type}${n.length>0?` ${n.join(" ")}`:""}>${o}</${e.type}>`},d=e=>e==null||e===!1?"":X(e)?String(e):Array.isArray(e)?e.map(d).join(""):c(e)?U(e,d):"";function A(e){let t=e.props||{};if(!("xmlns"in t)){let r={...e,props:{...t,xmlns:"http://www.w3.org/2000/svg"}};return d(r)||""}return d(e)||""}async function fe(e,t){let r=await l(e,{presets:q(t),tailwindClassesProperty:t?.tailwindClassesProperty??"tw"}),n=r.nodes,i;return n.length===0?i=h({}):n.length===1&&n[0]!==void 0?i=n[0]:i=h({children:n,style:{width:w(100),height:w(100)}}),{node:i,stylesheets:r.stylesheets}}async function l(e,t){return e==null||e===!1?{nodes:[],stylesheets:[]}:e instanceof Promise?l(await e,t):typeof e=="object"&&Symbol.iterator in e?te(e,t):c(e)?await j(e,t):{nodes:[R({text:String(e),preset:t.presets?.span})],stylesheets:[]}}function q(e){if(e?.defaultStyles!==!1)return e?.defaultStyles??T}function Z(e,t){if(!(typeof e.type!="object"||e.type===null)){if(F(e.type)&&"render"in e.type){let r=e.type;return l(r.render(e.props,null),t)}if(O(e.type)&&"type"in e.type){let n=e.type.type;if(u(n))return l(n(e.props),t);let i={...e,type:n};return j(i,t)}}}function m(e){if(typeof e.props=="object"&&e.props!==null&&"children"in e.props)return e.props.children}function z(e){if(!c(e))return;let t=m(e);if(typeof t=="string")return t;if(typeof t=="number")return String(t);if(Array.isArray(t)||typeof t=="object"&&t!==null&&Symbol.iterator in t)return J(t);if(c(t)&&x(t))return z(t)}function $(e){let t="";for(let r of e){let n=b(r);if(n===void 0)return;t+=n}return t}function b(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(e==null||typeof e=="boolean"||typeof e=="symbol")return"";if(typeof e=="object"&&Symbol.iterator in e)return $(e);if(!c(e))return;if(x(e))return b(m(e));let t=m(e);return t===void 0?"":typeof t=="object"&&t!==null&&Symbol.iterator in t?$(t):b(t)}function J(e){let t="";for(let r of e){if(c(r))return;if(typeof r=="string"){t+=r;continue}if(typeof r=="number"){t+=String(r);continue}return}return t}async function j(e,t){if(u(e.type))return l(e.type(e.props),t);let r=Z(e,t);if(r!==void 0)return r;if(x(e))return I(e,t);if(f(e,"style")){let p=b(m(e));return{nodes:[],stylesheets:p&&p.length>0?[p]:[]}}if(typeof e.type!="string"||C(e))return{nodes:[],stylesheets:[]};let n=e.props;if(f(e,"br"))return{nodes:[R({text:`
|
|
2
|
+
`,preset:t.presets?.span,tagName:"br",className:e.props.className,id:e.props.id})],stylesheets:[]};if(f(e,"img"))return{nodes:[G(e,t)],stylesheets:[]};if(f(e,"svg"))return{nodes:[Q(e,t)],stylesheets:[]};let{preset:i,style:o}=E(e,t),s=P(e,t),a=z(e);if(a!==void 0)return{nodes:[R({text:a,preset:i,style:o,tw:s,className:n.className,id:n.id,tagName:e.type})],stylesheets:[]};let y=await I(e,t);return{nodes:[h({children:y.nodes,preset:i,style:o,tw:s,tagName:e.type,className:n.className,id:n.id})],stylesheets:y.stylesheets}}function G(e,t){if(!e.props.src)throw new Error("Image element must have a 'src' prop.");let{preset:r,style:n}=E(e,t),i=P(e,t),o=e.props.width!==void 0?Number(e.props.width):void 0,s=e.props.height!==void 0?Number(e.props.height):void 0;return k({src:e.props.src,width:o,height:s,preset:r,style:n,tw:i,className:e.props.className,id:e.props.id,tagName:"img"})}function Q(e,t){let{preset:r,style:n}=E(e,t),i=P(e,t),o=A(e),s=e.props.width!==void 0?Number(e.props.width):void 0,a=e.props.height!==void 0?Number(e.props.height):void 0;return k({preset:r,width:s,height:a,style:n,src:o,tw:i,className:e.props.className,id:e.props.id,tagName:"svg"})}function E(e,t){let r,n,i=t.presets;i&&typeof e.type=="string"&&e.type in i&&(r=i[e.type]);let o=typeof e.props=="object"&&e.props!==null&&"style"in e.props&&typeof e.props.style=="object"&&e.props.style!==null?e.props.style:void 0;if(o){for(let s in o)if(Object.hasOwn(o,s)){n=o;break}}return{preset:r,style:n}}function P(e,t){let r=t.tailwindClassesProperty;if(typeof e.props!="object"||e.props===null||!(r in e.props))return;let n=e.props[r];if(typeof n=="string")return n}function I(e,t){let r=m(e);return r===void 0?Promise.resolve({nodes:[],stylesheets:[]}):l(r,t)}var ee=8;async function te(e,t){let r=[],n=new Set,i=0;for(let a of e){let y=i;i+=1;let p=l(a,t).then(B=>{r[y]=B}).finally(()=>n.delete(p));n.add(p),n.size>=ee&&await Promise.race(n)}await Promise.all(n);let o=[],s=[];for(let a of r)a&&(o.push(...a.nodes),s.push(...a.stylesheets));return{nodes:o,stylesheets:s}}export{T as defaultStylePresets,fe as fromJsx};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type BaseNode = {
|
|
4
|
+
tagName?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
id?: string;
|
|
6
7
|
tw?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
preset?: CSSProperties;
|
|
10
|
+
};
|
|
11
|
+
type AnyNode = BaseNode & {
|
|
12
|
+
type: string;
|
|
7
13
|
[key: string]: unknown;
|
|
8
14
|
};
|
|
9
15
|
/**
|
|
@@ -11,28 +17,19 @@ type AnyNode = {
|
|
|
11
17
|
*/
|
|
12
18
|
type PartialStyle = CSSProperties;
|
|
13
19
|
type Node = ContainerNode | TextNode | ImageNode | AnyNode;
|
|
14
|
-
type ContainerNode = {
|
|
20
|
+
type ContainerNode = BaseNode & {
|
|
15
21
|
type: "container";
|
|
16
|
-
preset?: CSSProperties;
|
|
17
|
-
style?: CSSProperties;
|
|
18
22
|
children?: Node[];
|
|
19
|
-
tw?: string;
|
|
20
23
|
};
|
|
21
|
-
type TextNode = {
|
|
24
|
+
type TextNode = BaseNode & {
|
|
22
25
|
type: "text";
|
|
23
26
|
text: string;
|
|
24
|
-
preset?: CSSProperties;
|
|
25
|
-
style?: CSSProperties;
|
|
26
|
-
tw?: string;
|
|
27
27
|
};
|
|
28
|
-
type ImageNode = {
|
|
28
|
+
type ImageNode = BaseNode & {
|
|
29
29
|
type: "image";
|
|
30
30
|
src: string;
|
|
31
31
|
width?: number;
|
|
32
32
|
height?: number;
|
|
33
|
-
preset?: CSSProperties;
|
|
34
|
-
style?: CSSProperties;
|
|
35
|
-
tw?: string;
|
|
36
33
|
};
|
|
37
34
|
|
|
38
|
-
export type { AnyNode as A, ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, TextNode as T };
|
|
35
|
+
export type { AnyNode as A, BaseNode as B, ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, TextNode as T };
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type BaseNode = {
|
|
4
|
+
tagName?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
id?: string;
|
|
6
7
|
tw?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
preset?: CSSProperties;
|
|
10
|
+
};
|
|
11
|
+
type AnyNode = BaseNode & {
|
|
12
|
+
type: string;
|
|
7
13
|
[key: string]: unknown;
|
|
8
14
|
};
|
|
9
15
|
/**
|
|
@@ -11,28 +17,19 @@ type AnyNode = {
|
|
|
11
17
|
*/
|
|
12
18
|
type PartialStyle = CSSProperties;
|
|
13
19
|
type Node = ContainerNode | TextNode | ImageNode | AnyNode;
|
|
14
|
-
type ContainerNode = {
|
|
20
|
+
type ContainerNode = BaseNode & {
|
|
15
21
|
type: "container";
|
|
16
|
-
preset?: CSSProperties;
|
|
17
|
-
style?: CSSProperties;
|
|
18
22
|
children?: Node[];
|
|
19
|
-
tw?: string;
|
|
20
23
|
};
|
|
21
|
-
type TextNode = {
|
|
24
|
+
type TextNode = BaseNode & {
|
|
22
25
|
type: "text";
|
|
23
26
|
text: string;
|
|
24
|
-
preset?: CSSProperties;
|
|
25
|
-
style?: CSSProperties;
|
|
26
|
-
tw?: string;
|
|
27
27
|
};
|
|
28
|
-
type ImageNode = {
|
|
28
|
+
type ImageNode = BaseNode & {
|
|
29
29
|
type: "image";
|
|
30
30
|
src: string;
|
|
31
31
|
width?: number;
|
|
32
32
|
height?: number;
|
|
33
|
-
preset?: CSSProperties;
|
|
34
|
-
style?: CSSProperties;
|
|
35
|
-
tw?: string;
|
|
36
33
|
};
|
|
37
34
|
|
|
38
|
-
export type { AnyNode as A, ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, TextNode as T };
|
|
35
|
+
export type { AnyNode as A, BaseNode as B, ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, TextNode as T };
|