@takumi-rs/helpers 1.0.0-rc.9 → 1.0.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/emoji.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./helpers-YexC8ywm.cjs`),t=/\uFE0F/g;function n(e){let n=e.indexOf(`‍`)<0?e.replace(t,``):e,r=``;for(let e=0,t=0;e<n.length;e++){let i=n.charCodeAt(e);if(t){let e=(65536+(t-55296<<10)+(i-56320)).toString(16);r+=(r?`-`:``)+e,t=0}else 55296<=i&&i<=56319?t=i:r+=(r?`-`:``)+i.toString(16)}return r}const r={twemoji:e=>`https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${e.toLowerCase()}.svg`,openmoji:`https://cdn.jsdelivr.net/npm/@svgmoji/openmoji@2.0.0/svg/`,blobmoji:`https://cdn.jsdelivr.net/npm/@svgmoji/blob@2.0.0/svg/`,noto:`https://cdn.jsdelivr.net/gh/svgmoji/svgmoji/packages/svgmoji__noto/svg/`};function i(e,t){let i=n(e);return t===`twemoji`?r.twemoji(i):`${r[t]}${i.toUpperCase()}.svg`}let a;function o(){return a===void 0&&(a=typeof Intl<`u`&&typeof Intl.Segmenter==`function`?new Intl.Segmenter(`en`,{granularity:`grapheme`}):null),a}function s(e){let t=o();return t?Array.from(t.segment(e)):Array.from(e).map(e=>({segment:e}))}function c(t,n){let r=[],a=``,o=s(t.text);for(let{segment:t}of o)/\p{Extended_Pictographic}/u.test(t)?(a&&=(r.push(e.l({text:a})),``),r.push(e.i({src:i(t,n),style:{display:`inline-block`,width:`1em`,height:`1em`,margin:`0 0.05em 0 0.1em`,verticalAlign:`-0.1em`}}))):a+=t;return a&&r.push(e.l({text:a})),r}function l(t,n){if(t.type===`text`){if(s(t.text).some(({segment:e})=>/\p{Extended_Pictographic}/u.test(e))){let{type:r,...i}=t;return e.t({...i,children:c(t,n)})}}else if(t.type===`container`&&t.children)return{...t,children:t.children.map(e=>e&&l(e,n))};return t}exports.extractEmojis=l;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./helpers-cmaAH67r.cjs`),t=/\uFE0F/g,n=/\p{Extended_Pictographic}/u,r=/^(?:\p{Regional_Indicator}){2}$/u,i=/^[#*0-9]\uFE0F?\u20E3$/u;function a(e){let n=e.indexOf(`‍`)<0?e.replace(t,``):e,r=``;for(let e=0,t=0;e<n.length;e++){let i=n.charCodeAt(e);if(t){let e=(65536+(t-55296<<10)+(i-56320)).toString(16);r+=(r?`-`:``)+e,t=0}else 55296<=i&&i<=56319?t=i:r+=(r?`-`:``)+i.toString(16)}return r}const o={twemoji:e=>`https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${e.toLowerCase()}.svg`,openmoji:`https://cdn.jsdelivr.net/npm/@svgmoji/openmoji@2.0.0/svg/`,blobmoji:`https://cdn.jsdelivr.net/npm/@svgmoji/blob@2.0.0/svg/`,noto:`https://cdn.jsdelivr.net/gh/svgmoji/svgmoji/packages/svgmoji__noto/svg/`,fluent:e=>`https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${e.toLowerCase()}_color.svg`,fluentFlat:e=>`https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${e.toLowerCase()}_flat.svg`};function s(e,t){let n=a(e),r=o[t];return typeof r==`function`?r(n):`${r}${n.toUpperCase()}.svg`}let c;function l(){return c===void 0&&(c=typeof Intl<`u`&&typeof Intl.Segmenter==`function`?new Intl.Segmenter(`en`,{granularity:`grapheme`}):null),c}function u(e){let t=l();return t?Array.from(t.segment(e)):Array.from(e).map(e=>({segment:e}))}function d(e){return n.test(e)||r.test(e)||i.test(e)}function f(t,n){let r=[],i=``,a=u(t.text);for(let{segment:t}of a)d(t)?(i&&=(r.push(e.l({text:i})),``),r.push(e.i({src:s(t,n),style:{display:`inline-block`,width:`1em`,height:`1em`,margin:`0 0.05em 0 0.1em`,verticalAlign:`-0.1em`}}))):i+=t;return i&&r.push(e.l({text:i})),r}function p(t,n){if(t.type===`text`){if(u(t.text).some(({segment:e})=>d(e))){let{type:r,...i}=t;return e.t({...i,children:f(t,n)})}}else if(t.type===`container`&&t.children)return{...t,children:t.children.map(e=>e&&p(e,n))};return t}exports.extractEmojis=p;
package/dist/emoji.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { r as Node } from "./types-BiW26s7h.cjs";
1
+ import { r as Node } from "./types-BMJCiuSY.cjs";
2
2
 
3
3
  //#region src/emoji.d.ts
4
- type EmojiType = "twemoji" | "blobmoji" | "noto" | "openmoji";
4
+ type EmojiType = "twemoji" | "blobmoji" | "noto" | "openmoji" | "fluent" | "fluentFlat";
5
5
  declare function extractEmojis(node: Node, emojiType: EmojiType): Node;
6
6
  //#endregion
7
7
  export { EmojiType, extractEmojis };
package/dist/emoji.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { r as Node } from "./types-Ds1Xw1hx.mjs";
1
+ import { r as Node } from "./types-CkIMwyWS.mjs";
2
2
 
3
3
  //#region src/emoji.d.ts
4
- type EmojiType = "twemoji" | "blobmoji" | "noto" | "openmoji";
4
+ type EmojiType = "twemoji" | "blobmoji" | "noto" | "openmoji" | "fluent" | "fluentFlat";
5
5
  declare function extractEmojis(node: Node, emojiType: EmojiType): Node;
6
6
  //#endregion
7
7
  export { EmojiType, extractEmojis };
