@tiennm99/aboutme 1.4.0 → 1.5.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/aboutme.js CHANGED
@@ -1,4 +1,4 @@
1
- (()=>{var Le="aboutme:hiddenUntil";var Ye=["home","blog","github","facebook","linkedin","x","youtube","email","telegram","cv","link"],We=["list","grid","icons"],Ee="aboutme:pos";var Ge={m:6e4,h:36e5,d:864e5,w:6048e5},Me=/^(\d{1,4})\s*([mhdw])$/i,Ve=/^[a-z0-9-]{1,32}$/;function ne(e){let t=Me.exec(String(e??"").trim());return!t||Number(t[1])===0?ne("7d"):Number(t[1])*Ge[t[2].toLowerCase()]}var oe={en:{about:"About {name}",drag:"Drag to the bottom to hide",close:"Close",hide:"Hide for {period}",units:{m:"minute",h:"hour",d:"day",w:"week"},plural:"s"},vi:{about:"Gi\u1EDBi thi\u1EC7u v\u1EC1 {name}",drag:"K\xE9o xu\u1ED1ng d\u01B0\u1EDBi \u0111\u1EC3 \u1EA9n",close:"\u0110\xF3ng",hide:"\u1EA8n trong {period}",units:{m:"ph\xFAt",h:"gi\u1EDD",d:"ng\xE0y",w:"tu\u1EA7n"},plural:""}};function Se(e,t){return e==="en"||e==="vi"?e:/^vi(-|$)/i.test(String(t??"").trim())?"vi":"en"}function ie(e,t,n){return e.replace(`{${t}}`,()=>n)}function re(e,t="en"){let n=Me.exec(String(e??"").trim());if(!n||Number(n[1])===0)return re("7d",t);let i=Number(n[1]),{units:r,plural:h}=oe[t];return`${i} ${r[n[2].toLowerCase()]}${i===1?"":h}`}function Ae(e){let t=/^(?:(top|bottom)-)?(left|right)$/.exec(String(e??""));return t?{side:t[2],fromBottom:t[1]!=="top"}:{side:"right",fromBottom:!0}}function Te(e){let t=/^(\d+)(px)?$/.exec(String(e??"").trim());return t?Number(t[1]):32}function Ce(e){try{let t=JSON.parse(e?.getItem(Ee)??"null"),{side:n,fromBottom:i,gap:r,share:h}=t??{},a=(d,v)=>typeof d=="number"&&d>=0&&d<=v;if((n==="left"||n==="right")&&typeof i=="boolean"&&a(r,1e5)&&a(h,1))return{side:n,fromBottom:i,gap:r,share:h}}catch{}return null}function He(e,{side:t,fromBottom:n,gap:i,share:r}){try{e?.setItem(Ee,JSON.stringify({side:t,fromBottom:n,gap:i,share:r}))}catch{}}function je(e,t){try{let n=new URL(e),i=new URL(t);if(!/^https?:$/.test(n.protocol)||n.origin!==i.origin)return!1;let r=n.pathname.replace(/(.)\/$/,"$1");return r==="/"||i.pathname===r||i.pathname.startsWith(`${r}/`)}catch{return!1}}function Ie(e,t){let n=e.filter(i=>!je(i.url,t));return n.length?n:e}function _e(e){return We.includes(e)?e:"list"}function Oe(e,t){try{let n=Number(e?.getItem(Le));return Number.isFinite(n)&&n>t}catch{return!1}}function De(e,t,n){try{e?.setItem(Le,String(t+n))}catch{}}function ee(e,t){if(typeof e!="string")return null;try{let n=new URL(e);return t.includes(n.protocol)?n.href:null}catch{return null}}function te(e,t){return typeof e=="string"?e.trim().slice(0,t):""}function ze(e,t){if(!e||typeof e!="object"||e.schemaVersion!==1)return null;let n=te(e.name,60);if(!n)return null;let i=[],r=new Set;for(let a of Array.isArray(e.links)?e.links.slice(0,12):[]){let d=typeof a?.id=="string"&&Ve.test(a.id)?a.id:null,v=te(a?.label,40),x=ee(a?.url,["https:","http:","mailto:"]);!d||!v||!x||r.has(d)||(r.add(d),i.push({id:d,label:v,url:x,icon:Ye.includes(a.icon)?a.icon:"link"}))}if(i.length===0)return null;let h=null;if(typeof e.events=="string")try{h=ee(new URL(e.events,t).href,["https:","http:"])}catch{h=null}return{name:n,tagline:te(e.tagline,120),avatar:ee(e.avatar,["https:"]),links:i,events:h}}var Xe=/^(rgba?|oklch|oklab|lab|lch|color)\((.*)\)$/i;function R(e,t){return e==="none"?0:e?.endsWith("%")?parseFloat(e)/100*t:parseFloat(e??"")}function ke(e){let t=Xe.exec(String(e??"").trim());if(!t)return null;let n=t[1].toLowerCase(),i=t[2].split(/[\s,/]+/).filter(Boolean),r;if(n==="color"){let a=i.shift()?.toLowerCase();if(a!=="srgb"&&a!=="srgb-linear"&&a!=="display-p3")return null;let d=f=>a!=="srgb-linear"?f:f<=.0031308?12.92*f:1.055*f**(1/2.4)-.055,[v,x,y]=i.slice(0,3).map(f=>d(R(f,1)));r=.299*v+.587*x+.114*y}else if(n.startsWith("rgb")){let[a,d,v]=i.map(x=>R(x,255));r=(.299*a+.587*d+.114*v)/255}else r=R(i[0],1)/(n.startsWith("ok")||i[0]?.endsWith("%")?1:100);let h=i.length>3?R(i[3],1):1;return!Number.isFinite(r)||!(h>=.5)?null:Math.min(Math.max(r,0),1)}function Ne({backgrounds:e,markers:t,text:n,prefersDark:i}){for(let h of e){let a=ke(h);if(a!==null)return a<.5?"dark":"light"}for(let h of t){let a=h?.trim().toLowerCase();if(a==="dark"||a==="light")return a}let r=ke(n);return r!==null&&r>.6?"dark":r!==null&&r<.4?"light":i?"dark":"light"}var p=52,b=16,E=8,se=280,Ke=160,Je=2,Ze=b*2+p+E+se,qe=6,Qe=72,et=["data-theme","data-bs-theme","data-mode","data-color-mode","data-color-scheme"],Re={person:'<circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-7 8-7s8 3 8 7"/>',close:'<path d="M6 6l12 12M18 6L6 18"/>',home:'<path d="M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z"/>',blog:'<path d="M4 20h4L19 9l-4-4L4 16z"/><path d="M14 6l4 4"/>',linkedin:'<rect x="3" y="7" width="18" height="13" rx="2"/><path d="M9 7V5h6v2"/>',email:'<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/>',cv:'<path d="M6 3h9l4 4v14H6z"/><path d="M14 3v5h5M9 12h7M9 16h7"/>',link:'<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>'},tt={github:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12",facebook:"M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036 26.805 26.805 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.686 1.686 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647Z",x:"M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z",youtube:"M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z",telegram:"M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"},nt=`
1
+ (()=>{var Lt="aboutme:hiddenUntil";var Yt=["home","blog","github","facebook","linkedin","x","youtube","email","telegram","cv","link"],Wt=["list","grid","icons"],Et="aboutme:pos";var Gt={m:6e4,h:36e5,d:864e5,w:6048e5},Mt=/^(\d{1,4})\s*([mhdw])$/i,Vt=/^[a-z0-9-]{1,32}$/;function nt(t){let e=Mt.exec(String(t??"").trim());return!e||Number(e[1])===0?nt("7d"):Number(e[1])*Gt[e[2].toLowerCase()]}var ot={en:{about:"About {name}",drag:"Drag to the bottom to hide",close:"Close",hide:"Hide for {period}",units:{m:"minute",h:"hour",d:"day",w:"week"},plural:"s"},vi:{about:"Gi\u1EDBi thi\u1EC7u v\u1EC1 {name}",drag:"K\xE9o xu\u1ED1ng d\u01B0\u1EDBi \u0111\u1EC3 \u1EA9n",close:"\u0110\xF3ng",hide:"\u1EA8n trong {period}",units:{m:"ph\xFAt",h:"gi\u1EDD",d:"ng\xE0y",w:"tu\u1EA7n"},plural:""}};function St(t,e){return t==="en"||t==="vi"?t:/^vi(-|$)/i.test(String(e??"").trim())?"vi":"en"}function it(t,e,n){return t.replace(`{${e}}`,()=>n)}function rt(t,e="en"){let n=Mt.exec(String(t??"").trim());if(!n||Number(n[1])===0)return rt("7d",e);let i=Number(n[1]),{units:r,plural:c}=ot[e];return`${i} ${r[n[2].toLowerCase()]}${i===1?"":c}`}function At(t){let e=/^(?:(top|bottom)-)?(left|right)$/.exec(String(t??""));return e?{side:e[2],fromBottom:e[1]!=="top"}:{side:"right",fromBottom:!0}}function Tt(t){let e=/^(\d+)(px)?$/.exec(String(t??"").trim());return e?Number(e[1]):32}function Ct(t){try{let e=JSON.parse(t?.getItem(Et)??"null"),{side:n,fromBottom:i,gap:r,share:c}=e??{},a=(u,v)=>typeof u=="number"&&u>=0&&u<=v;if((n==="left"||n==="right")&&typeof i=="boolean"&&a(r,1e5)&&a(c,1))return{side:n,fromBottom:i,gap:r,share:c}}catch{}return null}function Ht(t,{side:e,fromBottom:n,gap:i,share:r}){try{t?.setItem(Et,JSON.stringify({side:e,fromBottom:n,gap:i,share:r}))}catch{}}function jt(t,e){try{let n=new URL(t),i=new URL(e);if(!/^https?:$/.test(n.protocol)||n.origin!==i.origin)return!1;let r=n.pathname.replace(/(.)\/$/,"$1");return r==="/"||i.pathname===r||i.pathname.startsWith(`${r}/`)}catch{return!1}}function It(t,e){let n=t.filter(i=>!jt(i.url,e));return n.length?n:t}function _t(t){return Wt.includes(t)?t:"list"}function Ot(t,e){try{let n=Number(t?.getItem(Lt));return Number.isFinite(n)&&n>e}catch{return!1}}function $t(t,e,n){try{t?.setItem(Lt,String(e+n))}catch{}}function tt(t,e){if(typeof t!="string")return null;try{let n=new URL(t);return e.includes(n.protocol)?n.href:null}catch{return null}}function et(t,e){return typeof t=="string"?t.trim().slice(0,e):""}var Xt=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i;function Kt(t){if(typeof t!="string"||!Xt.test(t.trim()))return null;let e=t.trim().slice(1).toLowerCase();e.length===3&&(e=[...e].map(c=>c+c).join(""));let[n,i,r]=[0,2,4].map(c=>{let a=parseInt(e.slice(c,c+2),16)/255;return a<=.04045?a/12.92:((a+.055)/1.055)**2.4});return{color:`#${e}`,fg:.2126*n+.7152*i+.0722*r>.19?"#111111":"#ffffff"}}function Dt(t,e){if(!t||typeof t!="object"||t.schemaVersion!==1)return null;let n=et(t.name,60);if(!n)return null;let i=[],r=new Set;for(let a of Array.isArray(t.links)?t.links.slice(0,12):[]){let u=typeof a?.id=="string"&&Vt.test(a.id)?a.id:null,v=et(a?.label,40),x=tt(a?.url,["https:","http:","mailto:"]);!u||!v||!x||r.has(u)||(r.add(u),i.push({id:u,label:v,url:x,icon:Yt.includes(a.icon)?a.icon:"link"}))}if(i.length===0)return null;let c=null;if(typeof t.events=="string")try{c=tt(new URL(t.events,e).href,["https:","http:"])}catch{c=null}return{name:n,tagline:et(t.tagline,120),avatar:tt(t.avatar,["https:"]),links:i,events:c,accent:Kt(t.accent)}}var Jt=/^(rgba?|oklch|oklab|lab|lch|color)\((.*)\)$/i;function N(t,e){return t==="none"?0:t?.endsWith("%")?parseFloat(t)/100*e:parseFloat(t??"")}function kt(t){let e=Jt.exec(String(t??"").trim());if(!e)return null;let n=e[1].toLowerCase(),i=e[2].split(/[\s,/]+/).filter(Boolean),r;if(n==="color"){let a=i.shift()?.toLowerCase();if(a!=="srgb"&&a!=="srgb-linear"&&a!=="display-p3")return null;let u=h=>a!=="srgb-linear"?h:h<=.0031308?12.92*h:1.055*h**(1/2.4)-.055,[v,x,y]=i.slice(0,3).map(h=>u(N(h,1)));r=.299*v+.587*x+.114*y}else if(n.startsWith("rgb")){let[a,u,v]=i.map(x=>N(x,255));r=(.299*a+.587*u+.114*v)/255}else r=N(i[0],1)/(n.startsWith("ok")||i[0]?.endsWith("%")?1:100);let c=i.length>3?N(i[3],1):1;return!Number.isFinite(r)||!(c>=.5)?null:Math.min(Math.max(r,0),1)}function zt({backgrounds:t,markers:e,text:n,prefersDark:i}){for(let c of t){let a=kt(c);if(a!==null)return a<.5?"dark":"light"}for(let c of e){let a=c?.trim().toLowerCase();if(a==="dark"||a==="light")return a}let r=kt(n);return r!==null&&r>.6?"dark":r!==null&&r<.4?"light":i?"dark":"light"}var f=52,b=16,E=8,st=280,Zt=160,qt=2,Qt=b*2+f+E+st,te=6,ee=72,ne=["data-theme","data-bs-theme","data-mode","data-color-mode","data-color-scheme"],Nt={person:'<circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-7 8-7s8 3 8 7"/>',close:'<path d="M6 6l12 12M18 6L6 18"/>',home:'<path d="M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z"/>',blog:'<path d="M4 20h4L19 9l-4-4L4 16z"/><path d="M14 6l4 4"/>',linkedin:'<rect x="3" y="7" width="18" height="13" rx="2"/><path d="M9 7V5h6v2"/>',email:'<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/>',cv:'<path d="M6 3h9l4 4v14H6z"/><path d="M14 3v5h5M9 12h7M9 16h7"/>',link:'<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>'},oe={github:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12",facebook:"M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036 26.805 26.805 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.686 1.686 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647Z",x:"M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z",youtube:"M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z",telegram:"M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"},ie=`
2
2
  :host { all: initial; }
3
3
  * { box-sizing: border-box; }
4
4
  .root {
@@ -14,7 +14,7 @@
14
14
  svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
15
15
  svg.fill { fill: currentColor; stroke: none; padding: 1px; }
16
16
  .bubble {
17
- position: fixed; left: 0; top: 0; width: ${p}px; height: ${p}px; z-index: 2147483001;
17
+ position: fixed; left: 0; top: 0; width: ${f}px; height: ${f}px; z-index: 2147483001;
18
18
  border: 0; border-radius: 50%; padding: 0; cursor: grab; touch-action: none; user-select: none;
19
19
  background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; overflow: hidden;
20
20
  box-shadow: 0 4px 14px rgb(0 0 0 / 25%); transition: transform .2s ease;
@@ -25,7 +25,7 @@ svg.fill { fill: currentColor; stroke: none; padding: 1px; }
25
25
  a:focus-visible { outline-offset: -3px; }
26
26
  .bubble.dragging { cursor: grabbing; transition: none; }
27
27
  .panel {
28
- position: fixed; z-index: 2147483000; width: ${se}px; display: flex; flex-direction: column;
28
+ position: fixed; z-index: 2147483000; width: ${st}px; display: flex; flex-direction: column;
29
29
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
30
30
  box-shadow: 0 8px 30px rgb(0 0 0 / 20%); animation: open .12s ease-out;
31
31
  overflow-y: auto; overscroll-behavior: contain;
@@ -62,4 +62,4 @@ a span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-over
62
62
  .target.active { transform: scale(1.25); background: var(--danger); }
63
63
  @media (prefers-reduced-motion: reduce) { .bubble, .target { transition: none; } .panel { animation: none; } }
64
64
  @media print { .root { display: none; } }
65
- `;function H(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true");let n=tt[e];return n&&t.classList.add("fill"),t.innerHTML=n?`<path d="${n}"/>`:Re[e]??Re.link,t}function m(e,t,n){let i=document.createElement(e);return t&&(i.className=t),n&&(i.textContent=n),i}function A(){let e=document.compatMode==="BackCompat"?document.body:document.documentElement,t={w:e.clientWidth,h:e.clientHeight},n=window.visualViewport;return n&&n.scale<1&&(t.w=Math.max(t.w,n.width),t.h=Math.max(t.h,n.height)),t}function ae(e,t,n){return Math.max(Math.min(e,n),t)}function ot(e){let t=[document.documentElement,document.body],n=[];for(let i of t)n.push(...["dark","light"].filter(r=>i.classList.contains(r))),n.push(...et.map(r=>i.getAttribute(r)));return Ne({backgrounds:[t[1],t[0]].map(i=>getComputedStyle(i).backgroundColor),markers:n,text:getComputedStyle(t[1]).color,prefersDark:e.matches})}function $e({profile:e,placement:t,lang:n,theme:i,layout:r,hide:h,track:a,onDismiss:d,onMove:v}){let x=oe[n],y=ie(x.about,"name",e.name),f=document.createElement("aboutme-widget"),Fe=f.attachShadow({mode:"open"}),I=m("div","root");r!=="list"&&(I.dataset.l=r);let ce=m("style");ce.textContent=nt;let c=m("button","bubble");if(c.type="button",c.setAttribute("aria-label",y),c.setAttribute("aria-expanded","false"),c.setAttribute("aria-controls","aboutme-panel"),c.title=x.drag,e.avatar){let o=m("img");o.alt="",o.src=e.avatar,o.addEventListener("error",()=>o.replaceWith(H("person")),{once:!0}),c.append(o)}else c.append(H("person"));let u=m("div","panel");u.id="aboutme-panel",u.setAttribute("role","dialog"),u.setAttribute("aria-label",y),u.hidden=!0;let U=m("div","head");if(e.avatar){let o=m("img");o.alt="",o.src=e.avatar,U.append(o)}let F=m("div","who");F.append(m("div","name",e.name)),e.tagline&&F.append(m("div","tagline",e.tagline));let T=m("button","icon-btn");T.type="button",T.setAttribute("aria-label",x.close),T.append(H("close")),U.append(F,T);let L=m("ul");for(let o of e.links){let s=m("li"),l=m("a");l.href=o.url,l.target="_blank",l.rel="noopener noreferrer",l.title=o.label,l.append(H(o.icon),m("span","",o.label)),l.addEventListener("click",()=>a("click",o.id)),s.append(l),L.append(s)}let P=m("button","hide",ie(x.hide,"period",re(h,n)));P.type="button",u.append(U,L,P);let k=m("div","target");k.hidden=!0,k.append(H("close")),I.append(ce,c,u,k),Fe.append(I),document.body.append(f);let B=window.matchMedia("(prefers-color-scheme: dark)"),Y=0,W=0,_=null,G=null;function O(){I.dataset.t=i==="auto"?ot(B):i}function V(){cancelAnimationFrame(Y),Y=requestAnimationFrame(O),clearTimeout(W),W=setTimeout(O,400)}let M=0,w=0,{side:C,fromBottom:D,gap:z,share:j}=t,X=A();function le(){c.style.transform=`translate(${M}px, ${w}px)`}function K(){let{w:o,h:s}=A(),l=Math.min(z,j*(s-p));M=C==="left"?b:o-p-b,w=ae(D?s-p-l:l,b,s-p-b),X={w:o,h:s},le()}function Pe(){let{w:o,h:s}=A();C=M+p/2<o/2?"left":"right",D=w+p/2>s/2;let l=ae(w,b,s-p-b);z=D?s-p-l:l,j=s>p?Math.min(z/(s-p),1):1,K(),v({side:C,fromBottom:D,gap:z,share:j})}function de(){let{w:o,h:s}=A(),l=w-E-b,ge=s-w-p-E-b,be=Math.max(l,ge),xe=Math.min(se,o-b*2);u.style.width=`${xe}px`,u.style.maxHeight="none",L.style.minHeight="0px";let ve=L.firstElementChild?.offsetHeight??0,Be=u.offsetHeight-L.offsetHeight,N=be<Math.max(Ke,Be+Math.min(L.scrollHeight,ve*Je)),we=N&&o>=Ze;u.classList.toggle("over",N&&!we),L.style.minHeight=`${Math.min(L.scrollHeight,ve)}px`,u.style.maxHeight=`${Math.max(N?s-b*2:be,0)}px`;let q=u.offsetHeight,ye=C==="left"?b:o-b-xe,Q;N?(we&&(ye+=C==="left"?p+E:-p-E),Q=ae(w+p/2-q/2,b,s-b-q)):Q=l>=ge?w-E-q:w+p+E,u.style.left=`${ye}px`,u.style.top=`${Q}px`}function J(){g?.moved||(K(),u.hidden||de())}function Z(){let{w:o,h:s}=A();(o!==X.w||s!==X.h)&&J()}function S(o){o!==!u.hidden&&(u.hidden=!o,c.setAttribute("aria-expanded",String(o)),o&&(O(),de(),a("open")))}function ue(){a("dismiss"),f.remove(),window.removeEventListener("resize",J),window.visualViewport?.removeEventListener("resize",Z),document.removeEventListener("pointerdown",pe,!0),document.removeEventListener("keydown",he),B.removeEventListener("change",V),_?.disconnect(),G?.disconnect(),cancelAnimationFrame(Y),clearTimeout(W),d()}function pe(o){o.composedPath().includes(f)||S(!1)}function he(o){o.key==="Escape"&&!u.hidden&&(S(!1),c.focus())}function fe(){let o=k.getBoundingClientRect(),s=M+p/2-(o.left+o.width/2),l=w+p/2-(o.top+o.height/2);return Math.hypot(s,l)<Qe}let g=null;c.addEventListener("pointerdown",o=>{o.button===0&&(g={id:o.pointerId,startX:o.clientX,startY:o.clientY,dx:o.clientX-M,dy:o.clientY-w,moved:!1},c.setPointerCapture(o.pointerId))}),c.addEventListener("pointermove",o=>{if(!(!g||o.pointerId!==g.id)&&!(!g.moved&&Math.hypot(o.clientX-g.startX,o.clientY-g.startY)<qe)){if(!g.moved){g.moved=!0,c.classList.add("dragging");let{w:s,h:l}=A();k.style.left=`${s/2-32}px`,k.style.top=`${l-96}px`,k.hidden=!1,S(!1)}M=o.clientX-g.dx,w=o.clientY-g.dy,le(),k.classList.toggle("active",fe())}});function me(o){if(!g||o.pointerId!==g.id)return;let{moved:s}=g;if(g=null,!s){o.type==="pointerup"&&S(u.hidden);return}c.classList.remove("dragging");let l=o.type==="pointerup"&&fe();k.hidden=!0,k.classList.remove("active"),l?ue():Pe()}return c.addEventListener("pointerup",me),c.addEventListener("pointercancel",me),c.addEventListener("click",o=>{o.detail===0&&S(u.hidden)}),T.addEventListener("click",()=>{S(!1),c.focus()}),P.addEventListener("click",ue),window.addEventListener("resize",J),window.visualViewport?.addEventListener("resize",Z),window.ResizeObserver&&(G=new ResizeObserver(Z),G.observe(document.compatMode==="BackCompat"?document.body:document.documentElement)),document.addEventListener("pointerdown",pe,!0),document.addEventListener("keydown",he),O(),i==="auto"&&(B.addEventListener("change",V),_=new MutationObserver(V),_.observe(document.documentElement,{attributes:!0}),_.observe(document.body,{attributes:!0})),c.classList.add("dragging"),K(),c.getBoundingClientRect(),c.classList.remove("dragging"),f}function $(){try{return window.localStorage}catch{return null}}function it(e,t,n){if(!(!e||navigator.globalPrivacyControl===!0))try{fetch(e,{method:"POST",mode:"cors",credentials:"omit",keepalive:!0,headers:{"content-type":"text/plain"},body:JSON.stringify(n?{event:t,target:n}:{event:t})}).catch(()=>{})}catch{}}async function rt(e){let t=e.dataset.profile,n=e.dataset.hide,{position:i,offset:r}=e.dataset,h=["light","dark"].includes(e.dataset.theme)?e.dataset.theme:"auto",a=_e(e.dataset.layout);if(!t||Oe($(),Date.now()))return;let d;try{let y=new URL(t,document.baseURI).href,f=await fetch(y,{credentials:"omit"});if(!f.ok)return;d=ze(await f.json(),y)}catch{return}if(!d)return;d.links=Ie(d.links,location.href);let v=Ce($())??{...Ae(i),gap:Te(r),share:1},x=()=>$e({profile:d,placement:v,lang:Se(e.dataset.lang,document.documentElement.lang),theme:h,layout:a,hide:n??"",track:(y,f)=>it(d.events,y,f),onDismiss:()=>De($(),Date.now(),ne(n)),onMove:y=>He($(),y)});document.body?x():document.addEventListener("DOMContentLoaded",x,{once:!0})}var Ue=document.currentScript;Ue instanceof HTMLScriptElement&&!window.__aboutmeLoaded&&(window.__aboutmeLoaded=!0,rt(Ue));})();
65
+ `;function I(t){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("aria-hidden","true");let n=oe[t];return n&&e.classList.add("fill"),e.innerHTML=n?`<path d="${n}"/>`:Nt[t]??Nt.link,e}function m(t,e,n){let i=document.createElement(t);return e&&(i.className=e),n&&(i.textContent=n),i}function T(){let t=document.compatMode==="BackCompat"?document.body:document.documentElement,e={w:t.clientWidth,h:t.clientHeight},n=window.visualViewport;return n&&n.scale<1&&(e.w=Math.max(e.w,n.width),e.h=Math.max(e.h,n.height)),e}function at(t,e,n){return Math.max(Math.min(t,n),e)}function re(t){let e=[document.documentElement,document.body],n=[];for(let i of e)n.push(...["dark","light"].filter(r=>i.classList.contains(r))),n.push(...ne.map(r=>i.getAttribute(r)));return zt({backgrounds:[e[1],e[0]].map(i=>getComputedStyle(i).backgroundColor),markers:n,text:getComputedStyle(e[1]).color,prefersDark:t.matches})}function Rt({profile:t,placement:e,lang:n,theme:i,layout:r,hide:c,track:a,onDismiss:u,onMove:v}){let x=ot[n],y=it(x.about,"name",t.name),h=document.createElement("aboutme-widget"),Ut=h.attachShadow({mode:"open"}),M=m("div","root");r!=="list"&&(M.dataset.l=r),t.accent&&(M.style.setProperty("--accent",t.accent.color),M.style.setProperty("--accent-fg",t.accent.fg));let ct=m("style");ct.textContent=ie;let l=m("button","bubble");if(l.type="button",l.setAttribute("aria-label",y),l.setAttribute("aria-expanded","false"),l.setAttribute("aria-controls","aboutme-panel"),l.title=x.drag,t.avatar){let o=m("img");o.alt="",o.src=t.avatar,o.addEventListener("error",()=>o.replaceWith(I("person")),{once:!0}),l.append(o)}else l.append(I("person"));let p=m("div","panel");p.id="aboutme-panel",p.setAttribute("role","dialog"),p.setAttribute("aria-label",y),p.hidden=!0;let P=m("div","head");if(t.avatar){let o=m("img");o.alt="",o.src=t.avatar,P.append(o)}let U=m("div","who");U.append(m("div","name",t.name)),t.tagline&&U.append(m("div","tagline",t.tagline));let C=m("button","icon-btn");C.type="button",C.setAttribute("aria-label",x.close),C.append(I("close")),P.append(U,C);let L=m("ul");for(let o of t.links){let s=m("li"),d=m("a");d.href=o.url,d.target="_blank",d.rel="noopener noreferrer",d.title=o.label,d.append(I(o.icon),m("span","",o.label)),d.addEventListener("click",()=>a("click",o.id)),s.append(d),L.append(s)}let F=m("button","hide",it(x.hide,"period",rt(c,n)));F.type="button",p.append(P,L,F);let k=m("div","target");k.hidden=!0,k.append(I("close")),M.append(ct,l,p,k),Ut.append(M),document.body.append(h);let B=window.matchMedia("(prefers-color-scheme: dark)"),Y=0,W=0,_=null,G=null;function O(){M.dataset.t=i==="auto"?re(B):i}function V(){cancelAnimationFrame(Y),Y=requestAnimationFrame(O),clearTimeout(W),W=setTimeout(O,400)}let S=0,w=0,{side:H,fromBottom:$,gap:D,share:j}=e,X=T();function lt(){l.style.transform=`translate(${S}px, ${w}px)`}function K(){let{w:o,h:s}=T(),d=Math.min(D,j*(s-f));S=H==="left"?b:o-f-b,w=at($?s-f-d:d,b,s-f-b),X={w:o,h:s},lt()}function Ft(){let{w:o,h:s}=T();H=S+f/2<o/2?"left":"right",$=w+f/2>s/2;let d=at(w,b,s-f-b);D=$?s-f-d:d,j=s>f?Math.min(D/(s-f),1):1,K(),v({side:H,fromBottom:$,gap:D,share:j})}function dt(){let{w:o,h:s}=T(),d=w-E-b,gt=s-w-f-E-b,bt=Math.max(d,gt),xt=Math.min(st,o-b*2);p.style.width=`${xt}px`,p.style.maxHeight="none",L.style.minHeight="0px";let vt=L.firstElementChild?.offsetHeight??0,Bt=p.offsetHeight-L.offsetHeight,z=bt<Math.max(Zt,Bt+Math.min(L.scrollHeight,vt*qt)),wt=z&&o>=Qt;p.classList.toggle("over",z&&!wt),L.style.minHeight=`${Math.min(L.scrollHeight,vt)}px`,p.style.maxHeight=`${Math.max(z?s-b*2:bt,0)}px`;let q=p.offsetHeight,yt=H==="left"?b:o-b-xt,Q;z?(wt&&(yt+=H==="left"?f+E:-f-E),Q=at(w+f/2-q/2,b,s-b-q)):Q=d>=gt?w-E-q:w+f+E,p.style.left=`${yt}px`,p.style.top=`${Q}px`}function J(){g?.moved||(K(),p.hidden||dt())}function Z(){let{w:o,h:s}=T();(o!==X.w||s!==X.h)&&J()}function A(o){o!==!p.hidden&&(p.hidden=!o,l.setAttribute("aria-expanded",String(o)),o&&(O(),dt(),a("open")))}function ut(){a("dismiss"),h.remove(),window.removeEventListener("resize",J),window.visualViewport?.removeEventListener("resize",Z),document.removeEventListener("pointerdown",pt,!0),document.removeEventListener("keydown",ft),B.removeEventListener("change",V),_?.disconnect(),G?.disconnect(),cancelAnimationFrame(Y),clearTimeout(W),u()}function pt(o){o.composedPath().includes(h)||A(!1)}function ft(o){o.key==="Escape"&&!p.hidden&&(A(!1),l.focus())}function ht(){let o=k.getBoundingClientRect(),s=S+f/2-(o.left+o.width/2),d=w+f/2-(o.top+o.height/2);return Math.hypot(s,d)<ee}let g=null;l.addEventListener("pointerdown",o=>{o.button===0&&(g={id:o.pointerId,startX:o.clientX,startY:o.clientY,dx:o.clientX-S,dy:o.clientY-w,moved:!1},l.setPointerCapture(o.pointerId))}),l.addEventListener("pointermove",o=>{if(!(!g||o.pointerId!==g.id)&&!(!g.moved&&Math.hypot(o.clientX-g.startX,o.clientY-g.startY)<te)){if(!g.moved){g.moved=!0,l.classList.add("dragging");let{w:s,h:d}=T();k.style.left=`${s/2-32}px`,k.style.top=`${d-96}px`,k.hidden=!1,A(!1)}S=o.clientX-g.dx,w=o.clientY-g.dy,lt(),k.classList.toggle("active",ht())}});function mt(o){if(!g||o.pointerId!==g.id)return;let{moved:s}=g;if(g=null,!s){o.type==="pointerup"&&A(p.hidden);return}l.classList.remove("dragging");let d=o.type==="pointerup"&&ht();k.hidden=!0,k.classList.remove("active"),d?ut():Ft()}return l.addEventListener("pointerup",mt),l.addEventListener("pointercancel",mt),l.addEventListener("click",o=>{o.detail===0&&A(p.hidden)}),C.addEventListener("click",()=>{A(!1),l.focus()}),F.addEventListener("click",ut),window.addEventListener("resize",J),window.visualViewport?.addEventListener("resize",Z),window.ResizeObserver&&(G=new ResizeObserver(Z),G.observe(document.compatMode==="BackCompat"?document.body:document.documentElement)),document.addEventListener("pointerdown",pt,!0),document.addEventListener("keydown",ft),O(),i==="auto"&&(B.addEventListener("change",V),_=new MutationObserver(V),_.observe(document.documentElement,{attributes:!0}),_.observe(document.body,{attributes:!0})),l.classList.add("dragging"),K(),l.getBoundingClientRect(),l.classList.remove("dragging"),h}function R(){try{return window.localStorage}catch{return null}}function ae(t,e,n){if(!(!t||navigator.globalPrivacyControl===!0))try{fetch(t,{method:"POST",mode:"cors",credentials:"omit",keepalive:!0,headers:{"content-type":"text/plain"},body:JSON.stringify(n?{event:e,target:n}:{event:e})}).catch(()=>{})}catch{}}async function se(t){let e=t.dataset.profile,n=t.dataset.hide,{position:i,offset:r}=t.dataset,c=["light","dark"].includes(t.dataset.theme)?t.dataset.theme:"auto",a=_t(t.dataset.layout);if(!e||Ot(R(),Date.now()))return;let u;try{let y=new URL(e,document.baseURI).href,h=await fetch(y,{credentials:"omit"});if(!h.ok)return;u=Dt(await h.json(),y)}catch{return}if(!u)return;u.links=It(u.links,location.href);let v=Ct(R())??{...At(i),gap:Tt(r),share:1},x=()=>Rt({profile:u,placement:v,lang:St(t.dataset.lang,document.documentElement.lang),theme:c,layout:a,hide:n??"",track:(y,h)=>ae(u.events,y,h),onDismiss:()=>$t(R(),Date.now(),nt(n)),onMove:y=>Ht(R(),y)});document.body?x():document.addEventListener("DOMContentLoaded",x,{once:!0})}var Pt=document.currentScript;Pt instanceof HTMLScriptElement&&!window.__aboutmeLoaded&&(window.__aboutmeLoaded=!0,se(Pt));})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiennm99/aboutme",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "A draggable floating bubble that shows links about the site's author, loaded from a profile JSON.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -10,6 +10,11 @@
10
10
  "name": { "type": "string", "minLength": 1, "maxLength": 60 },
11
11
  "tagline": { "type": "string", "maxLength": 120 },
12
12
  "avatar": { "type": "string", "format": "uri", "pattern": "^https://" },
13
+ "accent": {
14
+ "type": "string",
15
+ "pattern": "^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$",
16
+ "description": "Bubble and focus-ring colour in both themes, as #rgb or #rrggbb. Leave it out for the default blue."
17
+ },
13
18
  "events": {
14
19
  "type": "string",
15
20
  "description": "Count endpoint, absolute or relative to the profile URL. Leave it out to send no counts."