@tiennm99/aboutme 1.2.0 → 1.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.
Files changed (2) hide show
  1. package/dist/aboutme.js +10 -3
  2. package/package.json +2 -1
package/dist/aboutme.js CHANGED
@@ -1,4 +1,4 @@
1
- (()=>{var ge="aboutme:hiddenUntil";var He=["home","blog","github","facebook","linkedin","x","youtube","email","telegram","cv","link"],Ie={m:6e4,h:36e5,d:864e5,w:6048e5},Te={m:"minute",h:"hour",d:"day",w:"week"},be=/^(\d{1,4})\s*([mhdw])$/i,_e=/^[a-z0-9-]{1,32}$/;function J(e){let n=be.exec(String(e??"").trim());return!n||Number(n[1])===0?J("7d"):Number(n[1])*Ie[n[2].toLowerCase()]}function Z(e){let n=be.exec(String(e??"").trim());if(!n||Number(n[1])===0)return Z("7d");let o=Number(n[1]),r=Te[n[2].toLowerCase()];return`${o} ${r}${o===1?"":"s"}`}function ve(e,n){try{let o=Number(e?.getItem(ge));return Number.isFinite(o)&&o>n}catch{return!1}}function xe(e,n,o){try{e?.setItem(ge,String(n+o))}catch{}}function K(e,n){if(typeof e!="string")return null;try{let o=new URL(e);return n.includes(o.protocol)?o.href:null}catch{return null}}function q(e,n){return typeof e=="string"?e.trim().slice(0,n):""}function we(e,n){if(!e||typeof e!="object"||e.schemaVersion!==1)return null;let o=q(e.name,60);if(!o)return null;let r=[],d=new Set;for(let i of Array.isArray(e.links)?e.links.slice(0,12):[]){let m=typeof i?.id=="string"&&_e.test(i.id)?i.id:null,g=q(i?.label,40),w=K(i?.url,["https:","http:","mailto:"]);!m||!g||!w||d.has(m)||(d.add(m),r.push({id:m,label:g,url:w,icon:He.includes(i.icon)?i.icon:"link"}))}if(r.length===0)return null;let h=null;if(typeof e.events=="string")try{h=K(new URL(e.events,n).href,["https:","http:"])}catch{h=null}return{name:o,tagline:q(e.tagline,120),avatar:K(e.avatar,["https:"]),links:r,events:h}}var Ce=/^(rgba?|oklch|oklab|lab|lch|color)\((.*)\)$/i;function C(e,n){return e==="none"?0:e?.endsWith("%")?parseFloat(e)/100*n:parseFloat(e??"")}function me(e){let n=Ce.exec(String(e??"").trim());if(!n)return null;let o=n[1].toLowerCase(),r=n[2].split(/[\s,/]+/).filter(Boolean),d;if(o==="color"){let i=r.shift()?.toLowerCase();if(i!=="srgb"&&i!=="srgb-linear"&&i!=="display-p3")return null;let m=a=>i!=="srgb-linear"?a:a<=.0031308?12.92*a:1.055*a**(1/2.4)-.055,[g,w,s]=r.slice(0,3).map(a=>m(C(a,1)));d=.299*g+.587*w+.114*s}else if(o.startsWith("rgb")){let[i,m,g]=r.map(w=>C(w,255));d=(.299*i+.587*m+.114*g)/255}else d=C(r[0],1)/(o.startsWith("ok")||r[0]?.endsWith("%")?1:100);let h=r.length>3?C(r[3],1):1;return!Number.isFinite(d)||!(h>=.5)?null:Math.min(Math.max(d,0),1)}function ye({backgrounds:e,markers:n,text:o,prefersDark:r}){for(let h of e){let i=me(h);if(i!==null)return i<.5?"dark":"light"}for(let h of n){let i=h?.trim().toLowerCase();if(i==="dark"||i==="light")return i}let d=me(o);return d!==null&&d>.6?"dark":d!==null&&d<.4?"light":r?"dark":"light"}var u=52,f=16,k=8,ee=280,De=160,ze=2,Ne=f*2+u+k+ee,Re=6,$e=72,Oe=["data-theme","data-bs-theme","data-mode","data-color-mode","data-color-scheme"],ke={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"/>',github:'<path d="M8 8l-4 4 4 4M16 8l4 4-4 4"/>',facebook:'<circle cx="9" cy="8" r="3"/><path d="M3 20c0-3 3-5 6-5s6 2 6 5"/><circle cx="17" cy="9" r="2.5"/><path d="M15 15c3 0 6 1.5 6 4.5"/>',linkedin:'<rect x="3" y="7" width="18" height="13" rx="2"/><path d="M9 7V5h6v2"/>',x:'<path d="M4 5h16v11H9l-5 4z"/>',youtube:'<rect x="3" y="6" width="18" height="12" rx="3"/><path d="M10 9l5 3-5 3z"/>',email:'<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/>',telegram:'<path d="M21 4L3 11l6 2 2 6 3-4 5 4z"/><path d="M9 13l12-9"/>',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"/>'},Ue=`
1
+ (()=>{var be="aboutme:hiddenUntil";var Te=["home","blog","github","facebook","linkedin","x","youtube","email","telegram","cv","link"],_e=["list","grid","icons"],Ie={m:6e4,h:36e5,d:864e5,w:6048e5},ze={m:"minute",h:"hour",d:"day",w:"week"},xe=/^(\d{1,4})\s*([mhdw])$/i,De=/^[a-z0-9-]{1,32}$/;function J(e){let n=xe.exec(String(e??"").trim());return!n||Number(n[1])===0?J("7d"):Number(n[1])*Ie[n[2].toLowerCase()]}function Q(e){let n=xe.exec(String(e??"").trim());if(!n||Number(n[1])===0)return Q("7d");let o=Number(n[1]),r=ze[n[2].toLowerCase()];return`${o} ${r}${o===1?"":"s"}`}function ve(e){return _e.includes(e)?e:"list"}function we(e,n){try{let o=Number(e?.getItem(be));return Number.isFinite(o)&&o>n}catch{return!1}}function ye(e,n,o){try{e?.setItem(be,String(n+o))}catch{}}function Z(e,n){if(typeof e!="string")return null;try{let o=new URL(e);return n.includes(o.protocol)?o.href:null}catch{return null}}function q(e,n){return typeof e=="string"?e.trim().slice(0,n):""}function ke(e,n){if(!e||typeof e!="object"||e.schemaVersion!==1)return null;let o=q(e.name,60);if(!o)return null;let r=[],l=new Set;for(let a of Array.isArray(e.links)?e.links.slice(0,12):[]){let p=typeof a?.id=="string"&&De.test(a.id)?a.id:null,x=q(a?.label,40),f=Z(a?.url,["https:","http:","mailto:"]);!p||!x||!f||l.has(p)||(l.add(p),r.push({id:p,label:x,url:f,icon:Te.includes(a.icon)?a.icon:"link"}))}if(r.length===0)return null;let g=null;if(typeof e.events=="string")try{g=Z(new URL(e.events,n).href,["https:","http:"])}catch{g=null}return{name:o,tagline:q(e.tagline,120),avatar:Z(e.avatar,["https:"]),links:r,events:g}}var Ne=/^(rgba?|oklch|oklab|lab|lch|color)\((.*)\)$/i;function z(e,n){return e==="none"?0:e?.endsWith("%")?parseFloat(e)/100*n:parseFloat(e??"")}function ge(e){let n=Ne.exec(String(e??"").trim());if(!n)return null;let o=n[1].toLowerCase(),r=n[2].split(/[\s,/]+/).filter(Boolean),l;if(o==="color"){let a=r.shift()?.toLowerCase();if(a!=="srgb"&&a!=="srgb-linear"&&a!=="display-p3")return null;let p=i=>a!=="srgb-linear"?i:i<=.0031308?12.92*i:1.055*i**(1/2.4)-.055,[x,f,S]=r.slice(0,3).map(i=>p(z(i,1)));l=.299*x+.587*f+.114*S}else if(o.startsWith("rgb")){let[a,p,x]=r.map(f=>z(f,255));l=(.299*a+.587*p+.114*x)/255}else l=z(r[0],1)/(o.startsWith("ok")||r[0]?.endsWith("%")?1:100);let g=r.length>3?z(r[3],1):1;return!Number.isFinite(l)||!(g>=.5)?null:Math.min(Math.max(l,0),1)}function Le({backgrounds:e,markers:n,text:o,prefersDark:r}){for(let g of e){let a=ge(g);if(a!==null)return a<.5?"dark":"light"}for(let g of n){let a=g?.trim().toLowerCase();if(a==="dark"||a==="light")return a}let l=ge(o);return l!==null&&l>.6?"dark":l!==null&&l<.4?"light":r?"dark":"light"}var u=52,m=16,k=8,te=280,Re=160,$e=2,Oe=m*2+u+k+te,Ue=6,Fe=72,Be=["data-theme","data-bs-theme","data-mode","data-color-mode","data-color-scheme"],Ee={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"/>'},Pe={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"},Ye=`
2
2
  :host { all: initial; }
3
3
  * { box-sizing: border-box; }
4
4
  .root {
@@ -12,6 +12,7 @@
12
12
  color-scheme: dark;
13
13
  }
14
14
  svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
15
+ svg.fill { fill: currentColor; stroke: none; padding: 1px; }
15
16
  .bubble {
16
17
  position: fixed; left: 0; top: 0; width: ${u}px; height: ${u}px; z-index: 2147483001;
17
18
  border: 0; border-radius: 50%; padding: 0; cursor: grab; touch-action: none; user-select: none;
@@ -24,7 +25,7 @@ svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width:
24
25
  a:focus-visible { outline-offset: -3px; }
25
26
  .bubble.dragging { cursor: grabbing; transition: none; }
26
27
  .panel {
27
- position: fixed; z-index: 2147483000; width: ${ee}px; display: flex; flex-direction: column;
28
+ position: fixed; z-index: 2147483000; width: ${te}px; display: flex; flex-direction: column;
28
29
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
29
30
  box-shadow: 0 8px 30px rgb(0 0 0 / 20%); animation: open .12s ease-out;
30
31
  overflow-y: auto; overscroll-behavior: contain;
@@ -44,6 +45,12 @@ ul { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y
44
45
  a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; color: var(--fg); text-decoration: none; }
45
46
  a:hover { background: var(--hover); }
46
47
  a span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
48
+ /* Grid and icons layouts: tiles with the icon above a caption, at most 4 columns. */
49
+ .root[data-l] ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 4px; align-content: start; }
50
+ .root[data-l] a { position: relative; flex-direction: column; justify-content: center; gap: 4px; min-height: 56px; padding: 8px 2px; }
51
+ .root[data-l] a svg { width: 24px; height: 24px; }
52
+ .root[data-l] a span { flex: none; width: 100%; font-size: 11px; line-height: 1.2; text-align: center; }
53
+ .root[data-l="icons"] a span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
47
54
  .hide { flex: none; width: 100%; margin-top: 8px; padding: 6px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
48
55
  .hide:hover { color: var(--fg); }
49
56
  .target {
@@ -55,4 +62,4 @@ a span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-over
55
62
  .target.active { transform: scale(1.25); background: var(--danger); }
56
63
  @media (prefers-reduced-motion: reduce) { .bubble, .target { transition: none; } .panel { animation: none; } }
57
64
  @media print { .root { display: none; } }
58
- `;function S(e){let n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("aria-hidden","true"),n.innerHTML=ke[e]??ke.link,n}function p(e,n,o){let r=document.createElement(e);return n&&(r.className=n),o&&(r.textContent=o),r}function M(){let e=document.compatMode==="BackCompat"?document.body:document.documentElement,n={w:e.clientWidth,h:e.clientHeight},o=window.visualViewport;return o&&o.scale<1&&(n.w=Math.max(n.w,o.width),n.h=Math.max(n.h,o.height)),n}function Q(e,n,o){return Math.max(Math.min(e,o),n)}function Fe(e){let n=[document.documentElement,document.body],o=[];for(let r of n)o.push(...["dark","light"].filter(d=>r.classList.contains(d))),o.push(...Oe.map(d=>r.getAttribute(d)));return ye({backgrounds:[n[1],n[0]].map(r=>getComputedStyle(r).backgroundColor),markers:o,text:getComputedStyle(n[1]).color,prefersDark:e.matches})}function Ee({profile:e,position:n,theme:o,hide:r,track:d,onDismiss:h}){let i=document.createElement("aboutme-widget"),m=i.attachShadow({mode:"open"}),g=p("div","root"),w=p("style");w.textContent=Ue;let s=p("button","bubble");if(s.type="button",s.setAttribute("aria-label",`About ${e.name}`),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-controls","aboutme-panel"),s.title="Drag to the bottom to hide",e.avatar){let t=p("img");t.alt="",t.src=e.avatar,t.addEventListener("error",()=>t.replaceWith(S("person")),{once:!0}),s.append(t)}else s.append(S("person"));let a=p("div","panel");a.id="aboutme-panel",a.setAttribute("role","dialog"),a.setAttribute("aria-label",`About ${e.name}`),a.hidden=!0;let D=p("div","head");if(e.avatar){let t=p("img");t.alt="",t.src=e.avatar,D.append(t)}let z=p("div","who");z.append(p("div","name",e.name)),e.tagline&&z.append(p("div","tagline",e.tagline));let A=p("button","icon-btn");A.type="button",A.setAttribute("aria-label","Close"),A.append(S("close")),D.append(z,A);let y=p("ul");for(let t of e.links){let c=p("li"),l=p("a");l.href=t.url,l.target="_blank",l.rel="noopener noreferrer",l.title=t.label,l.append(S(t.icon),p("span","",t.label)),l.addEventListener("click",()=>d("click",t.id)),c.append(l),y.append(c)}let N=p("button","hide",`Hide for ${Z(r)}`);N.type="button",a.append(D,y,N);let x=p("div","target");x.hidden=!0,x.append(S("close")),g.append(w,s,a,x),m.append(g),document.body.append(i);let R=window.matchMedia("(prefers-color-scheme: dark)"),$=0,O=0,H=null,U=null;function I(){g.dataset.t=o==="auto"?Fe(R):o}function F(){cancelAnimationFrame($),$=requestAnimationFrame(I),clearTimeout(O),O=setTimeout(I,400)}let E=0,v=0,T=n,B=!0,P=f*2,te=1,W=M();function ne(){s.style.transform=`translate(${E}px, ${v}px)`}function Y(){let{w:t,h:c}=M(),l=Math.min(P,te*(c-u));E=T==="left"?f:t-u-f,v=Q(B?c-u-l:l,f,c-u-f),W={w:t,h:c},ne()}function Ae(){let{w:t,h:c}=M();T=E+u/2<t/2?"left":"right",B=v+u/2>c/2;let l=Q(v,f,c-u-f);P=B?c-u-l:l,te=c>u?P/(c-u):1,Y()}function oe(){let{w:t,h:c}=M(),l=v-k-f,de=c-v-u-k-f,le=Math.max(l,de),ue=Math.min(ee,t-f*2);a.style.width=`${ue}px`,a.style.maxHeight="none",y.style.minHeight="0px";let pe=y.firstElementChild?.offsetHeight??0,Se=a.offsetHeight-y.offsetHeight,_=le<Math.max(De,Se+Math.min(y.scrollHeight,pe*ze)),he=_&&t>=Ne;a.classList.toggle("over",_&&!he),y.style.minHeight=`${Math.min(y.scrollHeight,pe)}px`,a.style.maxHeight=`${Math.max(_?c-f*2:le,0)}px`;let j=a.offsetHeight,fe=T==="left"?f:t-f-ue,G;_?(he&&(fe+=T==="left"?u+k:-u-k),G=Q(v+u/2-j/2,f,c-f-j)):G=l>=de?v-k-j:v+u+k,a.style.left=`${fe}px`,a.style.top=`${G}px`}function V(){b?.moved||(Y(),a.hidden||oe())}function X(){let{w:t,h:c}=M();(t!==W.w||c!==W.h)&&V()}function L(t){t!==!a.hidden&&(a.hidden=!t,s.setAttribute("aria-expanded",String(t)),t&&(I(),oe(),d("open")))}function ie(){d("dismiss"),i.remove(),window.removeEventListener("resize",V),window.visualViewport?.removeEventListener("resize",X),document.removeEventListener("pointerdown",re,!0),document.removeEventListener("keydown",ae),R.removeEventListener("change",F),H?.disconnect(),U?.disconnect(),cancelAnimationFrame($),clearTimeout(O),h()}function re(t){t.composedPath().includes(i)||L(!1)}function ae(t){t.key==="Escape"&&!a.hidden&&(L(!1),s.focus())}function se(){let t=x.getBoundingClientRect(),c=E+u/2-(t.left+t.width/2),l=v+u/2-(t.top+t.height/2);return Math.hypot(c,l)<$e}let b=null;s.addEventListener("pointerdown",t=>{t.button===0&&(b={id:t.pointerId,startX:t.clientX,startY:t.clientY,dx:t.clientX-E,dy:t.clientY-v,moved:!1},s.setPointerCapture(t.pointerId))}),s.addEventListener("pointermove",t=>{if(!(!b||t.pointerId!==b.id)&&!(!b.moved&&Math.hypot(t.clientX-b.startX,t.clientY-b.startY)<Re)){if(!b.moved){b.moved=!0,s.classList.add("dragging");let{w:c,h:l}=M();x.style.left=`${c/2-32}px`,x.style.top=`${l-96}px`,x.hidden=!1,L(!1)}E=t.clientX-b.dx,v=t.clientY-b.dy,ne(),x.classList.toggle("active",se())}});function ce(t){if(!b||t.pointerId!==b.id)return;let{moved:c}=b;if(b=null,!c){t.type==="pointerup"&&L(a.hidden);return}s.classList.remove("dragging");let l=t.type==="pointerup"&&se();x.hidden=!0,x.classList.remove("active"),l?ie():Ae()}return s.addEventListener("pointerup",ce),s.addEventListener("pointercancel",ce),s.addEventListener("click",t=>{t.detail===0&&L(a.hidden)}),A.addEventListener("click",()=>{L(!1),s.focus()}),N.addEventListener("click",ie),window.addEventListener("resize",V),window.visualViewport?.addEventListener("resize",X),window.ResizeObserver&&(U=new ResizeObserver(X),U.observe(document.compatMode==="BackCompat"?document.body:document.documentElement)),document.addEventListener("pointerdown",re,!0),document.addEventListener("keydown",ae),I(),o==="auto"&&(R.addEventListener("change",F),H=new MutationObserver(F),H.observe(document.documentElement,{attributes:!0}),H.observe(document.body,{attributes:!0})),s.classList.add("dragging"),Y(),s.getBoundingClientRect(),s.classList.remove("dragging"),i}function Le(){try{return window.localStorage}catch{return null}}function Be(e,n,o){if(e)try{fetch(e,{method:"POST",mode:"cors",credentials:"omit",keepalive:!0,headers:{"content-type":"text/plain"},body:JSON.stringify(o?{event:n,target:o}:{event:n})}).catch(()=>{})}catch{}}async function Pe(e){let n=e.dataset.profile,o=e.dataset.hide,r=e.dataset.position==="left"?"left":"right",d=["light","dark"].includes(e.dataset.theme)?e.dataset.theme:"auto";if(!n||ve(Le(),Date.now()))return;let h;try{let m=new URL(n,document.baseURI).href,g=await fetch(m,{credentials:"omit"});if(!g.ok)return;h=we(await g.json(),m)}catch{return}if(!h)return;let i=()=>Ee({profile:h,position:r,theme:d,hide:o??"",track:(m,g)=>Be(h.events,m,g),onDismiss:()=>xe(Le(),Date.now(),J(o))});document.body?i():document.addEventListener("DOMContentLoaded",i,{once:!0})}var Me=document.currentScript;Me instanceof HTMLScriptElement&&!window.__aboutmeLoaded&&(window.__aboutmeLoaded=!0,Pe(Me));})();
65
+ `;function H(e){let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("aria-hidden","true");let o=Pe[e];return o&&n.classList.add("fill"),n.innerHTML=o?`<path d="${o}"/>`:Ee[e]??Ee.link,n}function h(e,n,o){let r=document.createElement(e);return n&&(r.className=n),o&&(r.textContent=o),r}function M(){let e=document.compatMode==="BackCompat"?document.body:document.documentElement,n={w:e.clientWidth,h:e.clientHeight},o=window.visualViewport;return o&&o.scale<1&&(n.w=Math.max(n.w,o.width),n.h=Math.max(n.h,o.height)),n}function ee(e,n,o){return Math.max(Math.min(e,o),n)}function We(e){let n=[document.documentElement,document.body],o=[];for(let r of n)o.push(...["dark","light"].filter(l=>r.classList.contains(l))),o.push(...Be.map(l=>r.getAttribute(l)));return Le({backgrounds:[n[1],n[0]].map(r=>getComputedStyle(r).backgroundColor),markers:o,text:getComputedStyle(n[1]).color,prefersDark:e.matches})}function Me({profile:e,position:n,theme:o,layout:r,hide:l,track:g,onDismiss:a}){let p=document.createElement("aboutme-widget"),x=p.attachShadow({mode:"open"}),f=h("div","root");r!=="list"&&(f.dataset.l=r);let S=h("style");S.textContent=Ye;let i=h("button","bubble");if(i.type="button",i.setAttribute("aria-label",`About ${e.name}`),i.setAttribute("aria-expanded","false"),i.setAttribute("aria-controls","aboutme-panel"),i.title="Drag to the bottom to hide",e.avatar){let t=h("img");t.alt="",t.src=e.avatar,t.addEventListener("error",()=>t.replaceWith(H("person")),{once:!0}),i.append(t)}else i.append(H("person"));let d=h("div","panel");d.id="aboutme-panel",d.setAttribute("role","dialog"),d.setAttribute("aria-label",`About ${e.name}`),d.hidden=!0;let D=h("div","head");if(e.avatar){let t=h("img");t.alt="",t.src=e.avatar,D.append(t)}let N=h("div","who");N.append(h("div","name",e.name)),e.tagline&&N.append(h("div","tagline",e.tagline));let A=h("button","icon-btn");A.type="button",A.setAttribute("aria-label","Close"),A.append(H("close")),D.append(N,A);let y=h("ul");for(let t of e.links){let s=h("li"),c=h("a");c.href=t.url,c.target="_blank",c.rel="noopener noreferrer",c.title=t.label,c.append(H(t.icon),h("span","",t.label)),c.addEventListener("click",()=>g("click",t.id)),s.append(c),y.append(s)}let R=h("button","hide",`Hide for ${Q(l)}`);R.type="button",d.append(D,y,R);let w=h("div","target");w.hidden=!0,w.append(H("close")),f.append(S,i,d,w),x.append(f),document.body.append(p);let $=window.matchMedia("(prefers-color-scheme: dark)"),O=0,U=0,C=null,F=null;function T(){f.dataset.t=o==="auto"?We($):o}function B(){cancelAnimationFrame(O),O=requestAnimationFrame(T),clearTimeout(U),U=setTimeout(T,400)}let L=0,v=0,_=n,P=!0,Y=m*2,ne=1,W=M();function oe(){i.style.transform=`translate(${L}px, ${v}px)`}function V(){let{w:t,h:s}=M(),c=Math.min(Y,ne*(s-u));L=_==="left"?m:t-u-m,v=ee(P?s-u-c:c,m,s-u-m),W={w:t,h:s},oe()}function Se(){let{w:t,h:s}=M();_=L+u/2<t/2?"left":"right",P=v+u/2>s/2;let c=ee(v,m,s-u-m);Y=P?s-u-c:c,ne=s>u?Y/(s-u):1,V()}function ie(){let{w:t,h:s}=M(),c=v-k-m,de=s-v-u-k-m,ue=Math.max(c,de),pe=Math.min(te,t-m*2);d.style.width=`${pe}px`,d.style.maxHeight="none",y.style.minHeight="0px";let he=y.firstElementChild?.offsetHeight??0,Ce=d.offsetHeight-y.offsetHeight,I=ue<Math.max(Re,Ce+Math.min(y.scrollHeight,he*$e)),fe=I&&t>=Oe;d.classList.toggle("over",I&&!fe),y.style.minHeight=`${Math.min(y.scrollHeight,he)}px`,d.style.maxHeight=`${Math.max(I?s-m*2:ue,0)}px`;let X=d.offsetHeight,me=_==="left"?m:t-m-pe,K;I?(fe&&(me+=_==="left"?u+k:-u-k),K=ee(v+u/2-X/2,m,s-m-X)):K=c>=de?v-k-X:v+u+k,d.style.left=`${me}px`,d.style.top=`${K}px`}function j(){b?.moved||(V(),d.hidden||ie())}function G(){let{w:t,h:s}=M();(t!==W.w||s!==W.h)&&j()}function E(t){t!==!d.hidden&&(d.hidden=!t,i.setAttribute("aria-expanded",String(t)),t&&(T(),ie(),g("open")))}function re(){g("dismiss"),p.remove(),window.removeEventListener("resize",j),window.visualViewport?.removeEventListener("resize",G),document.removeEventListener("pointerdown",ae,!0),document.removeEventListener("keydown",se),$.removeEventListener("change",B),C?.disconnect(),F?.disconnect(),cancelAnimationFrame(O),clearTimeout(U),a()}function ae(t){t.composedPath().includes(p)||E(!1)}function se(t){t.key==="Escape"&&!d.hidden&&(E(!1),i.focus())}function ce(){let t=w.getBoundingClientRect(),s=L+u/2-(t.left+t.width/2),c=v+u/2-(t.top+t.height/2);return Math.hypot(s,c)<Fe}let b=null;i.addEventListener("pointerdown",t=>{t.button===0&&(b={id:t.pointerId,startX:t.clientX,startY:t.clientY,dx:t.clientX-L,dy:t.clientY-v,moved:!1},i.setPointerCapture(t.pointerId))}),i.addEventListener("pointermove",t=>{if(!(!b||t.pointerId!==b.id)&&!(!b.moved&&Math.hypot(t.clientX-b.startX,t.clientY-b.startY)<Ue)){if(!b.moved){b.moved=!0,i.classList.add("dragging");let{w:s,h:c}=M();w.style.left=`${s/2-32}px`,w.style.top=`${c-96}px`,w.hidden=!1,E(!1)}L=t.clientX-b.dx,v=t.clientY-b.dy,oe(),w.classList.toggle("active",ce())}});function le(t){if(!b||t.pointerId!==b.id)return;let{moved:s}=b;if(b=null,!s){t.type==="pointerup"&&E(d.hidden);return}i.classList.remove("dragging");let c=t.type==="pointerup"&&ce();w.hidden=!0,w.classList.remove("active"),c?re():Se()}return i.addEventListener("pointerup",le),i.addEventListener("pointercancel",le),i.addEventListener("click",t=>{t.detail===0&&E(d.hidden)}),A.addEventListener("click",()=>{E(!1),i.focus()}),R.addEventListener("click",re),window.addEventListener("resize",j),window.visualViewport?.addEventListener("resize",G),window.ResizeObserver&&(F=new ResizeObserver(G),F.observe(document.compatMode==="BackCompat"?document.body:document.documentElement)),document.addEventListener("pointerdown",ae,!0),document.addEventListener("keydown",se),T(),o==="auto"&&($.addEventListener("change",B),C=new MutationObserver(B),C.observe(document.documentElement,{attributes:!0}),C.observe(document.body,{attributes:!0})),i.classList.add("dragging"),V(),i.getBoundingClientRect(),i.classList.remove("dragging"),p}function Ae(){try{return window.localStorage}catch{return null}}function Ve(e,n,o){if(e)try{fetch(e,{method:"POST",mode:"cors",credentials:"omit",keepalive:!0,headers:{"content-type":"text/plain"},body:JSON.stringify(o?{event:n,target:o}:{event:n})}).catch(()=>{})}catch{}}async function je(e){let n=e.dataset.profile,o=e.dataset.hide,r=e.dataset.position==="left"?"left":"right",l=["light","dark"].includes(e.dataset.theme)?e.dataset.theme:"auto",g=ve(e.dataset.layout);if(!n||we(Ae(),Date.now()))return;let a;try{let x=new URL(n,document.baseURI).href,f=await fetch(x,{credentials:"omit"});if(!f.ok)return;a=ke(await f.json(),x)}catch{return}if(!a)return;let p=()=>Me({profile:a,position:r,theme:l,layout:g,hide:o??"",track:(x,f)=>Ve(a.events,x,f),onDismiss:()=>ye(Ae(),Date.now(),J(o))});document.body?p():document.addEventListener("DOMContentLoaded",p,{once:!0})}var He=document.currentScript;He instanceof HTMLScriptElement&&!window.__aboutmeLoaded&&(window.__aboutmeLoaded=!0,je(He));})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiennm99/aboutme",
3
- "version": "1.2.0",
3
+ "version": "1.3.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",
@@ -31,6 +31,7 @@
31
31
  },
32
32
  "scripts": {
33
33
  "build": "node build.js",
34
+ "size": "node scripts/check-size.js",
34
35
  "test": "vitest run",
35
36
  "test:e2e": "npm run build && playwright test",
36
37
  "prepublishOnly": "npm run build && npm test"