Comparing version 0.0.7 to 0.0.8-beta.0
@@ -1,1 +0,1 @@ | ||
var st=Object.defineProperty,ft=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var lt=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var Q=(t,o,e)=>o in t?st(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,N=(t,o)=>{for(var e in o||(o={}))lt.call(o,e)&&Q(t,e,o[e]);if(K)for(var e of K(o))ct.call(o,e)&&Q(t,e,o[e]);return t},Z=(t,o)=>ft(t,ut(o));import L from"yoga-layout-prebuilt";import $t from"yoga-layout-prebuilt";function w(t){let o=typeof t;return!(o==="number"||o==="bigint"||o==="string"||o==="boolean")}function tt(t){return/^class\s/.test(Function.prototype.toString.call(t))}function F(t,o){return[t[0]*o[0]+t[2]*o[1],t[1]*o[0]+t[3]*o[1],t[0]*o[2]+t[2]*o[3],t[1]*o[2]+t[3]*o[3],t[0]*o[4]+t[2]*o[5]+t[4],t[1]*o[4]+t[3]*o[5]+t[5]]}import s from"yoga-layout-prebuilt";var et={p:{display:"block",marginTop:"1em",marginBottom:"1em"},div:{display:"block"},blockquote:{display:"block",marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40},center:{display:"block",textAlign:"center"},hr:{display:"block",marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,borderStyle:"inset"},h1:{display:"block",fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h2:{display:"block",fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold"},h3:{display:"block",fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold"},h4:{display:"block",marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},h5:{display:"block",fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h6:{display:"block",fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},u:{textDecoration:"underline"},strong:{fontWeight:"bold"},b:{fontWeight:"bold"},i:{fontStyle:"italic"},em:{fontStyle:"italic"},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{display:"block",fontFamily:"monospace",whiteSpace:"pre",marginTop:"1em",marginBottom:"1em"},mark:{backgroundColor:"yellow",color:"black"},big:{fontSize:"larger"},small:{fontSize:"smaller"},s:{textDecoration:"line-through"}};var mt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","opacity"]);function M(t){let o={};for(let e in t)mt.has(e)&&(o[e]=t[e]);return o}import dt,{getPropertyName as pt}from"css-to-react-native";import ot from"parse-css-dimension";import{parseElementStyle as gt}from"css-background-parser";var ht=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),rt=[1,0,0,1,0,0];function bt(t,o){return typeof o=="number"?ht.has(t)?String(o):o+"px":o}function nt(t,o){if(typeof t=="number")return t;try{let e=new ot(t);if(e.type==="length")switch(e.unit){case"em":return e.value*o;case"rem":return e.value*16;default:return e.value}else if(e.type==="angle")switch(e.unit){case"deg":return e.value;case"rad":return e.value*180/Math.PI;default:return e.value}}catch{}}function B(t,o){let e=[];for(let r in t){let i=pt(r);e.push([i,bt(i,t[r])])}let n=dt(e);if(n.backgroundImage){let{backgrounds:r}=gt(n);n.backgroundImage=r}let f=n.fontSize||o.fontSize;if(typeof f=="string")try{let r=new ot(f);switch(r.unit){case"em":f=r.value*o.fontSize;break;case"rem":f=r.value*16;break}}catch{f=16}n.fontSize=f;for(let r in n){let i=n[r];if(typeof i=="string"){let a=nt(i,f);typeof a!="undefined"&&(n[r]=a),i=n[r]}if(r==="opacity"&&(i=n[r]=i*o.opacity),r==="transform"){let a=[...rt],c=i;for(let u of c){let d=Object.keys(u)[0],g=u[d],m=typeof g=="string"?nt(g,f):g,l=[...rt];switch(d){case"translateX":l[4]=m;break;case"translateY":l[5]=m;break;case"scaleX":l[0]=m;break;case"scaleY":l[3]=m;break;case"rotate":let p=m*Math.PI/180,h=Math.cos(p),E=Math.sin(p);l[0]=h,l[1]=E,l[2]=-E,l[3]=h;break;case"skewX":l[2]=Math.tan(m*Math.PI/180);break;case"skewY":l[1]=Math.tan(m*Math.PI/180);break}a=F(l,a)}n.transform=a}}return n}function S(t,o,e){let n=o[t];return typeof n=="undefined"?e:n}function Y(t,o,e,n,f){let r=N(N(N({},e),B(et[o],e)),B(n,e));if(o==="img"){let i=parseInt(f.width),c=parseInt(f.height)/i;r.width||(r.width=i),r.height||(r.height=c*r.width)}return t.setDisplay(S(r.display,{flex:s.DISPLAY_FLEX,none:s.DISPLAY_NONE},s.DISPLAY_FLEX)),t.setAlignContent(S(r.alignContent,{stretch:s.ALIGN_STRETCH,center:s.ALIGN_CENTER,"flex-start":s.ALIGN_FLEX_START,"flex-end":s.ALIGN_FLEX_END,"space-between":s.ALIGN_SPACE_BETWEEN,"space-around":s.ALIGN_SPACE_AROUND,baseline:s.ALIGN_BASELINE,normal:s.ALIGN_AUTO},s.ALIGN_AUTO)),t.setAlignItems(S(r.alignItems,{stretch:s.ALIGN_STRETCH,center:s.ALIGN_CENTER,"flex-start":s.ALIGN_FLEX_START,"flex-end":s.ALIGN_FLEX_END,baseline:s.ALIGN_BASELINE,normal:s.ALIGN_AUTO},s.ALIGN_FLEX_START)),t.setAlignSelf(S(r.alignSelf,{stretch:s.ALIGN_STRETCH,center:s.ALIGN_CENTER,"flex-start":s.ALIGN_FLEX_START,"flex-end":s.ALIGN_FLEX_END,baseline:s.ALIGN_BASELINE,normal:s.ALIGN_AUTO},s.ALIGN_AUTO)),t.setJustifyContent(S(r.justifyContent,{center:s.JUSTIFY_CENTER,"flex-start":s.JUSTIFY_FLEX_START,"flex-end":s.JUSTIFY_FLEX_END,"space-between":s.JUSTIFY_SPACE_BETWEEN,"space-around":s.JUSTIFY_SPACE_AROUND},s.JUSTIFY_FLEX_START)),t.setFlexDirection(S(r.flexDirection,{row:s.FLEX_DIRECTION_ROW,column:s.FLEX_DIRECTION_COLUMN,"row-reverse":s.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":s.FLEX_DIRECTION_COLUMN_REVERSE},s.FLEX_DIRECTION_ROW)),t.setFlexWrap(S(r.flexWrap,{wrap:s.WRAP_WRAP,nowrap:s.WRAP_NO_WRAP,"wrap-reverse":s.WRAP_WRAP_REVERSE},s.WRAP_WRAP)),typeof r.flexBasis!="undefined"&&t.setFlexBasis(r.flexBasis),t.setFlexGrow(typeof r.flexGrow=="undefined"?0:r.flexGrow),t.setFlexShrink(typeof r.flexShrink=="undefined"?1:r.flexShrink),typeof r.maxHeight!="undefined"&&t.setMaxHeight(r.maxHeight),typeof r.maxWidth!="undefined"&&t.setMaxWidth(r.maxWidth),typeof r.minHeight!="undefined"&&t.setMinHeight(r.minHeight),typeof r.minWidth!="undefined"&&t.setMinWidth(r.minWidth),t.setOverflow(S(r.overflow,{visible:s.OVERFLOW_VISIBLE,hidden:s.OVERFLOW_HIDDEN},s.OVERFLOW_VISIBLE)),t.setMargin(s.EDGE_TOP,r.marginTop||0),t.setMargin(s.EDGE_BOTTOM,r.marginBottom||0),t.setMargin(s.EDGE_LEFT,r.marginLeft||0),t.setMargin(s.EDGE_RIGHT,r.marginRight||0),t.setBorder(s.EDGE_TOP,r.borderWidth||0),t.setBorder(s.EDGE_BOTTOM,r.borderWidth||0),t.setBorder(s.EDGE_LEFT,r.borderWidth||0),t.setBorder(s.EDGE_RIGHT,r.borderWidth||0),t.setPadding(s.EDGE_TOP,r.paddingTop||0),t.setPadding(s.EDGE_BOTTOM,r.paddingBottom||0),t.setPadding(s.EDGE_LEFT,r.paddingLeft||0),t.setPadding(s.EDGE_RIGHT,r.paddingRight||0),t.setPositionType((r.position,s.POSITION_TYPE_ABSOLUTE,s.POSITION_TYPE_RELATIVE,s.POSITION_TYPE_RELATIVE)),typeof r.top!="undefined"&&t.setPosition(s.EDGE_TOP,r.top),typeof r.bottom!="undefined"&&t.setPosition(s.EDGE_BOTTOM,r.bottom),typeof r.left!="undefined"&&t.setPosition(s.EDGE_LEFT,r.left),typeof r.right!="undefined"&&t.setPosition(s.EDGE_RIGHT,r.right),typeof r.height!="undefined"?t.setHeight(r.height):t.setHeightAuto(),typeof r.width!="undefined"?t.setWidth(r.width):t.setWidthAuto(),[r,M(r)]}import I from"yoga-layout-prebuilt";import{LineBreaker as yt}from"css-line-break";function O({left:t,top:o,width:e,height:n},f,r){let i;if(r)i=f;else{let a=t+e/2,c=o+n/2;i=F([1,0,0,1,a,c],F(f,[1,0,0,1,-a,-c])),f.__parent&&(i=F(f.__parent,i)),f.splice(0,6,...i)}return`matrix(${i.join(",")})`}function X({left:t,top:o,width:e,height:n,isInheritingTransform:f,path:r,debug:i},a){let c="",u=1,d="";return a.transform&&(c=O({left:t,top:o,width:e,height:n},a.transform,f)),a.opacity&&(u=+a.opacity),i&&(d=`<rect x="${t}" y="${o}" width="${e}" height="${n}" fill="transparent" stroke="#575eff" stroke-width="1" ${c?`transform="${c}"`:""}></rect>`),`<path fill="${a.color}" ${c?`transform="${c}"`:""} ${u!==1?`opacity="${u}"`:""} d="${r}"></path>${d}`}function*U(t,o){let{parentStyle:e,parent:n,font:f,id:r,isInheritingTransform:i,debug:a}=o,c=yt(t,{lineBreak:"strict",wordBreak:"normal"}),u=[];for(let p;!(p=c.next()).done;)u.push(p.value.slice());let d=[];n.setAlignItems(I.ALIGN_BASELINE),e.textAlign==="left"?n.setJustifyContent(I.JUSTIFY_FLEX_START):e.textAlign==="center"?n.setJustifyContent(I.JUSTIFY_CENTER):e.textAlign==="right"?n.setJustifyContent(I.JUSTIFY_FLEX_END):e.textAlign==="justify"&&n.setJustifyContent(I.JUSTIFY_SPACE_BETWEEN);for(let p of u){let h=I.Node.create();n.insertChild(h,n.getChildCount());let E=f.measure(p,e),_=(e.letterSpacing||0)*p.length;h.setWidth(E.width+_),h.setHeight(E.ascent*1.2),h.setMargin(I.EDGE_BOTTOM,E.descent*1.2),d.push(h)}let[g,m]=yield,l="";for(let p=0;p<d.length;p++){let h=d[p],E=u[p];e.position==="absolute"&&h.calculateLayout();let{left:_,top:T,width:$,height:R}=h.getComputedLayout();_+=g,T+=m;let A=f.getSVG(E,Z(N({},e),{top:T,left:_,letterSpacing:e.letterSpacing}));l+=X({id:r,left:_,top:T,width:$,height:R,isInheritingTransform:i,path:A,debug:a},e)}return l}import Et from"gradient-parser";function _t(t){return t.type==="literal"?t.value:t.type==="hex"?`#${t.value}`:t.type==="rgb"?`rgb(${t.value.join(",")})`:t.type==="rgba"?`rgba(${t.value.join(",")})`:"transparent"}function H({id:t,width:o},{image:e}){if(e.startsWith("linear-gradient(")){let n=Et.parse(e)[0],f,r,i,a;if(n.orientation.type==="directional")[f,r,i,a]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[n.orientation.value];else if(n.orientation.type==="angular"){let l=+n.orientation.value/180*Math.PI-Math.PI/2,p=Math.cos(l),h=Math.sin(l);f=0,r=0,i=p,a=h,i<0&&(f-=i,i=0),a<0&&(r-=a,a=0)}let c=o,u=[];for(let l of n.colorStops){let p=_t(l);if(!u.length&&(u.push({offset:0,color:p}),typeof l.length=="undefined"||l.length.value==="0"))continue;let h=typeof l.length=="undefined"?void 0:l.length.type==="%"?l.length.value/100:l.length.value/c;u.push({offset:h,color:p})}u.length||u.push({offset:0,color:"transparent"});let d=u[u.length-1];d.offset!==1&&(typeof d.offset=="undefined"?d.offset=1:u.push({offset:1,color:d.color}));let g=0,m=1;for(let l=0;l<u.length;l++)if(typeof u[l].offset=="undefined"){for(m<l&&(m=l);typeof u[m].offset=="undefined";)m++;u[l].offset=(u[m].offset-u[g].offset)/(m-g)*(l-g)+u[g].offset}else g=l;return[`satori_bi${t}`,`<linearGradient id="satori_bi${t}" x1="${f}" y1="${r}" x2="${i}" y2="${a}">${u.map(l=>`<stop offset="${l.offset*100}%" stop-color="${l.color}"/>`).join("")}</linearGradient>`]}if(e.startsWith("url(")){let n=e.slice(4,-1);return[`satori_bi${t}`,`<pattern id="satori_bi${t}" patternContentUnits="objectBoundingBox" width="1" height="1"><image href="${n}" x="0" y="0" width="1" height="1"/></pattern>`]}}function v(t,o,e){return e<t+o&&(e/2<t&&e/2<o?t=o=e/2:e/2<t?t=e-o:e/2<o&&(o=e-t)),[t,o]}function W({left:t,top:o,width:e,height:n},f){let{borderTopLeftRadius:r,borderTopRightRadius:i,borderBottomLeftRadius:a,borderBottomRightRadius:c}=f;return r=Math.min(r||0,e,n),i=Math.min(i||0,e,n),a=Math.min(a||0,e,n),c=Math.min(c||0,e,n),!r&&!i&&!a&&!c?"":([r,i]=v(r,i,e),[r,a]=v(r,a,n),[i,c]=v(i,c,n),[a,c]=v(a,c,e),`M${t+r},${o} h${e-r-i} a${i},${i} 0 0 1 ${i},${i} v${n-i-c} a${c},${c} 0 0 1 ${-c},${c} h${c+a-e} a${a},${a} 0 0 1 ${-a},${-a} v${a+r-n} a${r},${r} 0 0 1 ${r},${-r}`)}function k({id:t,width:o,height:e},n){if(!n.shadowColor||!n.shadowOffset||typeof n.shadowRadius=="undefined")return"";let f=Math.min(n.shadowOffset.width-n.shadowRadius*2,0),r=Math.max(n.shadowOffset.width+n.shadowRadius*2+o,o),i=Math.min(n.shadowOffset.height-n.shadowRadius*2,0),a=Math.max(n.shadowOffset.height+n.shadowRadius*2+e,e);return`<defs><filter id="satori_s-${t}" x="${f/o*100}%" y="${i/e*100}%" width="${(r-f)/o*100}%" height="${(a-i)/e*100}%"><feDropShadow dx="${n.shadowOffset.width}" dy="${n.shadowOffset.height}" stdDeviation="${n.shadowRadius}" flood-color="${n.shadowColor}" flood-opacity="1"/></filter></defs>`}function J({id:t,left:o,top:e,width:n,height:f,isInheritingTransform:r,debug:i},a){if(a.display==="none")return"";let c="rect",u="transparent",d=0,g="",m="",l=[],p=1,h="";if(a.backgroundColor&&l.push(a.backgroundColor),a.borderWidth&&(d=a.borderWidth,u=a.borderColor),a.opacity&&(p=+a.opacity),a.transform&&(g=O({left:o,top:e,width:n,height:f},a.transform,r)),a.backgroundImage){let T=a.backgroundImage.map(($,R)=>H({id:t+"_"+R,width:n,height:f},$)).filter(Boolean);for(let $ of T)m+=$[1],l.push(`url(#${$[0]})`)}let E=W({left:o,top:e,width:n,height:f},a);E&&(c="path");let _=k({width:n,height:f,id:t},a);return l.length||l.push("transparent"),i&&(h=`<rect x="${o}" y="${e}" width="${n}" height="${f}" fill="transparent" stroke="#ff5757" stroke-width="1" ${g?`transform="${g}"`:""}></rect>`),`${m?`<defs>${m}</defs>`:""}${_?`${_}<g filter="url(#satori_s-${t})">`:""}${p!==1?`<g opacity="${p}">`:""}${l.map((T,$)=>T==="transparent"&&!($===l.length-1&&d)?"":`<${c} x="${o}" y="${e}" width="${n}" height="${f}" fill="${T}" ${$===l.length-1&&d?`stroke="${u}" stroke-width="${d}"`:""} ${E?`d="${E}"`:""} ${g?`transform="${g}"`:""}></${c}>`).join("")}${p!==1?"</g>":""}${_?"</g>":""}${h}`}function z({id:t,left:o,top:e,width:n,height:f,src:r,debug:i},a){if(a.display==="none")return"";let c="",u=1,d=a.objectFit==="contain"?"xMidYMid":a.objectFit==="cover"?"xMidYMid slice":"none",g=W({left:o,top:e,width:n,height:f},a);g&&(c=`<clipPath id="satori_c-${t}"><path x="${o}" y="${e}" width="${n}" height="${f}" d="${g}"></path></clipPath>`),a.opacity&&(u=+a.opacity);let m=k({width:n,height:f,id:t},a);return`${m}${m?`<g filter="url(#satori_s-${t})">`:""}${c}<image href="${r}" x="${o}" y="${e}" width="${n}" height="${f}" preserveAspectRatio="${d}" ${c?`clip-path="url(#satori_c-${t})"`:""} ${u!==1?`opacity="${u}"`:""}></image>${m?"</g>":""}`}function*C(t,o){let{id:e,inheritedStyle:n,parent:f,font:r,debug:i}=o;if(t===null||typeof t=="undefined")return yield,"";if(!w(t)||typeof t.type=="function"){let x;if(!w(t))x=U(String(t),o);else{if(tt(t.type))throw new Error("Class component is not supported.");x=C(t.type(t.props),o)}x.next();let P=yield;return x.next(P).value}let{type:a,props:c}=t,{style:u,children:d}=c,g=$t.Node.create();f.insertChild(g,f.getChildCount());let[m,l]=Y(g,a,n,u,c),p=m.transform===n.transform;p||(m.transform.__parent=n.transform);let h=typeof d=="undefined"?[]:[].concat(d),E=[],_=0;for(let x of h){let P=C(x,{id:e*h.length+ ++_,parentStyle:m,inheritedStyle:l,isInheritingTransform:!0,parent:g,font:r,debug:i});P.next(),E.push(P)}let[T,$]=yield;m.position==="absolute"&&g.calculateLayout();let{left:R,top:A,width:j,height:q}=g.getComputedLayout();R+=T,A+=$;let G="";a==="img"?G=z({id:e,left:R,top:A,width:j,height:q,src:c.src,isInheritingTransform:p,debug:i},m):G=J({id:e,left:R,top:A,width:j,height:q,isInheritingTransform:p,debug:i},m);for(let x of E)G+=x.next([R,A]).value;return G}import it from"opentype.js";var D=class{constructor(o){this.fonts=new Map;for(let e of o){let n=e.data,f="buffer"in n?it.parse(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)):it.parse(n);this.defaultFont||(this.defaultFont=f),this.fonts.has(e.name)||this.fonts.set(e.name,[]),this.fonts.get(e.name).push([f,e.weight,e.style])}}get({name:o,weight:e,style:n}){if(!this.fonts.has(o))return this.defaultFont;e==="normal"&&(e=400),e==="bold"&&(e=700);let f=[...this.fonts.get(o)];return f.sort(([r,i,a],[c,u,d])=>{if(i!==u)return i?!u||i===e?-1:u===e?1:e===400&&i===500||e===500&&i===400?-1:e===400&&u===500||e===500&&u===400?1:e<400?i<e&&u<e?u-i:i<e?-1:u<e?1:i-u:e<i&&e<u?i-u:e<i?-1:e<u?1:u-i:1;if(a!==d){if(a===n)return-1;if(d===n)return 1}return-1}),f[0][0]}measure(o,{fontFamily:e,fontSize:n,fontWeight:f=400,fontStyle:r="normal"}){let i=this.get({name:e,weight:f,style:r});return{width:i.getAdvanceWidth(o,n),ascent:i.ascender/i.unitsPerEm*n,descent:-(i.descender/i.unitsPerEm)*n}}getSVG(o,{fontFamily:e,fontSize:n,fontWeight:f=400,fontStyle:r="normal",top:i,left:a,letterSpacing:c=0}){let u=this.get({name:e,weight:f,style:r});return i+=u.ascender/u.unitsPerEm*n,u.getPath(o,a,i,n,{letterSpacing:c/n}).toPathData(3)}};function V({width:t,height:o,content:e},n){return`<svg width="${t}" height="${o}" viewBox="0 0 ${t} ${o}" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}function at(t,o){let e=new D(o.fonts),n=L.Node.create();n.setWidth(o.width),n.setHeight(o.height),n.setFlexDirection(L.FLEX_DIRECTION_ROW),n.setFlexWrap(L.WRAP_WRAP),n.setAlignContent(L.ALIGN_AUTO),n.setAlignItems(L.ALIGN_FLEX_START),n.setJustifyContent(L.JUSTIFY_FLEX_START);let f=C(t,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:n,font:e,debug:o.debug});f.next(),n.calculateLayout(o.width,o.height,L.DIRECTION_LTR);let r=f.next([0,0]).value;return V({width:o.width,height:o.height,content:r})}export{at as default}; | ||
var ft=Object.defineProperty,ut=Object.defineProperties;var lt=Object.getOwnPropertyDescriptors;var q=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var K=(t,r,e)=>r in t?ft(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,L=(t,r)=>{for(var e in r||(r={}))mt.call(r,e)&&K(t,e,r[e]);if(q)for(var e of q(r))ct.call(r,e)&&K(t,e,r[e]);return t},Q=(t,r)=>ut(t,lt(r));var Z=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(r,e)=>(typeof require!="undefined"?require:r)[e]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var dt=Z("yoga-wasm-web"),tt;async function pt(t){t||(t=Z("yoga-wasm-web/dist/yoga.wasm")),tt=await dt(t)}var i=tt;function w(t){let r=typeof t;return!(r==="number"||r==="bigint"||r==="string"||r==="boolean")}function et(t){return/^class\s/.test(Function.prototype.toString.call(t))}function A(t,r){return[t[0]*r[0]+t[2]*r[1],t[1]*r[0]+t[3]*r[1],t[0]*r[2]+t[2]*r[3],t[1]*r[2]+t[3]*r[3],t[0]*r[4]+t[2]*r[5]+t[4],t[1]*r[4]+t[3]*r[5]+t[5]]}var nt={p:{display:"block",marginTop:"1em",marginBottom:"1em"},div:{display:"block"},blockquote:{display:"block",marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40},center:{display:"block",textAlign:"center"},hr:{display:"block",marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,borderStyle:"inset"},h1:{display:"block",fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h2:{display:"block",fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold"},h3:{display:"block",fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold"},h4:{display:"block",marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},h5:{display:"block",fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h6:{display:"block",fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},u:{textDecoration:"underline"},strong:{fontWeight:"bold"},b:{fontWeight:"bold"},i:{fontStyle:"italic"},em:{fontStyle:"italic"},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{display:"block",fontFamily:"monospace",whiteSpace:"pre",marginTop:"1em",marginBottom:"1em"},mark:{backgroundColor:"yellow",color:"black"},big:{fontSize:"larger"},small:{fontSize:"smaller"},s:{textDecoration:"line-through"}};var gt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","opacity"]);function D(t){let r={};for(let e in t)gt.has(e)&&(r[e]=t[e]);return r}import ht,{getPropertyName as bt}from"css-to-react-native";import it from"parse-css-dimension";import{parseElementStyle as yt}from"css-background-parser";var Et=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),rt=[1,0,0,1,0,0];function $t(t,r){return typeof r=="number"?Et.has(t)?String(r):r+"px":r}function ot(t,r){if(typeof t=="number")return t;try{let e=new it(t);if(e.type==="length")switch(e.unit){case"em":return e.value*r;case"rem":return e.value*16;default:return e.value}else if(e.type==="angle")switch(e.unit){case"deg":return e.value;case"rad":return e.value*180/Math.PI;default:return e.value}}catch{}}function P(t,r){let e=[];for(let n in t){let a=bt(n);e.push([a,$t(a,t[n])])}let o=ht(e);if(o.backgroundImage){let{backgrounds:n}=yt(o);o.backgroundImage=n}let f=o.fontSize||r.fontSize;if(typeof f=="string")try{let n=new it(f);switch(n.unit){case"em":f=n.value*r.fontSize;break;case"rem":f=n.value*16;break}}catch{f=16}o.fontSize=f;for(let n in o){let a=o[n];if(typeof a=="string"){let s=ot(a,f);typeof s!="undefined"&&(o[n]=s),a=o[n]}if(n==="opacity"&&(a=o[n]=a*r.opacity),n==="transform"){let s=[...rt],l=a;for(let u of l){let d=Object.keys(u)[0],p=u[d],c=typeof p=="string"?ot(p,f):p,m=[...rt];switch(d){case"translateX":m[4]=c;break;case"translateY":m[5]=c;break;case"scaleX":m[0]=c;break;case"scaleY":m[3]=c;break;case"rotate":let E=c*Math.PI/180,g=Math.cos(E),h=Math.sin(E);m[0]=g,m[1]=h,m[2]=-h,m[3]=g;break;case"skewX":m[2]=Math.tan(c*Math.PI/180);break;case"skewY":m[1]=Math.tan(c*Math.PI/180);break}s=A(m,s)}o.transform=s}}return o}function x(t,r,e){let o=r[t];return typeof o=="undefined"?e:o}function M(t,r,e,o,f){let n=L(L(L({},e),P(nt[r],e)),P(o,e));if(r==="img"){let a=parseInt(f.width),l=parseInt(f.height)/a;n.width||(n.width=a),n.height||(n.height=l*n.width)}return t.setDisplay(x(n.display,{flex:i.DISPLAY_FLEX,none:i.DISPLAY_NONE},i.DISPLAY_FLEX)),t.setAlignContent(x(n.alignContent,{stretch:i.ALIGN_STRETCH,center:i.ALIGN_CENTER,"flex-start":i.ALIGN_FLEX_START,"flex-end":i.ALIGN_FLEX_END,"space-between":i.ALIGN_SPACE_BETWEEN,"space-around":i.ALIGN_SPACE_AROUND,baseline:i.ALIGN_BASELINE,normal:i.ALIGN_AUTO},i.ALIGN_AUTO)),t.setAlignItems(x(n.alignItems,{stretch:i.ALIGN_STRETCH,center:i.ALIGN_CENTER,"flex-start":i.ALIGN_FLEX_START,"flex-end":i.ALIGN_FLEX_END,baseline:i.ALIGN_BASELINE,normal:i.ALIGN_AUTO},i.ALIGN_FLEX_START)),t.setAlignSelf(x(n.alignSelf,{stretch:i.ALIGN_STRETCH,center:i.ALIGN_CENTER,"flex-start":i.ALIGN_FLEX_START,"flex-end":i.ALIGN_FLEX_END,baseline:i.ALIGN_BASELINE,normal:i.ALIGN_AUTO},i.ALIGN_AUTO)),t.setJustifyContent(x(n.justifyContent,{center:i.JUSTIFY_CENTER,"flex-start":i.JUSTIFY_FLEX_START,"flex-end":i.JUSTIFY_FLEX_END,"space-between":i.JUSTIFY_SPACE_BETWEEN,"space-around":i.JUSTIFY_SPACE_AROUND},i.JUSTIFY_FLEX_START)),t.setFlexDirection(x(n.flexDirection,{row:i.FLEX_DIRECTION_ROW,column:i.FLEX_DIRECTION_COLUMN,"row-reverse":i.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":i.FLEX_DIRECTION_COLUMN_REVERSE},i.FLEX_DIRECTION_ROW)),t.setFlexWrap(x(n.flexWrap,{wrap:i.WRAP_WRAP,nowrap:i.WRAP_NO_WRAP,"wrap-reverse":i.WRAP_WRAP_REVERSE},i.WRAP_WRAP)),typeof n.flexBasis!="undefined"&&t.setFlexBasis(n.flexBasis),t.setFlexGrow(typeof n.flexGrow=="undefined"?0:n.flexGrow),t.setFlexShrink(typeof n.flexShrink=="undefined"?1:n.flexShrink),typeof n.maxHeight!="undefined"&&t.setMaxHeight(n.maxHeight),typeof n.maxWidth!="undefined"&&t.setMaxWidth(n.maxWidth),typeof n.minHeight!="undefined"&&t.setMinHeight(n.minHeight),typeof n.minWidth!="undefined"&&t.setMinWidth(n.minWidth),t.setOverflow(x(n.overflow,{visible:i.OVERFLOW_VISIBLE,hidden:i.OVERFLOW_HIDDEN},i.OVERFLOW_VISIBLE)),t.setMargin(i.EDGE_TOP,n.marginTop||0),t.setMargin(i.EDGE_BOTTOM,n.marginBottom||0),t.setMargin(i.EDGE_LEFT,n.marginLeft||0),t.setMargin(i.EDGE_RIGHT,n.marginRight||0),t.setBorder(i.EDGE_TOP,n.borderWidth||0),t.setBorder(i.EDGE_BOTTOM,n.borderWidth||0),t.setBorder(i.EDGE_LEFT,n.borderWidth||0),t.setBorder(i.EDGE_RIGHT,n.borderWidth||0),t.setPadding(i.EDGE_TOP,n.paddingTop||0),t.setPadding(i.EDGE_BOTTOM,n.paddingBottom||0),t.setPadding(i.EDGE_LEFT,n.paddingLeft||0),t.setPadding(i.EDGE_RIGHT,n.paddingRight||0),t.setPositionType(x(n.position,{absolute:i.POSITION_TYPE_ABSOLUTE,relative:i.POSITION_TYPE_RELATIVE},i.POSITION_TYPE_RELATIVE)),typeof n.top!="undefined"&&t.setPosition(i.EDGE_TOP,n.top),typeof n.bottom!="undefined"&&t.setPosition(i.EDGE_BOTTOM,n.bottom),typeof n.left!="undefined"&&t.setPosition(i.EDGE_LEFT,n.left),typeof n.right!="undefined"&&t.setPosition(i.EDGE_RIGHT,n.right),typeof n.height!="undefined"?t.setHeight(n.height):t.setHeightAuto(),typeof n.width!="undefined"?t.setWidth(n.width):t.setWidthAuto(),[n,D(n)]}import{LineBreaker as _t}from"css-line-break";function N({left:t,top:r,width:e,height:o},f,n){let a;if(n)a=f;else{let s=t+e/2,l=r+o/2;a=A([1,0,0,1,s,l],A(f,[1,0,0,1,-s,-l])),f.__parent&&(a=A(f.__parent,a)),f.splice(0,6,...a)}return`matrix(${a.join(",")})`}function Y({content:t,left:r,top:e,width:o,height:f,isInheritingTransform:n,path:a,debug:s},l){let u="",d=1,p="";return l.transform&&(u=N({left:r,top:e,width:o,height:f},l.transform,n)),l.opacity&&(d=+l.opacity),s&&(p=`<rect x="${r}" y="${e}" width="${o}" height="${a===null?.5:f}" fill="transparent" stroke="#575eff" stroke-width="1" ${u?`transform="${u}"`:""}></rect>`),a===null?`<text x="${r}" y="${e}" width="${o}" height="${f}" fill="${l.color}" font-weight="${l.fontWeight}" font-style="${l.fontStyle}" font-size="${l.fontSize}" font-family="${l.fontFamily}" ${l.letterSpacing?`letter-spacing="${l.letterSpacing}"`:""} ${u?`transform="${u}"`:""} ${d!==1?`opacity="${d}"`:""}>${t}</text>${p}`:`<path fill="${l.color}" ${u?`transform="${u}"`:""} ${d!==1?`opacity="${d}"`:""} d="${a}"></path>${p}`}function*X(t,r){let{parentStyle:e,parent:o,font:f,id:n,isInheritingTransform:a,debug:s,embedFont:l}=r,u=_t(t,{lineBreak:"strict",wordBreak:"normal"}),d=[];for(let g;!(g=u.next()).done;)d.push(g.value.slice());let p=[];o.setAlignItems(i.ALIGN_BASELINE),e.textAlign==="left"?o.setJustifyContent(i.JUSTIFY_FLEX_START):e.textAlign==="center"?o.setJustifyContent(i.JUSTIFY_CENTER):e.textAlign==="right"?o.setJustifyContent(i.JUSTIFY_FLEX_END):e.textAlign==="justify"&&o.setJustifyContent(i.JUSTIFY_SPACE_BETWEEN);for(let g of d){let h=i.Node.create();o.insertChild(h,o.getChildCount());let _=f.measure(g,e),S=(e.letterSpacing||0)*g.length;h.setWidth(_.width+S),h.setHeight(_.ascent*1.2),h.setMargin(i.EDGE_BOTTOM,_.descent*1.2),p.push(h)}let[c,m]=yield,E="";for(let g=0;g<p.length;g++){let h=p[g],_=d[g];e.position==="absolute"&&h.calculateLayout();let{left:S,top:$,width:F,height:I}=h.getComputedLayout();S+=c,$+=m;let R=null;l?R=f.getSVG(_,Q(L({},e),{top:$,left:S,letterSpacing:e.letterSpacing})):$+=f.getAscent(e),E+=Y({content:_,id:n,left:S,top:$,width:F,height:I,isInheritingTransform:a,path:R,debug:s},e)}return E}import St from"gradient-parser";function xt(t){return t.type==="literal"?t.value:t.type==="hex"?`#${t.value}`:t.type==="rgb"?`rgb(${t.value.join(",")})`:t.type==="rgba"?`rgba(${t.value.join(",")})`:"transparent"}function U({id:t,width:r},{image:e}){if(e.startsWith("linear-gradient(")){let o=St.parse(e)[0],f,n,a,s;if(o.orientation.type==="directional")[f,n,a,s]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[o.orientation.value];else if(o.orientation.type==="angular"){let m=+o.orientation.value/180*Math.PI-Math.PI/2,E=Math.cos(m),g=Math.sin(m);f=0,n=0,a=E,s=g,a<0&&(f-=a,a=0),s<0&&(n-=s,s=0)}let l=r,u=[];for(let m of o.colorStops){let E=xt(m);if(!u.length&&(u.push({offset:0,color:E}),typeof m.length=="undefined"||m.length.value==="0"))continue;let g=typeof m.length=="undefined"?void 0:m.length.type==="%"?m.length.value/100:m.length.value/l;u.push({offset:g,color:E})}u.length||u.push({offset:0,color:"transparent"});let d=u[u.length-1];d.offset!==1&&(typeof d.offset=="undefined"?d.offset=1:u.push({offset:1,color:d.color}));let p=0,c=1;for(let m=0;m<u.length;m++)if(typeof u[m].offset=="undefined"){for(c<m&&(c=m);typeof u[c].offset=="undefined";)c++;u[m].offset=(u[c].offset-u[p].offset)/(c-p)*(m-p)+u[p].offset}else p=m;return[`satori_bi${t}`,`<linearGradient id="satori_bi${t}" x1="${f}" y1="${n}" x2="${a}" y2="${s}">${u.map(m=>`<stop offset="${m.offset*100}%" stop-color="${m.color}"/>`).join("")}</linearGradient>`]}if(e.startsWith("url(")){let o=e.slice(4,-1);return[`satori_bi${t}`,`<pattern id="satori_bi${t}" patternContentUnits="objectBoundingBox" width="1" height="1"><image href="${o}" x="0" y="0" width="1" height="1"/></pattern>`]}}function B(t,r,e){return e<t+r&&(e/2<t&&e/2<r?t=r=e/2:e/2<t?t=e-r:e/2<r&&(r=e-t)),[t,r]}function W({left:t,top:r,width:e,height:o},f){let{borderTopLeftRadius:n,borderTopRightRadius:a,borderBottomLeftRadius:s,borderBottomRightRadius:l}=f;return n=Math.min(n||0,e,o),a=Math.min(a||0,e,o),s=Math.min(s||0,e,o),l=Math.min(l||0,e,o),!n&&!a&&!s&&!l?"":([n,a]=B(n,a,e),[n,s]=B(n,s,o),[a,l]=B(a,l,o),[s,l]=B(s,l,e),`M${t+n},${r} h${e-n-a} a${a},${a} 0 0 1 ${a},${a} v${o-a-l} a${l},${l} 0 0 1 ${-l},${l} h${l+s-e} a${s},${s} 0 0 1 ${-s},${-s} v${s+n-o} a${n},${n} 0 0 1 ${n},${-n}`)}function O({id:t,width:r,height:e},o){if(!o.shadowColor||!o.shadowOffset||typeof o.shadowRadius=="undefined")return"";let f=Math.min(o.shadowOffset.width-o.shadowRadius*2,0),n=Math.max(o.shadowOffset.width+o.shadowRadius*2+r,r),a=Math.min(o.shadowOffset.height-o.shadowRadius*2,0),s=Math.max(o.shadowOffset.height+o.shadowRadius*2+e,e);return`<defs><filter id="satori_s-${t}" x="${f/r*100}%" y="${a/e*100}%" width="${(n-f)/r*100}%" height="${(s-a)/e*100}%"><feDropShadow dx="${o.shadowOffset.width}" dy="${o.shadowOffset.height}" stdDeviation="${o.shadowRadius}" flood-color="${o.shadowColor}" flood-opacity="1"/></filter></defs>`}function H({id:t,left:r,top:e,width:o,height:f,isInheritingTransform:n,debug:a},s){if(s.display==="none")return"";let l="rect",u="transparent",d=0,p="",c="",m=[],E=1,g="";if(s.backgroundColor&&m.push(s.backgroundColor),s.borderWidth&&(d=s.borderWidth,u=s.borderColor),s.opacity&&(E=+s.opacity),s.transform&&(p=N({left:r,top:e,width:o,height:f},s.transform,n)),s.backgroundImage){let S=s.backgroundImage.map(($,F)=>U({id:t+"_"+F,width:o,height:f},$)).filter(Boolean);for(let $ of S)c+=$[1],m.push(`url(#${$[0]})`)}let h=W({left:r,top:e,width:o,height:f},s);h&&(l="path");let _=O({width:o,height:f,id:t},s);return m.length||m.push("transparent"),a&&(g=`<rect x="${r}" y="${e}" width="${o}" height="${f}" fill="transparent" stroke="#ff5757" stroke-width="1" ${p?`transform="${p}"`:""}></rect>`),`${c?`<defs>${c}</defs>`:""}${_?`${_}<g filter="url(#satori_s-${t})">`:""}${E!==1?`<g opacity="${E}">`:""}${m.map((S,$)=>S==="transparent"&&!($===m.length-1&&d)?"":`<${l} x="${r}" y="${e}" width="${o}" height="${f}" fill="${S}" ${$===m.length-1&&d?`stroke="${u}" stroke-width="${d}"`:""} ${h?`d="${h}"`:""} ${p?`transform="${p}"`:""}></${l}>`).join("")}${E!==1?"</g>":""}${_?"</g>":""}${g}`}function z({id:t,left:r,top:e,width:o,height:f,src:n,debug:a},s){if(s.display==="none")return"";let l="",u=1,d=s.objectFit==="contain"?"xMidYMid":s.objectFit==="cover"?"xMidYMid slice":"none",p=W({left:r,top:e,width:o,height:f},s);p&&(l=`<clipPath id="satori_c-${t}"><path x="${r}" y="${e}" width="${o}" height="${f}" d="${p}"></path></clipPath>`),s.opacity&&(u=+s.opacity);let c=O({width:o,height:f,id:t},s);return`${c}${c?`<g filter="url(#satori_s-${t})">`:""}${l}<image href="${n}" x="${r}" y="${e}" width="${o}" height="${f}" preserveAspectRatio="${d}" ${l?`clip-path="url(#satori_c-${t})"`:""} ${u!==1?`opacity="${u}"`:""}></image>${c?"</g>":""}`}function*k(t,r){let{id:e,inheritedStyle:o,parent:f,font:n,debug:a,embedFont:s=!0}=r;if(t===null||typeof t=="undefined")return yield,"";if(!w(t)||typeof t.type=="function"){let T;if(!w(t))T=X(String(t),r);else{if(et(t.type))throw new Error("Class component is not supported.");T=k(t.type(t.props),r)}T.next();let G=yield;return T.next(G).value}let{type:l,props:u}=t,{style:d,children:p}=u,c=i.Node.create();f.insertChild(c,f.getChildCount());let[m,E]=M(c,l,o,d,u),g=m.transform===o.transform;g||(m.transform.__parent=o.transform);let h=typeof p=="undefined"?[]:[].concat(p),_=[],S=0;for(let T of h){let G=k(T,{id:e*h.length+ ++S,parentStyle:m,inheritedStyle:E,isInheritingTransform:!0,parent:c,font:n,embedFont:s,debug:a});G.next(),_.push(G)}let[$,F]=yield;m.position==="absolute"&&c.calculateLayout();let{left:I,top:R,width:V,height:j}=c.getComputedLayout();I+=$,R+=F;let C="";l==="img"?C=z({id:e,left:I,top:R,width:V,height:j,src:u.src,isInheritingTransform:g,debug:a},m):C=H({id:e,left:I,top:R,width:V,height:j,isInheritingTransform:g,debug:a},m);for(let T of _)C+=T.next([I,R]).value;return C}import at from"opentype.js";var v=class{constructor(r){this.fonts=new Map;for(let e of r){let o=e.data,f="buffer"in o?at.parse(o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)):at.parse(o);this.defaultFont||(this.defaultFont=f),this.fonts.has(e.name)||this.fonts.set(e.name,[]),this.fonts.get(e.name).push([f,e.weight,e.style])}}get({name:r,weight:e,style:o}){if(!this.fonts.has(r))return this.defaultFont;e==="normal"&&(e=400),e==="bold"&&(e=700);let f=[...this.fonts.get(r)];return f.sort(([n,a,s],[l,u,d])=>{if(a!==u)return a?!u||a===e?-1:u===e?1:e===400&&a===500||e===500&&a===400?-1:e===400&&u===500||e===500&&u===400?1:e<400?a<e&&u<e?u-a:a<e?-1:u<e?1:a-u:e<a&&e<u?a-u:e<a?-1:e<u?1:u-a:1;if(s!==d){if(s===o)return-1;if(d===o)return 1}return-1}),f[0][0]}measure(r,{fontFamily:e,fontSize:o,fontWeight:f=400,fontStyle:n="normal"}){let a=this.get({name:e,weight:f,style:n});return{width:a.getAdvanceWidth(r,o),ascent:a.ascender/a.unitsPerEm*o,descent:-(a.descender/a.unitsPerEm)*o}}getSVG(r,{fontFamily:e,fontSize:o,fontWeight:f=400,fontStyle:n="normal",top:a,left:s,letterSpacing:l=0}){let u=this.get({name:e,weight:f,style:n});return a+=u.ascender/u.unitsPerEm*o,u.getPath(r,s,a,o,{letterSpacing:l/o}).toPathData(2)}getAscent({fontFamily:r,fontSize:e,fontWeight:o=400,fontStyle:f="normal"}){let n=this.get({name:r,weight:o,style:f});return n.ascender/n.unitsPerEm*e}};function J({width:t,height:r,content:e},o){return`<svg width="${t}" height="${r}" viewBox="0 0 ${t} ${r}" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}function st(t,r){if(!i)throw new Error("Satori is not initialized.");let e=new v(r.fonts),o=i.Node.create();o.setWidth(r.width),o.setHeight(r.height),o.setFlexDirection(i.FLEX_DIRECTION_ROW),o.setFlexWrap(i.WRAP_WRAP),o.setAlignContent(i.ALIGN_AUTO),o.setAlignItems(i.ALIGN_FLEX_START),o.setJustifyContent(i.JUSTIFY_FLEX_START);let f=k(t,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:o,font:e,embedFont:r.embedFont,debug:r.debug});f.next(),o.calculateLayout(r.width,r.height,i.DIRECTION_LTR);let n=f.next([0,0]).value;return J({width:r.width,height:r.height,content:n})}export{st as default,pt as init}; |
import { ReactNode } from 'react'; | ||
declare function init(wasm: any): Promise<void>; | ||
/** | ||
@@ -20,6 +22,8 @@ * This class handles everything related to fonts. | ||
fonts: FontOptions[]; | ||
embedFont?: boolean; | ||
debug?: boolean; | ||
} | ||
declare function satori(element: ReactNode, options: SatoriOptions): string; | ||
export { SatoriOptions, satori as default }; | ||
export { SatoriOptions, satori as default, init }; |
{ | ||
"name": "satori", | ||
"version": "0.0.7", | ||
"version": "0.0.8-beta.0", | ||
"description": "A lightweight library to convert HTML JSX to SVG string.", | ||
"main": "./dist/index.js", | ||
"module": "./dist/esm/index.js", | ||
"types": "./dist/index.d.ts", | ||
"type": "module", | ||
"files": [ | ||
@@ -12,4 +12,4 @@ "dist/**" | ||
"scripts": { | ||
"dev": "tsup src/index.ts --watch --format cjs,esm --legacy-output --ignore-watch playground", | ||
"build": "tsup src/index.ts --dts --minify --format cjs,esm --legacy-output", | ||
"dev": "tsup src/index.ts --watch --format esm --legacy-output --ignore-watch playground", | ||
"build": "tsup src/index.ts --dts --minify --format esm --legacy-output", | ||
"test": "vitest run", | ||
@@ -39,2 +39,3 @@ "dev:test": "vitest" | ||
"@types/react": "^17.0.38", | ||
"@types/yoga-layout": "^1.9.4", | ||
"react": "^17.0.2", | ||
@@ -52,4 +53,4 @@ "tsup": "^5.11.13", | ||
"parse-css-dimension": "^1.1.0", | ||
"yoga-layout-prebuilt": "^1.10.0" | ||
"yoga-wasm-web": "^0.0.3" | ||
} | ||
} |
@@ -5,3 +5,3 @@ <h1 align="center"> | ||
## Quick Start | ||
## API | ||
@@ -25,2 +25,4 @@ `satori` is a function that takes a JSX element and returns a SVG string: | ||
], | ||
embedFont: true, // Embed the font in SVG as path data | ||
debug: false, // Show/hide the bounding box | ||
} | ||
@@ -124,2 +126,6 @@ ) | ||
And visit localhost:3000/test. | ||
To start the development mode, run `pnpm dev` in the root directory (can be used together with the playground to view it in live). | ||
To start and live-watch the tests, run: | ||
@@ -126,0 +132,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1
143
Yes
23349
8
4
91
3
+ Addedyoga-wasm-web@^0.0.3
+ Addedyoga-wasm-web@0.0.3(transitive)
- Removedyoga-layout-prebuilt@^1.10.0
- Removed@types/yoga-layout@1.9.2(transitive)
- Removedyoga-layout-prebuilt@1.10.0(transitive)