package/dist/emoji.mjs CHANGED
@@ -1 +1 @@
1
- import{i as e,l as t,t as n}from"./helpers-DrCXPa0N.mjs";const r=/\uFE0F/g;function i(e){let t=e.indexOf(`‍`)<0?e.replace(r,``):e,n=``;for(let e=0,r=0;e<t.length;e++){let i=t.charCodeAt(e);if(r){let e=(65536+(r-55296<<10)+(i-56320)).toString(16);n+=(n?`-`:``)+e,r=0}else 55296<=i&&i<=56319?r=i:n+=(n?`-`:``)+i.toString(16)}return n}const a={twemoji:e=>`https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${e.toLowerCase()}.svg`,openmoji:`https://cdn.jsdelivr.net/npm/@svgmoji/openmoji@2.0.0/svg/`,blobmoji:`https://cdn.jsdelivr.net/npm/@svgmoji/blob@2.0.0/svg/`,noto:`https://cdn.jsdelivr.net/gh/svgmoji/svgmoji/packages/svgmoji__noto/svg/`};function o(e,t){let n=i(e);return t===`twemoji`?a.twemoji(n):`${a[t]}${n.toUpperCase()}.svg`}let s;function c(){return s===void 0&&(s=typeof Intl<`u`&&typeof Intl.Segmenter==`function`?new Intl.Segmenter(`en`,{granularity:`grapheme`}):null),s}function l(e){let t=c();return t?Array.from(t.segment(e)):Array.from(e).map(e=>({segment:e}))}function u(n,r){let i=[],a=``,s=l(n.text);for(let{segment:n}of s)/\p{Extended_Pictographic}/u.test(n)?(a&&=(i.push(t({text:a})),``),i.push(e({src:o(n,r),style:{display:`inline-block`,width:`1em`,height:`1em`,margin:`0 0.05em 0 0.1em`,verticalAlign:`-0.1em`}}))):a+=n;return a&&i.push(t({text:a})),i}function d(e,t){if(e.type===`text`){if(l(e.text).some(({segment:e})=>/\p{Extended_Pictographic}/u.test(e))){let{type:r,...i}=e;return n({...i,children:u(e,t)})}}else if(e.type===`container`&&e.children)return{...e,children:e.children.map(e=>e&&d(e,t))};return e}export{d as extractEmojis};
1
+ import{i as e,l as t,t as n}from"./helpers-6Yvy3K-3.mjs";const r=/\uFE0F/g,i=/\p{Extended_Pictographic}/u,a=/^(?:\p{Regional_Indicator}){2}$/u,o=/^[#*0-9]\uFE0F?\u20E3$/u;function s(e){let t=e.indexOf(`‍`)<0?e.replace(r,``):e,n=``;for(let e=0,r=0;e<t.length;e++){let i=t.charCodeAt(e);if(r){let e=(65536+(r-55296<<10)+(i-56320)).toString(16);n+=(n?`-`:``)+e,r=0}else 55296<=i&&i<=56319?r=i:n+=(n?`-`:``)+i.toString(16)}return n}const c={twemoji:e=>`https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${e.toLowerCase()}.svg`,openmoji:`https://cdn.jsdelivr.net/npm/@svgmoji/openmoji@2.0.0/svg/`,blobmoji:`https://cdn.jsdelivr.net/npm/@svgmoji/blob@2.0.0/svg/`,noto:`https://cdn.jsdelivr.net/gh/svgmoji/svgmoji/packages/svgmoji__noto/svg/`,fluent:e=>`https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${e.toLowerCase()}_color.svg`,fluentFlat:e=>`https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${e.toLowerCase()}_flat.svg`};function l(e,t){let n=s(e),r=c[t];return typeof r==`function`?r(n):`${r}${n.toUpperCase()}.svg`}let u;function d(){return u===void 0&&(u=typeof Intl<`u`&&typeof Intl.Segmenter==`function`?new Intl.Segmenter(`en`,{granularity:`grapheme`}):null),u}function f(e){let t=d();return t?Array.from(t.segment(e)):Array.from(e).map(e=>({segment:e}))}function p(e){return i.test(e)||a.test(e)||o.test(e)}function m(n,r){let i=[],a=``,o=f(n.text);for(let{segment:n}of o)p(n)?(a&&=(i.push(t({text:a})),``),i.push(e({src:l(n,r),style:{display:`inline-block`,width:`1em`,height:`1em`,margin:`0 0.05em 0 0.1em`,verticalAlign:`-0.1em`}}))):a+=n;return a&&i.push(t({text:a})),i}function h(e,t){if(e.type===`text`){if(f(e.text).some(({segment:e})=>p(e))){let{type:r,...i}=e;return n({...i,children:m(e,t)})}}else if(e.type===`container`&&e.children)return{...e,children:e.children.map(e=>e&&h(e,t))};return e}export{h as extractEmojis};
@@ -0,0 +1 @@
1
+ function e(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function t(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function n(e,t){t.tagName!==void 0&&(e.tagName=t.tagName),t.className!==void 0&&(e.className=t.className),t.id!==void 0&&(e.id=t.id),t.dir!==void 0&&(e.dir=t.dir),t.attributes!==void 0&&(e.attributes=t.attributes)}function r(r){let i={type:`container`,children:r.children};return r.tw&&(i.tw=r.tw),n(i,r),t(i,r.preset),e(i,r.style),i}function i(r,i){if(typeof r==`string`){let t={type:`text`,text:r};return e(t,i),t}let a={type:`text`,text:r.text};return r.tw&&(a.tw=r.tw),n(a,r),t(a,r.preset),e(a,i??r.style),a}function a(r){let i={type:`image`,src:r.src,width:r.width,height:r.height};return r.tw&&(i.tw=r.tw),n(i,r),t(i,r.preset),e(i,r.style),i}function o(e){return e}function s(e){return`${e}%`}function c(e){return`${e}vw`}function l(e){return`${e}vh`}function u(e){return`${e}em`}function d(e){return`${e}rem`}function f(e){return`${e}fr`}function p(e,t,n,r=1){return`rgb(${e} ${t} ${n} / ${r})`}export{s as a,o as c,c as d,a as i,i as l,u as n,d as o,f as r,p as s,r as t,l as u};
@@ -0,0 +1 @@
1
+ function e(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function t(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function n(e,t){t.tagName!==void 0&&(e.tagName=t.tagName),t.className!==void 0&&(e.className=t.className),t.id!==void 0&&(e.id=t.id),t.dir!==void 0&&(e.dir=t.dir),t.attributes!==void 0&&(e.attributes=t.attributes)}function r(r){let i={type:`container`,children:r.children};return r.tw&&(i.tw=r.tw),n(i,r),t(i,r.preset),e(i,r.style),i}function i(r,i){if(typeof r==`string`){let t={type:`text`,text:r};return e(t,i),t}let a={type:`text`,text:r.text};return r.tw&&(a.tw=r.tw),n(a,r),t(a,r.preset),e(a,i??r.style),a}function a(r){let i={type:`image`,src:r.src,width:r.width,height:r.height};return r.tw&&(i.tw=r.tw),n(i,r),t(i,r.preset),e(i,r.style),i}function o(e){return e}function s(e){return`${e}%`}function c(e){return`${e}vw`}function l(e){return`${e}vh`}function u(e){return`${e}em`}function d(e){return`${e}rem`}function f(e){return`${e}fr`}function p(e,t,n,r=1){return`rgb(${e} ${t} ${n} / ${r})`}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return l}});
package/dist/html.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./helpers-cmaAH67r.cjs`),t=require(`./markup-BoHMcJO0.cjs`);function n(n){let{nodes:r,stylesheets:i}=t.t(n);return r.length===0?{node:e.t({}),stylesheets:i}:r.length===1&&r[0]?{node:r[0],stylesheets:i}:{node:e.t({style:{width:e.a(100),height:e.a(100)},children:r}),stylesheets:i}}exports.fromHtml=n;
@@ -0,0 +1,8 @@
1
+ import { r as Node } from "./types-BMJCiuSY.cjs";
2
+ //#region src/html/index.d.ts
3
+ declare function fromHtml(html: string): {
4
+ node: Node;
5
+ stylesheets: string[];
6
+ };
7
+ //#endregion
8
+ export { fromHtml };
@@ -0,0 +1,8 @@
1
+ import { r as Node } from "./types-CkIMwyWS.mjs";
2
+ //#region src/html/index.d.ts
3
+ declare function fromHtml(html: string): {
4
+ node: Node;
5
+ stylesheets: string[];
6
+ };
7
+ //#endregion
8
+ export { fromHtml };
package/dist/html.mjs ADDED
@@ -0,0 +1 @@
1
+ import{a as e,t}from"./helpers-6Yvy3K-3.mjs";import{t as n}from"./markup-KH2xSwwo.mjs";function r(r){let{nodes:i,stylesheets:a}=n(r);return i.length===0?{node:t({}),stylesheets:a}:i.length===1&&i[0]?{node:i[0],stylesheets:a}:{node:t({style:{width:e(100),height:e(100)},children:i}),stylesheets:a}}export{r as fromHtml};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./helpers-YexC8ywm.cjs`);async function t(e,t){let n=AbortSignal.timeout(t?.timeout??5e3),r=t?.fetch??globalThis.fetch,i=t?.throwOnError??!0,a=[...new Set(e)].map(async e=>{if(t?.cache?.has(e)){let n=t.cache.get(e);if(n)return{src:e,data:n}}let i=await r(e,{signal:n});if(!i.ok)throw Error(`HTTP ${i.status}: ${i.statusText} for ${e}`);let a=await i.arrayBuffer();return t?.cache?.set(e,a),{src:e,data:a}});return i?Promise.all(a):(await Promise.allSettled(a)).filter(e=>e.status===`fulfilled`).map(e=>e.value)}exports.container=e.t,exports.em=e.n,exports.fetchResources=t,exports.fr=e.r,exports.image=e.i,exports.percentage=e.a,exports.rem=e.o,exports.rgba=e.s,exports.style=e.c,exports.text=e.l,exports.vh=e.u,exports.vw=e.d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./helpers-cmaAH67r.cjs`),t=/url\(\s*(['"]?)(.*?)\1\s*\)/g;function n(e){return e.startsWith(`https://`)||e.startsWith(`http://`)}function r(e,i){if(typeof e==`string`)for(let r of e.matchAll(t)){let e=r[2]?.trim();e&&n(e)&&i.add(e)}else if(Array.isArray(e))for(let t of e)r(t,i)}function i(e){let t=new Set,i=e=>{let a=e=>{e&&(r(e.backgroundImage,t),r(e.maskImage,t))};if(a(e.style),a(e.preset),e.type===`image`){typeof e.src==`string`&&n(e.src)&&t.add(e.src);return}if(e.type===`container`)for(let t of e.children??[])i(t)};return i(e),[...t]}async function a(e,t){let n=AbortSignal.timeout(t?.timeout??5e3),r=t?.fetch??globalThis.fetch,i=t?.throwOnError??!0,a=[...new Set(e)].map(async e=>{if(t?.cache?.has(e)){let n=t.cache.get(e);if(n)return{src:e,data:n}}let i=await r(e,{signal:n});if(!i.ok)throw Error(`HTTP ${i.status}: ${i.statusText} for ${e}`);let a=await i.arrayBuffer();return t?.cache?.set(e,a),{src:e,data:a}});return i?Promise.all(a):(await Promise.allSettled(a)).filter(e=>e.status===`fulfilled`).map(e=>e.value)}exports.container=e.t,exports.em=e.n,exports.extractResourceUrls=i,exports.fetchResources=a,exports.fr=e.r,exports.image=e.i,exports.percentage=e.a,exports.rem=e.o,exports.rgba=e.s,exports.style=e.c,exports.text=e.l,exports.vh=e.u,exports.vw=e.d;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as NodeMetadata, i as NodeAttributes, n as ImageNode, o as ReactElementLike, r as Node, s as TextNode, t as ContainerNode } from "./types-BiW26s7h.cjs";
1
+ import { a as NodeMetadata, i as NodeAttributes, n as ImageNode, o as ReactElementLike, r as Node, s as TextNode, t as ContainerNode } from "./types-BMJCiuSY.cjs";
2
2
  import { CSSProperties } from "react";
3
3
 
4
4
  //#region src/helpers.d.ts
@@ -16,6 +16,7 @@ declare function fr(fr: number): `${number}fr`;
16
16
  declare function rgba(r: number, g: number, b: number, a?: number): `rgb(${number} ${number} ${number} / ${number})`;
17
17
  //#endregion
18
18
  //#region src/utils.d.ts
19
+ declare function extractResourceUrls(node: Node): string[];
19
20
  type FetchResourcesOptions = {
20
21
  /**
21
22
  * Timeout in milliseconds.
@@ -51,4 +52,4 @@ declare function fetchResources(urls: string[], options?: FetchResourcesOptions)
51
52
  data: ArrayBuffer;
52
53
  }[]>;
53
54
  //#endregion
54
- export { ContainerNode, FetchResourcesOptions, ImageNode, Node, NodeAttributes, NodeMetadata, ReactElementLike, TextNode, container, em, fetchResources, fr, image, percentage, rem, rgba, style, text, vh, vw };
55
+ export { ContainerNode, FetchResourcesOptions, ImageNode, Node, NodeAttributes, NodeMetadata, ReactElementLike, TextNode, container, em, extractResourceUrls, fetchResources, fr, image, percentage, rem, rgba, style, text, vh, vw };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as NodeMetadata, i as NodeAttributes, n as ImageNode, o as ReactElementLike, r as Node, s as TextNode, t as ContainerNode } from "./types-Ds1Xw1hx.mjs";
1
+ import { a as NodeMetadata, i as NodeAttributes, n as ImageNode, o as ReactElementLike, r as Node, s as TextNode, t as ContainerNode } from "./types-CkIMwyWS.mjs";
2
2
  import { CSSProperties } from "react";
3
3
 
4
4
  //#region src/helpers.d.ts
@@ -16,6 +16,7 @@ declare function fr(fr: number): `${number}fr`;
16
16
  declare function rgba(r: number, g: number, b: number, a?: number): `rgb(${number} ${number} ${number} / ${number})`;
17
17
  //#endregion
18
18
  //#region src/utils.d.ts
19
+ declare function extractResourceUrls(node: Node): string[];
19
20
  type FetchResourcesOptions = {
20
21
  /**
21
22
  * Timeout in milliseconds.
@@ -51,4 +52,4 @@ declare function fetchResources(urls: string[], options?: FetchResourcesOptions)
51
52
  data: ArrayBuffer;
52
53
  }[]>;
53
54
  //#endregion
54
- export { ContainerNode, FetchResourcesOptions, ImageNode, Node, NodeAttributes, NodeMetadata, ReactElementLike, TextNode, container, em, fetchResources, fr, image, percentage, rem, rgba, style, text, vh, vw };
55
+ export { ContainerNode, FetchResourcesOptions, ImageNode, Node, NodeAttributes, NodeMetadata, ReactElementLike, TextNode, container, em, extractResourceUrls, fetchResources, fr, image, percentage, rem, rgba, style, text, vh, vw };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,i as r,l as i,n as a,o,r as s,s as c,t as l,u}from"./helpers-DrCXPa0N.mjs";async function d(e,t){let n=AbortSignal.timeout(t?.timeout??5e3),r=t?.fetch??globalThis.fetch,i=t?.throwOnError??!0,a=[...new Set(e)].map(async e=>{if(t?.cache?.has(e)){let n=t.cache.get(e);if(n)return{src:e,data:n}}let i=await r(e,{signal:n});if(!i.ok)throw Error(`HTTP ${i.status}: ${i.statusText} for ${e}`);let a=await i.arrayBuffer();return t?.cache?.set(e,a),{src:e,data:a}});return i?Promise.all(a):(await Promise.allSettled(a)).filter(e=>e.status===`fulfilled`).map(e=>e.value)}export{l as container,a as em,d as fetchResources,s as fr,r as image,e as percentage,o as rem,c as rgba,t as style,i as text,u as vh,n as vw};
1
+ import{a as e,c as t,d as n,i as r,l as i,n as a,o,r as s,s as c,t as l,u}from"./helpers-6Yvy3K-3.mjs";const d=/url\(\s*(['"]?)(.*?)\1\s*\)/g;function f(e){return e.startsWith(`https://`)||e.startsWith(`http://`)}function p(e,t){if(typeof e==`string`)for(let n of e.matchAll(d)){let e=n[2]?.trim();e&&f(e)&&t.add(e)}else if(Array.isArray(e))for(let n of e)p(n,t)}function m(e){let t=new Set,n=e=>{let r=e=>{e&&(p(e.backgroundImage,t),p(e.maskImage,t))};if(r(e.style),r(e.preset),e.type===`image`){typeof e.src==`string`&&f(e.src)&&t.add(e.src);return}if(e.type===`container`)for(let t of e.children??[])n(t)};return n(e),[...t]}async function h(e,t){let n=AbortSignal.timeout(t?.timeout??5e3),r=t?.fetch??globalThis.fetch,i=t?.throwOnError??!0,a=[...new Set(e)].map(async e=>{if(t?.cache?.has(e)){let n=t.cache.get(e);if(n)return{src:e,data:n}}let i=await r(e,{signal:n});if(!i.ok)throw Error(`HTTP ${i.status}: ${i.statusText} for ${e}`);let a=await i.arrayBuffer();return t?.cache?.set(e,a),{src:e,data:a}});return i?Promise.all(a):(await Promise.allSettled(a)).filter(e=>e.status===`fulfilled`).map(e=>e.value)}export{l as container,a as em,m as extractResourceUrls,h as fetchResources,s as fr,r as image,e as percentage,o as rem,c as rgba,t as style,i as text,u as vh,n as vw};
package/dist/jsx.cjs ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./helpers-cmaAH67r.cjs`),t=require(`./markup-BoHMcJO0.cjs`);function n(e){return typeof e==`string`||typeof e==`number`}function r(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function i(e){return Object.keys(e).map(t=>`${t.replace(/([A-Z])/g,`-$1`).toLowerCase()}:${String(e[t]).trim()}`).join(`;`)}const a=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`.split(`.`));function o(e,n){if(e===`children`||n==null)return;let o;if(o=e===`className`?`class`:a.has(e)?t.n(e):e,typeof n==`boolean`)return`${o}="${String(n)}"`;if(e===`style`&&typeof n==`object`){let e=i(n);if(e)return`style="${r(e)}"`}return`${o}="${r(String(n))}"`}function s(e){return Object.entries(e).map(([e,t])=>o(e,t)).filter(e=>e!==void 0)}const c=(e,n)=>{let r=e.props||{};if(t.r(e.type))return l(e.type(e.props));if(typeof e.type==`symbol`||typeof e.type!=`string`)return``;let i=s(r),a=r.children,o=Array.isArray(a)?a.map(e=>n(e)).join(``):n(a);return`<${e.type}${i.length>0?` ${i.join(` `)}`:``}>${o}</${e.type}>`},l=e=>e==null||e===!1?``:n(e)?String(e):Array.isArray(e)?e.map(l).join(``):t.l(e)?c(e,l):``;function u(e){let t=e.props||{};return`xmlns`in t?l(e)||``:l({...e,props:{...t,xmlns:`http://www.w3.org/2000/svg`}})||``}const d=[/Invalid hook call\./,/Cannot read properties of null \(reading 'use[A-Z][A-Za-z]+'\)/,/null is not an object \(evaluating 'dispatcher\.use[A-Z][A-Za-z]+'\)/];let f,p;async function m(n,r){let i={defaultStyles:g(r),presets:t.d(r?.defaultStyles),tailwindClassesProperty:r?.tailwindClassesProperty??`tw`},a=await h(n,i).catch(async e=>{if(!v(e))throw e;return await D(n,i)||h(n,i)}),o=a.nodes,s;return s=o.length===0?e.t({}):o.length===1&&o[0]!==void 0?o[0]:e.t({children:o,style:{width:e.a(100),height:e.a(100)}}),{node:s,stylesheets:a.stylesheets}}async function h(n,r){return n==null||n===!1?{nodes:[],stylesheets:[]}:n instanceof Promise?h(await n,r):typeof n==`object`&&Symbol.iterator in n?z(n,r):t.l(n)?await M(n,r):{nodes:[e.l({text:String(n),preset:r.presets?.span})],stylesheets:[]}}function g(e){return e&&`defaultStyles`in e?e.defaultStyles??t.f:t.f}function _(e){return!t.l(e)||typeof e.type!=`object`||e.type===null||!(`$$typeof`in e.type)?!1:e.type.$$typeof===Symbol.for(`react.context`)||e.type.$$typeof===Symbol.for(`react.provider`)}function v(e){return e instanceof Error?d.some(t=>t.test(e.message)):!1}async function y(e){let t=console.error;console.error=(...e)=>{let[n]=e;typeof n==`string`&&d.some(e=>e.test(n))||t(...e)};try{return await e()}finally{console.error=t}}async function b(e,t,n){return y(()=>h(e(t),n))}function x(e,n){if(!(typeof e.type!=`object`||e.type===null)){if(t.o(e.type)&&`render`in e.type){let t=e.type;return b(e=>t.render(e,null),e.props,n)}if(t.c(e.type)&&`type`in e.type){let r=e.type.type;return t.r(r)?b(r,e.props,n):M({...e,type:r},n)}}}function S(e){if(typeof e.props==`object`&&e.props!==null&&`children`in e.props)return e.props.children}function C(e){return typeof e==`object`&&!!e&&`createElement`in e&&typeof e.createElement==`function`}function w(e){return typeof e==`object`&&!!e&&`renderToStaticMarkup`in e&&typeof e.renderToStaticMarkup==`function`}async function T(){return p??=import(`react`).then(e=>{let t=e.default??e;return C(t)?t:null}).catch(()=>null),p}async function E(){return f??=import(`react-dom/server`).then(e=>{let t=e.default??e;return w(t)?t:null}).catch(()=>null),f}async function D(e,n){let[r,i]=await Promise.all([T(),E()]);return!r||!i?null:t.t(i.renderToStaticMarkup(r.createElement(r.Fragment??void 0,null,e)),{defaultStyles:n.defaultStyles,tailwindClassesProperty:n.tailwindClassesProperty})}function O(e){if(!t.l(e))return;let n=S(e);if(typeof n==`string`)return n;if(typeof n==`number`)return String(n);if(Array.isArray(n)||typeof n==`object`&&n&&Symbol.iterator in n)return j(n);if(t.l(n)&&t.s(n))return O(n)}function k(e){let t=``;for(let n of e){let e=A(n);if(e===void 0)return;t+=e}return t}function A(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 k(e);if(!t.l(e))return;if(t.s(e))return A(S(e));let n=S(e);return n===void 0?``:typeof n==`object`&&n&&Symbol.iterator in n?k(n):A(n)}function j(e){let n=``;for(let r of e){if(t.l(r))return;if(typeof r==`string`){n+=r;continue}if(typeof r==`number`){n+=String(r);continue}return}return n}async function M(n,r){if(_(n))return await D(n,r)||R(n,r);if(t.r(n.type))return b(n.type,n.props,r);let i=x(n,r);if(i!==void 0)return i;if(t.s(n))return R(n,r);if(t.i(n,`style`)){let e=A(S(n));return{nodes:[],stylesheets:e&&e.length>0?[e]:[]}}if(typeof n.type!=`string`||t.a(n.type))return{nodes:[],stylesheets:[]};let a=L(n,r);if(t.i(n,`br`))return{nodes:[e.l({text:`
2
+ `,preset:r.presets?.span,...a})],stylesheets:[]};if(t.i(n,`img`))return{nodes:[N(n,r)],stylesheets:[]};if(t.i(n,`svg`))return{nodes:[P(n,r)],stylesheets:[]};let o=O(n);if(o!==void 0)return{nodes:[e.l({text:o,...a})],stylesheets:[]};let s=await R(n,r);return{nodes:[e.t({children:s.nodes,...a})],stylesheets:s.stylesheets}}function N(t,n){if(!t.props.src)throw Error(`Image element must have a 'src' prop.`);let r=L(t,n),i=t.props.width===void 0?void 0:Number(t.props.width),a=t.props.height===void 0?void 0:Number(t.props.height);return e.i({src:t.props.src,width:i,height:a,...r})}function P(t,n){let r=L(t,n);return e.i({src:u(t),width:t.props.width===void 0?void 0:Number(t.props.width),height:t.props.height===void 0?void 0:Number(t.props.height),...r})}function F(e,t){let n,r,i=t.presets;i&&typeof e.type==`string`&&e.type in i&&(n=i[e.type]);let a=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(a){for(let e in a)if(Object.hasOwn(a,e)){r=a;break}}return{preset:n,style:r}}function I(e,t){let n=t.tailwindClassesProperty;if(typeof e.props!=`object`||e.props===null||!(n in e.props))return;let r=e.props[n];if(typeof r==`string`)return r}function L(e,n){let r=e.props,{preset:i,style:a}=F(e,n),o=I(e,n),s=t.u(r,n.tailwindClassesProperty);return{tagName:typeof e.type==`string`?e.type:void 0,className:r.className??r.class,id:r.id,dir:r.dir,attributes:s,tw:o,style:a,preset:i}}function R(e,t){let n=S(e);return n===void 0?Promise.resolve({nodes:[],stylesheets:[]}):h(n,t)}async function z(e,t){let n=[],r=new Set,i=0;for(let a of e){let e=i;i+=1;let o=h(a,t).then(t=>{n[e]=t}).finally(()=>r.delete(o));r.add(o),r.size>=8&&await Promise.race(r)}await Promise.all(r);let a=[],o=[];for(let e of n)e&&(a.push(...e.nodes),o.push(...e.stylesheets));return{nodes:a,stylesheets:o}}exports.defaultStylePresets=t.f,exports.fromJsx=m;
@@ -1,28 +1,20 @@
1
- import { o as ReactElementLike, r as Node } from "../types-BiW26s7h.cjs";
1
+ import { o as ReactElementLike, r as Node } from "./types-BMJCiuSY.cjs";
2
2
  import { CSSProperties, JSX, ReactNode } from "react";
3
3
 
4
4
  //#region src/jsx/style-presets.d.ts
5
5
  declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
6
6
  //#endregion
7
- //#region src/jsx/markup.d.ts
8
- interface FromStaticMarkupOptions extends FromJsxOptions {}
9
- interface FromStaticMarkupResult {
10
- nodes: Node[];
11
- stylesheets: string[];
12
- }
13
- /**
14
- * Convert static HTML/SVG markup into Takumi nodes.
15
- *
16
- * This is primarily used as the React DOM Server fallback for `fromJsx()`,
17
- * but it is also exposed as a public API for callers that already have
18
- * serialized markup.
19
- *
20
- * The output preserves extracted stylesheet contents from `<style>` tags and
21
- * converts `<img>` / `<svg>` elements into Takumi image nodes.
22
- */
23
- declare function fromStaticMarkup(markup: string, options?: FromStaticMarkupOptions): FromStaticMarkupResult;
7
+ //#region src/jsx/metadata.d.ts
8
+ type HtmlProps = {
9
+ className?: string;
10
+ class?: string;
11
+ id?: string;
12
+ style?: string | CSSProperties;
13
+ dir?: string;
14
+ [key: string]: unknown;
15
+ };
24
16
  //#endregion
25
- //#region src/jsx/jsx.d.ts
17
+ //#region src/jsx/index.d.ts
26
18
  declare module "react" {
27
19
  interface DOMAttributes<T> {
28
20
  tw?: string;
@@ -50,4 +42,4 @@ interface FromJsxResult {
50
42
  }
51
43
  declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<FromJsxResult>;
52
44
  //#endregion
53
- export { FromJsxOptions, FromJsxResult, FromStaticMarkupOptions, FromStaticMarkupResult, defaultStylePresets, fromJsx, fromStaticMarkup };
45
+ export { FromJsxOptions, FromJsxResult, type HtmlProps, defaultStylePresets, fromJsx };
@@ -1,28 +1,20 @@
1
- import { o as ReactElementLike, r as Node } from "../types-Ds1Xw1hx.mjs";
1
+ import { o as ReactElementLike, r as Node } from "./types-CkIMwyWS.mjs";
2
2
  import { CSSProperties, JSX, ReactNode } from "react";
3
3
 
4
4
  //#region src/jsx/style-presets.d.ts
5
5
  declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
6
6
  //#endregion
7
- //#region src/jsx/markup.d.ts
8
- interface FromStaticMarkupOptions extends FromJsxOptions {}
9
- interface FromStaticMarkupResult {
10
- nodes: Node[];
11
- stylesheets: string[];
12
- }
13
- /**
14
- * Convert static HTML/SVG markup into Takumi nodes.
15
- *
16
- * This is primarily used as the React DOM Server fallback for `fromJsx()`,
17
- * but it is also exposed as a public API for callers that already have
18
- * serialized markup.
19
- *
20
- * The output preserves extracted stylesheet contents from `<style>` tags and
21
- * converts `<img>` / `<svg>` elements into Takumi image nodes.
22
- */
23
- declare function fromStaticMarkup(markup: string, options?: FromStaticMarkupOptions): FromStaticMarkupResult;
7
+ //#region src/jsx/metadata.d.ts
8
+ type HtmlProps = {
9
+ className?: string;
10
+ class?: string;
11
+ id?: string;
12
+ style?: string | CSSProperties;
13
+ dir?: string;
14
+ [key: string]: unknown;
15
+ };
24
16
  //#endregion
25
- //#region src/jsx/jsx.d.ts
17
+ //#region src/jsx/index.d.ts
26
18
  declare module "react" {
27
19
  interface DOMAttributes<T> {
28
20
  tw?: string;
@@ -50,4 +42,4 @@ interface FromJsxResult {
50
42
  }
51
43
  declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<FromJsxResult>;
52
44
  //#endregion
53
- export { FromJsxOptions, FromJsxResult, FromStaticMarkupOptions, FromStaticMarkupResult, defaultStylePresets, fromJsx, fromStaticMarkup };
45
+ export { FromJsxOptions, FromJsxResult, type HtmlProps, defaultStylePresets, fromJsx };
package/dist/jsx.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import{a as e,i as t,l as n,t as r}from"./helpers-6Yvy3K-3.mjs";import{a as i,c as a,d as o,f as s,i as c,l,n as u,o as d,r as f,s as p,t as m,u as h}from"./markup-KH2xSwwo.mjs";function g(e){return typeof e==`string`||typeof e==`number`}function _(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function v(e){return Object.keys(e).map(t=>`${t.replace(/([A-Z])/g,`-$1`).toLowerCase()}:${String(e[t]).trim()}`).join(`;`)}const y=new Set(`stopColor.stopOpacity.strokeWidth.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.fillRule.clipRule.colorInterpolationFilters.floodColor.floodOpacity.accentHeight.alignmentBaseline.arabicForm.baselineShift.capHeight.clipPath.clipPathUnits.colorInterpolation.colorProfile.colorRendering.enableBackground.fillOpacity.fontFamily.fontSize.fontSizeAdjust.fontStretch.fontStyle.fontVariant.fontWeight.glyphName.glyphOrientationHorizontal.glyphOrientationVertical.horizAdvX.horizOriginX.imageRendering.letterSpacing.lightingColor.markerEnd.markerMid.markerStart.overlinePosition.overlineThickness.paintOrder.preserveAspectRatio.pointerEvents.shapeRendering.strokeMiterlimit.strokeOpacity.textAnchor.textDecoration.textRendering.transformOrigin.underlinePosition.underlineThickness.unicodeBidi.unicodeRange.unitsPerEm.vectorEffect.vertAdvY.vertOriginX.vertOriginY.vAlphabetic.vHanging.vIdeographic.vMathematical.wordSpacing.writingMode`.split(`.`));function b(e,t){if(e===`children`||t==null)return;let n;if(n=e===`className`?`class`:y.has(e)?u(e):e,typeof t==`boolean`)return`${n}="${String(t)}"`;if(e===`style`&&typeof t==`object`){let e=v(t);if(e)return`style="${_(e)}"`}return`${n}="${_(String(t))}"`}function x(e){return Object.entries(e).map(([e,t])=>b(e,t)).filter(e=>e!==void 0)}const S=(e,t)=>{let n=e.props||{};if(f(e.type))return C(e.type(e.props));if(typeof e.type==`symbol`||typeof e.type!=`string`)return``;let r=x(n),i=n.children,a=Array.isArray(i)?i.map(e=>t(e)).join(``):t(i);return`<${e.type}${r.length>0?` ${r.join(` `)}`:``}>${a}</${e.type}>`},C=e=>e==null||e===!1?``:g(e)?String(e):Array.isArray(e)?e.map(C).join(``):l(e)?S(e,C):``;function w(e){let t=e.props||{};return`xmlns`in t?C(e)||``:C({...e,props:{...t,xmlns:`http://www.w3.org/2000/svg`}})||``}const T=[/Invalid hook call\./,/Cannot read properties of null \(reading 'use[A-Z][A-Za-z]+'\)/,/null is not an object \(evaluating 'dispatcher\.use[A-Z][A-Za-z]+'\)/];let E,D;async function O(t,n){let i={defaultStyles:A(n),presets:o(n?.defaultStyles),tailwindClassesProperty:n?.tailwindClassesProperty??`tw`},a=await k(t,i).catch(async e=>{if(!M(e))throw e;return await V(t,i)||k(t,i)}),s=a.nodes,c;return c=s.length===0?r({}):s.length===1&&s[0]!==void 0?s[0]:r({children:s,style:{width:e(100),height:e(100)}}),{node:c,stylesheets:a.stylesheets}}async function k(e,t){return e==null||e===!1?{nodes:[],stylesheets:[]}:e instanceof Promise?k(await e,t):typeof e==`object`&&Symbol.iterator in e?$(e,t):l(e)?await K(e,t):{nodes:[n({text:String(e),preset:t.presets?.span})],stylesheets:[]}}function A(e){return e&&`defaultStyles`in e?e.defaultStyles??s:s}function j(e){return!l(e)||typeof e.type!=`object`||e.type===null||!(`$$typeof`in e.type)?!1:e.type.$$typeof===Symbol.for(`react.context`)||e.type.$$typeof===Symbol.for(`react.provider`)}function M(e){return e instanceof Error?T.some(t=>t.test(e.message)):!1}async function N(e){let t=console.error;console.error=(...e)=>{let[n]=e;typeof n==`string`&&T.some(e=>e.test(n))||t(...e)};try{return await e()}finally{console.error=t}}async function P(e,t,n){return N(()=>k(e(t),n))}function F(e,t){if(!(typeof e.type!=`object`||e.type===null)){if(d(e.type)&&`render`in e.type){let n=e.type;return P(e=>n.render(e,null),e.props,t)}if(a(e.type)&&`type`in e.type){let n=e.type.type;return f(n)?P(n,e.props,t):K({...e,type:n},t)}}}function I(e){if(typeof e.props==`object`&&e.props!==null&&`children`in e.props)return e.props.children}function L(e){return typeof e==`object`&&!!e&&`createElement`in e&&typeof e.createElement==`function`}function R(e){return typeof e==`object`&&!!e&&`renderToStaticMarkup`in e&&typeof e.renderToStaticMarkup==`function`}async function z(){return D??=import(`react`).then(e=>{let t=e.default??e;return L(t)?t:null}).catch(()=>null),D}async function B(){return E??=import(`react-dom/server`).then(e=>{let t=e.default??e;return R(t)?t:null}).catch(()=>null),E}async function V(e,t){let[n,r]=await Promise.all([z(),B()]);return!n||!r?null:m(r.renderToStaticMarkup(n.createElement(n.Fragment??void 0,null,e)),{defaultStyles:t.defaultStyles,tailwindClassesProperty:t.tailwindClassesProperty})}function H(e){if(!l(e))return;let t=I(e);if(typeof t==`string`)return t;if(typeof t==`number`)return String(t);if(Array.isArray(t)||typeof t==`object`&&t&&Symbol.iterator in t)return G(t);if(l(t)&&p(t))return H(t)}function U(e){let t=``;for(let n of e){let e=W(n);if(e===void 0)return;t+=e}return t}function W(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 U(e);if(!l(e))return;if(p(e))return W(I(e));let t=I(e);return t===void 0?``:typeof t==`object`&&t&&Symbol.iterator in t?U(t):W(t)}function G(e){let t=``;for(let n of e){if(l(n))return;if(typeof n==`string`){t+=n;continue}if(typeof n==`number`){t+=String(n);continue}return}return t}async function K(e,t){if(j(e))return await V(e,t)||Q(e,t);if(f(e.type))return P(e.type,e.props,t);let a=F(e,t);if(a!==void 0)return a;if(p(e))return Q(e,t);if(c(e,`style`)){let t=W(I(e));return{nodes:[],stylesheets:t&&t.length>0?[t]:[]}}if(typeof e.type!=`string`||i(e.type))return{nodes:[],stylesheets:[]};let o=Z(e,t);if(c(e,`br`))return{nodes:[n({text:`
2
+ `,preset:t.presets?.span,...o})],stylesheets:[]};if(c(e,`img`))return{nodes:[q(e,t)],stylesheets:[]};if(c(e,`svg`))return{nodes:[J(e,t)],stylesheets:[]};let s=H(e);if(s!==void 0)return{nodes:[n({text:s,...o})],stylesheets:[]};let l=await Q(e,t);return{nodes:[r({children:l.nodes,...o})],stylesheets:l.stylesheets}}function q(e,n){if(!e.props.src)throw Error(`Image element must have a 'src' prop.`);let r=Z(e,n),i=e.props.width===void 0?void 0:Number(e.props.width),a=e.props.height===void 0?void 0:Number(e.props.height);return t({src:e.props.src,width:i,height:a,...r})}function J(e,n){let r=Z(e,n);return t({src:w(e),width:e.props.width===void 0?void 0:Number(e.props.width),height:e.props.height===void 0?void 0:Number(e.props.height),...r})}function Y(e,t){let n,r,i=t.presets;i&&typeof e.type==`string`&&e.type in i&&(n=i[e.type]);let a=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(a){for(let e in a)if(Object.hasOwn(a,e)){r=a;break}}return{preset:n,style:r}}function X(e,t){let n=t.tailwindClassesProperty;if(typeof e.props!=`object`||e.props===null||!(n in e.props))return;let r=e.props[n];if(typeof r==`string`)return r}function Z(e,t){let n=e.props,{preset:r,style:i}=Y(e,t),a=X(e,t),o=h(n,t.tailwindClassesProperty);return{tagName:typeof e.type==`string`?e.type:void 0,className:n.className??n.class,id:n.id,dir:n.dir,attributes:o,tw:a,style:i,preset:r}}function Q(e,t){let n=I(e);return n===void 0?Promise.resolve({nodes:[],stylesheets:[]}):k(n,t)}async function $(e,t){let n=[],r=new Set,i=0;for(let a of e){let e=i;i+=1;let o=k(a,t).then(t=>{n[e]=t}).finally(()=>r.delete(o));r.add(o),r.size>=8&&await Promise.race(r)}await Promise.all(r);let a=[],o=[];for(let e of n)e&&(a.push(...e.nodes),o.push(...e.stylesheets));return{nodes:a,stylesheets:o}}export{s as defaultStylePresets,O as fromJsx};
@@ -0,0 +1,2 @@
1
+ const e=require(`./helpers-cmaAH67r.cjs`),t={html:{display:`block`},head:{display:`none`},meta:{display:`none`},title:{display:`none`},link:{display:`none`},style:{display:`none`},script:{display:`none`},body:{margin:8,display:`block`},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`},strong:{fontWeight:`bold`},b:{fontWeight:`bold`},i:{fontStyle:`italic`},em:{fontStyle:`italic`},code:{fontFamily:`monospace`},kbd:{fontFamily:`monospace`},pre:{fontFamily:`monospace`,margin:`1em 0`,display:`block`},mark:{backgroundColor:`yellow`,color:`black`},big:{fontSize:`1.2em`},small:{fontSize:`0.8em`},s:{textDecoration:`line-through`},div:{display:`block`}};function n(e){if(e!==!1)return e??t}function r(e,t){let n={};for(let[r,i]of Object.entries(e))r===`children`||r===`className`||r===`class`||r===`id`||r===`style`||r===t||r===`ref`||r===`key`||r===`dangerouslySetInnerHTML`||r===`suppressHydrationWarning`||i==null||i===!1||typeof i==`function`||typeof i==`symbol`||typeof i!=`object`&&(n[r]=i===!0?``:String(i));if(Object.keys(n).length!==0)return n}var i=Symbol(`Fragment`),a=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),o=new Set([`script`,`style`]),s=/(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:-]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!)([\s\S]*?)(>))/gm,c=/[\@\.a-z0-9_\:\-]/i;function l(e){let t={};if(e){let n=`none`,r,i=``,a,o;for(let s=0;s<e.length;s++){let l=e[s];n===`none`?c.test(l)?(r&&(t[r]=i,r=void 0,i=``),a=s,n=`key`):l===`=`&&r&&(n=`value`):n===`key`?c.test(l)||(r=e.substring(a,s),n=l===`=`?`value`:`none`):l===o&&s>0&&e[s-1]!==`\\`?o&&(i=e.substring(a,s),o=void 0,n=`none`):(l===`"`||l===`'`)&&!o&&(a=s+1,o=l)}n===`key`&&a!=null&&a<e.length&&(r=e.substring(a,e.length)),r&&(t[r]=i)}return t}function u(e){let t=typeof e==`string`?e:e.value,n,r,i,c,u,d,f,p,m,h=[];s.lastIndex=0,r=n={type:0,children:[]};let g=0;function _(){c=t.substring(g,s.lastIndex-i[0].length),c&&r.children.push({type:2,value:c,parent:r})}for(;i=s.exec(t);){if(d=i[5]||i[8],f=i[6]||i[9],p=i[7]||i[10],o.has(r.name)&&i[2]!==r.name){u=s.lastIndex-i[0].length,r.children.length>0&&(r.children[0].value+=i[0]);continue}else if(d===`<!--`){if(u=s.lastIndex-i[0].length,o.has(r.name))continue;m={type:3,value:f,parent:r,loc:[{start:u,end:u+d.length},{start:s.lastIndex-p.length,end:s.lastIndex}]},h.push(m),m.parent.children.push(m)}else if(d===`<!`)u=s.lastIndex-i[0].length,m={type:4,value:f,parent:r,loc:[{start:u,end:u+d.length},{start:s.lastIndex-p.length,end:s.lastIndex}]},h.push(m),m.parent.children.push(m);else if(i[1]!==`/`)if(_(),o.has(r.name)){g=s.lastIndex,_();continue}else m={type:1,name:i[2]+``,attributes:l(i[3]),parent:r,children:[],loc:[{start:s.lastIndex-i[0].length,end:s.lastIndex}]},h.push(m),m.parent.children.push(m),i[4]&&i[4].indexOf(`/`)>-1||a.has(m.name)?(m.loc[1]=m.loc[0],m.isSelfClosingTag=!0):r=m;else _(),i[2]+``===r.name?(m=r,r=m.parent,m.loc.push({start:s.lastIndex-i[0].length,end:s.lastIndex}),c=t.substring(m.loc[0].end,m.loc[1].start),m.children.length===0&&m.children.push({type:2,value:c,parent:r})):i[2]+``===h[h.length-1].name&&h[h.length-1].isSelfClosingTag===!0&&(m=h[h.length-1],m.loc.push({start:s.lastIndex-i[0].length,end:s.lastIndex}));g=s.lastIndex}return c=t.slice(g),r.children.push({type:2,value:c,parent:r}),n}var d=Symbol(`HTMLString`),f=Symbol(`AttrString`),p=Symbol(`RenderFn`);function m(e,t=[d]){let n={value:e};for(let e of t)Object.defineProperty(n,e,{value:!0,enumerable:!1,writable:!1});return n}var h={"&":`&amp;`,"<":`&lt;`,">":`&gt;`};function g(e){return e.replace(/[&<>]/g,e=>h[e]||e)}function _(e){let t=``;for(let[n,r]of Object.entries(e))t+=` ${n}="${r}"`;return m(t,[d,f])}function v(e){if(e.children.length===0){let t=e;for(;t=t.parent;)if(t.name===`svg`)return!0}return!1}function y(e){let{name:t,attributes:n={}}=e,r=e.children.map(e=>b(e)).join(``);if(p in e){let t=e[p](n,m(r));return t&&t[d]?t.value:g(String(t))}if(t===i)return r;let o=v(e);return o||a.has(t)?`<${e.name}${_(n).value}${o?` /`:``}>`:`<${e.name}${_(n).value}>${r}</${e.name}>`}function b(e){switch(e.type){case 0:return e.children.map(e=>b(e)).join(``);case 1:return y(e);case 2:return`${e.value}`;case 3:return`<!--${e.value}-->`;case 4:return`<!${e.value}>`}}const x=new Set([`head`,`meta`,`link`,`style`,`script`]);function S(e){return x.has(e)}function C(e,t){return e.type===t&&`props`in e}function w(e){return e.replace(/([A-Z])/g,`-$1`).toLowerCase()}function T(e){return typeof e==`object`&&!!e&&`type`in e}function E(e){return typeof e==`function`}const D=Symbol.for(`react.forward_ref`),O=Symbol.for(`react.memo`),k=Symbol.for(`react.fragment`);function A(e){return e.$$typeof===D}function j(e){return e.$$typeof===O}function M(e){return e.type===k}function N(e,t){let r=u(e),i=[],a=[],o=n(t?.defaultStyles),s=t?.tailwindClassesProperty??`tw`;for(let e of r.children){let t=P(e,o,s);i.push(...t.nodes),a.push(...t.stylesheets)}return{nodes:i,stylesheets:a}}function P(t,n,r){if(t.type===3)return{nodes:[],stylesheets:[]};if(t.type===2){let r=t.value??``;return{nodes:r?[e.l({text:r,preset:n?.span})]:[],stylesheets:[]}}if(t.type===0)return t.children.reduce((e,t)=>{let i=P(t,n,r);return e.nodes.push(...i.nodes),e.stylesheets.push(...i.stylesheets),e},{nodes:[],stylesheets:[]});if(t.type!==1)return{nodes:[],stylesheets:[]};let i=t;if(i.name===`style`){let e=i.children.filter(e=>e.type===2&&typeof e.value==`string`).map(e=>e.value).join(``);return{nodes:[],stylesheets:e?[e]:[]}}let a=F(i,n,r);if(i.name===`br`)return{nodes:[e.l({text:`
2
+ `,preset:n?.span,...a})],stylesheets:[]};if(i.name===`img`){let t=i.attributes?.src;if(!t)throw Error(`Image element must have a 'src' prop.`);return{nodes:[e.i({src:t,width:R(i.attributes?.width),height:R(i.attributes?.height),...a})],stylesheets:[]}}if(S(i.name))return{nodes:[],stylesheets:[]};if(i.name===`svg`)return{nodes:[e.i({src:b(i),width:R(i.attributes?.width),height:R(i.attributes?.height),...a})],stylesheets:[]};let o=i.children.reduce((e,t)=>{let i=P(t,n,r);return e.nodes.push(...i.nodes),e.stylesheets.push(...i.stylesheets),e},{nodes:[],stylesheets:[]});return{nodes:[i.children.every(e=>e.type===2||e.type===3)&&o.nodes.length>0?e.l({text:o.nodes.map(e=>e.type===`text`?e.text:``).join(``),...a}):e.t({children:o.nodes,...a})],stylesheets:o.stylesheets}}function F(e,t,n){let i=e.attributes??{},a=typeof i.style==`string`?I(i.style):void 0,o=r(i,n),s=typeof i[n]==`string`?i[n]:void 0,c=t&&e.name in t?t[e.name]:void 0;return{tagName:e.name,className:i.class,id:i.id,dir:i.dir,attributes:o,tw:s,style:a,preset:c}}function I(e){let t={};for(let n of e.split(`;`)){let[e,...r]=n.split(`:`);if(!e||r.length===0)continue;let i=e.trim(),a=r.join(`:`).trim();!i||!a||(t[L(i)]=a)}return Object.keys(t).length>0?t:void 0}function L(e){return e.startsWith(`--`)?e:e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function R(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return r}});
@@ -0,0 +1,2 @@
1
+ import{i as e,l as t,t as n}from"./helpers-6Yvy3K-3.mjs";const r={html:{display:`block`},head:{display:`none`},meta:{display:`none`},title:{display:`none`},link:{display:`none`},style:{display:`none`},script:{display:`none`},body:{margin:8,display:`block`},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`},strong:{fontWeight:`bold`},b:{fontWeight:`bold`},i:{fontStyle:`italic`},em:{fontStyle:`italic`},code:{fontFamily:`monospace`},kbd:{fontFamily:`monospace`},pre:{fontFamily:`monospace`,margin:`1em 0`,display:`block`},mark:{backgroundColor:`yellow`,color:`black`},big:{fontSize:`1.2em`},small:{fontSize:`0.8em`},s:{textDecoration:`line-through`},div:{display:`block`}};function i(e){if(e!==!1)return e??r}function a(e,t){let n={};for(let[r,i]of Object.entries(e))r===`children`||r===`className`||r===`class`||r===`id`||r===`style`||r===t||r===`ref`||r===`key`||r===`dangerouslySetInnerHTML`||r===`suppressHydrationWarning`||i==null||i===!1||typeof i==`function`||typeof i==`symbol`||typeof i!=`object`&&(n[r]=i===!0?``:String(i));if(Object.keys(n).length!==0)return n}var o=Symbol(`Fragment`),s=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),c=new Set([`script`,`style`]),l=/(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:-]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!)([\s\S]*?)(>))/gm,u=/[\@\.a-z0-9_\:\-]/i;function d(e){let t={};if(e){let n=`none`,r,i=``,a,o;for(let s=0;s<e.length;s++){let c=e[s];n===`none`?u.test(c)?(r&&(t[r]=i,r=void 0,i=``),a=s,n=`key`):c===`=`&&r&&(n=`value`):n===`key`?u.test(c)||(r=e.substring(a,s),n=c===`=`?`value`:`none`):c===o&&s>0&&e[s-1]!==`\\`?o&&(i=e.substring(a,s),o=void 0,n=`none`):(c===`"`||c===`'`)&&!o&&(a=s+1,o=c)}n===`key`&&a!=null&&a<e.length&&(r=e.substring(a,e.length)),r&&(t[r]=i)}return t}function f(e){let t=typeof e==`string`?e:e.value,n,r,i,a,o,u,f,p,m,h=[];l.lastIndex=0,r=n={type:0,children:[]};let g=0;function _(){a=t.substring(g,l.lastIndex-i[0].length),a&&r.children.push({type:2,value:a,parent:r})}for(;i=l.exec(t);){if(u=i[5]||i[8],f=i[6]||i[9],p=i[7]||i[10],c.has(r.name)&&i[2]!==r.name){o=l.lastIndex-i[0].length,r.children.length>0&&(r.children[0].value+=i[0]);continue}else if(u===`<!--`){if(o=l.lastIndex-i[0].length,c.has(r.name))continue;m={type:3,value:f,parent:r,loc:[{start:o,end:o+u.length},{start:l.lastIndex-p.length,end:l.lastIndex}]},h.push(m),m.parent.children.push(m)}else if(u===`<!`)o=l.lastIndex-i[0].length,m={type:4,value:f,parent:r,loc:[{start:o,end:o+u.length},{start:l.lastIndex-p.length,end:l.lastIndex}]},h.push(m),m.parent.children.push(m);else if(i[1]!==`/`)if(_(),c.has(r.name)){g=l.lastIndex,_();continue}else m={type:1,name:i[2]+``,attributes:d(i[3]),parent:r,children:[],loc:[{start:l.lastIndex-i[0].length,end:l.lastIndex}]},h.push(m),m.parent.children.push(m),i[4]&&i[4].indexOf(`/`)>-1||s.has(m.name)?(m.loc[1]=m.loc[0],m.isSelfClosingTag=!0):r=m;else _(),i[2]+``===r.name?(m=r,r=m.parent,m.loc.push({start:l.lastIndex-i[0].length,end:l.lastIndex}),a=t.substring(m.loc[0].end,m.loc[1].start),m.children.length===0&&m.children.push({type:2,value:a,parent:r})):i[2]+``===h[h.length-1].name&&h[h.length-1].isSelfClosingTag===!0&&(m=h[h.length-1],m.loc.push({start:l.lastIndex-i[0].length,end:l.lastIndex}));g=l.lastIndex}return a=t.slice(g),r.children.push({type:2,value:a,parent:r}),n}var p=Symbol(`HTMLString`),m=Symbol(`AttrString`),h=Symbol(`RenderFn`);function g(e,t=[p]){let n={value:e};for(let e of t)Object.defineProperty(n,e,{value:!0,enumerable:!1,writable:!1});return n}var _={"&":`&amp;`,"<":`&lt;`,">":`&gt;`};function v(e){return e.replace(/[&<>]/g,e=>_[e]||e)}function y(e){let t=``;for(let[n,r]of Object.entries(e))t+=` ${n}="${r}"`;return g(t,[p,m])}function b(e){if(e.children.length===0){let t=e;for(;t=t.parent;)if(t.name===`svg`)return!0}return!1}function x(e){let{name:t,attributes:n={}}=e,r=e.children.map(e=>S(e)).join(``);if(h in e){let t=e[h](n,g(r));return t&&t[p]?t.value:v(String(t))}if(t===o)return r;let i=b(e);return i||s.has(t)?`<${e.name}${y(n).value}${i?` /`:``}>`:`<${e.name}${y(n).value}>${r}</${e.name}>`}function S(e){switch(e.type){case 0:return e.children.map(e=>S(e)).join(``);case 1:return x(e);case 2:return`${e.value}`;case 3:return`<!--${e.value}-->`;case 4:return`<!${e.value}>`}}const C=new Set([`head`,`meta`,`link`,`style`,`script`]);function w(e){return C.has(e)}function T(e,t){return e.type===t&&`props`in e}function E(e){return e.replace(/([A-Z])/g,`-$1`).toLowerCase()}function D(e){return typeof e==`object`&&!!e&&`type`in e}function O(e){return typeof e==`function`}const k=Symbol.for(`react.forward_ref`),A=Symbol.for(`react.memo`),j=Symbol.for(`react.fragment`);function M(e){return e.$$typeof===k}function N(e){return e.$$typeof===A}function P(e){return e.type===j}function F(e,t){let n=f(e),r=[],a=[],o=i(t?.defaultStyles),s=t?.tailwindClassesProperty??`tw`;for(let e of n.children){let t=I(e,o,s);r.push(...t.nodes),a.push(...t.stylesheets)}return{nodes:r,stylesheets:a}}function I(r,i,a){if(r.type===3)return{nodes:[],stylesheets:[]};if(r.type===2){let e=r.value??``;return{nodes:e?[t({text:e,preset:i?.span})]:[],stylesheets:[]}}if(r.type===0)return r.children.reduce((e,t)=>{let n=I(t,i,a);return e.nodes.push(...n.nodes),e.stylesheets.push(...n.stylesheets),e},{nodes:[],stylesheets:[]});if(r.type!==1)return{nodes:[],stylesheets:[]};let o=r;if(o.name===`style`){let e=o.children.filter(e=>e.type===2&&typeof e.value==`string`).map(e=>e.value).join(``);return{nodes:[],stylesheets:e?[e]:[]}}let s=L(o,i,a);if(o.name===`br`)return{nodes:[t({text:`
2
+ `,preset:i?.span,...s})],stylesheets:[]};if(o.name===`img`){let t=o.attributes?.src;if(!t)throw Error(`Image element must have a 'src' prop.`);return{nodes:[e({src:t,width:B(o.attributes?.width),height:B(o.attributes?.height),...s})],stylesheets:[]}}if(w(o.name))return{nodes:[],stylesheets:[]};if(o.name===`svg`)return{nodes:[e({src:S(o),width:B(o.attributes?.width),height:B(o.attributes?.height),...s})],stylesheets:[]};let c=o.children.reduce((e,t)=>{let n=I(t,i,a);return e.nodes.push(...n.nodes),e.stylesheets.push(...n.stylesheets),e},{nodes:[],stylesheets:[]});return{nodes:[o.children.every(e=>e.type===2||e.type===3)&&c.nodes.length>0?t({text:c.nodes.map(e=>e.type===`text`?e.text:``).join(``),...s}):n({children:c.nodes,...s})],stylesheets:c.stylesheets}}function L(e,t,n){let r=e.attributes??{},i=typeof r.style==`string`?R(r.style):void 0,o=a(r,n),s=typeof r[n]==`string`?r[n]:void 0,c=t&&e.name in t?t[e.name]:void 0;return{tagName:e.name,className:r.class,id:r.id,dir:r.dir,attributes:o,tw:s,style:i,preset:c}}function R(e){let t={};for(let n of e.split(`;`)){let[e,...r]=n.split(`:`);if(!e||r.length===0)continue;let i=e.trim(),a=r.join(`:`).trim();!i||!a||(t[z(i)]=a)}return Object.keys(t).length>0?t:void 0}function z(e){return e.startsWith(`--`)?e:e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function B(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}export{w as a,N as c,i as d,r as f,T as i,D as l,E as n,M as o,O as r,P as s,F as t,a as u};
@@ -11,6 +11,7 @@ type NodeMetadata = {
11
11
  tagName?: string;
12
12
  className?: string;
13
13
  id?: string;
14
+ dir?: "ltr" | "rtl";
14
15
  attributes?: NodeAttributes;
15
16
  tw?: string;
16
17
  style?: CSSProperties;
@@ -27,7 +28,7 @@ type TextNode = NodeMetadata & {
27
28
  };
28
29
  type ImageNode = NodeMetadata & {
29
30
  type: "image";
30
- src: string;
31
+ src: string | Uint8Array | ArrayBuffer;
31
32
  width?: number;
32
33
  height?: number;
33
34
  };
@@ -11,6 +11,7 @@ type NodeMetadata = {
11
11
  tagName?: string;
12
12
  className?: string;
13
13
  id?: string;
14
+ dir?: "ltr" | "rtl";
14
15
  attributes?: NodeAttributes;
15
16
  tw?: string;
16
17
  style?: CSSProperties;
@@ -27,7 +28,7 @@ type TextNode = NodeMetadata & {
27
28
  };
28
29
  type ImageNode = NodeMetadata & {
29
30
  type: "image";
30
- src: string;
31
+ src: string | Uint8Array | ArrayBuffer;
31
32
  width?: number;
32
33
  height?: number;
33
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takumi-rs/helpers",
3
- "version": "1.0.0-rc.9",
3
+ "version": "1.0.0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "author": {
6
6
  "name": "Kane Wang",
@@ -24,11 +24,17 @@
24
24
  "require": "./dist/index.cjs",
25
25
  "default": "./dist/index.mjs"
26
26
  },
27
+ "./html": {
28
+ "types": "./dist/html.d.mts",
29
+ "import": "./dist/html.mjs",
30
+ "require": "./dist/html.cjs",
31
+ "default": "./dist/html.mjs"
32
+ },
27
33
  "./jsx": {
28
- "types": "./dist/jsx/jsx.d.mts",
29
- "import": "./dist/jsx/jsx.mjs",
30
- "require": "./dist/jsx/jsx.cjs",
31
- "default": "./dist/jsx/jsx.mjs"
34
+ "types": "./dist/jsx.d.mts",
35
+ "import": "./dist/jsx.mjs",
36
+ "require": "./dist/jsx.cjs",
37
+ "default": "./dist/jsx.mjs"
32
38
  },
33
39
  "./emoji": {
34
40
  "types": "./dist/emoji.d.mts",
@@ -40,9 +46,6 @@
40
46
  "scripts": {
41
47
  "build": "tsdown"
42
48
  },
43
- "dependencies": {
44
- "ultrahtml": "^1.6.0"
45
- },
46
49
  "devDependencies": {
47
50
  "@types/bun": "catalog:",
48
51
  "@types/react": "catalog:",
@@ -51,10 +54,11 @@
51
54
  "react": "catalog:",
52
55
  "react-dom": "catalog:",
53
56
  "tsdown": "catalog:",
54
- "typescript": "catalog:"
57
+ "typescript": "catalog:",
58
+ "ultrahtml": "^1.6.0"
55
59
  },
56
60
  "peerDependencies": {
57
- "react": "^18.0.0 || ^19.0.0",
61
+ "react": "^19.2.5",
58
62
  "react-dom": "^18.0.0 || ^19.0.0"
59
63
  },
60
64
  "peerDependenciesMeta": {
@@ -1 +0,0 @@
1
- function e(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function t(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function n(e,t){t.tagName!==void 0&&(e.tagName=t.tagName),t.className!==void 0&&(e.className=t.className),t.id!==void 0&&(e.id=t.id),t.attributes!==void 0&&(e.attributes=t.attributes)}function r(r){let i={type:`container`,children:r.children};return r.tw&&(i.tw=r.tw),n(i,r),t(i,r.preset),e(i,r.style),i}function i(r,i){if(typeof r==`string`){let t={type:`text`,text:r};return e(t,i),t}let a={type:`text`,text:r.text};return r.tw&&(a.tw=r.tw),n(a,r),t(a,r.preset),e(a,i??r.style),a}function a(r){let i={type:`image`,src:r.src,width:r.width,height:r.height};return r.tw&&(i.tw=r.tw),n(i,r),t(i,r.preset),e(i,r.style),i}function o(e){return e}function s(e){return`${e}%`}function c(e){return`${e}vw`}function l(e){return`${e}vh`}function u(e){return`${e}em`}function d(e){return`${e}rem`}function f(e){return`${e}fr`}function p(e,t,n,r=1){return`rgb(${e} ${t} ${n} / ${r})`}export{s as a,o as c,c as d,a as i,i as l,u as n,d as o,f as r,p as s,r as t,l as u};
@@ -1 +0,0 @@
1
- function e(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function t(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function n(e,t){t.tagName!==void 0&&(e.tagName=t.tagName),t.className!==void 0&&(e.className=t.className),t.id!==void 0&&(e.id=t.id),t.attributes!==void 0&&(e.attributes=t.attributes)}function r(r){let i={type:`container`,children:r.children};return r.tw&&(i.tw=r.tw),n(i,r),t(i,r.preset),e(i,r.style),i}function i(r,i){if(typeof r==`string`){let t={type:`text`,text:r};return e(t,i),t}let a={type:`text`,text:r.text};return r.tw&&(a.tw=r.tw),n(a,r),t(a,r.preset),e(a,i??r.style),a}function a(r){let i={type:`image`,src:r.src,width:r.width,height:r.height};return r.tw&&(i.tw=r.tw),n(i,r),t(i,r.preset),e(i,r.style),i}function o(e){return e}function s(e){return`${e}%`}function c(e){return`${e}vw`}function l(e){return`${e}vh`}function u(e){return`${e}em`}function d(e){return`${e}rem`}function f(e){return`${e}fr`}function p(e,t,n,r=1){return`rgb(${e} ${t} ${n} / ${r})`}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return l}});
package/dist/jsx/jsx.cjs DELETED
@@ -1,3 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../helpers-YexC8ywm.cjs`);let t=require(`ultrahtml`);const n={html:{display:`block`},head:{display:`none`},meta:{display:`none`},title:{display:`none`},link:{display:`none`},style:{display:`none`},script:{display:`none`},body:{margin:8,display:`block`},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`},strong:{fontWeight:`bold`},b:{fontWeight:`bold`},i:{fontStyle:`italic`},em:{fontStyle:`italic`},code:{fontFamily:`monospace`},kbd:{fontFamily:`monospace`},pre:{fontFamily:`monospace`,margin:`1em 0`,display:`block`},mark:{backgroundColor:`yellow`,color:`black`},big:{fontSize:`1.2em`},small:{fontSize:`0.8em`},s:{textDecoration:`line-through`},div:{display:`block`}},r=new Set([`head`,`meta`,`link`,`style`,`script`]);function i(e){return r.has(e)}function a(e,t){return e.type===t&&`props`in e}function o(e){return e.replace(/([A-Z])/g,`-$1`).toLowerCase()}function s(e){return typeof e==`object`&&!!e&&`type`in e}function c(e){return typeof e==`function`}const l=Symbol.for(`react.forward_ref`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.fragment`);function f(e){return e.$$typeof===l}function p(e){return e.$$typeof===u}function m(e){return e.type===d}function h(e,n){let r=(0,t.parse)(e),i=[],a=[],o=S(n),s=n?.tailwindClassesProperty??`tw`;for(let e of r.children){let t=g(e,o,s);i.push(...t.nodes),a.push(...t.stylesheets)}return{nodes:i,stylesheets:a}}function g(n,r,a){if(n.type===t.COMMENT_NODE)return{nodes:[],stylesheets:[]};if(n.type===t.TEXT_NODE){let t=n.value??``;return{nodes:t?[e.l({text:t,preset:r?.span})]:[],stylesheets:[]}}if(n.type===t.DOCUMENT_NODE)return n.children.reduce((e,t)=>{let n=g(t,r,a);return e.nodes.push(...n.nodes),e.stylesheets.push(...n.stylesheets),e},{nodes:[],stylesheets:[]});if(n.type!==t.ELEMENT_NODE)return{nodes:[],stylesheets:[]};let o=n;if(o.name===`style`){let e=o.children.filter(e=>e.type===t.TEXT_NODE&&typeof e.value==`string`).map(e=>e.value).join(``);return{nodes:[],stylesheets:e?[e]:[]}}let s=_(o,r,a);if(o.name===`br`)return{nodes:[e.l({text:`
2
- `,preset:r?.span,...s})],stylesheets:[]};if(o.name===`img`){let t=o.attributes?.src;if(!t)throw Error(`Image element must have a 'src' prop.`);return{nodes:[e.i({src:t,width:x(o.attributes?.width),height:x(o.attributes?.height),...s})],stylesheets:[]}}if(i(o.name))return{nodes:[],stylesheets:[]};if(o.name===`svg`)return{nodes:[e.i({src:(0,t.renderSync)(o),width:x(o.attributes?.width),height:x(o.attributes?.height),...s})],stylesheets:[]};let c=o.children.reduce((e,t)=>{let n=g(t,r,a);return e.nodes.push(...n.nodes),e.stylesheets.push(...n.stylesheets),e},{nodes:[],stylesheets:[]});return{nodes:[o.children.every(e=>e.type===t.TEXT_NODE||e.type===t.COMMENT_NODE)&&c.nodes.length>0?e.l({text:c.nodes.map(e=>e.type===`text`?e.text:``).join(``),...s}):e.t({children:c.nodes,...s})],stylesheets:c.stylesheets}}function _(e,t,n){let r=e.attributes??{},i=typeof r.style==`string`?y(r.style):void 0,a=v(r,n),o=typeof r[n]==`string`?r[n]:void 0,s=t&&e.name in t?t[e.name]:void 0;return{tagName:e.name,className:r.class,id:r.id,attributes:a,tw:o,style:i,preset:s}}function v(e,t){let n={};for(let[r,i]of Object.entries(e))r===`children`||r===`className`||r===`class`||r===`id`||r===`style`||r===t||r===`ref`||r===`key`||r===`dangerouslySetInnerHTML`||r===`suppressHydrationWarning`||i==null||i===!1||typeof i==`function`||typeof i==`symbol`||typeof i!=`object`&&(n[r]=i===!0?``:String(i));return Object.keys(n).length>0?n:void 0}function y(e){let t={};for(let n of e.split(`;`)){let[e,...r]=n.split(`:`);if(!e||r.length===0)continue;let i=e.trim(),a=r.join(`:`).trim();!i||!a||(t[b(i)]=a)}return Object.keys(t).length>0?t:void 0}function b(e){return e.startsWith(`--`)?e:e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function x(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function S(e){if(e?.defaultStyles!==!1)return e?.defaultStyles??n}function C(e){return typeof e==`string`||typeof e==`number`}function w(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function T(e){return Object.keys(e).map(t=>`${t.replace(/([A-Z])/g,`-$1`).toLowerCase()}:${String(e[t]).trim()}`).join(`;`)}const E=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`.split(`.`));function ee(e,t){if(e===`children`||t==null)return;let n;if(n=e===`className`?`class`:E.has(e)?o(e):e,typeof t==`boolean`)return`${n}="${String(t)}"`;if(e===`style`&&typeof t==`object`){let e=T(t);if(e)return`style="${w(e)}"`}return`${n}="${w(String(t))}"`}function te(e){return Object.entries(e).map(([e,t])=>ee(e,t)).filter(e=>e!==void 0)}const ne=(e,t)=>{let n=e.props||{};if(c(e.type))return D(e.type(e.props));if(typeof e.type==`symbol`||typeof e.type!=`string`)return``;let r=te(n),i=n.children,a=Array.isArray(i)?i.map(e=>t(e)).join(``):t(i);return`<${e.type}${r.length>0?` ${r.join(` `)}`:``}>${a}</${e.type}>`},D=e=>e==null||e===!1?``:C(e)?String(e):Array.isArray(e)?e.map(D).join(``):s(e)?ne(e,D):``;function O(e){let t=e.props||{};return`xmlns`in t?D(e)||``:D({...e,props:{...t,xmlns:`http://www.w3.org/2000/svg`}})||``}const k=[/Invalid hook call\./,/Cannot read properties of null \(reading 'use[A-Z][A-Za-z]+'\)/,/null is not an object \(evaluating 'dispatcher\.use[A-Z][A-Za-z]+'\)/];let A,j;async function M(t,n){let r={defaultStyles:I(n),presets:F(n),tailwindClassesProperty:n?.tailwindClassesProperty??`tw`},i=await N(t,r).catch(async e=>{if(!R(e))throw e;return await K(t,r)||N(t,r)}),a=i.nodes,o;return o=a.length===0?e.t({}):a.length===1&&a[0]!==void 0?a[0]:e.t({children:a,style:{width:e.a(100),height:e.a(100)}}),{node:o,stylesheets:i.stylesheets}}async function N(t,n){return t==null||t===!1?{nodes:[],stylesheets:[]}:t instanceof Promise?N(await t,n):typeof t==`object`&&Symbol.iterator in t?ce(t,n):s(t)?await Z(t,n):{nodes:[e.l({text:String(t),preset:n.presets?.span})],stylesheets:[]}}function P(e,t){let n={};for(let[r,i]of Object.entries(e))r===`children`||r===`className`||r===`class`||r===`id`||r===`style`||r===t||r===`ref`||r===`key`||r===`dangerouslySetInnerHTML`||r===`suppressHydrationWarning`||i==null||i===!1||typeof i==`function`||typeof i==`symbol`||typeof i!=`object`&&(n[r]=i===!0?``:String(i));if(Object.keys(n).length!==0)return n}function F(e){if(e?.defaultStyles!==!1)return e?.defaultStyles??n}function I(e){return e&&`defaultStyles`in e?e.defaultStyles??n:n}function L(e){return!s(e)||typeof e.type!=`object`||e.type===null||!(`$$typeof`in e.type)?!1:e.type.$$typeof===Symbol.for(`react.context`)||e.type.$$typeof===Symbol.for(`react.provider`)}function R(e){return e instanceof Error?k.some(t=>t.test(e.message)):!1}async function z(e){let t=console.error;console.error=(...e)=>{let[n]=e;typeof n==`string`&&k.some(e=>e.test(n))||t(...e)};try{return await e()}finally{console.error=t}}async function B(e,t,n){return z(()=>N(e(t),n))}function V(e,t){if(!(typeof e.type!=`object`||e.type===null)){if(f(e.type)&&`render`in e.type){let n=e.type;return B(e=>n.render(e,null),e.props,t)}if(p(e.type)&&`type`in e.type){let n=e.type.type;return c(n)?B(n,e.props,t):Z({...e,type:n},t)}}}function H(e){if(typeof e.props==`object`&&e.props!==null&&`children`in e.props)return e.props.children}function re(e){return typeof e==`object`&&!!e&&`createElement`in e&&typeof e.createElement==`function`}function U(e){return typeof e==`object`&&!!e&&`renderToStaticMarkup`in e&&typeof e.renderToStaticMarkup==`function`}async function W(){return j??=import(`react`).then(e=>{let t=e.default??e;return re(t)?t:null}).catch(()=>null),j}async function G(){return A??=import(`react-dom/server`).then(e=>{let t=e.default??e;return U(t)?t:null}).catch(()=>null),A}async function K(e,t){let[n,r]=await Promise.all([W(),G()]);return!n||!r?null:h(r.renderToStaticMarkup(n.createElement(n.Fragment??void 0,null,e)),{defaultStyles:t.defaultStyles,tailwindClassesProperty:t.tailwindClassesProperty})}function q(e){if(!s(e))return;let t=H(e);if(typeof t==`string`)return t;if(typeof t==`number`)return String(t);if(Array.isArray(t)||typeof t==`object`&&t&&Symbol.iterator in t)return X(t);if(s(t)&&m(t))return q(t)}function J(e){let t=``;for(let n of e){let e=Y(n);if(e===void 0)return;t+=e}return t}function Y(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(!s(e))return;if(m(e))return Y(H(e));let t=H(e);return t===void 0?``:typeof t==`object`&&t&&Symbol.iterator in t?J(t):Y(t)}function X(e){let t=``;for(let n of e){if(s(n))return;if(typeof n==`string`){t+=n;continue}if(typeof n==`number`){t+=String(n);continue}return}return t}async function Z(t,n){if(L(t))return await K(t,n)||$(t,n);if(c(t.type))return B(t.type,t.props,n);let r=V(t,n);if(r!==void 0)return r;if(m(t))return $(t,n);if(a(t,`style`)){let e=Y(H(t));return{nodes:[],stylesheets:e&&e.length>0?[e]:[]}}if(typeof t.type!=`string`||i(t.type))return{nodes:[],stylesheets:[]};let o=Q(t,n);if(a(t,`br`))return{nodes:[e.l({text:`
3
- `,preset:n.presets?.span,...o})],stylesheets:[]};if(a(t,`img`))return{nodes:[ie(t,n)],stylesheets:[]};if(a(t,`svg`))return{nodes:[ae(t,n)],stylesheets:[]};let s=q(t);if(s!==void 0)return{nodes:[e.l({text:s,...o})],stylesheets:[]};let l=await $(t,n);return{nodes:[e.t({children:l.nodes,...o})],stylesheets:l.stylesheets}}function ie(t,n){if(!t.props.src)throw Error(`Image element must have a 'src' prop.`);let r=Q(t,n),i=t.props.width===void 0?void 0:Number(t.props.width),a=t.props.height===void 0?void 0:Number(t.props.height);return e.i({src:t.props.src,width:i,height:a,...r})}function ae(t,n){let r=Q(t,n);return e.i({src:O(t),width:t.props.width===void 0?void 0:Number(t.props.width),height:t.props.height===void 0?void 0:Number(t.props.height),...r})}function oe(e,t){let n,r,i=t.presets;i&&typeof e.type==`string`&&e.type in i&&(n=i[e.type]);let a=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(a){for(let e in a)if(Object.hasOwn(a,e)){r=a;break}}return{preset:n,style:r}}function se(e,t){let n=t.tailwindClassesProperty;if(typeof e.props!=`object`||e.props===null||!(n in e.props))return;let r=e.props[n];if(typeof r==`string`)return r}function Q(e,t){let n=e.props,{preset:r,style:i}=oe(e,t),a=se(e,t),o=P(n,t.tailwindClassesProperty);return{tagName:typeof e.type==`string`?e.type:void 0,className:n.className??n.class,id:n.id,attributes:o,tw:a,style:i,preset:r}}function $(e,t){let n=H(e);return n===void 0?Promise.resolve({nodes:[],stylesheets:[]}):N(n,t)}async function ce(e,t){let n=[],r=new Set,i=0;for(let a of e){let e=i;i+=1;let o=N(a,t).then(t=>{n[e]=t}).finally(()=>r.delete(o));r.add(o),r.size>=8&&await Promise.race(r)}await Promise.all(r);let a=[],o=[];for(let e of n)e&&(a.push(...e.nodes),o.push(...e.stylesheets));return{nodes:a,stylesheets:o}}exports.defaultStylePresets=n,exports.fromJsx=M,exports.fromStaticMarkup=h;
package/dist/jsx/jsx.mjs DELETED
@@ -1,3 +0,0 @@
1
- import{a as e,i as t,l as n,t as r}from"../helpers-DrCXPa0N.mjs";import{COMMENT_NODE as i,DOCUMENT_NODE as a,ELEMENT_NODE as o,TEXT_NODE as s,parse as c,renderSync as ee}from"ultrahtml";const l={html:{display:`block`},head:{display:`none`},meta:{display:`none`},title:{display:`none`},link:{display:`none`},style:{display:`none`},script:{display:`none`},body:{margin:8,display:`block`},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`},strong:{fontWeight:`bold`},b:{fontWeight:`bold`},i:{fontStyle:`italic`},em:{fontStyle:`italic`},code:{fontFamily:`monospace`},kbd:{fontFamily:`monospace`},pre:{fontFamily:`monospace`,margin:`1em 0`,display:`block`},mark:{backgroundColor:`yellow`,color:`black`},big:{fontSize:`1.2em`},small:{fontSize:`0.8em`},s:{textDecoration:`line-through`},div:{display:`block`}},u=new Set([`head`,`meta`,`link`,`style`,`script`]);function d(e){return u.has(e)}function f(e,t){return e.type===t&&`props`in e}function p(e){return e.replace(/([A-Z])/g,`-$1`).toLowerCase()}function m(e){return typeof e==`object`&&!!e&&`type`in e}function h(e){return typeof e==`function`}const g=Symbol.for(`react.forward_ref`),_=Symbol.for(`react.memo`),v=Symbol.for(`react.fragment`);function y(e){return e.$$typeof===g}function b(e){return e.$$typeof===_}function x(e){return e.type===v}function S(e,t){let n=c(e),r=[],i=[],a=D(t),o=t?.tailwindClassesProperty??`tw`;for(let e of n.children){let t=C(e,a,o);r.push(...t.nodes),i.push(...t.stylesheets)}return{nodes:r,stylesheets:i}}function C(e,c,l){if(e.type===i)return{nodes:[],stylesheets:[]};if(e.type===s){let t=e.value??``;return{nodes:t?[n({text:t,preset:c?.span})]:[],stylesheets:[]}}if(e.type===a)return e.children.reduce((e,t)=>{let n=C(t,c,l);return e.nodes.push(...n.nodes),e.stylesheets.push(...n.stylesheets),e},{nodes:[],stylesheets:[]});if(e.type!==o)return{nodes:[],stylesheets:[]};let u=e;if(u.name===`style`){let e=u.children.filter(e=>e.type===s&&typeof e.value==`string`).map(e=>e.value).join(``);return{nodes:[],stylesheets:e?[e]:[]}}let f=te(u,c,l);if(u.name===`br`)return{nodes:[n({text:`
2
- `,preset:c?.span,...f})],stylesheets:[]};if(u.name===`img`){let e=u.attributes?.src;if(!e)throw Error(`Image element must have a 'src' prop.`);return{nodes:[t({src:e,width:E(u.attributes?.width),height:E(u.attributes?.height),...f})],stylesheets:[]}}if(d(u.name))return{nodes:[],stylesheets:[]};if(u.name===`svg`)return{nodes:[t({src:ee(u),width:E(u.attributes?.width),height:E(u.attributes?.height),...f})],stylesheets:[]};let p=u.children.reduce((e,t)=>{let n=C(t,c,l);return e.nodes.push(...n.nodes),e.stylesheets.push(...n.stylesheets),e},{nodes:[],stylesheets:[]});return{nodes:[u.children.every(e=>e.type===s||e.type===i)&&p.nodes.length>0?n({text:p.nodes.map(e=>e.type===`text`?e.text:``).join(``),...f}):r({children:p.nodes,...f})],stylesheets:p.stylesheets}}function te(e,t,n){let r=e.attributes??{},i=typeof r.style==`string`?T(r.style):void 0,a=w(r,n),o=typeof r[n]==`string`?r[n]:void 0,s=t&&e.name in t?t[e.name]:void 0;return{tagName:e.name,className:r.class,id:r.id,attributes:a,tw:o,style:i,preset:s}}function w(e,t){let n={};for(let[r,i]of Object.entries(e))r===`children`||r===`className`||r===`class`||r===`id`||r===`style`||r===t||r===`ref`||r===`key`||r===`dangerouslySetInnerHTML`||r===`suppressHydrationWarning`||i==null||i===!1||typeof i==`function`||typeof i==`symbol`||typeof i!=`object`&&(n[r]=i===!0?``:String(i));return Object.keys(n).length>0?n:void 0}function T(e){let t={};for(let n of e.split(`;`)){let[e,...r]=n.split(`:`);if(!e||r.length===0)continue;let i=e.trim(),a=r.join(`:`).trim();!i||!a||(t[ne(i)]=a)}return Object.keys(t).length>0?t:void 0}function ne(e){return e.startsWith(`--`)?e:e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function E(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function D(e){if(e?.defaultStyles!==!1)return e?.defaultStyles??l}function O(e){return typeof e==`string`||typeof e==`number`}function k(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function re(e){return Object.keys(e).map(t=>`${t.replace(/([A-Z])/g,`-$1`).toLowerCase()}:${String(e[t]).trim()}`).join(`;`)}const ie=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`.split(`.`));function ae(e,t){if(e===`children`||t==null)return;let n;if(n=e===`className`?`class`:ie.has(e)?p(e):e,typeof t==`boolean`)return`${n}="${String(t)}"`;if(e===`style`&&typeof t==`object`){let e=re(t);if(e)return`style="${k(e)}"`}return`${n}="${k(String(t))}"`}function oe(e){return Object.entries(e).map(([e,t])=>ae(e,t)).filter(e=>e!==void 0)}const A=(e,t)=>{let n=e.props||{};if(h(e.type))return j(e.type(e.props));if(typeof e.type==`symbol`||typeof e.type!=`string`)return``;let r=oe(n),i=n.children,a=Array.isArray(i)?i.map(e=>t(e)).join(``):t(i);return`<${e.type}${r.length>0?` ${r.join(` `)}`:``}>${a}</${e.type}>`},j=e=>e==null||e===!1?``:O(e)?String(e):Array.isArray(e)?e.map(j).join(``):m(e)?A(e,j):``;function M(e){let t=e.props||{};return`xmlns`in t?j(e)||``:j({...e,props:{...t,xmlns:`http://www.w3.org/2000/svg`}})||``}const N=[/Invalid hook call\./,/Cannot read properties of null \(reading 'use[A-Z][A-Za-z]+'\)/,/null is not an object \(evaluating 'dispatcher\.use[A-Z][A-Za-z]+'\)/];let P,F;async function I(t,n){let i={defaultStyles:B(n),presets:z(n),tailwindClassesProperty:n?.tailwindClassesProperty??`tw`},a=await L(t,i).catch(async e=>{if(!H(e))throw e;return await q(t,i)||L(t,i)}),o=a.nodes,s;return s=o.length===0?r({}):o.length===1&&o[0]!==void 0?o[0]:r({children:o,style:{width:e(100),height:e(100)}}),{node:s,stylesheets:a.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?ge(e,t):m(e)?await Z(e,t):{nodes:[n({text:String(e),preset:t.presets?.span})],stylesheets:[]}}function R(e,t){let n={};for(let[r,i]of Object.entries(e))r===`children`||r===`className`||r===`class`||r===`id`||r===`style`||r===t||r===`ref`||r===`key`||r===`dangerouslySetInnerHTML`||r===`suppressHydrationWarning`||i==null||i===!1||typeof i==`function`||typeof i==`symbol`||typeof i!=`object`&&(n[r]=i===!0?``:String(i));if(Object.keys(n).length!==0)return n}function z(e){if(e?.defaultStyles!==!1)return e?.defaultStyles??l}function B(e){return e&&`defaultStyles`in e?e.defaultStyles??l:l}function V(e){return!m(e)||typeof e.type!=`object`||e.type===null||!(`$$typeof`in e.type)?!1:e.type.$$typeof===Symbol.for(`react.context`)||e.type.$$typeof===Symbol.for(`react.provider`)}function H(e){return e instanceof Error?N.some(t=>t.test(e.message)):!1}async function U(e){let t=console.error;console.error=(...e)=>{let[n]=e;typeof n==`string`&&N.some(e=>e.test(n))||t(...e)};try{return await e()}finally{console.error=t}}async function W(e,t,n){return U(()=>L(e(t),n))}function se(e,t){if(!(typeof e.type!=`object`||e.type===null)){if(y(e.type)&&`render`in e.type){let n=e.type;return W(e=>n.render(e,null),e.props,t)}if(b(e.type)&&`type`in e.type){let n=e.type.type;return h(n)?W(n,e.props,t):Z({...e,type:n},t)}}}function G(e){if(typeof e.props==`object`&&e.props!==null&&`children`in e.props)return e.props.children}function K(e){return typeof e==`object`&&!!e&&`createElement`in e&&typeof e.createElement==`function`}function ce(e){return typeof e==`object`&&!!e&&`renderToStaticMarkup`in e&&typeof e.renderToStaticMarkup==`function`}async function le(){return F??=import(`react`).then(e=>{let t=e.default??e;return K(t)?t:null}).catch(()=>null),F}async function ue(){return P??=import(`react-dom/server`).then(e=>{let t=e.default??e;return ce(t)?t:null}).catch(()=>null),P}async function q(e,t){let[n,r]=await Promise.all([le(),ue()]);return!n||!r?null:S(r.renderToStaticMarkup(n.createElement(n.Fragment??void 0,null,e)),{defaultStyles:t.defaultStyles,tailwindClassesProperty:t.tailwindClassesProperty})}function J(e){if(!m(e))return;let t=G(e);if(typeof t==`string`)return t;if(typeof t==`number`)return String(t);if(Array.isArray(t)||typeof t==`object`&&t&&Symbol.iterator in t)return de(t);if(m(t)&&x(t))return J(t)}function Y(e){let t=``;for(let n of e){let e=X(n);if(e===void 0)return;t+=e}return t}function X(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 Y(e);if(!m(e))return;if(x(e))return X(G(e));let t=G(e);return t===void 0?``:typeof t==`object`&&t&&Symbol.iterator in t?Y(t):X(t)}function de(e){let t=``;for(let n of e){if(m(n))return;if(typeof n==`string`){t+=n;continue}if(typeof n==`number`){t+=String(n);continue}return}return t}async function Z(e,t){if(V(e))return await q(e,t)||$(e,t);if(h(e.type))return W(e.type,e.props,t);let i=se(e,t);if(i!==void 0)return i;if(x(e))return $(e,t);if(f(e,`style`)){let t=X(G(e));return{nodes:[],stylesheets:t&&t.length>0?[t]:[]}}if(typeof e.type!=`string`||d(e.type))return{nodes:[],stylesheets:[]};let a=Q(e,t);if(f(e,`br`))return{nodes:[n({text:`
3
- `,preset:t.presets?.span,...a})],stylesheets:[]};if(f(e,`img`))return{nodes:[fe(e,t)],stylesheets:[]};if(f(e,`svg`))return{nodes:[pe(e,t)],stylesheets:[]};let o=J(e);if(o!==void 0)return{nodes:[n({text:o,...a})],stylesheets:[]};let s=await $(e,t);return{nodes:[r({children:s.nodes,...a})],stylesheets:s.stylesheets}}function fe(e,n){if(!e.props.src)throw Error(`Image element must have a 'src' prop.`);let r=Q(e,n),i=e.props.width===void 0?void 0:Number(e.props.width),a=e.props.height===void 0?void 0:Number(e.props.height);return t({src:e.props.src,width:i,height:a,...r})}function pe(e,n){let r=Q(e,n);return t({src:M(e),width:e.props.width===void 0?void 0:Number(e.props.width),height:e.props.height===void 0?void 0:Number(e.props.height),...r})}function me(e,t){let n,r,i=t.presets;i&&typeof e.type==`string`&&e.type in i&&(n=i[e.type]);let a=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(a){for(let e in a)if(Object.hasOwn(a,e)){r=a;break}}return{preset:n,style:r}}function he(e,t){let n=t.tailwindClassesProperty;if(typeof e.props!=`object`||e.props===null||!(n in e.props))return;let r=e.props[n];if(typeof r==`string`)return r}function Q(e,t){let n=e.props,{preset:r,style:i}=me(e,t),a=he(e,t),o=R(n,t.tailwindClassesProperty);return{tagName:typeof e.type==`string`?e.type:void 0,className:n.className??n.class,id:n.id,attributes:o,tw:a,style:i,preset:r}}function $(e,t){let n=G(e);return n===void 0?Promise.resolve({nodes:[],stylesheets:[]}):L(n,t)}async function ge(e,t){let n=[],r=new Set,i=0;for(let a of e){let e=i;i+=1;let o=L(a,t).then(t=>{n[e]=t}).finally(()=>r.delete(o));r.add(o),r.size>=8&&await Promise.race(r)}await Promise.all(r);let a=[],o=[];for(let e of n)e&&(a.push(...e.nodes),o.push(...e.stylesheets));return{nodes:a,stylesheets:o}}export{l as defaultStylePresets,I as fromJsx,S as fromStaticMarkup};