@takumi-rs/helpers 2.14.0 → 2.15.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 +1 -1
- package/dist/emoji.mjs +1 -1
- package/dist/fonts-By0vjazB.cjs +1 -0
- package/dist/fonts-CuoRVPJ8.mjs +1 -0
- package/dist/{fonts-BrUiG8am.d.cts → fonts-DPg6KAvr.d.cts} +251 -245
- package/dist/{fonts-Du-K60HL.d.mts → fonts-DSTCfPh9.d.mts} +251 -245
- package/dist/helpers-CrbDeBIp.mjs +1 -0
- package/dist/helpers-_gtvoVXa.cjs +1 -0
- package/dist/html.cjs +2 -2
- package/dist/html.d.cts +2 -7
- package/dist/html.d.mts +2 -7
- package/dist/html.mjs +2 -2
- package/dist/index-BZLLNDfO.d.mts +53 -0
- package/dist/index-CnGC2zXt.d.cts +53 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/jsx.cjs +2 -2
- package/dist/jsx.d.cts +1 -52
- package/dist/jsx.d.mts +1 -52
- package/dist/jsx.mjs +2 -2
- package/dist/renderer.cjs +1 -1
- package/dist/renderer.d.cts +1 -1
- package/dist/renderer.d.mts +1 -1
- package/dist/renderer.mjs +1 -1
- package/dist/utils-DXKpO9jU.cjs +1 -0
- package/dist/utils-DivIadzC.mjs +1 -0
- package/package.json +3 -3
- package/dist/fonts-B-pwvIqE.cjs +0 -1
- package/dist/fonts-CBLz8Mte.mjs +0 -1
- package/dist/helpers-4kGcvc-Q.cjs +0 -1
- package/dist/helpers-CVQCT1Rh.mjs +0 -1
- package/dist/utils-4GQubbLq.mjs +0 -1
- package/dist/utils-BndQkSnW.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,n,r=n.style){n.tw&&(e.tw=n.tw),n.tagName!==void 0&&(e.tagName=n.tagName),n.className!==void 0&&(e.className=n.className),n.id!==void 0&&(e.id=n.id),n.dir!==void 0&&(e.dir=n.dir),n.lang!==void 0&&(e.lang=n.lang),n.attributes!==void 0&&(e.attributes=n.attributes),t(n.preset)&&(e.preset=n.preset),t(r)&&(e.style=r)}function t(e){return e!==void 0&&Object.keys(e).length>0}function n(t){let n={type:`container`,children:t.children};return e(n,t),n}function r(t,n){let r=typeof t==`string`?{text:t}:t,i={type:`text`,text:r.text};return e(i,r,n??r.style),i}function i(t){let n={type:`image`,src:t.src,width:t.width,height:t.height};return e(n,t),n}function a(e){return e}function o(e){return`${e}%`}function s(e){return`${e}vw`}function c(e){return`${e}vh`}function l(e){return`${e}em`}function u(e){return`${e}rem`}function d(e){return`${e}fr`}function f(e,t,n,r=1){return`rgb(${e} ${t} ${n} / ${r})`}export{o as a,a as c,s as d,i,r as l,l as n,u as o,d as r,f as s,n as t,c as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,n,r=n.style){n.tw&&(e.tw=n.tw),n.tagName!==void 0&&(e.tagName=n.tagName),n.className!==void 0&&(e.className=n.className),n.id!==void 0&&(e.id=n.id),n.dir!==void 0&&(e.dir=n.dir),n.lang!==void 0&&(e.lang=n.lang),n.attributes!==void 0&&(e.attributes=n.attributes),t(n.preset)&&(e.preset=n.preset),t(r)&&(e.style=r)}function t(e){return e!==void 0&&Object.keys(e).length>0}function n(t){let n={type:`container`,children:t.children};return e(n,t),n}function r(t,n){let r=typeof t==`string`?{text:t}:t,i={type:`text`,text:r.text};return e(i,r,n??r.style),i}function i(t){let n={type:`image`,src:t.src,width:t.width,height:t.height};return e(n,t),n}function a(e){return e}function o(e){return`${e}%`}function s(e){return`${e}vw`}function c(e){return`${e}vh`}function l(e){return`${e}em`}function u(e){return`${e}rem`}function d(e){return`${e}fr`}function f(e,t,n,r=1){return`rgb(${e} ${t} ${n} / ${r})`}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return c}});
|
package/dist/html.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-
|
|
2
|
-
`,preset:
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-_gtvoVXa.cjs"),t=require("./utils-DXKpO9jU.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}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}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={"&":`&`,"<":`<`,">":`>`};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}>`}}const D={quot:`"`,amp:`&`,lt:`<`,gt:`>`,apos:`'`,nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:``,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`⟨`,rang:`⟩`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:``,zwj:``,lrm:``,rlm:``,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`};function O(e){return e.includes(`&`)?e.replace(/&(?:#(\d+)|#[xX]([\da-fA-F]+)|([a-zA-Z][\w-]+));/g,(e,t,n,r)=>t?k(Number(t))??e:n?k(Number.parseInt(n,16))??e:Object.hasOwn(D,r)?D[r]??e:e):e}function k(e){if(!(!Number.isInteger(e)||e<0||e>1114111)&&!(e>=55296&&e<=57343))return e===0?`�`:e>=128&&e<=159?`€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ`[e-128]:String.fromCodePoint(e)}function A(e){return new j(new t.l).build(_(e))}var j=class{metadata;css=[];constructor(e){this.metadata=e}build(e){return{nodes:this.nodes(e.children),css:this.css}}nodes(e){let t=[];for(let n of e)this.append(n,t);return t}append(n,r){if(n.type===3)return;if(n.type===2){let t=O(n.value??``);t&&r.push(e.l({text:t,preset:this.metadata.presets?.span}));return}if(n.type===0){for(let e of n.children)this.append(e,r);return}if(n.type!==1)return;let i=n;if(i.name===`style`){let e=``;for(let t of i.children)t.type===2&&typeof t.value==`string`&&(e+=t.value);e&&this.css.push(e);return}if(i.name===`head`){this.nodes(i.children);return}let a=this.elementMetadata(i);if(i.name===`br`){r.push(e.l({text:`
|
|
2
|
+
`,preset:this.metadata.presets?.br,...a}));return}if(i.name===`img`){let t=i.attributes?.src;if(!t)throw Error(`Image element must have a 'src' prop.`);r.push(e.i({src:O(t),...M(i),...a}));return}if(t.s(i.name))return;if(i.name===`svg`){r.push(e.i({src:E(i),...M(i),...a}));return}let o=!0,s=``;for(let e of i.children)if(e.type!==3){if(e.type!==2){o=!1;break}s+=e.value??``}if(o&&s){r.push(e.l({text:O(s),...a}));return}r.push(e.t({children:this.nodes(i.children),...a}))}elementMetadata(e){let t=e.attributes?N(e.attributes):{};return this.metadata.read(e.name,t,t.class,typeof t.style==`string`?P(t.style):void 0)}};function M(e){return{width:R(e.attributes?.width),height:R(e.attributes?.height)}}function N(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=O(r))}return t}function P(e){let t={},n=0,r=-1,i=0,a=i=>{if(r<0)return;let a=e.slice(n,r).trim(),o=e.slice(r+1,i).trim();a&&o&&(t[L(a)]=o)};for(let t=0;t<e.length;t+=1){let o=e[t];if(o===`\\`)t+=1;else if(o===`"`||o===`'`)t=F(e,t);else if(o===`/`&&e[t+1]===`*`)t=I(e,t);else if(o===`(`)i+=1;else if(o===`)`)i=Math.max(0,i-1);else if(i>0)continue;else o===`:`&&r<0?r=t:o===`;`&&(a(t),n=t+1,r=-1)}return a(e.length),Object.keys(t).length>0?t:void 0}function F(e,t){let n=e[t];for(let r=t+1;r<e.length;r+=1)if(e[r]===`\\`)r+=1;else if(e[r]===n)return r;return e.length}function I(e,t){let n=e.indexOf(`*/`,t+2);return n<0?e.length:n+1}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}const z=e=>e!==void 0&&`text`in e&&typeof e.text==`string`&&e.text.trim()===``;function B(e){let n=A(e);for(;z(n.nodes[0]);)n.nodes.shift();for(;z(n.nodes.at(-1));)n.nodes.pop();return t.d(n)}exports.fromHtml=B;
|
package/dist/html.d.cts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as FromJsxResult } from "./index-CnGC2zXt.cjs";
|
|
2
2
|
//#region src/html/index.d.ts
|
|
3
|
-
interface FromHtmlResult {
|
|
4
|
-
node: Node;
|
|
5
|
-
css: string[];
|
|
6
|
-
/** @deprecated Use `css` instead. */
|
|
7
|
-
stylesheets: string[];
|
|
8
|
-
}
|
|
3
|
+
interface FromHtmlResult extends FromJsxResult {}
|
|
9
4
|
declare function fromHtml(html: string): FromHtmlResult;
|
|
10
5
|
//#endregion
|
|
11
6
|
export { FromHtmlResult, fromHtml };
|
package/dist/html.d.mts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as FromJsxResult } from "./index-BZLLNDfO.mjs";
|
|
2
2
|
//#region src/html/index.d.ts
|
|
3
|
-
interface FromHtmlResult {
|
|
4
|
-
node: Node;
|
|
5
|
-
css: string[];
|
|
6
|
-
/** @deprecated Use `css` instead. */
|
|
7
|
-
stylesheets: string[];
|
|
8
|
-
}
|
|
3
|
+
interface FromHtmlResult extends FromJsxResult {}
|
|
9
4
|
declare function fromHtml(html: string): FromHtmlResult;
|
|
10
5
|
//#endregion
|
|
11
6
|
export { FromHtmlResult, fromHtml };
|
package/dist/html.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`,preset:
|
|
1
|
+
import{i as e,l as t,t as n}from"./helpers-CrbDeBIp.mjs";import{d as r,l as i,s as a}from"./utils-DivIadzC.mjs";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=64,d=46,f=45,p=58,m=95,h=61,g=34,_=39,v=92;function y(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===u||e===d||e===f||e===p||e===m}function b(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`)y(s)?(r&&(t[r]=i,r=void 0,i=``),a=o,n=`key`):s===h&&r&&(n=`value`);else if(n===`key`)y(s)||(r=e.substring(a,o),n=s===h?`value`:`none`);else if(s===g||s===_){let t=s===g?`"`:`'`,r=o+1,a=e.indexOf(t,r);for(;a>0&&e.charCodeAt(a-1)===v;)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 x(e){let t=typeof e==`string`?e:e.value,n,r,i,a,o,u,d,f,p,m=[];l.lastIndex=0,r=n={type:0,children:[]};let h=0;function g(){a=t.substring(h,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],d=i[6]||i[9],f=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}if(u===`<!--`){if(o=l.lastIndex-i[0].length,c.has(r.name))continue;p={type:3,value:d,parent:r,loc:[{start:o,end:o+u.length},{start:l.lastIndex-f.length,end:l.lastIndex}]},m.push(p),p.parent.children.push(p)}else if(u===`<!`)o=l.lastIndex-i[0].length,p={type:4,value:d,parent:r,loc:[{start:o,end:o+u.length},{start:l.lastIndex-f.length,end:l.lastIndex}]},m.push(p),p.parent.children.push(p);else if(i[1]!==`/`){if(g(),c.has(r.name)){h=l.lastIndex,g();continue}p={type:1,name:i[2]+``,attributes:b(i[3]),parent:r,children:[],loc:[{start:l.lastIndex-i[0].length,end:l.lastIndex}]},m.push(p),p.parent.children.push(p),i[4]&&i[4].indexOf(`/`)>-1||s.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:l.lastIndex-i[0].length,end:l.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:l.lastIndex-i[0].length,end:l.lastIndex}));h=l.lastIndex}return a=t.slice(h),r.children.push({type:2,value:a,parent:r}),n}var S=Symbol(`HTMLString`),C=Symbol(`RenderFn`);function w(e,t=[S]){let n={value:e};for(let e of t)Object.defineProperty(n,e,{value:!0,enumerable:!1,writable:!1});return n}var T={"&":`&`,"<":`<`,">":`>`};function E(e){return e.replace(/[&<>]/g,e=>T[e]||e)}function D(e){let t=``;for(let[n,r]of Object.entries(e))t+=` ${n}="${r}"`;return t}function O(e){if(e.children.length===0){let t=e;for(;t=t.parent;)if(t.name===`svg`)return!0}return!1}function k(e){let{name:t,attributes:n={}}=e,r=e.children.map(e=>A(e)).join(``);if(C in e){let t=e[C](n,w(r));return t&&t[S]?t.value:E(String(t))}if(t===o)return r;let i=O(e);return i||s.has(t)?`<${e.name}${D(n)}${i?` /`:``}>`:`<${e.name}${D(n)}>${r}</${e.name}>`}function A(e){switch(e.type){case 0:return e.children.map(e=>A(e)).join(``);case 1:return k(e);case 2:return`${e.value}`;case 3:return`<!--${e.value}-->`;case 4:return`<!${e.value}>`}}const j={quot:`"`,amp:`&`,lt:`<`,gt:`>`,apos:`'`,nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:``,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`⟨`,rang:`⟩`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:``,zwj:``,lrm:``,rlm:``,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`};function M(e){return e.includes(`&`)?e.replace(/&(?:#(\d+)|#[xX]([\da-fA-F]+)|([a-zA-Z][\w-]+));/g,(e,t,n,r)=>t?N(Number(t))??e:n?N(Number.parseInt(n,16))??e:Object.hasOwn(j,r)?j[r]??e:e):e}function N(e){if(!(!Number.isInteger(e)||e<0||e>1114111)&&!(e>=55296&&e<=57343))return e===0?`�`:e>=128&&e<=159?`€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ`[e-128]:String.fromCodePoint(e)}function P(e){return new F(new i).build(x(e))}var F=class{metadata;css=[];constructor(e){this.metadata=e}build(e){return{nodes:this.nodes(e.children),css:this.css}}nodes(e){let t=[];for(let n of e)this.append(n,t);return t}append(r,i){if(r.type===3)return;if(r.type===2){let e=M(r.value??``);e&&i.push(t({text:e,preset:this.metadata.presets?.span}));return}if(r.type===0){for(let e of r.children)this.append(e,i);return}if(r.type!==1)return;let o=r;if(o.name===`style`){let e=``;for(let t of o.children)t.type===2&&typeof t.value==`string`&&(e+=t.value);e&&this.css.push(e);return}if(o.name===`head`){this.nodes(o.children);return}let s=this.elementMetadata(o);if(o.name===`br`){i.push(t({text:`
|
|
2
|
+
`,preset:this.metadata.presets?.br,...s}));return}if(o.name===`img`){let t=o.attributes?.src;if(!t)throw Error(`Image element must have a 'src' prop.`);i.push(e({src:M(t),...I(o),...s}));return}if(a(o.name))return;if(o.name===`svg`){i.push(e({src:A(o),...I(o),...s}));return}let c=!0,l=``;for(let e of o.children)if(e.type!==3){if(e.type!==2){c=!1;break}l+=e.value??``}if(c&&l){i.push(t({text:M(l),...s}));return}i.push(n({children:this.nodes(o.children),...s}))}elementMetadata(e){let t=e.attributes?L(e.attributes):{};return this.metadata.read(e.name,t,t.class,typeof t.style==`string`?R(t.style):void 0)}};function I(e){return{width:H(e.attributes?.width),height:H(e.attributes?.height)}}function L(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=M(r))}return t}function R(e){let t={},n=0,r=-1,i=0,a=i=>{if(r<0)return;let a=e.slice(n,r).trim(),o=e.slice(r+1,i).trim();a&&o&&(t[V(a)]=o)};for(let t=0;t<e.length;t+=1){let o=e[t];if(o===`\\`)t+=1;else if(o===`"`||o===`'`)t=z(e,t);else if(o===`/`&&e[t+1]===`*`)t=B(e,t);else if(o===`(`)i+=1;else if(o===`)`)i=Math.max(0,i-1);else if(i>0)continue;else o===`:`&&r<0?r=t:o===`;`&&(a(t),n=t+1,r=-1)}return a(e.length),Object.keys(t).length>0?t:void 0}function z(e,t){let n=e[t];for(let r=t+1;r<e.length;r+=1)if(e[r]===`\\`)r+=1;else if(e[r]===n)return r;return e.length}function B(e,t){let n=e.indexOf(`*/`,t+2);return n<0?e.length:n+1}function V(e){return e.startsWith(`--`)?e:e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function H(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}const U=e=>e!==void 0&&`text`in e&&typeof e.text==`string`&&e.text.trim()===``;function W(e){let t=P(e);for(;U(t.nodes[0]);)t.nodes.shift();for(;U(t.nodes.at(-1));)t.nodes.pop();return r(t)}export{W as fromHtml};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { c as Node, d as ReactElementLike, f as RgbaImage, i as Declarations } from "./types-XYUVkGQq.mjs";
|
|
2
|
+
import { CSSProperties, ComponentProps, JSX, ReactElement, ReactNode } from "react";
|
|
3
|
+
//#region src/jsx/style-presets.d.ts
|
|
4
|
+
declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/jsx/metadata.d.ts
|
|
7
|
+
type HtmlProps = {
|
|
8
|
+
className?: string;
|
|
9
|
+
class?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
style?: string | Declarations;
|
|
12
|
+
dir?: string;
|
|
13
|
+
lang?: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/jsx/index.d.ts
|
|
18
|
+
declare module "react" {
|
|
19
|
+
interface DOMAttributes<T> {
|
|
20
|
+
tw?: string;
|
|
21
|
+
}
|
|
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">;
|
|
29
|
+
interface FromJsxOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Override or disable the default Chromium style presets.
|
|
32
|
+
*
|
|
33
|
+
* If an object is provided, all the default style presets will be overridden.
|
|
34
|
+
*
|
|
35
|
+
* If `false` is provided explicitly, no default style presets will be used.
|
|
36
|
+
*/
|
|
37
|
+
defaultStyles?: typeof defaultStylePresets | false;
|
|
38
|
+
/**
|
|
39
|
+
* The JSX prop name used to pass Tailwind classes.
|
|
40
|
+
*
|
|
41
|
+
* @default "tw"
|
|
42
|
+
*/
|
|
43
|
+
tailwindClassesProperty?: string;
|
|
44
|
+
}
|
|
45
|
+
interface FromJsxResult {
|
|
46
|
+
node: Node;
|
|
47
|
+
css: string[];
|
|
48
|
+
/** @deprecated Use `css` instead. */
|
|
49
|
+
stylesheets: string[];
|
|
50
|
+
}
|
|
51
|
+
declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<FromJsxResult>;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { fromJsx as a, FromJsxResult as i, BitmapProps as n, HtmlProps as o, FromJsxOptions as r, defaultStylePresets as s, Bitmap as t };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { c as Node, d as ReactElementLike, f as RgbaImage, i as Declarations } from "./types-XYUVkGQq.cjs";
|
|
2
|
+
import { CSSProperties, ComponentProps, JSX, ReactElement, ReactNode } from "react";
|
|
3
|
+
//#region src/jsx/style-presets.d.ts
|
|
4
|
+
declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/jsx/metadata.d.ts
|
|
7
|
+
type HtmlProps = {
|
|
8
|
+
className?: string;
|
|
9
|
+
class?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
style?: string | Declarations;
|
|
12
|
+
dir?: string;
|
|
13
|
+
lang?: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/jsx/index.d.ts
|
|
18
|
+
declare module "react" {
|
|
19
|
+
interface DOMAttributes<T> {
|
|
20
|
+
tw?: string;
|
|
21
|
+
}
|
|
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">;
|
|
29
|
+
interface FromJsxOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Override or disable the default Chromium style presets.
|
|
32
|
+
*
|
|
33
|
+
* If an object is provided, all the default style presets will be overridden.
|
|
34
|
+
*
|
|
35
|
+
* If `false` is provided explicitly, no default style presets will be used.
|
|
36
|
+
*/
|
|
37
|
+
defaultStyles?: typeof defaultStylePresets | false;
|
|
38
|
+
/**
|
|
39
|
+
* The JSX prop name used to pass Tailwind classes.
|
|
40
|
+
*
|
|
41
|
+
* @default "tw"
|
|
42
|
+
*/
|
|
43
|
+
tailwindClassesProperty?: string;
|
|
44
|
+
}
|
|
45
|
+
interface FromJsxResult {
|
|
46
|
+
node: Node;
|
|
47
|
+
css: string[];
|
|
48
|
+
/** @deprecated Use `css` instead. */
|
|
49
|
+
stylesheets: string[];
|
|
50
|
+
}
|
|
51
|
+
declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<FromJsxResult>;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { fromJsx as a, FromJsxResult as i, BitmapProps as n, HtmlProps as o, FromJsxOptions as r, defaultStylePresets as s, Bitmap as t };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./fonts-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./fonts-By0vjazB.cjs"),t=require("./helpers-_gtvoVXa.cjs"),n=/url\(\s*(['"]?)(.*?)\1\s*\)/g;function r(e){return e.startsWith(`https://`)||e.startsWith(`http://`)}function i(e,t){if(typeof e==`string`)for(let i of e.matchAll(n)){let e=i[2]?.trim();e&&r(e)&&t.add(e)}else if(Array.isArray(e))for(let n of e)i(n,t)}function a(e,t){e&&(i(e.backgroundImage,t),i(e.maskImage,t),i(e.listStyleImage,t))}function o(e,t){if(a(e.style,t),a(e.preset,t),i(e.tw,t),e.type===`image`){typeof e.src==`string`&&r(e.src)&&t.add(e.src);return}if(e.type===`container`)for(let n of e.children??[])o(n,t)}function s(t,n,r){let i=n.maxBytes??33554432,a=r?.get(t);if(a)return new e.l(n).waitFor(a).then(e=>{if(n.allowUrl&&!n.allowUrl(t))throw Error(`URL blocked by allowUrl policy: ${t}`);if(e.byteLength>i)throw Error(`Response exceeds ${i} bytes`);return e});let o=e.s(t,n).then(t=>e.c(t,i)).catch(e=>{throw r?.delete(t),e});return r?.set(t,o),o}async function c({node:e,sources:t=[],fetchCache:n,fetch:r,timeout:i,signal:a,maxBytes:c,allowUrl:l,throwOnError:u=!0}){let d=new Map(t.map(e=>[e.src,e])),f=new Set;for(let t of Array.isArray(e)?e:[e])o(t,f);let p=[...f].filter(e=>!d.has(e)),m={fetch:r,timeout:i,signal:a,maxBytes:c,allowUrl:l},h=p.map(async e=>({src:e,data:await s(e,m,n)})),g=u?await Promise.all(h):(await Promise.allSettled(h)).filter(e=>e.status===`fulfilled`).map(e=>e.value);return[...d.values(),...g]}exports.LIST_MARKER_CHARACTERS=e.t,exports.collectCodepoints=e.n,exports.container=t.t,exports.defaultMaxFetchBytes=e.o,exports.em=t.n,exports.fetchOk=e.s,exports.fontFromUrl=e.r,exports.fr=t.r,exports.googleFonts=e.i,exports.image=t.i,exports.percentage=t.a,exports.prepareImages=c,exports.readBodyLimited=e.c,exports.rem=t.o,exports.rgba=t.s,exports.style=t.c,exports.subsetFonts=e.a,exports.text=t.l,exports.vh=t.u,exports.vw=t.d;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as ImageNode, c as Node, d as ReactElementLike, f as RgbaImage, g as TextNode, h as TextFit, i as Declarations, l as NodeAttributes, m as SupportsRule, n as ContainerNode, o as LayerRule, p as StyleRule, r as CssInput, s as MediaRule, t as AnimationRule, u as NodeMetadata } from "./types-XYUVkGQq.cjs";
|
|
2
|
-
import { a as GoogleFontsOptions, c as fontFromUrl, d as FetchLike, f as FetchOptions, h as readBodyLimited, i as GoogleFontFamily, l as googleFonts, m as fetchOk, n as FontSubset, o as LIST_MARKER_CHARACTERS, p as defaultMaxFetchBytes, r as GenericFontFamily, s as collectCodepoints, t as CodepointSource, u as subsetFonts } from "./fonts-
|
|
2
|
+
import { a as GoogleFontsOptions, c as fontFromUrl, d as FetchLike, f as FetchOptions, h as readBodyLimited, i as GoogleFontFamily, l as googleFonts, m as fetchOk, n as FontSubset, o as LIST_MARKER_CHARACTERS, p as defaultMaxFetchBytes, r as GenericFontFamily, s as collectCodepoints, t as CodepointSource, u as subsetFonts } from "./fonts-DPg6KAvr.cjs";
|
|
3
3
|
//#region src/helpers.d.ts
|
|
4
4
|
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
5
5
|
declare function text(text: string, style?: Declarations): TextNode;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as ImageNode, c as Node, d as ReactElementLike, f as RgbaImage, g as TextNode, h as TextFit, i as Declarations, l as NodeAttributes, m as SupportsRule, n as ContainerNode, o as LayerRule, p as StyleRule, r as CssInput, s as MediaRule, t as AnimationRule, u as NodeMetadata } from "./types-XYUVkGQq.mjs";
|
|
2
|
-
import { a as GoogleFontsOptions, c as fontFromUrl, d as FetchLike, f as FetchOptions, h as readBodyLimited, i as GoogleFontFamily, l as googleFonts, m as fetchOk, n as FontSubset, o as LIST_MARKER_CHARACTERS, p as defaultMaxFetchBytes, r as GenericFontFamily, s as collectCodepoints, t as CodepointSource, u as subsetFonts } from "./fonts-
|
|
2
|
+
import { a as GoogleFontsOptions, c as fontFromUrl, d as FetchLike, f as FetchOptions, h as readBodyLimited, i as GoogleFontFamily, l as googleFonts, m as fetchOk, n as FontSubset, o as LIST_MARKER_CHARACTERS, p as defaultMaxFetchBytes, r as GenericFontFamily, s as collectCodepoints, t as CodepointSource, u as subsetFonts } from "./fonts-DSTCfPh9.mjs";
|
|
3
3
|
//#region src/helpers.d.ts
|
|
4
4
|
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
5
5
|
declare function text(text: string, style?: Declarations): TextNode;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./fonts-
|
|
1
|
+
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./fonts-CuoRVPJ8.mjs";import{a as l,c as u,d,i as f,l as p,n as m,o as h,r as g,s as _,t as v,u as y}from"./helpers-CrbDeBIp.mjs";const b=/url\(\s*(['"]?)(.*?)\1\s*\)/g;function x(e){return e.startsWith(`https://`)||e.startsWith(`http://`)}function S(e,t){if(typeof e==`string`)for(let n of e.matchAll(b)){let e=n[2]?.trim();e&&x(e)&&t.add(e)}else if(Array.isArray(e))for(let n of e)S(n,t)}function C(e,t){e&&(S(e.backgroundImage,t),S(e.maskImage,t),S(e.listStyleImage,t))}function w(e,t){if(C(e.style,t),C(e.preset,t),S(e.tw,t),e.type===`image`){typeof e.src==`string`&&x(e.src)&&t.add(e.src);return}if(e.type===`container`)for(let n of e.children??[])w(n,t)}function T(e,n,i){let a=n.maxBytes??33554432,o=i?.get(e);if(o)return new r(n).waitFor(o).then(t=>{if(n.allowUrl&&!n.allowUrl(e))throw Error(`URL blocked by allowUrl policy: ${e}`);if(t.byteLength>a)throw Error(`Response exceeds ${a} bytes`);return t});let c=s(e,n).then(e=>t(e,a)).catch(t=>{throw i?.delete(e),t});return i?.set(e,c),c}async function E({node:e,sources:t=[],fetchCache:n,fetch:r,timeout:i,signal:a,maxBytes:o,allowUrl:s,throwOnError:c=!0}){let l=new Map(t.map(e=>[e.src,e])),u=new Set;for(let t of Array.isArray(e)?e:[e])w(t,u);let d=[...u].filter(e=>!l.has(e)),f={fetch:r,timeout:i,signal:a,maxBytes:o,allowUrl:s},p=d.map(async e=>({src:e,data:await T(e,f,n)})),m=c?await Promise.all(p):(await Promise.allSettled(p)).filter(e=>e.status===`fulfilled`).map(e=>e.value);return[...l.values(),...m]}export{c as LIST_MARKER_CHARACTERS,i as collectCodepoints,v as container,a as defaultMaxFetchBytes,m as em,s as fetchOk,o as fontFromUrl,g as fr,n as googleFonts,f as image,l as percentage,E as prepareImages,t as readBodyLimited,h as rem,_ as rgba,u as style,e as subsetFonts,p as text,y as vh,d as vw};
|
package/dist/jsx.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-
|
|
2
|
-
`,preset:
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-_gtvoVXa.cjs"),t=require("./utils-DXKpO9jU.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)return o(t,`H`);let n=r(r(e,`__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED`),`ReactCurrentDispatcher`);return typeof n==`object`&&n&&`current`in n?o(n,`current`):null}function o(e,t){return{get:()=>e[t],set:n=>{e[t]=n}}}function s(){return n??=import(`react`).then(e=>a(e.default??e)).catch(()=>null),n}function c(e,t){return e.contexts.has(t)?e.contexts.get(t):r(t,`_currentValue`)}const l=()=>{};function u(e,t){let n=t=>c(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,l],useReducer:(e,t,n)=>[n?n(t):t,l],useMemo:e=>e(),useCallback:e=>e,useRef:e=>({current:e}),useEffect:l,useLayoutEffect:l,useInsertionEffect:l,useImperativeHandle:l,useDebugValue:l,useDeferredValue:e=>e,useTransition:()=>[!1,l],useOptimistic:e=>[e,l],useActionState:(e,t)=>[t,l,!1],useSyncExternalStore:(e,t,n)=>(n??t)(),useId:()=>`:t${t}-${r++}:`,useCacheRefresh:()=>l,useHostTransitionStatus:()=>({pending:!1,data:null,method:null,action:null})}}async function d(e,t,n){let r=await s();if(!r)return e(t);let a=n.ids.current++;for(let o=0;;o++){let s=r.get();r.set(u(n,a));let c;try{return e(t)}catch(e){c=e}finally{r.set(s)}if(!i(c)||o>=64)throw c;await f(c)}}async function f(e){try{e.value=await e,e.status=`fulfilled`}catch(t){e.reason=t,e.status=`rejected`}}const p=`:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\u{10000}-\\u{EFFFF}`,m=RegExp(`^[${p}][${p}\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`,`u`),h=/^(?:--|-?[A-Za-z_\u0080-\u{10FFFF}])[\w\u0080-\u{10FFFF}-]*$/u,g=new Map([[`(`,`)`],[`[`,`]`],[`{`,`}`]]),_=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 v(e){let{xmlns:t,...n}=e.props;return y(t==null?{...e,props:{...n,xmlns:`http://www.w3.org/2000/svg`}}:e)}function y(e){return typeof e==`string`||typeof e==`number`?E(String(e)):Array.isArray(e)?e.map(e=>y(e)).join(``):t.c(e)?b(e):``}function b(e){let{type:n}=e,r=e.props||{};return t.n(n)?y(n(e.props)):typeof n==`symbol`?y(r.children):t.i(n)?y(n.render(e.props,null)):t.o(n)?b({...e,type:n.type}):typeof n==`string`?(T(n,`element`),`<${n}${x(r)}>${y(r.children)}</${n}>`):``}function x(e){let t=``;for(let[n,r]of Object.entries(e)){if(n===`children`||r==null)continue;let e=S(n);T(e,`attribute`);let i=n===`style`&&typeof r==`object`?C(r):String(r);t+=` ${e}="${E(i)}"`}return t}function S(e){return e===`className`?`class`:_.has(e)?t.t(e):e}function C(e){return Object.entries(e).map(([e,n])=>{let r=t.t(e),i=String(n).trim();if(!h.test(r))throw Error(`Invalid SVG style property: ${JSON.stringify(e)}`);if(!w(i))throw Error(`Invalid SVG style value: ${JSON.stringify(i)}`);return`${r}:${i}`}).join(`;`)}function w(e){let t=[],n;for(let r=0;r<e.length;r++){let i=e.charAt(r);if(i===`\\`){if(r===e.length-1)return!1;r++;continue}if(n){i===n&&(n=void 0);continue}if(i===`"`||i===`'`){n=i;continue}if(i===`/`&&e.charAt(r+1)===`*`){let t=e.indexOf(`*/`,r+2);if(t===-1)return!1;r=t+1;continue}let a=g.get(i);if(a){t.push(a);continue}if(i===`)`||i===`]`||i===`}`){if(t.pop()!==i)return!1;continue}if(i===`;`&&t.length===0)return/^[;\s]*$/.test(e.slice(r))}return n===void 0&&t.length===0}function T(e,t){if(!m.test(e))throw Error(`Invalid SVG ${t} name: ${JSON.stringify(e)}`)}function E(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`)}function D({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}}async function O(e,n){let r=new P(new t.l(n),new Map,{current:0});return t.d(await r.build(e))}const k=Symbol.for(`react.context`),A=Symbol.for(`react.provider`),j=Symbol.for(`react.consumer`);function M(){return{nodes:[],css:[]}}function N(e){return{nodes:[e],css:[]}}var P=class n{metadata;contexts;ids;constructor(e,t,n){this.metadata=e,this.contexts=t,this.ids=n}async build(n){return n==null||n===!1?M():n instanceof Promise?this.build(await n):typeof n==`object`&&Symbol.iterator in n?this.iterable(n):t.c(n)?this.element(n):N(e.l({text:String(n),preset:this.metadata.presets?.span}))}async element(n){let r=this.tryContext(n);if(r!==void 0)return r;if(t.n(n.type))return this.functionComponent(n.type,n.props);let i=this.tryWrapper(n);if(i!==void 0)return i;if(t.a(n))return this.children(n);if(t.r(n,`style`)){let e=z(I(n));return{nodes:[],css:e&&e.length>0?[e]:[]}}if(t.r(n,`head`))return{nodes:[],css:(await this.children(n)).css};if(typeof n.type!=`string`||t.s(n.type))return M();let a=this.elementMetadata(n);if(t.r(n,`br`))return N(e.l({text:`
|
|
2
|
+
`,preset:this.metadata.presets?.br,...a}));if(t.r(n,`img`)){if(!n.props.src)throw Error(`Image element must have a 'src' prop.`);return N(e.i({src:n.props.src,...F(n.props),...a}))}if(t.r(n,`svg`))return N(e.i({src:v(n),...F(n.props),...a}));let o=L(n);if(o!==void 0)return N(e.l({text:o,...a}));let s=await this.children(n);return{nodes:[e.t({children:s.nodes,...a})],css:s.css}}tryContext(e){let t=e.type;if(typeof t!=`object`||!t)return;let n=r(t,`$$typeof`);if(n===A)return this.childrenWithContext(e,r(t,`_context`));if(n===j)return this.consumer(e,r(t,`_context`)??t);if(n===k)return typeof I(e)==`function`?this.consumer(e,t):this.childrenWithContext(e,t)}tryWrapper(e){if(t.i(e.type)){let{render:t}=e.type;return this.functionComponent(e=>t(e,null),e.props)}if(t.o(e.type)){let n=e.type.type;return t.n(n)?this.functionComponent(n,e.props):this.element({...e,type:n})}}childrenWithContext(e,t){let i=new Map(this.contexts);return i.set(t,r(e.props,`value`)),new n(this.metadata,i,this.ids).children(e)}consumer(e,n){let r=I(e);return t.n(r)?this.build(r(c(this,n))):this.children(e)}async functionComponent(e,t){return this.build(await d(e,t,this))}children(e){let t=I(e);return t===void 0?Promise.resolve(M()):this.build(t)}async iterable(e){let t=[],n=new Set,r=0;for(let i of e){let e=r++,a=this.build(i).then(n=>{t[e]=n}).finally(()=>n.delete(a));n.add(a),n.size>=8&&await Promise.race(n)}return await Promise.all(n),{nodes:t.flatMap(e=>e.nodes),css:t.flatMap(e=>e.css)}}elementMetadata(e){let t=e.props,n=t.style;return this.metadata.read(typeof e.type==`string`?e.type:void 0,t,t.className??t.class,typeof n==`object`&&n&&Object.keys(n).length>0?n:void 0)}};function F({width:e,height:t}){return{width:e===void 0?void 0:Number(e),height:t===void 0?void 0:Number(t)}}function I(e){return r(e.props,`children`)}function L(e){let n=I(e);if(typeof n==`string`)return n;if(typeof n==`number`)return String(n);if(typeof n==`object`&&n&&Symbol.iterator in n)return R(n);if(t.c(n)&&t.a(n))return L(n)}function R(e){let t;for(let n of e){if(typeof n!=`string`&&typeof n!=`number`)return;t=(t??``)+n}return t}function z(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 B(e);if(t.c(e))return z(I(e))}function B(e){let t=[];for(let n of e){let e=z(n);if(e===void 0)return;t.push(e)}return t.join(``)}exports.Bitmap=D,exports.defaultStylePresets=t.u,exports.fromJsx=O;
|
package/dist/jsx.d.cts
CHANGED
|
@@ -1,53 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CSSProperties, ComponentProps, JSX, ReactElement, ReactNode } from "react";
|
|
3
|
-
//#region src/jsx/style-presets.d.ts
|
|
4
|
-
declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/jsx/metadata.d.ts
|
|
7
|
-
type HtmlProps = {
|
|
8
|
-
className?: string;
|
|
9
|
-
class?: string;
|
|
10
|
-
id?: string;
|
|
11
|
-
style?: string | Declarations;
|
|
12
|
-
dir?: string;
|
|
13
|
-
lang?: string;
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
};
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/jsx/index.d.ts
|
|
18
|
-
declare module "react" {
|
|
19
|
-
interface DOMAttributes<T> {
|
|
20
|
-
tw?: string;
|
|
21
|
-
}
|
|
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">;
|
|
29
|
-
interface FromJsxOptions {
|
|
30
|
-
/**
|
|
31
|
-
* Override or disable the default Chromium style presets.
|
|
32
|
-
*
|
|
33
|
-
* If an object is provided, all the default style presets will be overridden.
|
|
34
|
-
*
|
|
35
|
-
* If `false` is provided explicitly, no default style presets will be used.
|
|
36
|
-
*/
|
|
37
|
-
defaultStyles?: typeof defaultStylePresets | false;
|
|
38
|
-
/**
|
|
39
|
-
* The JSX prop name used to pass Tailwind classes.
|
|
40
|
-
*
|
|
41
|
-
* @default "tw"
|
|
42
|
-
*/
|
|
43
|
-
tailwindClassesProperty?: string;
|
|
44
|
-
}
|
|
45
|
-
interface FromJsxResult {
|
|
46
|
-
node: Node;
|
|
47
|
-
css: string[];
|
|
48
|
-
/** @deprecated Use `css` instead. */
|
|
49
|
-
stylesheets: string[];
|
|
50
|
-
}
|
|
51
|
-
declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<FromJsxResult>;
|
|
52
|
-
//#endregion
|
|
1
|
+
import { a as fromJsx, i as FromJsxResult, n as BitmapProps, o as HtmlProps, r as FromJsxOptions, s as defaultStylePresets, t as Bitmap } from "./index-CnGC2zXt.cjs";
|
|
53
2
|
export { Bitmap, BitmapProps, FromJsxOptions, FromJsxResult, type HtmlProps, defaultStylePresets, fromJsx };
|
package/dist/jsx.d.mts
CHANGED
|
@@ -1,53 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CSSProperties, ComponentProps, JSX, ReactElement, ReactNode } from "react";
|
|
3
|
-
//#region src/jsx/style-presets.d.ts
|
|
4
|
-
declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/jsx/metadata.d.ts
|
|
7
|
-
type HtmlProps = {
|
|
8
|
-
className?: string;
|
|
9
|
-
class?: string;
|
|
10
|
-
id?: string;
|
|
11
|
-
style?: string | Declarations;
|
|
12
|
-
dir?: string;
|
|
13
|
-
lang?: string;
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
};
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/jsx/index.d.ts
|
|
18
|
-
declare module "react" {
|
|
19
|
-
interface DOMAttributes<T> {
|
|
20
|
-
tw?: string;
|
|
21
|
-
}
|
|
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">;
|
|
29
|
-
interface FromJsxOptions {
|
|
30
|
-
/**
|
|
31
|
-
* Override or disable the default Chromium style presets.
|
|
32
|
-
*
|
|
33
|
-
* If an object is provided, all the default style presets will be overridden.
|
|
34
|
-
*
|
|
35
|
-
* If `false` is provided explicitly, no default style presets will be used.
|
|
36
|
-
*/
|
|
37
|
-
defaultStyles?: typeof defaultStylePresets | false;
|
|
38
|
-
/**
|
|
39
|
-
* The JSX prop name used to pass Tailwind classes.
|
|
40
|
-
*
|
|
41
|
-
* @default "tw"
|
|
42
|
-
*/
|
|
43
|
-
tailwindClassesProperty?: string;
|
|
44
|
-
}
|
|
45
|
-
interface FromJsxResult {
|
|
46
|
-
node: Node;
|
|
47
|
-
css: string[];
|
|
48
|
-
/** @deprecated Use `css` instead. */
|
|
49
|
-
stylesheets: string[];
|
|
50
|
-
}
|
|
51
|
-
declare function fromJsx(element: ReactNode | ReactElementLike, options?: FromJsxOptions): Promise<FromJsxResult>;
|
|
52
|
-
//#endregion
|
|
1
|
+
import { a as fromJsx, i as FromJsxResult, n as BitmapProps, o as HtmlProps, r as FromJsxOptions, s as defaultStylePresets, t as Bitmap } from "./index-BZLLNDfO.mjs";
|
|
53
2
|
export { Bitmap, BitmapProps, FromJsxOptions, FromJsxResult, type HtmlProps, defaultStylePresets, fromJsx };
|
package/dist/jsx.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`,preset:
|
|
1
|
+
import{i as e,l as t,t as n}from"./helpers-CrbDeBIp.mjs";import{a as r,c as i,d as a,i as o,l as s,n as c,o as l,r as u,s as d,t as f,u as p}from"./utils-DivIadzC.mjs";let m;function h(e,t){return typeof e==`object`&&e&&t in e?e[t]:void 0}function g(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function _(e){let t=h(e,`__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE`);if(typeof t==`object`&&t&&`H`in t)return v(t,`H`);let n=h(h(e,`__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED`),`ReactCurrentDispatcher`);return typeof n==`object`&&n&&`current`in n?v(n,`current`):null}function v(e,t){return{get:()=>e[t],set:n=>{e[t]=n}}}function y(){return m??=import(`react`).then(e=>_(e.default??e)).catch(()=>null),m}function b(e,t){return e.contexts.has(t)?e.contexts.get(t):h(t,`_currentValue`)}const x=()=>{};function S(e,t){let n=t=>b(e,t),r=0;return{readContext:n,useContext:n,use:e=>{if(g(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 C(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(S(n,i));let s;try{return e(t)}catch(e){s=e}finally{r.set(o)}if(!g(s)||a>=64)throw s;await w(s)}}async function w(e){try{e.value=await e,e.status=`fulfilled`}catch(t){e.reason=t,e.status=`rejected`}}const T=`:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\u{10000}-\\u{EFFFF}`,E=RegExp(`^[${T}][${T}\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`,`u`),D=/^(?:--|-?[A-Za-z_\u0080-\u{10FFFF}])[\w\u0080-\u{10FFFF}-]*$/u,O=new Map([[`(`,`)`],[`[`,`]`],[`{`,`}`]]),k=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 A(e){let{xmlns:t,...n}=e.props;return j(t==null?{...e,props:{...n,xmlns:`http://www.w3.org/2000/svg`}}:e)}function j(e){return typeof e==`string`||typeof e==`number`?R(String(e)):Array.isArray(e)?e.map(e=>j(e)).join(``):i(e)?M(e):``}function M(e){let{type:t}=e,n=e.props||{};return c(t)?j(t(e.props)):typeof t==`symbol`?j(n.children):o(t)?j(t.render(e.props,null)):l(t)?M({...e,type:t.type}):typeof t==`string`?(L(t,`element`),`<${t}${N(n)}>${j(n.children)}</${t}>`):``}function N(e){let t=``;for(let[n,r]of Object.entries(e)){if(n===`children`||r==null)continue;let e=P(n);L(e,`attribute`);let i=n===`style`&&typeof r==`object`?F(r):String(r);t+=` ${e}="${R(i)}"`}return t}function P(e){return e===`className`?`class`:k.has(e)?f(e):e}function F(e){return Object.entries(e).map(([e,t])=>{let n=f(e),r=String(t).trim();if(!D.test(n))throw Error(`Invalid SVG style property: ${JSON.stringify(e)}`);if(!I(r))throw Error(`Invalid SVG style value: ${JSON.stringify(r)}`);return`${n}:${r}`}).join(`;`)}function I(e){let t=[],n;for(let r=0;r<e.length;r++){let i=e.charAt(r);if(i===`\\`){if(r===e.length-1)return!1;r++;continue}if(n){i===n&&(n=void 0);continue}if(i===`"`||i===`'`){n=i;continue}if(i===`/`&&e.charAt(r+1)===`*`){let t=e.indexOf(`*/`,r+2);if(t===-1)return!1;r=t+1;continue}let a=O.get(i);if(a){t.push(a);continue}if(i===`)`||i===`]`||i===`}`){if(t.pop()!==i)return!1;continue}if(i===`;`&&t.length===0)return/^[;\s]*$/.test(e.slice(r))}return n===void 0&&t.length===0}function L(e,t){if(!E.test(e))throw Error(`Invalid SVG ${t} name: ${JSON.stringify(e)}`)}function R(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`)}function z({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}}async function B(e,t){let n=new K(new s(t),new Map,{current:0});return a(await n.build(e))}const V=Symbol.for(`react.context`),H=Symbol.for(`react.provider`),U=Symbol.for(`react.consumer`);function W(){return{nodes:[],css:[]}}function G(e){return{nodes:[e],css:[]}}var K=class a{metadata;contexts;ids;constructor(e,t,n){this.metadata=e,this.contexts=t,this.ids=n}async build(e){return e==null||e===!1?W():e instanceof Promise?this.build(await e):typeof e==`object`&&Symbol.iterator in e?this.iterable(e):i(e)?this.element(e):G(t({text:String(e),preset:this.metadata.presets?.span}))}async element(i){let a=this.tryContext(i);if(a!==void 0)return a;if(c(i.type))return this.functionComponent(i.type,i.props);let o=this.tryWrapper(i);if(o!==void 0)return o;if(r(i))return this.children(i);if(u(i,`style`)){let e=Z(J(i));return{nodes:[],css:e&&e.length>0?[e]:[]}}if(u(i,`head`))return{nodes:[],css:(await this.children(i)).css};if(typeof i.type!=`string`||d(i.type))return W();let s=this.elementMetadata(i);if(u(i,`br`))return G(t({text:`
|
|
2
|
+
`,preset:this.metadata.presets?.br,...s}));if(u(i,`img`)){if(!i.props.src)throw Error(`Image element must have a 'src' prop.`);return G(e({src:i.props.src,...q(i.props),...s}))}if(u(i,`svg`))return G(e({src:A(i),...q(i.props),...s}));let l=Y(i);if(l!==void 0)return G(t({text:l,...s}));let f=await this.children(i);return{nodes:[n({children:f.nodes,...s})],css:f.css}}tryContext(e){let t=e.type;if(typeof t!=`object`||!t)return;let n=h(t,`$$typeof`);if(n===H)return this.childrenWithContext(e,h(t,`_context`));if(n===U)return this.consumer(e,h(t,`_context`)??t);if(n===V)return typeof J(e)==`function`?this.consumer(e,t):this.childrenWithContext(e,t)}tryWrapper(e){if(o(e.type)){let{render:t}=e.type;return this.functionComponent(e=>t(e,null),e.props)}if(l(e.type)){let t=e.type.type;return c(t)?this.functionComponent(t,e.props):this.element({...e,type:t})}}childrenWithContext(e,t){let n=new Map(this.contexts);return n.set(t,h(e.props,`value`)),new a(this.metadata,n,this.ids).children(e)}consumer(e,t){let n=J(e);return c(n)?this.build(n(b(this,t))):this.children(e)}async functionComponent(e,t){return this.build(await C(e,t,this))}children(e){let t=J(e);return t===void 0?Promise.resolve(W()):this.build(t)}async iterable(e){let t=[],n=new Set,r=0;for(let i of e){let e=r++,a=this.build(i).then(n=>{t[e]=n}).finally(()=>n.delete(a));n.add(a),n.size>=8&&await Promise.race(n)}return await Promise.all(n),{nodes:t.flatMap(e=>e.nodes),css:t.flatMap(e=>e.css)}}elementMetadata(e){let t=e.props,n=t.style;return this.metadata.read(typeof e.type==`string`?e.type:void 0,t,t.className??t.class,typeof n==`object`&&n&&Object.keys(n).length>0?n:void 0)}};function q({width:e,height:t}){return{width:e===void 0?void 0:Number(e),height:t===void 0?void 0:Number(t)}}function J(e){return h(e.props,`children`)}function Y(e){let t=J(e);if(typeof t==`string`)return t;if(typeof t==`number`)return String(t);if(typeof t==`object`&&t&&Symbol.iterator in t)return X(t);if(i(t)&&r(t))return Y(t)}function X(e){let t;for(let n of e){if(typeof n!=`string`&&typeof n!=`number`)return;t=(t??``)+n}return t}function Z(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(i(e))return Z(J(e))}function Q(e){let t=[];for(let n of e){let e=Z(n);if(e===void 0)return;t.push(e)}return t.join(``)}export{z as Bitmap,p as defaultStylePresets,B as fromJsx};
|
package/dist/renderer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./fonts-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./fonts-By0vjazB.cjs");function t(e){return e instanceof Uint8Array||e instanceof ArrayBuffer||typeof Buffer<`u`&&Buffer.isBuffer(e)}function n(e){return e instanceof ArrayBuffer?new Uint8Array(e):e}function r(e){return t(e)?e:typeof e.data==`function`?e.data():e.data}function i(e){return t(e)?e:`key`in e&&e.key?e.key:typeof e.data==`function`?`${e.name??``}:${e.weight??``}:${e.style??``}`:e.data}async function a(e){let{sources:t=[],cache:r}=Array.isArray(e)?{sources:e}:e,i=new Map(t.map(e=>[e.src,e]));return Promise.all([...i.values()].map(async({src:e,data:t,cache:i})=>({src:e,data:n(typeof t==`function`?await t():t),cache:i??r})))}var o=class{registerInner;byKey=new Map;byData=new WeakMap;constructor(e){this.registerInner=e}getFont(e){return typeof e==`string`?this.byKey.get(e):this.byData.get(e)}setFont(e,t){typeof e==`string`?this.byKey.set(e,t):this.byData.set(e,t)}deleteFont(e){typeof e==`string`?this.byKey.delete(e):this.byData.delete(e)}async register(a){let o=typeof a==`string`?e.r(a):a,s=i(o),c=this.getFont(s);if(c)return c;let l=Promise.resolve(r(o)).then(e=>{let r=n(e);return this.registerInner(t(o)?r:{...o,data:r})}).catch(e=>{throw this.deleteFont(s),e});return this.setFont(s,l),l}async prepareFonts(e){if(!e)return;let t=await Promise.all(e.map(e=>this.register(e)));return[...new Set(t.flat().map(e=>e.name))]}async resolveResources(e,t,n){let r=await this.prepareFonts(e);return{images:t?await a(t):void 0,fontFamilies:n??r}}};async function s(t,n,r){let{fonts:i,fontFamilies:a,signal:o,images:s,...c}=n;o?.throwIfAborted();let l=await i,u=await t.resolveResources(l&&e.a({fonts:l,source:[...Array.isArray(r)?r:[r],`•◦■▪▸◂▾ 0123456789.-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`]}),s,a);return o?.throwIfAborted(),{options:{...c,...u},signal:o}}exports.FontRegistry=o,exports.prepareRenderInput=s,exports.resolveImageLoaders=a;
|
package/dist/renderer.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as GenericFontFamily, t as CodepointSource } from "./fonts-
|
|
1
|
+
import { r as GenericFontFamily, t as CodepointSource } from "./fonts-DPg6KAvr.cjs";
|
|
2
2
|
//#region src/renderer.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Shared wrapper primitives for the `@takumi-rs/core` (napi) and `@takumi-rs/wasm` renderer
|
package/dist/renderer.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as GenericFontFamily, t as CodepointSource } from "./fonts-
|
|
1
|
+
import { r as GenericFontFamily, t as CodepointSource } from "./fonts-DSTCfPh9.mjs";
|
|
2
2
|
//#region src/renderer.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Shared wrapper primitives for the `@takumi-rs/core` (napi) and `@takumi-rs/wasm` renderer
|
package/dist/renderer.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,r as t}from"./fonts-
|
|
1
|
+
import{a as e,r as t}from"./fonts-CuoRVPJ8.mjs";function n(e){return e instanceof Uint8Array||e instanceof ArrayBuffer||typeof Buffer<`u`&&Buffer.isBuffer(e)}function r(e){return e instanceof ArrayBuffer?new Uint8Array(e):e}function i(e){return n(e)?e:typeof e.data==`function`?e.data():e.data}function a(e){return n(e)?e:`key`in e&&e.key?e.key:typeof e.data==`function`?`${e.name??``}:${e.weight??``}:${e.style??``}`:e.data}async function o(e){let{sources:t=[],cache:n}=Array.isArray(e)?{sources:e}:e,i=new Map(t.map(e=>[e.src,e]));return Promise.all([...i.values()].map(async({src:e,data:t,cache:i})=>({src:e,data:r(typeof t==`function`?await t():t),cache:i??n})))}var s=class{registerInner;byKey=new Map;byData=new WeakMap;constructor(e){this.registerInner=e}getFont(e){return typeof e==`string`?this.byKey.get(e):this.byData.get(e)}setFont(e,t){typeof e==`string`?this.byKey.set(e,t):this.byData.set(e,t)}deleteFont(e){typeof e==`string`?this.byKey.delete(e):this.byData.delete(e)}async register(e){let o=typeof e==`string`?t(e):e,s=a(o),c=this.getFont(s);if(c)return c;let l=Promise.resolve(i(o)).then(e=>{let t=r(e);return this.registerInner(n(o)?t:{...o,data:t})}).catch(e=>{throw this.deleteFont(s),e});return this.setFont(s,l),l}async prepareFonts(e){if(!e)return;let t=await Promise.all(e.map(e=>this.register(e)));return[...new Set(t.flat().map(e=>e.name))]}async resolveResources(e,t,n){let r=await this.prepareFonts(e);return{images:t?await o(t):void 0,fontFamilies:n??r}}};async function c(t,n,r){let{fonts:i,fontFamilies:a,signal:o,images:s,...c}=n;o?.throwIfAborted();let l=await i,u=await t.resolveResources(l&&e({fonts:l,source:[...Array.isArray(r)?r:[r],`•◦■▪▸◂▾ 0123456789.-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`]}),s,a);return o?.throwIfAborted(),{options:{...c,...u},signal:o}}export{s as FontRegistry,c as prepareRenderInput,o as resolveImageLoaders};
|