@plotdb/lotion 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/vector.min.js ADDED
@@ -0,0 +1 @@
1
+ !function(){var C,A,t,e,n,r,R,B,w,o,v,L,P,x,T,z,I,i,m,a,l,s,f,u,h,F,g,W,j,N,b,y,c,S=window.lotion,d=S.libs;for(d.satori="https://cdn.jsdelivr.net/npm/satori@0.36.0/+esm",d.woff2="https://cdn.jsdelivr.net/npm/woff2-encoder@2.0.0/dist/decompress.js",d.hbsubset="https://cdn.jsdelivr.net/npm/harfbuzzjs@1.6.3/dist/harfbuzz-subset.wasm",C=["color","fontFamily","fontSize","fontWeight","fontStyle","lineHeight","letterSpacing","textAlign","whiteSpace","wordBreak","textTransform","textShadow","textIndent","backgroundColor","backgroundImage","backgroundPosition","backgroundSize","backgroundRepeat","backgroundClip","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","paddingTop","paddingRight","paddingBottom","paddingLeft","boxShadow","opacity","filter","clipPath","overflow","zIndex","transform","transformOrigin","maskImage","maskPosition","maskSize","maskRepeat"],A={textShadow:"none",textIndent:"0px",textTransform:"none",backgroundColor:"rgba(0, 0, 0, 0)",backgroundImage:"none",backgroundPosition:"0% 0%",backgroundSize:"auto",backgroundRepeat:"repeat",backgroundClip:"border-box",boxShadow:"none",opacity:"1",filter:"none",clipPath:"none",overflow:"visible",zIndex:"auto",transform:"none",maskImage:"none",maskPosition:"0% 0%",maskSize:"auto",maskRepeat:"repeat",lineHeight:"normal",letterSpacing:"normal"},t=0,e=(d=["Top","Right","Bottom","Left"]).length;t<e;++t)n=d[t],A["border"+n+"Width"]="0px",A["border"+n+"Style"]="none",A["padding"+n]="0px";for(t=0,e=(d=["TopLeft","TopRight","BottomRight","BottomLeft"]).length;t<e;++t)r=d[t],A["border"+r+"Radius"]="0px";function O(t,e){for(var n=-1,r=e.length>>>0;++n<r;)if(t===e[n])return 1}R=["color","fontFamily","fontSize","fontWeight","fontStyle","lineHeight","letterSpacing","textAlign","whiteSpace","wordBreak","textTransform","textShadow","textIndent"],B={backdropFilter:"none",textDecorationLine:"none"},w=function(t){for(var e,n=new Uint8Array(t),r="",o=0,i=n.length;o<i;o+=32768)e=o,r+=String.fromCharCode.apply(null,n.subarray(e,e+32768));return btoa(r)},o=function(t){return w((new TextEncoder).encode(t))},v=function(t){return"data:image/svg+xml;base64,"+o(t)},L=function(t){return t.replace(/url\("data:image\/svg\+xml(?:;charset=[^,;]+)?(?:;utf8)?,([^"]*)"\)/g,function(t,e){return'url("'+v((()=>{try{return decodeURIComponent(e)}catch(t){return e}})())+'")'})},P=function(t,e,n,r){var o,i;return null!=t.offsetWidth?(o=t.offsetLeft,i=t.offsetTop,t.offsetParent!==e&&e.offsetParent===t.offsetParent&&(o-=e.offsetLeft+e.clientLeft,i-=e.offsetTop+e.clientTop),[o,i,t.offsetWidth,t.offsetHeight]):(o=(e=[parseFloat(n.width)||0,parseFloat(n.height)||0])[0],i=e[1],"absolute"===(e=n.position)||"fixed"===e?[parseFloat(n.left)||0,parseFloat(n.top)||0,o,i]:(r.warn("<"+t.tagName.toLowerCase()+"> not absolutely positioned: placed at its parent's origin"),[0,0,o,i]))},x=["font-family","font-size","font-weight","font-style","letter-spacing","text-anchor","dominant-baseline","fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","paint-order","opacity","visibility","display","filter","mask","clip-path","color"],T=function(t,e,n,h,c){var d,p,r,o,i,a,l,s,f,u,g,m,b,y=t.cloneNode(!0);for(y.setAttribute("width",e),y.setAttribute("height",n),y.getAttribute("viewBox")||y.setAttribute("viewBox","0 0 "+e+" "+n),y.removeAttribute("style"),e=[t].concat(Array.from(t.querySelectorAll("*"))),d=[y].concat(Array.from(y.querySelectorAll("*"))),p=[],e.map(function(t,e){for(var n,r,o,i=d[e],a=getComputedStyle(t),l=0===e?null:getComputedStyle(t.parentNode),s=[],f=0,u=(n=x).length;f<u;++f)r=n[f],o=a.getPropertyValue(r),l&&l.getPropertyValue(r)===o||(0!==e||"opacity"!==r&&"visibility"!==r&&"display"!==r&&"filter"!==r&&"mask"!==r&&"clip-path"!==r)&&s.push(r+":"+o);if(s.length&&i.setAttribute("style",s.join(";")),("text"===(n=t.tagName.toLowerCase())||"tspan"===n||"textpath"===n)&&!t.querySelector("tspan, textPath"))return h.text(a,t.textContent,t={}),p.push([i,t])}),r=new Set,o=0,i=d.length;o<i;++o)for(a=d[o],l=0,f=(s=Array.from(a.attributes)).length;l<f;++l)for(u=s[l],g=/url\(\s*['"]?#([^'")\s]+)['"]?\s*\)|^#(.+)$/g;m=g.exec(u.value);)r.add(m[1]||m[2]);return b=null,r.forEach(function(t){if(!y.querySelector('[id="'+CSS.escape(t)+'"]')&&(t=document.getElementById(t)))return b||(b=document.createElementNS("http://www.w3.org/2000/svg","defs"),y.insertBefore(b,y.firstChild)),b.appendChild(t.cloneNode(!0))}),h.later(function(t){for(var e,n,r,o,i,a,l,s,f=new Set,u=0,h=(e=p).length;u<h;++u)if(r=(n=e[u])[0],(o=n[1]).fontFamily)for(i=r.getAttribute("style")||"",r.setAttribute("style",i+";font-family:"+o.fontFamily),a=0,l=(n=o.fontFamily.split(",")).length;a<l;++a)s=n[a],f.add(s.trim().replace(/'/g,""));return(t=t.filter(function(t){return f.has(t.name)}).map(function(t){return"@font-face{font-family:'"+t.name+"';font-weight:"+t.weight+";font-style:"+t.style+";src:url(data:font/ttf;base64,"+w(t.data)+") format('truetype')}"})).length&&((i=document.createElementNS("http://www.w3.org/2000/svg","style")).textContent=t.join(""),y.insertBefore(i,y.firstChild)),c.props.src=v((new XMLSerializer).serializeToString(y))}),""},z=function(t,e){var n,r=t.props.style;return(r.maskImage||r.clipPath)&&r.transform&&((n=(n=/^matrix\(([^)]+)\)$/.exec(r.transform))?n[1].split(",").map(function(t){return+t}):null)&&1===n[0]&&0===n[1]&&0===n[2]&&1===n[3]?(r.left+=n[4],r.top+=n[5],delete r.transform,delete r.transformOrigin):e.warn("mask / clip-path with a non-translation transform: misplaced")),t},I=function(t,e,n){var r,o,i,a,l,s,f,u,h,c,d,p,g,m,b,y,w,v,x,S,_,k=0===(n=null==n?0:n);if("none"===(r=getComputedStyle(t)).display||0==+r.opacity)return null;for(h in o=t.tagName.toLowerCase(),a=(i=P(t,t.parentNode,r,e))[0],l=i[1],s=i[2],f=i[3],u="visible"!==r.visibility,i=B)c=i[h],r[h]&&r[h]!==c&&e.warn(h+": "+r[h]);for((d="normal"!==r.mixBlendMode?r.mixBlendMode:null)&&1!==n&&e.warn("mixBlendMode on a nested element: "+d+" ignored"),p=(S=Array.from(t.childNodes)).filter(function(t){return 3===t.nodeType&&t.textContent.trim()}),g=S.filter(function(t){return 1===t.nodeType}),p.length&&g.length&&e.warn("mixed text and elements in <"+o+">"),m={display:"flex",boxSizing:"border-box",width:s,height:f},k||(m.position="absolute",m.left=a,m.top=l),b=0,y=(i=C).length;b<y;++b)h=i[b],!p.length&&O(h,R)||(c=r[h])&&A[h]!==c&&(m[h]=/data:image\/svg/.test(c)?L(c):c);for(b=0,y=(i=["Top","Right","Bottom","Left"]).length;b<y;++b)m["border"+(w=i[b])+"Width"]||delete m["border"+w+"Color"];if(m.overflow&&(m.overflow="hidden"),m.transform?m.transformOrigin=r.transformOrigin:delete m.transformOrigin,u){for(b=0,y=(i=["backgroundColor","backgroundImage","boxShadow","color","textShadow"]).length;b<y;++b)delete m[h=i[b]];for(b=0,y=(i=["Top","Right","Bottom","Left"]).length;b<y;++b)delete m["border"+(w=i[b])+"Width"]}if("img"===o||"canvas"===o||"svg"===o)return u?null:((v={blend:1===n?d:null,type:"img",props:{width:s,height:f,style:m}}).props.src=(()=>{switch(o){case"img":return t.currentSrc||t.src;case"canvas":return t.toDataURL();case"svg":return T(t,s,f,e,v)}})(),z(v,e));for(x=[],p.length&&!u&&(S=p.map(function(t){return t.textContent}).join(""),e.text(r,S,m),x.push(S),k={center:"center",right:"flex-end",end:"flex-end"}[r.textAlign])&&!g.length&&(m.justifyContent=k),b=0,y=g.length;b<y;++b)_=g[b],(_=I(_,e,n+1))&&x.push(_);return v={type:"div",props:{style:m,children:x}},d&&1===n&&(v.blend=d),z(v,e)},i={},m=function(t){return t.trim().replace(/^["']|["']$/g,"")},a=function(t){return t?t.split(",").map(function(t){var e;return t=t.trim().replace(/^u\+/i,""),/\?/.test(t)?[parseInt(t.replace(/\?/g,"0"),16),parseInt(t.replace(/\?/g,"F"),16)]:(e=(t=t.split("-"))[0],t=t[1],[parseInt(e,16),parseInt(t||e,16)])}):[[0,1114111]]},l=function(t,e){for(var n,r=[],o=/url\(\s*(['"]?)([^'")]+)\1\s*\)\s*(?:format\(\s*['"]?([^'")]+)['"]?\s*\))?/g;n=o.exec(t);)try{r.push({url:new URL(n[2],e).href,format:(n[3]||n[2].split(".").pop()).toLowerCase()})}catch(t){}return r},s=function(t,e){return{family:m(t("font-family")),weight:(t("font-weight")||"400").split(/\s+/).map(function(t){return"normal"===t?400:"bold"===t?700:+t}),style:t("font-style")||"normal",range:a(t("unicode-range")),src:l(t("src"),e)}},f=function(t,n){return(t.match(/@font-face\s*\{[^}]*\}/g)||[]).map(function(e){return s(function(t){return(new RegExp("(?:^|[{;\\s])"+t+"\\s*:\\s*([^;}]+)").exec(e)||[])[1]},n)})},u=function(t){var e,n=t.href||location.href;try{e=t.cssRules}catch(t){e=null}return e?Promise.all(Array.from(e).map(function(e){return e.styleSheet?u(e.styleSheet):5===e.type?[s(function(t){return e.style.getPropertyValue(t)},n)]:[]})).then(function(t){return t.flat()}):t.href?fetch(t.href).then(function(t){return t.text()}).then(function(t){return f(t,n)}).catch(function(){return[]}):Promise.resolve([])},h=function(){return Promise.all(Array.from(document.styleSheets).map(u)).then(function(t){return t.flat()})},F=function(t){var e,n=t.find(function(t){return"truetype"===(t=t.format)||"opentype"===t||"woff"===t||"ttf"===t||"otf"===t})||t.find(function(t){return"woff2"===t.format});return n?null!=(e=i[t=n.url])?e:i[t]=fetch(n.url).then(function(t){return t.arrayBuffer()}).then(function(e){return"woff2"!==n.format?e:S.lib("woff2").then(function(t){return(t.decompress||t.default)(e)}).then(function(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)})}):Promise.resolve(null)},g=function(){return fetch(S.libs.hbsubset).then(function(t){return t.arrayBuffer()}).then(function(t){return WebAssembly.instantiate(t,{})}).then(function(t){t=t.instance.exports;return t._initialize&&t._initialize(),t})},W=function(c,d,p){return g().then(function(t){var e,n,r,o,i,a,l,s,f,u=c.byteLength,h=t.malloc(u);for(new Uint8Array(t.memory.buffer).set(new Uint8Array(c),h),u=t.hb_blob_create(h,u,1,0,0),e=t.hb_face_create(u,0),t.hb_blob_destroy(u),u=t.hb_subset_input_create_or_fail(),n=t.hb_subset_input_unicode_set(u),r=0,i=(o=p).length;r<i;++r)a=o[r],t.hb_set_add(n,a);return t.hb_subset_input_pin_axis_location(u,e,2003265652,d),l=t.hb_subset_or_fail(e,u),t.hb_subset_input_destroy(u),u=null,l&&(s=t.hb_face_reference_blob(l),f=t.hb_blob_get_data(s,0),u=new Uint8Array(t.memory.buffer).slice(f,f+t.hb_blob_get_length(s)).buffer,t.hb_blob_destroy(s),t.hb_face_destroy(l)),t.hb_face_destroy(e),t.free(h),u})},j=function(t,e,n){return Math.min(n,Math.max(e,t))},N=function(t,e){var t=[t.weight[0],t.weight[1]||t.weight[0]],n=t[0],t=t[1];return n<=e&&e<=t?0:500<e?e<n?n-e:1e3+e-t:e<400?t<e?e-t:1e3+n-e:e<n&&n<=500?n-e:t<e?1e3+e-t:2e3+n-e},b=function(C,A){return h().then(function(t){var e,n,r,o,i,a,l,s,f,u,h,c,d,p,g,m,b,y,w={},v=0,x=0;for(e in n=C)for((r=n[e]).names=[],o=0,a=(i=Array.from(r.chars)).length;o<a;++o)if(g=i[o],!((l=g.codePointAt(0))<33)){for(s=null,f=0,h=(u=r.families).length;f<h;++f)if(c=u[f],(d=t.filter(S)).length){s=(d=(p=d.filter(_)).length?p:d).reduce(k);break}s?(g=j(r.weight,s.weight[0],s.weight[1]||s.weight[0]),m=s.src[0].url+"|"+r.weight+"|"+r.style,(m=null!=(u=w[m])?u:w[m]={name:"lotion-font-"+x++,face:s,weight:r.weight,pin:g,style:r.style,cps:new Set([32])}).cps.add(l),O(m.name,r.names)||r.names.push(m.name)):v++}return v&&A.warn(v+" characters have no web font ( system fonts are not available to satori )"),Promise.all((()=>{var t,e=[];for(b in t=w)y=t[b],e.push(y);return e})().map(function(e){return F(e.face.src).then(function(t){return t?W(t,e.pin,Array.from(e.cps)).then(function(t){return t?{name:e.name,data:t,weight:e.weight,style:e.style}:(A.warn("font "+e.face.family+": subset failed"),null)}):null})})).then(function(t){return t.filter(function(t){return t})});function S(t){return t.family===c&&t.src.length&&t.range.some(function(t){return l>=t[0]&&l<=t[1]})}function _(t){return t.style===r.style}function k(t,e){return N(e,r.weight)<N(t,r.weight)?e:t}})},y=function(t,r,o){var e,n,i,a,l,s=r.props.children;if(!s.some(function(t){return t.blend}))return t(r,o);for(e=[{kids:[]}],n=0,i=s.length;n<i;++n)(a=s[n]).blend?e.push({blend:a.blend,kids:[a]}):e[e.length-1].blend?e.push({kids:[a]}):e[e.length-1].kids.push(a);return l={display:"flex",width:o.width,height:o.height,overflow:"hidden"},Promise.all(e.map(function(e,n){return t({type:"div",props:{style:0===n?r.props.style:l,children:e.kids}},o).then(function(t){t=t.replace(/^<svg[^>]*>/,"").replace(/<\/svg>\s*$/,"").replace(/satori_/g,"satori_"+n+"_");return e.blend?'<g style="mix-blend-mode:'+e.blend+'">'+t+"</g>":"<g>"+t+"</g>"})})).then(function(t){return'<svg width="'+o.width+'" height="'+o.height+'" viewBox="0 0 '+o.width+" "+o.height+'" xmlns="http://www.w3.org/2000/svg">'+t.join("")+"</svg>"})},S.vector=c=function(t,u){var o,h,c,e,d,p,g;return null==u&&(u={}),o={},h={},c=[],d=I(t,e={warn:function(t){return o[t]=(o[t]||0)+1},later:function(t){return c.push(t)},text:function(t,e,n){for(var r,o,i=+t.fontWeight||400,a=t.fontFamily+"|"+i+"|"+t.fontStyle,l=null!=(r=h[a])?r:h[a]={families:t.fontFamily.split(",").map(m),weight:i,style:t.fontStyle,chars:new Set,styles:[]},s=0,f=(r=Array.from(e)).length;s<f;++s)o=r[s],l.chars.add(o);return l.styles.push(n)}}),p=u.width||t.offsetWidth,g=u.height||t.offsetHeight,(t=d.props.style).width=p,t.height=g,t.overflow="hidden",delete d.props.style.transform,delete d.props.style.transformOrigin,Promise.all([(t=u.satori)?Promise.resolve(t):S.lib("satori"),(t=u.fonts)?Promise.resolve(t):b(h,e)]).then(function(t){var e,n,r,o,i,a,l=t[0],s=t[1];if(!u.fonts)for(e in n=h)for(o=0,a=(i=(r=n[e]).styles).length;o<a;++o)i[o].fontFamily=r.names.map(f).join(", ");for(o=0,a=(n=c).length;o<a;++o)(0,n[o])(s);return t=l.default||l.satori||l,y(t,d,{width:p,height:g,fonts:s});function f(t){return"'"+t+"'"}}).then(function(t){var n,r;return{svg:t,warnings:(()=>{var t,e=[];for(n in t=o)r=t[n],e.push(n+(1<r?" ( x"+r+" )":""));return e})()}})},S.player.prototype.vector=function(e,t){var n=this;return null==t&&(t={}),null!=e&&this.opt.seek(e),c(this.stage,t).then(function(t){return null!=e&&n.opt.seek(n.t),t})}}.call(this);