@tiennm99/aboutme 1.0.1 → 1.1.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 +2 -2
- package/package.json +1 -1
- package/profile.schema.json +1 -1
package/dist/aboutme.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(()=>{var P="aboutme:hiddenUntil";var q=["home","blog","github","facebook","linkedin","x","youtube","email","link"],Q={m:6e4,h:36e5,d:864e5,w:6048e5},ee={m:"minute",h:"hour",d:"day",w:"week"},F=/^(\d{1,4})\s*([mhdw])$/i,te=/^[a-z0-9-]{1,32}$/;function H(t){let n=F.exec(String(t??"").trim());return!n||Number(n[1])===0?H("7d"):Number(n[1])*Q[n[2].toLowerCase()]}function N(t){let n=F.exec(String(t??"").trim());if(!n||Number(n[1])===0)return N("7d");let i=Number(n[1]),a=ee[n[2].toLowerCase()];return`${i} ${a}${i===1?"":"s"}`}function W(t,n){try{let i=Number(t?.getItem(P));return Number.isFinite(i)&&i>n}catch{return!1}}function X(t,n,i){try{t?.setItem(P,String(n+i))}catch{}}function I(t,n){if(typeof t!="string")return null;try{let i=new URL(t);return n.includes(i.protocol)?i.href:null}catch{return null}}function D(t,n){return typeof t=="string"?t.trim().slice(0,n):""}function j(t,n){if(!t||typeof t!="object"||t.schemaVersion!==1)return null;let i=D(t.name,60);if(!i)return null;let a=[],f=new Set;for(let s of Array.isArray(t.links)?t.links.slice(0,12):[]){let p=typeof s?.id=="string"&&te.test(s.id)?s.id:null,y=D(s?.label,40),o=I(s?.url,["https:","http:","mailto:"]);!p||!y||!o||f.has(p)||(f.add(p),a.push({id:p,label:y,url:o,icon:q.includes(s.icon)?s.icon:"link"}))}if(a.length===0)return null;let u=null;if(typeof t.events=="string")try{u=I(new URL(t.events,n).href,["https:","http:"])}catch{u=null}return{name:i,tagline:D(t.tagline,120),avatar:I(t.avatar,["https:"]),links:a,events:u}}var m=52,l=16,ne=6,oe=72,B={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"/>',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"/>'},ie=`
|
|
1
|
+
(()=>{var P="aboutme:hiddenUntil";var q=["home","blog","github","facebook","linkedin","x","youtube","email","telegram","cv","link"],Q={m:6e4,h:36e5,d:864e5,w:6048e5},ee={m:"minute",h:"hour",d:"day",w:"week"},F=/^(\d{1,4})\s*([mhdw])$/i,te=/^[a-z0-9-]{1,32}$/;function H(t){let n=F.exec(String(t??"").trim());return!n||Number(n[1])===0?H("7d"):Number(n[1])*Q[n[2].toLowerCase()]}function N(t){let n=F.exec(String(t??"").trim());if(!n||Number(n[1])===0)return N("7d");let i=Number(n[1]),a=ee[n[2].toLowerCase()];return`${i} ${a}${i===1?"":"s"}`}function W(t,n){try{let i=Number(t?.getItem(P));return Number.isFinite(i)&&i>n}catch{return!1}}function X(t,n,i){try{t?.setItem(P,String(n+i))}catch{}}function I(t,n){if(typeof t!="string")return null;try{let i=new URL(t);return n.includes(i.protocol)?i.href:null}catch{return null}}function D(t,n){return typeof t=="string"?t.trim().slice(0,n):""}function j(t,n){if(!t||typeof t!="object"||t.schemaVersion!==1)return null;let i=D(t.name,60);if(!i)return null;let a=[],f=new Set;for(let s of Array.isArray(t.links)?t.links.slice(0,12):[]){let p=typeof s?.id=="string"&&te.test(s.id)?s.id:null,y=D(s?.label,40),o=I(s?.url,["https:","http:","mailto:"]);!p||!y||!o||f.has(p)||(f.add(p),a.push({id:p,label:y,url:o,icon:q.includes(s.icon)?s.icon:"link"}))}if(a.length===0)return null;let u=null;if(typeof t.events=="string")try{u=I(new URL(t.events,n).href,["https:","http:"])}catch{u=null}return{name:i,tagline:D(t.tagline,120),avatar:I(t.avatar,["https:"]),links:a,events:u}}var m=52,l=16,ne=6,oe=72,B={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"/>'},ie=`
|
|
2
2
|
:host { all: initial; }
|
|
3
3
|
* { box-sizing: border-box; }
|
|
4
4
|
.root {
|
|
@@ -47,4 +47,4 @@ a:hover { background: var(--hover); }
|
|
|
47
47
|
.target[hidden] { display: none; }
|
|
48
48
|
.target.active { transform: scale(1.25); background: var(--danger); }
|
|
49
49
|
@media (prefers-reduced-motion: reduce) { .bubble, .target { transition: none; } }
|
|
50
|
-
`;function k(t){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=B[t]??B.link,n}function r(t,n,i){let a=document.createElement(t);return n&&(a.className=n),i&&(a.textContent=i),a}function G({profile:t,position:n,hide:i,track:a,onDismiss:f}){let u=document.createElement("aboutme-widget"),s=u.attachShadow({mode:"open"}),p=r("div","root"),y=r("style");y.textContent=ie;let o=r("button","bubble");if(o.type="button",o.setAttribute("aria-label",`About ${t.name}`),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls","aboutme-panel"),o.title="Drag to the bottom to hide",t.avatar){let e=r("img");e.alt="",e.src=t.avatar,e.addEventListener("error",()=>e.replaceWith(k("person")),{once:!0}),o.append(e)}else o.append(k("person"));let d=r("div","panel");d.id="aboutme-panel",d.setAttribute("role","dialog"),d.setAttribute("aria-label",`About ${t.name}`),d.hidden=!0;let A=r("div","head");if(t.avatar){let e=r("img");e.alt="",e.src=t.avatar,A.append(e)}let S=r("div","who");S.append(r("div","name",t.name)),t.tagline&&S.append(r("div","tagline",t.tagline));let L=r("button","icon-btn");L.type="button",L.setAttribute("aria-label","Close"),L.append(k("close")),A.append(S,L);let R=r("ul");for(let e of t.links){let b=r("li"),h=r("a");h.href=e.url,h.target="_blank",h.rel="noopener noreferrer",h.append(k(e.icon),r("span","",e.label)),h.addEventListener("click",()=>a("click",e.id)),b.append(h),R.append(b)}let _=r("button","hide",`Hide for ${N(i)}`);_.type="button",d.append(A,R,_);let x=r("div","target");x.hidden=!0,x.append(k("close")),p.append(y,d,x,o),s.append(p),document.body.append(u);let v=0,g=0,E=n;function T(){o.style.transform=`translate(${v}px, ${g}px)`}function M(){let e=window.innerHeight-m-l;E=v+m/2<window.innerWidth/2?"left":"right",v=E==="left"?l:window.innerWidth-m-l,g=Math.min(Math.max(g,l),Math.max(e,l)),T()}function J(){let e=d.offsetWidth,b=d.offsetHeight,h=E==="left"?l:window.innerWidth-e-l,Y=g-b-8,Z=Y>=l?Y:Math.min(g+m+8,window.innerHeight-b-l);d.style.left=`${Math.max(h,l)}px`,d.style.top=`${Math.max(Z,l)}px`}function w(e){e!==!d.hidden&&(d.hidden=!e,o.setAttribute("aria-expanded",String(e)),e&&(J(),a("open")))}function
|
|
50
|
+
`;function k(t){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=B[t]??B.link,n}function r(t,n,i){let a=document.createElement(t);return n&&(a.className=n),i&&(a.textContent=i),a}function G({profile:t,position:n,hide:i,track:a,onDismiss:f}){let u=document.createElement("aboutme-widget"),s=u.attachShadow({mode:"open"}),p=r("div","root"),y=r("style");y.textContent=ie;let o=r("button","bubble");if(o.type="button",o.setAttribute("aria-label",`About ${t.name}`),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls","aboutme-panel"),o.title="Drag to the bottom to hide",t.avatar){let e=r("img");e.alt="",e.src=t.avatar,e.addEventListener("error",()=>e.replaceWith(k("person")),{once:!0}),o.append(e)}else o.append(k("person"));let d=r("div","panel");d.id="aboutme-panel",d.setAttribute("role","dialog"),d.setAttribute("aria-label",`About ${t.name}`),d.hidden=!0;let A=r("div","head");if(t.avatar){let e=r("img");e.alt="",e.src=t.avatar,A.append(e)}let S=r("div","who");S.append(r("div","name",t.name)),t.tagline&&S.append(r("div","tagline",t.tagline));let L=r("button","icon-btn");L.type="button",L.setAttribute("aria-label","Close"),L.append(k("close")),A.append(S,L);let R=r("ul");for(let e of t.links){let b=r("li"),h=r("a");h.href=e.url,h.target="_blank",h.rel="noopener noreferrer",h.append(k(e.icon),r("span","",e.label)),h.addEventListener("click",()=>a("click",e.id)),b.append(h),R.append(b)}let _=r("button","hide",`Hide for ${N(i)}`);_.type="button",d.append(A,R,_);let x=r("div","target");x.hidden=!0,x.append(k("close")),p.append(y,d,x,o),s.append(p),document.body.append(u);let v=0,g=0,E=n;function T(){o.style.transform=`translate(${v}px, ${g}px)`}function M(){let e=window.innerHeight-m-l;E=v+m/2<window.innerWidth/2?"left":"right",v=E==="left"?l:window.innerWidth-m-l,g=Math.min(Math.max(g,l),Math.max(e,l)),T()}function J(){let e=d.offsetWidth,b=d.offsetHeight,h=E==="left"?l:window.innerWidth-e-l,Y=g-b-8,Z=Y>=l?Y:Math.min(g+m+8,window.innerHeight-b-l);d.style.left=`${Math.max(h,l)}px`,d.style.top=`${Math.max(Z,l)}px`}function w(e){e!==!d.hidden&&(d.hidden=!e,o.setAttribute("aria-expanded",String(e)),e&&(J(),a("open")))}function z(){a("dismiss"),u.remove(),window.removeEventListener("resize",M),document.removeEventListener("pointerdown",U,!0),document.removeEventListener("keydown",$),f()}function U(e){e.composedPath().includes(u)||w(!1)}function $(e){e.key==="Escape"&&!d.hidden&&(w(!1),o.focus())}function C(){let e=x.getBoundingClientRect(),b=v+m/2-(e.left+e.width/2),h=g+m/2-(e.top+e.height/2);return Math.hypot(b,h)<oe}let c=null;o.addEventListener("pointerdown",e=>{e.button===0&&(c={id:e.pointerId,startX:e.clientX,startY:e.clientY,dx:e.clientX-v,dy:e.clientY-g,moved:!1},o.setPointerCapture(e.pointerId))}),o.addEventListener("pointermove",e=>{!c||e.pointerId!==c.id||!c.moved&&Math.hypot(e.clientX-c.startX,e.clientY-c.startY)<ne||(c.moved||(c.moved=!0,o.classList.add("dragging"),x.hidden=!1,w(!1)),v=e.clientX-c.dx,g=e.clientY-c.dy,T(),x.classList.toggle("active",C()))});function O(e){if(!c||e.pointerId!==c.id)return;let{moved:b}=c;if(c=null,!b){e.type==="pointerup"&&w(d.hidden);return}o.classList.remove("dragging");let h=e.type==="pointerup"&&C();x.hidden=!0,x.classList.remove("active"),h?z():M()}return o.addEventListener("pointerup",O),o.addEventListener("pointercancel",O),o.addEventListener("click",e=>{e.detail===0&&w(d.hidden)}),L.addEventListener("click",()=>{w(!1),o.focus()}),_.addEventListener("click",z),window.addEventListener("resize",M),document.addEventListener("pointerdown",U,!0),document.addEventListener("keydown",$),o.classList.add("dragging"),v=E==="left"?0:window.innerWidth,g=window.innerHeight-m-l*2,M(),o.getBoundingClientRect(),o.classList.remove("dragging"),u}function V(){try{return window.localStorage}catch{return null}}function re(t,n,i){if(t)try{fetch(t,{method:"POST",mode:"cors",credentials:"omit",keepalive:!0,headers:{"content-type":"text/plain"},body:JSON.stringify(i?{event:n,target:i}:{event:n})}).catch(()=>{})}catch{}}async function ae(t){let n=t.dataset.profile,i=t.dataset.hide,a=t.dataset.position==="left"?"left":"right";if(!n||W(V(),Date.now()))return;let f;try{let s=new URL(n,document.baseURI).href,p=await fetch(s,{credentials:"omit"});if(!p.ok)return;f=j(await p.json(),s)}catch{return}if(!f)return;let u=()=>G({profile:f,position:a,hide:i??"",track:(s,p)=>re(f.events,s,p),onDismiss:()=>X(V(),Date.now(),H(i))});document.body?u():document.addEventListener("DOMContentLoaded",u,{once:!0})}var K=document.currentScript;K instanceof HTMLScriptElement&&!window.__aboutmeLoaded&&(window.__aboutmeLoaded=!0,ae(K));})();
|
package/package.json
CHANGED
package/profile.schema.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"label": { "type": "string", "minLength": 1, "maxLength": 40 },
|
|
27
27
|
"url": { "type": "string", "pattern": "^(https?:|mailto:)" },
|
|
28
28
|
"icon": {
|
|
29
|
-
"enum": ["home", "blog", "github", "facebook", "linkedin", "x", "youtube", "email", "link"]
|
|
29
|
+
"enum": ["home", "blog", "github", "facebook", "linkedin", "x", "youtube", "email", "telegram", "cv", "link"]
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|