@takumi-rs/helpers 2.2.3 → 2.3.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.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as Node } from "./types-BwfCrcx3.cjs";
1
+ import { r as Node } from "./types-Bfi8SERZ.cjs";
2
2
  //#region src/emoji.d.ts
3
3
  type EmojiType = "twemoji" | "blobmoji" | "noto" | "openmoji" | "fluent" | "fluentFlat";
4
4
  declare function extractEmojis(node: Node, emojiType: EmojiType): Node;
package/dist/emoji.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as Node } from "./types-BwfCrcx3.mjs";
1
+ import { r as Node } from "./types-Bfi8SERZ.mjs";
2
2
  //#region src/emoji.d.ts
3
3
  type EmojiType = "twemoji" | "blobmoji" | "noto" | "openmoji" | "fluent" | "fluentFlat";
4
4
  declare function extractEmojis(node: Node, emojiType: EmojiType): Node;
@@ -1,4 +1,4 @@
1
- import { r as Node } from "./types-BwfCrcx3.mjs";
1
+ import { r as Node } from "./types-Bfi8SERZ.cjs";
2
2
  //#region src/google-fonts-catalog.d.ts
3
3
  interface GoogleFontShapes {
4
4
  S0: {
@@ -1,4 +1,4 @@
1
- import { r as Node } from "./types-BwfCrcx3.cjs";
1
+ import { r as Node } from "./types-Bfi8SERZ.mjs";
2
2
  //#region src/google-fonts-catalog.d.ts
3
3
  interface GoogleFontShapes {
4
4
  S0: {
package/dist/html.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-4kGcvc-Q.cjs"),t=require("./utils-BfucapVz.cjs");var n=Symbol(`Fragment`),r=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),i=new Set([`script`,`style`]),a=/(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:-]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!)([\s\S]*?)(>))/gm,o=/[\@\.a-z0-9_\:\-]/i;function s(e){let t={};if(e){let n=`none`,r,i=``,a,s;for(let c=0;c<e.length;c++){let l=e[c];n===`none`?o.test(l)?(r&&(t[r]=i,r=void 0,i=``),a=c,n=`key`):l===`=`&&r&&(n=`value`):n===`key`?o.test(l)||(r=e.substring(a,c),n=l===`=`?`value`:`none`):l===s&&c>0&&e[c-1]!==`\\`?s&&(i=e.substring(a,c),s=void 0,n=`none`):(l===`"`||l===`'`)&&!s&&(a=c+1,s=l)}n===`key`&&a!=null&&a<e.length&&(r=e.substring(a,e.length)),r&&(t[r]=i)}return t}function c(e){let t=typeof e==`string`?e:e.value,n,o,c,l,u,d,f,p,m,h=[];a.lastIndex=0,o=n={type:0,children:[]};let g=0;function _(){l=t.substring(g,a.lastIndex-c[0].length),l&&o.children.push({type:2,value:l,parent:o})}for(;c=a.exec(t);){if(d=c[5]||c[8],f=c[6]||c[9],p=c[7]||c[10],i.has(o.name)&&c[2]!==o.name){u=a.lastIndex-c[0].length,o.children.length>0&&(o.children[0].value+=c[0]);continue}else if(d===`<!--`){if(u=a.lastIndex-c[0].length,i.has(o.name))continue;m={type:3,value:f,parent:o,loc:[{start:u,end:u+d.length},{start:a.lastIndex-p.length,end:a.lastIndex}]},h.push(m),m.parent.children.push(m)}else if(d===`<!`)u=a.lastIndex-c[0].length,m={type:4,value:f,parent:o,loc:[{start:u,end:u+d.length},{start:a.lastIndex-p.length,end:a.lastIndex}]},h.push(m),m.parent.children.push(m);else if(c[1]!==`/`)if(_(),i.has(o.name)){g=a.lastIndex,_();continue}else m={type:1,name:c[2]+``,attributes:s(c[3]),parent:o,children:[],loc:[{start:a.lastIndex-c[0].length,end:a.lastIndex}]},h.push(m),m.parent.children.push(m),c[4]&&c[4].indexOf(`/`)>-1||r.has(m.name)?(m.loc[1]=m.loc[0],m.isSelfClosingTag=!0):o=m;else _(),c[2]+``===o.name?(m=o,o=m.parent,m.loc.push({start:a.lastIndex-c[0].length,end:a.lastIndex}),l=t.substring(m.loc[0].end,m.loc[1].start),m.children.length===0&&m.children.push({type:2,value:l,parent:o})):c[2]+``===h[h.length-1].name&&h[h.length-1].isSelfClosingTag===!0&&(m=h[h.length-1],m.loc.push({start:a.lastIndex-c[0].length,end:a.lastIndex}));g=a.lastIndex}return l=t.slice(g),o.children.push({type:2,value:l,parent:o}),n}var l=Symbol(`HTMLString`),u=Symbol(`AttrString`),d=Symbol(`RenderFn`);function f(e,t=[l]){let n={value:e};for(let e of t)Object.defineProperty(n,e,{value:!0,enumerable:!1,writable:!1});return n}var p={"&":`&amp;`,"<":`&lt;`,">":`&gt;`};function m(e){return e.replace(/[&<>]/g,e=>p[e]||e)}function h(e){let t=``;for(let[n,r]of Object.entries(e))t+=` ${n}="${r}"`;return f(t,[l,u])}function g(e){if(e.children.length===0){let t=e;for(;t=t.parent;)if(t.name===`svg`)return!0}return!1}function _(e){let{name:t,attributes:i={}}=e,a=e.children.map(e=>v(e)).join(``);if(d in e){let t=e[d](i,f(a));return t&&t[l]?t.value:m(String(t))}if(t===n)return a;let o=g(e);return o||r.has(t)?`<${e.name}${h(i).value}${o?` /`:``}>`:`<${e.name}${h(i).value}>${a}</${e.name}>`}function v(e){switch(e.type){case 0:return e.children.map(e=>v(e)).join(``);case 1:return _(e);case 2:return`${e.value}`;case 3:return`<!--${e.value}-->`;case 4:return`<!${e.value}>`}}function y(e,n){let r=c(e),i={nodes:[],stylesheets:[]},a=t.u(n?.defaultStyles),o=n?.tailwindClassesProperty??`tw`;for(let e of r.children)b(e,a,o,i.nodes,i.stylesheets);return i}function b(n,r,i,a,o){if(n.type===3)return;if(n.type===2){let t=n.value??``;t&&a.push(e.l({text:t,preset:r?.span}));return}if(n.type===0){for(let e of n.children)b(e,r,i,a,o);return}if(n.type!==1)return;let s=n;if(s.name===`style`){let e=``;for(let t of s.children)t.type===2&&typeof t.value==`string`&&(e+=t.value);e&&o.push(e);return}let c=x(s,r,i);if(s.name===`br`){a.push(e.l({text:`
2
- `,preset:r?.span,...c}));return}if(s.name===`img`){let t=s.attributes?.src;if(!t)throw Error(`Image element must have a 'src' prop.`);a.push(e.i({src:t,width:O(s.attributes?.width),height:O(s.attributes?.height),...c}));return}if(t.i(s.name))return;if(s.name===`svg`){a.push(e.i({src:v(s),width:O(s.attributes?.width),height:O(s.attributes?.height),...c}));return}let l=!0,u=``;for(let e of s.children)if(e.type!==3){if(e.type!==2){l=!1;break}u+=e.value??``}if(l&&u){a.push(e.l({text:u,...c}));return}let d=[];for(let e of s.children)b(e,r,i,d,o);a.push(e.t({children:d,...c}))}function x(e,n,r){let i=e.attributes?S(e.attributes):{},a=typeof i.style==`string`?E(i.style):void 0,o=t.l(i,r),s=typeof i[r]==`string`?i[r]:void 0,c=n&&e.name in n?n[e.name]:void 0;return{tagName:e.name,className:i.class,id:i.id,dir:i.dir,lang:i.lang,attributes:o,tw:s,style:a,preset:c}}function S(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=C(r))}return t}function C(e){return e.includes(`&`)?e.replace(/&(?:#(\d+)|#x([\da-fA-F]+)|([a-zA-Z][\w-]+));/g,(e,t,n,r)=>t?w(Number(t))??e:n?w(Number.parseInt(n,16))??e:T[r]??e):e}function w(e){if(!(!Number.isInteger(e)||e<0||e>1114111))try{return String.fromCodePoint(e)}catch{return}}const T={amp:`&`,apos:`'`,gt:`>`,lt:`<`,nbsp:`\xA0`,quot:`"`};function E(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[D(i)]=a)}return Object.keys(t).length>0?t:void 0}function D(e){return e.startsWith(`--`)?e:e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function O(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function k(t){let{nodes:n,stylesheets:r}=y(t);return n.length===0?{node:e.t({}),stylesheets:r}:n.length===1&&n[0]?{node:n[0],stylesheets:r}:{node:e.t({style:{width:e.a(100),height:e.a(100)},children:n}),stylesheets:r}}exports.fromHtml=k;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-4kGcvc-Q.cjs"),t=require("./utils-BfucapVz.cjs");var n=Symbol(`Fragment`),r=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),i=new Set([`script`,`style`]),a=/(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:-]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!)([\s\S]*?)(>))/gm,o=64,s=46,c=45,l=58,u=95,d=61,f=34,p=39,m=92;function h(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===o||e===s||e===c||e===l||e===u}function g(e){let t={};if(e){let n=`none`,r,i=``,a;for(let o=0;o<e.length;o++){let s=e.charCodeAt(o);if(n===`none`)h(s)?(r&&(t[r]=i,r=void 0,i=``),a=o,n=`key`):s===d&&r&&(n=`value`);else if(n===`key`)h(s)||(r=e.substring(a,o),n=s===d?`value`:`none`);else if(s===f||s===p){let t=s===f?`"`:`'`,r=o+1,a=e.indexOf(t,r);for(;a>0&&e.charCodeAt(a-1)===m;)a=e.indexOf(t,a+1);if(a===-1)break;i=e.substring(r,a),o=a,n=`none`}}n===`key`&&a!=null&&a<e.length&&(r=e.substring(a,e.length)),r&&(t[r]=i)}return t}function _(e){let t=typeof e==`string`?e:e.value,n,o,s,c,l,u,d,f,p,m=[];a.lastIndex=0,o=n={type:0,children:[]};let h=0;function _(){c=t.substring(h,a.lastIndex-s[0].length),c&&o.children.push({type:2,value:c,parent:o})}for(;s=a.exec(t);){if(u=s[5]||s[8],d=s[6]||s[9],f=s[7]||s[10],i.has(o.name)&&s[2]!==o.name){l=a.lastIndex-s[0].length,o.children.length>0&&(o.children[0].value+=s[0]);continue}else if(u===`<!--`){if(l=a.lastIndex-s[0].length,i.has(o.name))continue;p={type:3,value:d,parent:o,loc:[{start:l,end:l+u.length},{start:a.lastIndex-f.length,end:a.lastIndex}]},m.push(p),p.parent.children.push(p)}else if(u===`<!`)l=a.lastIndex-s[0].length,p={type:4,value:d,parent:o,loc:[{start:l,end:l+u.length},{start:a.lastIndex-f.length,end:a.lastIndex}]},m.push(p),p.parent.children.push(p);else if(s[1]!==`/`)if(_(),i.has(o.name)){h=a.lastIndex,_();continue}else p={type:1,name:s[2]+``,attributes:g(s[3]),parent:o,children:[],loc:[{start:a.lastIndex-s[0].length,end:a.lastIndex}]},m.push(p),p.parent.children.push(p),s[4]&&s[4].indexOf(`/`)>-1||r.has(p.name)?(p.loc[1]=p.loc[0],p.isSelfClosingTag=!0):o=p;else _(),s[2]+``===o.name?(p=o,o=p.parent,p.loc.push({start:a.lastIndex-s[0].length,end:a.lastIndex}),c=t.substring(p.loc[0].end,p.loc[1].start),p.children.length===0&&p.children.push({type:2,value:c,parent:o})):s[2]+``===m[m.length-1].name&&m[m.length-1].isSelfClosingTag===!0&&(p=m[m.length-1],p.loc.push({start:a.lastIndex-s[0].length,end:a.lastIndex}));h=a.lastIndex}return c=t.slice(h),o.children.push({type:2,value:c,parent:o}),n}var v=Symbol(`HTMLString`),y=Symbol(`RenderFn`);function b(e,t=[v]){let n={value:e};for(let e of t)Object.defineProperty(n,e,{value:!0,enumerable:!1,writable:!1});return n}var x={"&":`&amp;`,"<":`&lt;`,">":`&gt;`};function S(e){return e.replace(/[&<>]/g,e=>x[e]||e)}function C(e){let t=``;for(let[n,r]of Object.entries(e))t+=` ${n}="${r}"`;return t}function w(e){if(e.children.length===0){let t=e;for(;t=t.parent;)if(t.name===`svg`)return!0}return!1}function T(e){let{name:t,attributes:i={}}=e,a=e.children.map(e=>E(e)).join(``);if(y in e){let t=e[y](i,b(a));return t&&t[v]?t.value:S(String(t))}if(t===n)return a;let o=w(e);return o||r.has(t)?`<${e.name}${C(i)}${o?` /`:``}>`:`<${e.name}${C(i)}>${a}</${e.name}>`}function E(e){switch(e.type){case 0:return e.children.map(e=>E(e)).join(``);case 1:return T(e);case 2:return`${e.value}`;case 3:return`<!--${e.value}-->`;case 4:return`<!${e.value}>`}}function D(e,n){let r=_(e),i={nodes:[],stylesheets:[]},a=t.u(n?.defaultStyles),o=n?.tailwindClassesProperty??`tw`;for(let e of r.children)O(e,a,o,i.nodes,i.stylesheets);return i}function O(n,r,i,a,o){if(n.type===3)return;if(n.type===2){let t=n.value??``;t&&a.push(e.l({text:t,preset:r?.span}));return}if(n.type===0){for(let e of n.children)O(e,r,i,a,o);return}if(n.type!==1)return;let s=n;if(s.name===`style`){let e=``;for(let t of s.children)t.type===2&&typeof t.value==`string`&&(e+=t.value);e&&o.push(e);return}let c=k(s,r,i);if(s.name===`br`){a.push(e.l({text:`
2
+ `,preset:r?.span,...c}));return}if(s.name===`img`){let t=s.attributes?.src;if(!t)throw Error(`Image element must have a 'src' prop.`);a.push(e.i({src:t,width:I(s.attributes?.width),height:I(s.attributes?.height),...c}));return}if(t.i(s.name))return;if(s.name===`svg`){a.push(e.i({src:E(s),width:I(s.attributes?.width),height:I(s.attributes?.height),...c}));return}let l=!0,u=``;for(let e of s.children)if(e.type!==3){if(e.type!==2){l=!1;break}u+=e.value??``}if(l&&u){a.push(e.l({text:u,...c}));return}let d=[];for(let e of s.children)O(e,r,i,d,o);a.push(e.t({children:d,...c}))}function k(e,n,r){let i=e.attributes?A(e.attributes):{},a=typeof i.style==`string`?P(i.style):void 0,o=t.l(i,r),s=typeof i[r]==`string`?i[r]:void 0,c=n&&e.name in n?n[e.name]:void 0;return{tagName:e.name,className:i.class,id:i.id,dir:i.dir,lang:i.lang,attributes:o,tw:s,style:a,preset:c}}function A(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=j(r))}return t}function j(e){return e.includes(`&`)?e.replace(/&(?:#(\d+)|#x([\da-fA-F]+)|([a-zA-Z][\w-]+));/g,(e,t,n,r)=>t?M(Number(t))??e:n?M(Number.parseInt(n,16))??e:N[r]??e):e}function M(e){if(!(!Number.isInteger(e)||e<0||e>1114111))try{return String.fromCodePoint(e)}catch{return}}const N={amp:`&`,apos:`'`,gt:`>`,lt:`<`,nbsp:`\xA0`,quot:`"`};function P(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[F(i)]=a)}return Object.keys(t).length>0?t:void 0}function F(e){return e.startsWith(`--`)?e:e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function I(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function L(t){let{nodes:n,stylesheets:r}=D(t);return n.length===0?{node:e.t({}),stylesheets:r}:n.length===1&&n[0]?{node:n[0],stylesheets:r}:{node:e.t({style:{width:e.a(100),height:e.a(100)},children:n}),stylesheets:r}}exports.fromHtml=L;
package/dist/html.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as Node } from "./types-BwfCrcx3.cjs";
1
+ import { r as Node } from "./types-Bfi8SERZ.cjs";
2
2
  import "./index.cjs";
3
3
  //#region src/html/index.d.ts
4
4
  declare function fromHtml(html: string): {
package/dist/html.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as Node } from "./types-BwfCrcx3.mjs";
1
+ import { r as Node } from "./types-Bfi8SERZ.mjs";
2
2
  import "./index.mjs";
3
3
  //#region src/html/index.d.ts
4
4
  declare function fromHtml(html: string): {
package/dist/html.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{a as e,i as t,l as n,t as r}from"./helpers-CVQCT1Rh.mjs";import{i,l as a,u as o}from"./utils-hT_pgw3g.mjs";var s=Symbol(`Fragment`),c=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),l=new Set([`script`,`style`]),u=/(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:-]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!)([\s\S]*?)(>))/gm,d=/[\@\.a-z0-9_\:\-]/i;function f(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`?d.test(c)?(r&&(t[r]=i,r=void 0,i=``),a=s,n=`key`):c===`=`&&r&&(n=`value`):n===`key`?d.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 p(e){let t=typeof e==`string`?e:e.value,n,r,i,a,o,s,d,p,m,h=[];u.lastIndex=0,r=n={type:0,children:[]};let g=0;function _(){a=t.substring(g,u.lastIndex-i[0].length),a&&r.children.push({type:2,value:a,parent:r})}for(;i=u.exec(t);){if(s=i[5]||i[8],d=i[6]||i[9],p=i[7]||i[10],l.has(r.name)&&i[2]!==r.name){o=u.lastIndex-i[0].length,r.children.length>0&&(r.children[0].value+=i[0]);continue}else if(s===`<!--`){if(o=u.lastIndex-i[0].length,l.has(r.name))continue;m={type:3,value:d,parent:r,loc:[{start:o,end:o+s.length},{start:u.lastIndex-p.length,end:u.lastIndex}]},h.push(m),m.parent.children.push(m)}else if(s===`<!`)o=u.lastIndex-i[0].length,m={type:4,value:d,parent:r,loc:[{start:o,end:o+s.length},{start:u.lastIndex-p.length,end:u.lastIndex}]},h.push(m),m.parent.children.push(m);else if(i[1]!==`/`)if(_(),l.has(r.name)){g=u.lastIndex,_();continue}else m={type:1,name:i[2]+``,attributes:f(i[3]),parent:r,children:[],loc:[{start:u.lastIndex-i[0].length,end:u.lastIndex}]},h.push(m),m.parent.children.push(m),i[4]&&i[4].indexOf(`/`)>-1||c.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:u.lastIndex-i[0].length,end:u.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:u.lastIndex-i[0].length,end:u.lastIndex}));g=u.lastIndex}return a=t.slice(g),r.children.push({type:2,value:a,parent:r}),n}var m=Symbol(`HTMLString`),h=Symbol(`AttrString`),g=Symbol(`RenderFn`);function _(e,t=[m]){let n={value:e};for(let e of t)Object.defineProperty(n,e,{value:!0,enumerable:!1,writable:!1});return n}var v={"&":`&amp;`,"<":`&lt;`,">":`&gt;`};function y(e){return e.replace(/[&<>]/g,e=>v[e]||e)}function b(e){let t=``;for(let[n,r]of Object.entries(e))t+=` ${n}="${r}"`;return _(t,[m,h])}function x(e){if(e.children.length===0){let t=e;for(;t=t.parent;)if(t.name===`svg`)return!0}return!1}function S(e){let{name:t,attributes:n={}}=e,r=e.children.map(e=>C(e)).join(``);if(g in e){let t=e[g](n,_(r));return t&&t[m]?t.value:y(String(t))}if(t===s)return r;let i=x(e);return i||c.has(t)?`<${e.name}${b(n).value}${i?` /`:``}>`:`<${e.name}${b(n).value}>${r}</${e.name}>`}function C(e){switch(e.type){case 0:return e.children.map(e=>C(e)).join(``);case 1:return S(e);case 2:return`${e.value}`;case 3:return`<!--${e.value}-->`;case 4:return`<!${e.value}>`}}function w(e,t){let n=p(e),r={nodes:[],stylesheets:[]},i=o(t?.defaultStyles),a=t?.tailwindClassesProperty??`tw`;for(let e of n.children)T(e,i,a,r.nodes,r.stylesheets);return r}function T(e,a,o,s,c){if(e.type===3)return;if(e.type===2){let t=e.value??``;t&&s.push(n({text:t,preset:a?.span}));return}if(e.type===0){for(let t of e.children)T(t,a,o,s,c);return}if(e.type!==1)return;let l=e;if(l.name===`style`){let e=``;for(let t of l.children)t.type===2&&typeof t.value==`string`&&(e+=t.value);e&&c.push(e);return}let u=E(l,a,o);if(l.name===`br`){s.push(n({text:`
2
- `,preset:a?.span,...u}));return}if(l.name===`img`){let e=l.attributes?.src;if(!e)throw Error(`Image element must have a 'src' prop.`);s.push(t({src:e,width:N(l.attributes?.width),height:N(l.attributes?.height),...u}));return}if(i(l.name))return;if(l.name===`svg`){s.push(t({src:C(l),width:N(l.attributes?.width),height:N(l.attributes?.height),...u}));return}let d=!0,f=``;for(let e of l.children)if(e.type!==3){if(e.type!==2){d=!1;break}f+=e.value??``}if(d&&f){s.push(n({text:f,...u}));return}let p=[];for(let e of l.children)T(e,a,o,p,c);s.push(r({children:p,...u}))}function E(e,t,n){let r=e.attributes?D(e.attributes):{},i=typeof r.style==`string`?j(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,lang:r.lang,attributes:o,tw:s,style:i,preset:c}}function D(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=O(r))}return t}function O(e){return e.includes(`&`)?e.replace(/&(?:#(\d+)|#x([\da-fA-F]+)|([a-zA-Z][\w-]+));/g,(e,t,n,r)=>t?k(Number(t))??e:n?k(Number.parseInt(n,16))??e:A[r]??e):e}function k(e){if(!(!Number.isInteger(e)||e<0||e>1114111))try{return String.fromCodePoint(e)}catch{return}}const A={amp:`&`,apos:`'`,gt:`>`,lt:`<`,nbsp:`\xA0`,quot:`"`};function j(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[M(i)]=a)}return Object.keys(t).length>0?t:void 0}function M(e){return e.startsWith(`--`)?e:e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function N(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function P(t){let{nodes:n,stylesheets:i}=w(t);return n.length===0?{node:r({}),stylesheets:i}:n.length===1&&n[0]?{node:n[0],stylesheets:i}:{node:r({style:{width:e(100),height:e(100)},children:n}),stylesheets:i}}export{P as fromHtml};
1
+ import{a as e,i as t,l as n,t as r}from"./helpers-CVQCT1Rh.mjs";import{i,l as a,u as o}from"./utils-hT_pgw3g.mjs";var s=Symbol(`Fragment`),c=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),l=new Set([`script`,`style`]),u=/(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:-]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!)([\s\S]*?)(>))/gm,d=64,f=46,p=45,m=58,h=95,g=61,_=34,v=39,y=92;function b(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===d||e===f||e===p||e===m||e===h}function x(e){let t={};if(e){let n=`none`,r,i=``,a;for(let o=0;o<e.length;o++){let s=e.charCodeAt(o);if(n===`none`)b(s)?(r&&(t[r]=i,r=void 0,i=``),a=o,n=`key`):s===g&&r&&(n=`value`);else if(n===`key`)b(s)||(r=e.substring(a,o),n=s===g?`value`:`none`);else if(s===_||s===v){let t=s===_?`"`:`'`,r=o+1,a=e.indexOf(t,r);for(;a>0&&e.charCodeAt(a-1)===y;)a=e.indexOf(t,a+1);if(a===-1)break;i=e.substring(r,a),o=a,n=`none`}}n===`key`&&a!=null&&a<e.length&&(r=e.substring(a,e.length)),r&&(t[r]=i)}return t}function S(e){let t=typeof e==`string`?e:e.value,n,r,i,a,o,s,d,f,p,m=[];u.lastIndex=0,r=n={type:0,children:[]};let h=0;function g(){a=t.substring(h,u.lastIndex-i[0].length),a&&r.children.push({type:2,value:a,parent:r})}for(;i=u.exec(t);){if(s=i[5]||i[8],d=i[6]||i[9],f=i[7]||i[10],l.has(r.name)&&i[2]!==r.name){o=u.lastIndex-i[0].length,r.children.length>0&&(r.children[0].value+=i[0]);continue}else if(s===`<!--`){if(o=u.lastIndex-i[0].length,l.has(r.name))continue;p={type:3,value:d,parent:r,loc:[{start:o,end:o+s.length},{start:u.lastIndex-f.length,end:u.lastIndex}]},m.push(p),p.parent.children.push(p)}else if(s===`<!`)o=u.lastIndex-i[0].length,p={type:4,value:d,parent:r,loc:[{start:o,end:o+s.length},{start:u.lastIndex-f.length,end:u.lastIndex}]},m.push(p),p.parent.children.push(p);else if(i[1]!==`/`)if(g(),l.has(r.name)){h=u.lastIndex,g();continue}else p={type:1,name:i[2]+``,attributes:x(i[3]),parent:r,children:[],loc:[{start:u.lastIndex-i[0].length,end:u.lastIndex}]},m.push(p),p.parent.children.push(p),i[4]&&i[4].indexOf(`/`)>-1||c.has(p.name)?(p.loc[1]=p.loc[0],p.isSelfClosingTag=!0):r=p;else g(),i[2]+``===r.name?(p=r,r=p.parent,p.loc.push({start:u.lastIndex-i[0].length,end:u.lastIndex}),a=t.substring(p.loc[0].end,p.loc[1].start),p.children.length===0&&p.children.push({type:2,value:a,parent:r})):i[2]+``===m[m.length-1].name&&m[m.length-1].isSelfClosingTag===!0&&(p=m[m.length-1],p.loc.push({start:u.lastIndex-i[0].length,end:u.lastIndex}));h=u.lastIndex}return a=t.slice(h),r.children.push({type:2,value:a,parent:r}),n}var C=Symbol(`HTMLString`),w=Symbol(`RenderFn`);function T(e,t=[C]){let n={value:e};for(let e of t)Object.defineProperty(n,e,{value:!0,enumerable:!1,writable:!1});return n}var E={"&":`&amp;`,"<":`&lt;`,">":`&gt;`};function D(e){return e.replace(/[&<>]/g,e=>E[e]||e)}function O(e){let t=``;for(let[n,r]of Object.entries(e))t+=` ${n}="${r}"`;return t}function k(e){if(e.children.length===0){let t=e;for(;t=t.parent;)if(t.name===`svg`)return!0}return!1}function A(e){let{name:t,attributes:n={}}=e,r=e.children.map(e=>j(e)).join(``);if(w in e){let t=e[w](n,T(r));return t&&t[C]?t.value:D(String(t))}if(t===s)return r;let i=k(e);return i||c.has(t)?`<${e.name}${O(n)}${i?` /`:``}>`:`<${e.name}${O(n)}>${r}</${e.name}>`}function j(e){switch(e.type){case 0:return e.children.map(e=>j(e)).join(``);case 1:return A(e);case 2:return`${e.value}`;case 3:return`<!--${e.value}-->`;case 4:return`<!${e.value}>`}}function M(e,t){let n=S(e),r={nodes:[],stylesheets:[]},i=o(t?.defaultStyles),a=t?.tailwindClassesProperty??`tw`;for(let e of n.children)N(e,i,a,r.nodes,r.stylesheets);return r}function N(e,a,o,s,c){if(e.type===3)return;if(e.type===2){let t=e.value??``;t&&s.push(n({text:t,preset:a?.span}));return}if(e.type===0){for(let t of e.children)N(t,a,o,s,c);return}if(e.type!==1)return;let l=e;if(l.name===`style`){let e=``;for(let t of l.children)t.type===2&&typeof t.value==`string`&&(e+=t.value);e&&c.push(e);return}let u=P(l,a,o);if(l.name===`br`){s.push(n({text:`
2
+ `,preset:a?.span,...u}));return}if(l.name===`img`){let e=l.attributes?.src;if(!e)throw Error(`Image element must have a 'src' prop.`);s.push(t({src:e,width:V(l.attributes?.width),height:V(l.attributes?.height),...u}));return}if(i(l.name))return;if(l.name===`svg`){s.push(t({src:j(l),width:V(l.attributes?.width),height:V(l.attributes?.height),...u}));return}let d=!0,f=``;for(let e of l.children)if(e.type!==3){if(e.type!==2){d=!1;break}f+=e.value??``}if(d&&f){s.push(n({text:f,...u}));return}let p=[];for(let e of l.children)N(e,a,o,p,c);s.push(r({children:p,...u}))}function P(e,t,n){let r=e.attributes?F(e.attributes):{},i=typeof r.style==`string`?z(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,lang:r.lang,attributes:o,tw:s,style:i,preset:c}}function F(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=I(r))}return t}function I(e){return e.includes(`&`)?e.replace(/&(?:#(\d+)|#x([\da-fA-F]+)|([a-zA-Z][\w-]+));/g,(e,t,n,r)=>t?L(Number(t))??e:n?L(Number.parseInt(n,16))??e:R[r]??e):e}function L(e){if(!(!Number.isInteger(e)||e<0||e>1114111))try{return String.fromCodePoint(e)}catch{return}}const R={amp:`&`,apos:`'`,gt:`>`,lt:`<`,nbsp:`\xA0`,quot:`"`};function z(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 V(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function H(t){let{nodes:n,stylesheets:i}=M(t);return n.length===0?{node:r({}),stylesheets:i}:n.length===1&&n[0]?{node:n[0],stylesheets:i}:{node:r({style:{width:e(100),height:e(100)},children:n}),stylesheets:i}}export{H as fromHtml};
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as NodeMetadata, c as TextNode, i as NodeAttributes, n as ImageNode, o as ReactElementLike, r as Node, s as TextFit, t as ContainerNode } from "./types-BwfCrcx3.cjs";
2
- import { _ as readBodyLimited, a as collectCodepoints, c as subsetFonts, d as FetchedImage, f as ImageFetchCache, g as prepareImages, h as fetchOk, i as GoogleFontsOptions, l as FetchLike, m as defaultMaxFetchBytes, n as GenericFontFamily, o as fontFromUrl, p as PrepareImagesOptions, r as GoogleFontFamily, s as googleFonts, t as FontSubset, u as FetchOptions } from "./fonts-CziVseDZ.cjs";
1
+ import { a as NodeMetadata, c as TextFit, i as NodeAttributes, l as TextNode, n as ImageNode, o as ReactElementLike, r as Node, s as RgbaImage, t as ContainerNode } from "./types-Bfi8SERZ.cjs";
2
+ import { _ as readBodyLimited, a as collectCodepoints, c as subsetFonts, d as FetchedImage, f as ImageFetchCache, g as prepareImages, h as fetchOk, i as GoogleFontsOptions, l as FetchLike, m as defaultMaxFetchBytes, n as GenericFontFamily, o as fontFromUrl, p as PrepareImagesOptions, r as GoogleFontFamily, s as googleFonts, t as FontSubset, u as FetchOptions } from "./fonts-BDH-QGS3.cjs";
3
3
  import { CSSProperties } from "react";
4
4
  //#region src/helpers.d.ts
5
5
  declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
@@ -15,4 +15,4 @@ declare function rem(rem: number): `${number}rem`;
15
15
  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
- export { ContainerNode, FetchLike, FetchOptions, FetchedImage, FontSubset, GenericFontFamily, GoogleFontFamily, GoogleFontsOptions, ImageFetchCache, ImageNode, Node, NodeAttributes, NodeMetadata, PrepareImagesOptions, ReactElementLike, TextFit, TextNode, collectCodepoints, container, defaultMaxFetchBytes, em, fetchOk, fontFromUrl, fr, googleFonts, image, percentage, prepareImages, readBodyLimited, rem, rgba, style, subsetFonts, text, vh, vw };
18
+ export { ContainerNode, FetchLike, FetchOptions, FetchedImage, FontSubset, GenericFontFamily, GoogleFontFamily, GoogleFontsOptions, ImageFetchCache, ImageNode, Node, NodeAttributes, NodeMetadata, PrepareImagesOptions, ReactElementLike, RgbaImage, TextFit, TextNode, collectCodepoints, container, defaultMaxFetchBytes, em, fetchOk, fontFromUrl, fr, googleFonts, image, percentage, prepareImages, readBodyLimited, rem, rgba, style, subsetFonts, text, vh, vw };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as NodeMetadata, c as TextNode, i as NodeAttributes, n as ImageNode, o as ReactElementLike, r as Node, s as TextFit, t as ContainerNode } from "./types-BwfCrcx3.mjs";
2
- import { _ as readBodyLimited, a as collectCodepoints, c as subsetFonts, d as FetchedImage, f as ImageFetchCache, g as prepareImages, h as fetchOk, i as GoogleFontsOptions, l as FetchLike, m as defaultMaxFetchBytes, n as GenericFontFamily, o as fontFromUrl, p as PrepareImagesOptions, r as GoogleFontFamily, s as googleFonts, t as FontSubset, u as FetchOptions } from "./fonts-CAwVZx4X.mjs";
1
+ import { a as NodeMetadata, c as TextFit, i as NodeAttributes, l as TextNode, n as ImageNode, o as ReactElementLike, r as Node, s as RgbaImage, t as ContainerNode } from "./types-Bfi8SERZ.mjs";
2
+ import { _ as readBodyLimited, a as collectCodepoints, c as subsetFonts, d as FetchedImage, f as ImageFetchCache, g as prepareImages, h as fetchOk, i as GoogleFontsOptions, l as FetchLike, m as defaultMaxFetchBytes, n as GenericFontFamily, o as fontFromUrl, p as PrepareImagesOptions, r as GoogleFontFamily, s as googleFonts, t as FontSubset, u as FetchOptions } from "./fonts-UnPqxrF6.mjs";
3
3
  import { CSSProperties } from "react";
4
4
  //#region src/helpers.d.ts
5
5
  declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
@@ -15,4 +15,4 @@ declare function rem(rem: number): `${number}rem`;
15
15
  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
- export { ContainerNode, FetchLike, FetchOptions, FetchedImage, FontSubset, GenericFontFamily, GoogleFontFamily, GoogleFontsOptions, ImageFetchCache, ImageNode, Node, NodeAttributes, NodeMetadata, PrepareImagesOptions, ReactElementLike, TextFit, TextNode, collectCodepoints, container, defaultMaxFetchBytes, em, fetchOk, fontFromUrl, fr, googleFonts, image, percentage, prepareImages, readBodyLimited, rem, rgba, style, subsetFonts, text, vh, vw };
18
+ export { ContainerNode, FetchLike, FetchOptions, FetchedImage, FontSubset, GenericFontFamily, GoogleFontFamily, GoogleFontsOptions, ImageFetchCache, ImageNode, Node, NodeAttributes, NodeMetadata, PrepareImagesOptions, ReactElementLike, RgbaImage, TextFit, TextNode, collectCodepoints, container, defaultMaxFetchBytes, em, fetchOk, fontFromUrl, fr, googleFonts, image, percentage, prepareImages, readBodyLimited, rem, rgba, style, subsetFonts, text, vh, vw };
package/dist/jsx.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-4kGcvc-Q.cjs"),t=require("./utils-BfucapVz.cjs");let n;function r(e,t){return typeof e==`object`&&e&&t in e?e[t]:void 0}function i(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function a(e){let t=r(e,`__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE`);if(typeof t==`object`&&t&&`H`in t){let e=t;return{get:()=>e.H,set:t=>{e.H=t}}}let n=r(r(e,`__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED`),`ReactCurrentDispatcher`);if(typeof n==`object`&&n&&`current`in n){let e=n;return{get:()=>e.current,set:t=>{e.current=t}}}return null}function o(){return n??=import(`react`).then(e=>a(e.default??e)).catch(()=>null),n}function s(e,t){return e.contexts.has(t)?e.contexts.get(t):r(t,`_currentValue`)}const c=()=>{};function l(e,t){let n=t=>s(e,t),r=0;return{readContext:n,useContext:n,use:e=>{if(i(e)){if(e.status===`fulfilled`)return e.value;throw e.status===`rejected`?e.reason:e}return n(e)},useState:e=>[typeof e==`function`?e():e,c],useReducer:(e,t,n)=>[n?n(t):t,c],useMemo:e=>e(),useCallback:e=>e,useRef:e=>({current:e}),useEffect:c,useLayoutEffect:c,useInsertionEffect:c,useImperativeHandle:c,useDebugValue:c,useDeferredValue:e=>e,useTransition:()=>[!1,c],useOptimistic:e=>[e,c],useActionState:(e,t)=>[t,c,!1],useSyncExternalStore:(e,t,n)=>(n??t)(),useId:()=>`:t${t}-${r++}:`,useCacheRefresh:()=>c,useHostTransitionStatus:()=>({pending:!1,data:null,method:null,action:null})}}async function u(e,t,n){let r=await o();if(!r)return e(t);let a=n.ids.current++;for(let o=0;;o++){let s=r.get();r.set(l(n,a));let c;try{return e(t)}catch(e){c=e}finally{r.set(s)}if(!i(c)||o>=64)throw c;await d(c)}}async function d(e){try{e.value=await e,e.status=`fulfilled`}catch(t){e.reason=t,e.status=`rejected`}}function f(e){return typeof e==`string`||typeof e==`number`}function p(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function m(e){let n=[];for(let r in e)Object.hasOwn(e,r)&&n.push(`${t.t(r)}:${String(e[r]).trim()}`);return n.join(`;`)}const h=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 g(e,n){if(e===`children`||n==null)return;let r;if(r=e===`className`?`class`:h.has(e)?t.t(e):e,typeof n==`boolean`)return`${r}="${String(n)}"`;if(e===`style`&&typeof n==`object`){let e=m(n);if(e)return`style="${p(e)}"`}return`${r}="${p(String(n))}"`}function _(e,t,n){let r=!1;for(let n in e){if(!Object.hasOwn(e,n))continue;let i=g(n,e[n]);i!==void 0&&(t.push(` `,i),n===`xmlns`&&(r=!0))}n&&!r&&t.push(` xmlns="http://www.w3.org/2000/svg"`)}const v=(e,n,r)=>{let i=e.props||{};if(t.n(e.type)){y(e.type(e.props),n,!1);return}if(typeof e.type==`symbol`||typeof e.type!=`string`)return;n.push(`<`,e.type),_(i,n,r&&e.type===`svg`);let a=i.children;n.push(`>`),y(a,n,!1),n.push(`</`,e.type,`>`)};function y(e,n,r){if(!(e==null||e===!1)){if(f(e)){n.push(String(e));return}if(Array.isArray(e)){for(let t of e)y(t,n,!1);return}t.c(e)&&v(e,n,r)}}function b(e){let t=[];return y(e,t,!0),t.join(``)}function x(){return{nodes:[],stylesheets:[]}}async function S(n,r){let i=await C(n,{defaultStyles:w(r),presets:t.u(r?.defaultStyles),tailwindClassesProperty:r?.tailwindClassesProperty??`tw`,contexts:new Map,ids:{current:0}}),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 C(n,r){return n==null||n===!1?x():n instanceof Promise?C(await n,r):typeof n==`object`&&Symbol.iterator in n?K(n,r):t.c(n)?await z(n,r):{nodes:[e.l({text:String(n),preset:r.presets?.span})],stylesheets:[]}}function w(e){return e&&`defaultStyles`in e?e.defaultStyles??t.d:t.d}const T=Symbol.for(`react.context`),E=Symbol.for(`react.provider`),D=Symbol.for(`react.consumer`);function O(e,t){let n=e.type;if(typeof n!=`object`||!n)return;let i=r(n,`$$typeof`);if(i===E)return k(e,r(n,`_context`),t);if(i===D)return j(e,r(n,`_context`)??n,t);if(i===T)return typeof P(e)==`function`?j(e,n,t):k(e,n,t)}function k(e,t,n){let i=new Map(n.contexts);return i.set(t,r(e.props,`value`)),G(e,{...n,contexts:i})}function A(e){return typeof e==`function`}function j(e,t,n){let r=P(e);return A(r)?C(r(s(n,t)),n):G(e,n)}async function M(e,t,n){return C(await u(e,t,n),n)}function N(e,n){if(!(typeof e.type!=`object`||e.type===null)){if(t.a(e.type)&&`render`in e.type){let t=e.type;return M(e=>t.render(e,null),e.props,n)}if(t.s(e.type)&&`type`in e.type){let r=e.type.type;return t.n(r)?M(r,e.props,n):z({...e,type:r},n)}}}function P(e){if(typeof e.props==`object`&&e.props!==null&&`children`in e.props)return e.props.children}function F(e){if(!t.c(e))return;let n=P(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 R(n);if(t.c(n)&&t.o(n))return F(n)}function I(e){let t=[];for(let n of e){let e=L(n);if(e===void 0)return;t.push(e)}return t.join(``)}function L(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 I(e);if(!t.c(e))return;if(t.o(e))return L(P(e));let n=P(e);return n===void 0?``:typeof n==`object`&&n&&Symbol.iterator in n?I(n):L(n)}function R(e){let n=[],r=!1;for(let i of e){if(t.c(i))return;if(typeof i==`string`){r=!0,n.push(i);continue}if(typeof i==`number`){r=!0,n.push(String(i));continue}return}if(r)return n.join(``)}async function z(n,r){let i=O(n,r);if(i!==void 0)return i;if(t.n(n.type))return M(n.type,n.props,r);let a=N(n,r);if(a!==void 0)return a;if(t.o(n))return G(n,r);if(t.r(n,`style`)){let e=L(P(n));return{nodes:[],stylesheets:e&&e.length>0?[e]:[]}}if(typeof n.type!=`string`||t.i(n.type))return x();let o=W(n,r);if(t.r(n,`br`))return{nodes:[e.l({text:`
2
- `,preset:r.presets?.span,...o})],stylesheets:[]};if(t.r(n,`img`))return{nodes:[B(n,r)],stylesheets:[]};if(t.r(n,`svg`))return{nodes:[V(n,r)],stylesheets:[]};let s=F(n);if(s!==void 0)return{nodes:[e.l({text:s,...o})],stylesheets:[]};let c=await G(n,r);return{nodes:[e.t({children:c.nodes,...o})],stylesheets:c.stylesheets}}function B(t,n){if(!t.props.src)throw Error(`Image element must have a 'src' prop.`);let r=W(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 V(t,n){let r=W(t,n);return e.i({src:b(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 H(e,t){let n=t.presets,r=n&&typeof e.type==`string`&&e.type in n?n[e.type]:void 0,i=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(!i)return{preset:r};for(let e in i)if(Object.hasOwn(i,e))return{preset:r,style:i};return{preset:r}}function U(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 W(e,n){let r=e.props,{preset:i,style:a}=H(e,n),o=U(e,n),s=t.l(r,n.tailwindClassesProperty);return{tagName:typeof e.type==`string`?e.type:void 0,className:r.className??r.class,id:r.id,dir:r.dir,lang:r.lang,attributes:s,tw:o,style:a,preset:i}}function G(e,t){let n=P(e);return n===void 0?Promise.resolve(x()):C(n,t)}async function K(e,t){let n=[],r=new Set,i=0;for(let a of e){let e=i;i+=1;let o=C(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.d,exports.fromJsx=S;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-4kGcvc-Q.cjs"),t=require("./utils-BfucapVz.cjs");let n;function r(e,t){return typeof e==`object`&&e&&t in e?e[t]:void 0}function i(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function a(e){let t=r(e,`__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE`);if(typeof t==`object`&&t&&`H`in t){let e=t;return{get:()=>e.H,set:t=>{e.H=t}}}let n=r(r(e,`__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED`),`ReactCurrentDispatcher`);if(typeof n==`object`&&n&&`current`in n){let e=n;return{get:()=>e.current,set:t=>{e.current=t}}}return null}function o(){return n??=import(`react`).then(e=>a(e.default??e)).catch(()=>null),n}function s(e,t){return e.contexts.has(t)?e.contexts.get(t):r(t,`_currentValue`)}const c=()=>{};function l(e,t){let n=t=>s(e,t),r=0;return{readContext:n,useContext:n,use:e=>{if(i(e)){if(e.status===`fulfilled`)return e.value;throw e.status===`rejected`?e.reason:e}return n(e)},useState:e=>[typeof e==`function`?e():e,c],useReducer:(e,t,n)=>[n?n(t):t,c],useMemo:e=>e(),useCallback:e=>e,useRef:e=>({current:e}),useEffect:c,useLayoutEffect:c,useInsertionEffect:c,useImperativeHandle:c,useDebugValue:c,useDeferredValue:e=>e,useTransition:()=>[!1,c],useOptimistic:e=>[e,c],useActionState:(e,t)=>[t,c,!1],useSyncExternalStore:(e,t,n)=>(n??t)(),useId:()=>`:t${t}-${r++}:`,useCacheRefresh:()=>c,useHostTransitionStatus:()=>({pending:!1,data:null,method:null,action:null})}}async function u(e,t,n){let r=await o();if(!r)return e(t);let a=n.ids.current++;for(let o=0;;o++){let s=r.get();r.set(l(n,a));let c;try{return e(t)}catch(e){c=e}finally{r.set(s)}if(!i(c)||o>=64)throw c;await d(c)}}async function d(e){try{e.value=await e,e.status=`fulfilled`}catch(t){e.reason=t,e.status=`rejected`}}function f(e){return typeof e==`string`||typeof e==`number`}function p(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function m(e){let n=[];for(let r in e)Object.hasOwn(e,r)&&n.push(`${t.t(r)}:${String(e[r]).trim()}`);return n.join(`;`)}const h=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 g(e,n){if(e===`children`||n==null)return;let r;if(r=e===`className`?`class`:h.has(e)?t.t(e):e,typeof n==`boolean`)return`${r}="${String(n)}"`;if(e===`style`&&typeof n==`object`){let e=m(n);if(e)return`style="${p(e)}"`}return`${r}="${p(String(n))}"`}function _(e,t,n){let r=!1;for(let n in e){if(!Object.hasOwn(e,n))continue;let i=g(n,e[n]);i!==void 0&&(t.push(` `,i),n===`xmlns`&&(r=!0))}n&&!r&&t.push(` xmlns="http://www.w3.org/2000/svg"`)}const v=(e,n,r)=>{let i=e.props||{};if(t.n(e.type)){y(e.type(e.props),n,!1);return}if(typeof e.type==`symbol`||typeof e.type!=`string`)return;n.push(`<`,e.type),_(i,n,r&&e.type===`svg`);let a=i.children;n.push(`>`),y(a,n,!1),n.push(`</`,e.type,`>`)};function y(e,n,r){if(!(e==null||e===!1)){if(f(e)){n.push(String(e));return}if(Array.isArray(e)){for(let t of e)y(t,n,!1);return}t.c(e)&&v(e,n,r)}}function b(e){let t=[];return y(e,t,!0),t.join(``)}function x({width:e,height:t,data:n,premultiplied:r,...i}){return{type:`img`,props:{...i,src:{width:e,height:t,data:n,premultiplied:r}},key:null}}function S(){return{nodes:[],stylesheets:[]}}async function C(n,r){let i=await w(n,{defaultStyles:T(r),presets:t.u(r?.defaultStyles),tailwindClassesProperty:r?.tailwindClassesProperty??`tw`,contexts:new Map,ids:{current:0}}),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 w(n,r){return n==null||n===!1?S():n instanceof Promise?w(await n,r):typeof n==`object`&&Symbol.iterator in n?q(n,r):t.c(n)?await B(n,r):{nodes:[e.l({text:String(n),preset:r.presets?.span})],stylesheets:[]}}function T(e){return e&&`defaultStyles`in e?e.defaultStyles??t.d:t.d}const E=Symbol.for(`react.context`),D=Symbol.for(`react.provider`),O=Symbol.for(`react.consumer`);function k(e,t){let n=e.type;if(typeof n!=`object`||!n)return;let i=r(n,`$$typeof`);if(i===D)return A(e,r(n,`_context`),t);if(i===O)return M(e,r(n,`_context`)??n,t);if(i===E)return typeof F(e)==`function`?M(e,n,t):A(e,n,t)}function A(e,t,n){let i=new Map(n.contexts);return i.set(t,r(e.props,`value`)),K(e,{...n,contexts:i})}function j(e){return typeof e==`function`}function M(e,t,n){let r=F(e);return j(r)?w(r(s(n,t)),n):K(e,n)}async function N(e,t,n){return w(await u(e,t,n),n)}function P(e,n){if(!(typeof e.type!=`object`||e.type===null)){if(t.a(e.type)&&`render`in e.type){let t=e.type;return N(e=>t.render(e,null),e.props,n)}if(t.s(e.type)&&`type`in e.type){let r=e.type.type;return t.n(r)?N(r,e.props,n):B({...e,type:r},n)}}}function F(e){if(typeof e.props==`object`&&e.props!==null&&`children`in e.props)return e.props.children}function I(e){if(!t.c(e))return;let n=F(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 z(n);if(t.c(n)&&t.o(n))return I(n)}function L(e){let t=[];for(let n of e){let e=R(n);if(e===void 0)return;t.push(e)}return t.join(``)}function R(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 L(e);if(!t.c(e))return;if(t.o(e))return R(F(e));let n=F(e);return n===void 0?``:typeof n==`object`&&n&&Symbol.iterator in n?L(n):R(n)}function z(e){let n=[],r=!1;for(let i of e){if(t.c(i))return;if(typeof i==`string`){r=!0,n.push(i);continue}if(typeof i==`number`){r=!0,n.push(String(i));continue}return}if(r)return n.join(``)}async function B(n,r){let i=k(n,r);if(i!==void 0)return i;if(t.n(n.type))return N(n.type,n.props,r);let a=P(n,r);if(a!==void 0)return a;if(t.o(n))return K(n,r);if(t.r(n,`style`)){let e=R(F(n));return{nodes:[],stylesheets:e&&e.length>0?[e]:[]}}if(typeof n.type!=`string`||t.i(n.type))return S();let o=G(n,r);if(t.r(n,`br`))return{nodes:[e.l({text:`
2
+ `,preset:r.presets?.span,...o})],stylesheets:[]};if(t.r(n,`img`))return{nodes:[V(n,r)],stylesheets:[]};if(t.r(n,`svg`))return{nodes:[H(n,r)],stylesheets:[]};let s=I(n);if(s!==void 0)return{nodes:[e.l({text:s,...o})],stylesheets:[]};let c=await K(n,r);return{nodes:[e.t({children:c.nodes,...o})],stylesheets:c.stylesheets}}function V(t,n){if(!t.props.src)throw Error(`Image element must have a 'src' prop.`);let r=G(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 H(t,n){let r=G(t,n);return e.i({src:b(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 U(e,t){let n=t.presets,r=n&&typeof e.type==`string`&&e.type in n?n[e.type]:void 0,i=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(!i)return{preset:r};for(let e in i)if(Object.hasOwn(i,e))return{preset:r,style:i};return{preset:r}}function W(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 G(e,n){let r=e.props,{preset:i,style:a}=U(e,n),o=W(e,n),s=t.l(r,n.tailwindClassesProperty);return{tagName:typeof e.type==`string`?e.type:void 0,className:r.className??r.class,id:r.id,dir:r.dir,lang:r.lang,attributes:s,tw:o,style:a,preset:i}}function K(e,t){let n=F(e);return n===void 0?Promise.resolve(S()):w(n,t)}async function q(e,t){let n=[],r=new Set,i=0;for(let a of e){let e=i;i+=1;let o=w(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.Bitmap=x,exports.defaultStylePresets=t.d,exports.fromJsx=C;
package/dist/jsx.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { o as ReactElementLike, r as Node } from "./types-BwfCrcx3.cjs";
2
- import { CSSProperties, JSX, ReactNode } from "react";
1
+ import { o as ReactElementLike, r as Node, s as RgbaImage } from "./types-Bfi8SERZ.cjs";
2
+ import { CSSProperties, ComponentProps, JSX, ReactElement, ReactNode } from "react";
3
3
  //#region src/jsx/style-presets.d.ts
4
4
  declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
5
5
  //#endregion
@@ -20,6 +20,12 @@ declare module "react" {
20
20
  tw?: string;
21
21
  }
22
22
  }
23
+ type BitmapProps = RgbaImage & Omit<ComponentProps<"img">, "src" | "width" | "height">;
24
+ type BitmapImgProps = Omit<BitmapProps, keyof RgbaImage> & {
25
+ src: RgbaImage;
26
+ };
27
+ /** An `<img>` fed by raw RGBA pixels instead of an encoded file. */
28
+ declare function Bitmap({ width, height, data, premultiplied, ...props }: BitmapProps): ReactElement<BitmapImgProps, "img">;
23
29
  interface FromJsxOptions {
24
30
  /**
25
31
  * Override or disable the default Chromium style presets.
@@ -42,4 +48,4 @@ interface FromJsxResult {
42
48
  }
43
49
  declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<FromJsxResult>;
44
50
  //#endregion
45
- export { FromJsxOptions, FromJsxResult, type HtmlProps, defaultStylePresets, fromJsx };
51
+ export { Bitmap, BitmapProps, FromJsxOptions, FromJsxResult, type HtmlProps, defaultStylePresets, fromJsx };
package/dist/jsx.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { o as ReactElementLike, r as Node } from "./types-BwfCrcx3.mjs";
2
- import { CSSProperties, JSX, ReactNode } from "react";
1
+ import { o as ReactElementLike, r as Node, s as RgbaImage } from "./types-Bfi8SERZ.mjs";
2
+ import { CSSProperties, ComponentProps, JSX, ReactElement, ReactNode } from "react";
3
3
  //#region src/jsx/style-presets.d.ts
4
4
  declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
5
5
  //#endregion
@@ -20,6 +20,12 @@ declare module "react" {
20
20
  tw?: string;
21
21
  }
22
22
  }
23
+ type BitmapProps = RgbaImage & Omit<ComponentProps<"img">, "src" | "width" | "height">;
24
+ type BitmapImgProps = Omit<BitmapProps, keyof RgbaImage> & {
25
+ src: RgbaImage;
26
+ };
27
+ /** An `<img>` fed by raw RGBA pixels instead of an encoded file. */
28
+ declare function Bitmap({ width, height, data, premultiplied, ...props }: BitmapProps): ReactElement<BitmapImgProps, "img">;
23
29
  interface FromJsxOptions {
24
30
  /**
25
31
  * Override or disable the default Chromium style presets.
@@ -42,4 +48,4 @@ interface FromJsxResult {
42
48
  }
43
49
  declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<FromJsxResult>;
44
50
  //#endregion
45
- export { FromJsxOptions, FromJsxResult, type HtmlProps, defaultStylePresets, fromJsx };
51
+ export { Bitmap, BitmapProps, FromJsxOptions, FromJsxResult, type HtmlProps, defaultStylePresets, fromJsx };
package/dist/jsx.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{a as e,i as t,l as n,t as r}from"./helpers-CVQCT1Rh.mjs";import{a as i,c as a,d as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p,u as m}from"./utils-hT_pgw3g.mjs";let h;function g(e,t){return typeof e==`object`&&e&&t in e?e[t]:void 0}function _(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function v(e){let t=g(e,`__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE`);if(typeof t==`object`&&t&&`H`in t){let e=t;return{get:()=>e.H,set:t=>{e.H=t}}}let n=g(g(e,`__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED`),`ReactCurrentDispatcher`);if(typeof n==`object`&&n&&`current`in n){let e=n;return{get:()=>e.current,set:t=>{e.current=t}}}return null}function y(){return h??=import(`react`).then(e=>v(e.default??e)).catch(()=>null),h}function b(e,t){return e.contexts.has(t)?e.contexts.get(t):g(t,`_currentValue`)}const x=()=>{};function ee(e,t){let n=t=>b(e,t),r=0;return{readContext:n,useContext:n,use:e=>{if(_(e)){if(e.status===`fulfilled`)return e.value;throw e.status===`rejected`?e.reason:e}return n(e)},useState:e=>[typeof e==`function`?e():e,x],useReducer:(e,t,n)=>[n?n(t):t,x],useMemo:e=>e(),useCallback:e=>e,useRef:e=>({current:e}),useEffect:x,useLayoutEffect:x,useInsertionEffect:x,useImperativeHandle:x,useDebugValue:x,useDeferredValue:e=>e,useTransition:()=>[!1,x],useOptimistic:e=>[e,x],useActionState:(e,t)=>[t,x,!1],useSyncExternalStore:(e,t,n)=>(n??t)(),useId:()=>`:t${t}-${r++}:`,useCacheRefresh:()=>x,useHostTransitionStatus:()=>({pending:!1,data:null,method:null,action:null})}}async function te(e,t,n){let r=await y();if(!r)return e(t);let i=n.ids.current++;for(let a=0;;a++){let o=r.get();r.set(ee(n,i));let s;try{return e(t)}catch(e){s=e}finally{r.set(o)}if(!_(s)||a>=64)throw s;await S(s)}}async function S(e){try{e.value=await e,e.status=`fulfilled`}catch(t){e.reason=t,e.status=`rejected`}}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){let t=[];for(let n in e)Object.hasOwn(e,n)&&t.push(`${p(n)}:${String(e[n]).trim()}`);return t.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 D(e,t){if(e===`children`||t==null)return;let n;if(n=e===`className`?`class`:E.has(e)?p(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 O(e,t,n){let r=!1;for(let n in e){if(!Object.hasOwn(e,n))continue;let i=D(n,e[n]);i!==void 0&&(t.push(` `,i),n===`xmlns`&&(r=!0))}n&&!r&&t.push(` xmlns="http://www.w3.org/2000/svg"`)}const k=(e,t,n)=>{let r=e.props||{};if(l(e.type)){A(e.type(e.props),t,!1);return}if(typeof e.type==`symbol`||typeof e.type!=`string`)return;t.push(`<`,e.type),O(r,t,n&&e.type===`svg`);let i=r.children;t.push(`>`),A(i,t,!1),t.push(`</`,e.type,`>`)};function A(e,t,n){if(!(e==null||e===!1)){if(C(e)){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)A(n,t,!1);return}a(e)&&k(e,t,n)}}function j(e){let t=[];return A(e,t,!0),t.join(``)}function M(){return{nodes:[],stylesheets:[]}}async function N(t,n){let i=await P(t,{defaultStyles:F(n),presets:m(n?.defaultStyles),tailwindClassesProperty:n?.tailwindClassesProperty??`tw`,contexts:new Map,ids:{current:0}}),a=i.nodes,o;return o=a.length===0?r({}):a.length===1&&a[0]!==void 0?a[0]:r({children:a,style:{width:e(100),height:e(100)}}),{node:o,stylesheets:i.stylesheets}}async function P(e,t){return e==null||e===!1?M():e instanceof Promise?P(await e,t):typeof e==`object`&&Symbol.iterator in e?ae(e,t):a(e)?await X(e,t):{nodes:[n({text:String(e),preset:t.presets?.span})],stylesheets:[]}}function F(e){return e&&`defaultStyles`in e?e.defaultStyles??o:o}const I=Symbol.for(`react.context`),L=Symbol.for(`react.provider`),R=Symbol.for(`react.consumer`);function z(e,t){let n=e.type;if(typeof n!=`object`||!n)return;let r=g(n,`$$typeof`);if(r===L)return B(e,g(n,`_context`),t);if(r===R)return H(e,g(n,`_context`)??n,t);if(r===I)return typeof G(e)==`function`?H(e,n,t):B(e,n,t)}function B(e,t,n){let r=new Map(n.contexts);return r.set(t,g(e.props,`value`)),$(e,{...n,contexts:r})}function V(e){return typeof e==`function`}function H(e,t,n){let r=G(e);return V(r)?P(r(b(n,t)),n):$(e,n)}async function U(e,t,n){return P(await te(e,t,n),n)}function W(e,t){if(!(typeof e.type!=`object`||e.type===null)){if(i(e.type)&&`render`in e.type){let n=e.type;return U(e=>n.render(e,null),e.props,t)}if(f(e.type)&&`type`in e.type){let n=e.type.type;return l(n)?U(n,e.props,t):X({...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){if(!a(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 Y(t);if(a(t)&&u(t))return K(t)}function q(e){let t=[];for(let n of e){let e=J(n);if(e===void 0)return;t.push(e)}return t.join(``)}function J(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 q(e);if(!a(e))return;if(u(e))return J(G(e));let t=G(e);return t===void 0?``:typeof t==`object`&&t&&Symbol.iterator in t?q(t):J(t)}function Y(e){let t=[],n=!1;for(let r of e){if(a(r))return;if(typeof r==`string`){n=!0,t.push(r);continue}if(typeof r==`number`){n=!0,t.push(String(r));continue}return}if(n)return t.join(``)}async function X(e,t){let i=z(e,t);if(i!==void 0)return i;if(l(e.type))return U(e.type,e.props,t);let a=W(e,t);if(a!==void 0)return a;if(u(e))return $(e,t);if(d(e,`style`)){let t=J(G(e));return{nodes:[],stylesheets:t&&t.length>0?[t]:[]}}if(typeof e.type!=`string`||s(e.type))return M();let o=Q(e,t);if(d(e,`br`))return{nodes:[n({text:`
2
- `,preset:t.presets?.span,...o})],stylesheets:[]};if(d(e,`img`))return{nodes:[Z(e,t)],stylesheets:[]};if(d(e,`svg`))return{nodes:[ne(e,t)],stylesheets:[]};let c=K(e);if(c!==void 0)return{nodes:[n({text:c,...o})],stylesheets:[]};let f=await $(e,t);return{nodes:[r({children:f.nodes,...o})],stylesheets:f.stylesheets}}function Z(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 ne(e,n){let r=Q(e,n);return t({src:j(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 re(e,t){let n=t.presets,r=n&&typeof e.type==`string`&&e.type in n?n[e.type]:void 0,i=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(!i)return{preset:r};for(let e in i)if(Object.hasOwn(i,e))return{preset:r,style:i};return{preset:r}}function ie(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}=re(e,t),a=ie(e,t),o=c(n,t.tailwindClassesProperty);return{tagName:typeof e.type==`string`?e.type:void 0,className:n.className??n.class,id:n.id,dir:n.dir,lang:n.lang,attributes:o,tw:a,style:i,preset:r}}function $(e,t){let n=G(e);return n===void 0?Promise.resolve(M()):P(n,t)}async function ae(e,t){let n=[],r=new Set,i=0;for(let a of e){let e=i;i+=1;let o=P(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{o as defaultStylePresets,N as fromJsx};
1
+ import{a as e,i as t,l as n,t as r}from"./helpers-CVQCT1Rh.mjs";import{a as i,c as a,d as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p,u as m}from"./utils-hT_pgw3g.mjs";let h;function g(e,t){return typeof e==`object`&&e&&t in e?e[t]:void 0}function _(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function v(e){let t=g(e,`__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE`);if(typeof t==`object`&&t&&`H`in t){let e=t;return{get:()=>e.H,set:t=>{e.H=t}}}let n=g(g(e,`__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED`),`ReactCurrentDispatcher`);if(typeof n==`object`&&n&&`current`in n){let e=n;return{get:()=>e.current,set:t=>{e.current=t}}}return null}function y(){return h??=import(`react`).then(e=>v(e.default??e)).catch(()=>null),h}function b(e,t){return e.contexts.has(t)?e.contexts.get(t):g(t,`_currentValue`)}const x=()=>{};function ee(e,t){let n=t=>b(e,t),r=0;return{readContext:n,useContext:n,use:e=>{if(_(e)){if(e.status===`fulfilled`)return e.value;throw e.status===`rejected`?e.reason:e}return n(e)},useState:e=>[typeof e==`function`?e():e,x],useReducer:(e,t,n)=>[n?n(t):t,x],useMemo:e=>e(),useCallback:e=>e,useRef:e=>({current:e}),useEffect:x,useLayoutEffect:x,useInsertionEffect:x,useImperativeHandle:x,useDebugValue:x,useDeferredValue:e=>e,useTransition:()=>[!1,x],useOptimistic:e=>[e,x],useActionState:(e,t)=>[t,x,!1],useSyncExternalStore:(e,t,n)=>(n??t)(),useId:()=>`:t${t}-${r++}:`,useCacheRefresh:()=>x,useHostTransitionStatus:()=>({pending:!1,data:null,method:null,action:null})}}async function te(e,t,n){let r=await y();if(!r)return e(t);let i=n.ids.current++;for(let a=0;;a++){let o=r.get();r.set(ee(n,i));let s;try{return e(t)}catch(e){s=e}finally{r.set(o)}if(!_(s)||a>=64)throw s;await S(s)}}async function S(e){try{e.value=await e,e.status=`fulfilled`}catch(t){e.reason=t,e.status=`rejected`}}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){let t=[];for(let n in e)Object.hasOwn(e,n)&&t.push(`${p(n)}:${String(e[n]).trim()}`);return t.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 D(e,t){if(e===`children`||t==null)return;let n;if(n=e===`className`?`class`:E.has(e)?p(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 O(e,t,n){let r=!1;for(let n in e){if(!Object.hasOwn(e,n))continue;let i=D(n,e[n]);i!==void 0&&(t.push(` `,i),n===`xmlns`&&(r=!0))}n&&!r&&t.push(` xmlns="http://www.w3.org/2000/svg"`)}const k=(e,t,n)=>{let r=e.props||{};if(l(e.type)){A(e.type(e.props),t,!1);return}if(typeof e.type==`symbol`||typeof e.type!=`string`)return;t.push(`<`,e.type),O(r,t,n&&e.type===`svg`);let i=r.children;t.push(`>`),A(i,t,!1),t.push(`</`,e.type,`>`)};function A(e,t,n){if(!(e==null||e===!1)){if(C(e)){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)A(n,t,!1);return}a(e)&&k(e,t,n)}}function j(e){let t=[];return A(e,t,!0),t.join(``)}function M({width:e,height:t,data:n,premultiplied:r,...i}){return{type:`img`,props:{...i,src:{width:e,height:t,data:n,premultiplied:r}},key:null}}function N(){return{nodes:[],stylesheets:[]}}async function P(t,n){let i=await F(t,{defaultStyles:I(n),presets:m(n?.defaultStyles),tailwindClassesProperty:n?.tailwindClassesProperty??`tw`,contexts:new Map,ids:{current:0}}),a=i.nodes,o;return o=a.length===0?r({}):a.length===1&&a[0]!==void 0?a[0]:r({children:a,style:{width:e(100),height:e(100)}}),{node:o,stylesheets:i.stylesheets}}async function F(e,t){return e==null||e===!1?N():e instanceof Promise?F(await e,t):typeof e==`object`&&Symbol.iterator in e?oe(e,t):a(e)?await Z(e,t):{nodes:[n({text:String(e),preset:t.presets?.span})],stylesheets:[]}}function I(e){return e&&`defaultStyles`in e?e.defaultStyles??o:o}const L=Symbol.for(`react.context`),R=Symbol.for(`react.provider`),z=Symbol.for(`react.consumer`);function B(e,t){let n=e.type;if(typeof n!=`object`||!n)return;let r=g(n,`$$typeof`);if(r===R)return V(e,g(n,`_context`),t);if(r===z)return U(e,g(n,`_context`)??n,t);if(r===L)return typeof K(e)==`function`?U(e,n,t):V(e,n,t)}function V(e,t,n){let r=new Map(n.contexts);return r.set(t,g(e.props,`value`)),$(e,{...n,contexts:r})}function H(e){return typeof e==`function`}function U(e,t,n){let r=K(e);return H(r)?F(r(b(n,t)),n):$(e,n)}async function W(e,t,n){return F(await te(e,t,n),n)}function G(e,t){if(!(typeof e.type!=`object`||e.type===null)){if(i(e.type)&&`render`in e.type){let n=e.type;return W(e=>n.render(e,null),e.props,t)}if(f(e.type)&&`type`in e.type){let n=e.type.type;return l(n)?W(n,e.props,t):Z({...e,type:n},t)}}}function K(e){if(typeof e.props==`object`&&e.props!==null&&`children`in e.props)return e.props.children}function q(e){if(!a(e))return;let t=K(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(a(t)&&u(t))return q(t)}function J(e){let t=[];for(let n of e){let e=Y(n);if(e===void 0)return;t.push(e)}return t.join(``)}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(!a(e))return;if(u(e))return Y(K(e));let t=K(e);return t===void 0?``:typeof t==`object`&&t&&Symbol.iterator in t?J(t):Y(t)}function X(e){let t=[],n=!1;for(let r of e){if(a(r))return;if(typeof r==`string`){n=!0,t.push(r);continue}if(typeof r==`number`){n=!0,t.push(String(r));continue}return}if(n)return t.join(``)}async function Z(e,t){let i=B(e,t);if(i!==void 0)return i;if(l(e.type))return W(e.type,e.props,t);let a=G(e,t);if(a!==void 0)return a;if(u(e))return $(e,t);if(d(e,`style`)){let t=Y(K(e));return{nodes:[],stylesheets:t&&t.length>0?[t]:[]}}if(typeof e.type!=`string`||s(e.type))return N();let o=Q(e,t);if(d(e,`br`))return{nodes:[n({text:`
2
+ `,preset:t.presets?.span,...o})],stylesheets:[]};if(d(e,`img`))return{nodes:[ne(e,t)],stylesheets:[]};if(d(e,`svg`))return{nodes:[re(e,t)],stylesheets:[]};let c=q(e);if(c!==void 0)return{nodes:[n({text:c,...o})],stylesheets:[]};let f=await $(e,t);return{nodes:[r({children:f.nodes,...o})],stylesheets:f.stylesheets}}function ne(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 re(e,n){let r=Q(e,n);return t({src:j(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 ie(e,t){let n=t.presets,r=n&&typeof e.type==`string`&&e.type in n?n[e.type]:void 0,i=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(!i)return{preset:r};for(let e in i)if(Object.hasOwn(i,e))return{preset:r,style:i};return{preset:r}}function ae(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}=ie(e,t),a=ae(e,t),o=c(n,t.tailwindClassesProperty);return{tagName:typeof e.type==`string`?e.type:void 0,className:n.className??n.class,id:n.id,dir:n.dir,lang:n.lang,attributes:o,tw:a,style:i,preset:r}}function $(e,t){let n=K(e);return n===void 0?Promise.resolve(N()):F(n,t)}async function oe(e,t){let n=[],r=new Set,i=0;for(let a of e){let e=i;i+=1;let o=F(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{M as Bitmap,o as defaultStylePresets,P as fromJsx};
@@ -1,5 +1,5 @@
1
- import { r as Node } from "./types-BwfCrcx3.cjs";
2
- import { n as GenericFontFamily } from "./fonts-CziVseDZ.cjs";
1
+ import { r as Node } from "./types-Bfi8SERZ.cjs";
2
+ import { n as GenericFontFamily } from "./fonts-BDH-QGS3.cjs";
3
3
  //#region src/renderer.d.ts
4
4
  /**
5
5
  * Shared wrapper primitives for the `@takumi-rs/core` (napi) and `@takumi-rs/wasm` renderer
@@ -1,5 +1,5 @@
1
- import { r as Node } from "./types-BwfCrcx3.mjs";
2
- import { n as GenericFontFamily } from "./fonts-CAwVZx4X.mjs";
1
+ import { r as Node } from "./types-Bfi8SERZ.mjs";
2
+ import { n as GenericFontFamily } from "./fonts-UnPqxrF6.mjs";
3
3
  //#region src/renderer.d.ts
4
4
  /**
5
5
  * Shared wrapper primitives for the `@takumi-rs/core` (napi) and `@takumi-rs/wasm` renderer
@@ -41,11 +41,22 @@ type TextNode = NodeMetadata & {
41
41
  type: "text";
42
42
  text: string;
43
43
  };
44
+ /** Raw row-major RGBA pixels, rendered without decoding. */
45
+ type RgbaImage = {
46
+ /** The image width in pixels. */
47
+ width: number;
48
+ /** The image height in pixels. */
49
+ height: number;
50
+ /** RGBA bytes, `width * height * 4` long. */
51
+ data: Uint8Array | ArrayBuffer;
52
+ /** The bytes are already alpha-premultiplied, so the premultiply pass is skipped. */
53
+ premultiplied?: boolean;
54
+ };
44
55
  type ImageNode = NodeMetadata & {
45
56
  type: "image";
46
- src: string | Uint8Array | ArrayBuffer;
57
+ src: string | Uint8Array | ArrayBuffer | RgbaImage;
47
58
  width?: number;
48
59
  height?: number;
49
60
  };
50
61
  //#endregion
51
- export { NodeMetadata as a, TextNode as c, NodeAttributes as i, ImageNode as n, ReactElementLike as o, Node as r, TextFit as s, ContainerNode as t };
62
+ export { NodeMetadata as a, TextFit as c, NodeAttributes as i, TextNode as l, ImageNode as n, ReactElementLike as o, Node as r, RgbaImage as s, ContainerNode as t };
@@ -41,11 +41,22 @@ type TextNode = NodeMetadata & {
41
41
  type: "text";
42
42
  text: string;
43
43
  };
44
+ /** Raw row-major RGBA pixels, rendered without decoding. */
45
+ type RgbaImage = {
46
+ /** The image width in pixels. */
47
+ width: number;
48
+ /** The image height in pixels. */
49
+ height: number;
50
+ /** RGBA bytes, `width * height * 4` long. */
51
+ data: Uint8Array | ArrayBuffer;
52
+ /** The bytes are already alpha-premultiplied, so the premultiply pass is skipped. */
53
+ premultiplied?: boolean;
54
+ };
44
55
  type ImageNode = NodeMetadata & {
45
56
  type: "image";
46
- src: string | Uint8Array | ArrayBuffer;
57
+ src: string | Uint8Array | ArrayBuffer | RgbaImage;
47
58
  width?: number;
48
59
  height?: number;
49
60
  };
50
61
  //#endregion
51
- export { NodeMetadata as a, TextNode as c, NodeAttributes as i, ImageNode as n, ReactElementLike as o, Node as r, TextFit as s, ContainerNode as t };
62
+ export { NodeMetadata as a, TextFit as c, NodeAttributes as i, TextNode as l, ImageNode as n, ReactElementLike as o, Node as r, RgbaImage as s, ContainerNode as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takumi-rs/helpers",
3
- "version": "2.2.3",
3
+ "version": "2.3.0",
4
4
  "description": "Utility helpers for converting JSX/HTML to Takumi node trees, loading fonts, and processing emoji.",
5
5
  "keywords": [
6
6
  "css",
@@ -102,8 +102,8 @@
102
102
  "preact": "^10.28.2",
103
103
  "react": "^19.2.7",
104
104
  "react-dom": "^19.2.7",
105
- "tsdown": "^0.22.5",
106
- "ultrahtml": "^1.6.0",
105
+ "tsdown": "0.22.5",
106
+ "ultrahtml": "^1.7.0",
107
107
  "unrun": "^0.3.1"
108
108
  },
109
109
  "peerDependencies": {