diff --git a/api/components/tooltip.mjs b/api/components/tooltip.mjs index 11cc418..f78cdc7 100644 --- a/api/components/tooltip.mjs +++ b/api/components/tooltip.mjs @@ -53,7 +53,7 @@ const countLines = ($el) => if (offsetDirection === 'right') x += rect.width + pad; _$tooltip.style.left = `${x}px`; _$tooltip.style.top = `${y}px`; - _$tooltip.style.textAlign = 'auto'; + _$tooltip.style.textAlign = 'start'; } return true; diff --git a/api/index.cjs b/api/index.cjs index de549b0..aaea141 100644 --- a/api/index.cjs +++ b/api/index.cjs @@ -3,7 +3,7 @@ var ce=Object.defineProperty;var Ge=e=>ce(e,"__esModule",{value:!0});var g=(e,t) ${JSON.stringify(e.tags)}`),!1):e.tags.map(i=>l(e,"tags.tag",i,"string"))},Pt=async e=>await l(e,"authors",e.authors,"array")?e.authors.map(n=>[l(e,"authors.author.name",n.name,"string"),l(e,"authors.author.email",n.email,"email",{optional:!0}),l(e,"authors.author.homepage",n.homepage,"url"),l(e,"authors.author.avatar",n.avatar,"url")]):!1,Ot=async e=>{if(!await l(e,"css",e.css,"object"))return!1;let n=[];for(let r of["frame","client","menu"]){if(!e.css[r])continue;let s=await l(e,`css.${r}`,e.css[r],"array");s&&(s=e.css[r].map(c=>l(e,`css.${r}.file`,c,"file",{extension:".css"}))),n.push(s)}return n},Rt=async e=>{if(!await l(e,"js",e.js,"object"))return!1;let n=[];for(let r of["frame","client","menu"]){if(!e.js[r])continue;let s=await l(e,`js.${r}`,e.js[r],"array");s&&(s=e.js[r].map(c=>l(e,`js.${r}.file`,c,"file",{extension:".mjs"}))),n.push(s)}if(e.js.electron)if(await l(e,"js.electron",e.js.electron,"array"))for(let s of e.js.electron){if(!await l(e,"js.electron.file",s,"object")){n.push(!1);continue}n.push([l(e,"js.electron.file.source",s.source,"file",{extension:".cjs"}),l(e,"js.electron.file.target",s.target,"string",{extension:".js"})])}else n.push(!1);return n},Nt=async e=>{if(!await l(e,"options",e.options,"array"))return!1;let n=[];for(let r of e.options){let s="options.option";if(!await l(e,`${s}.type`,r.type,y.optionTypes)){n.push(!1);continue}switch(r.environments=r.environments??y.supportedEnvs,n.push([l(e,`${s}.key`,r.key,"alphanumeric"),l(e,`${s}.label`,r.label,"string"),l(e,`${s}.tooltip`,r.tooltip,"string",{optional:!0}),l(e,`${s}.environments`,r.environments,"array").then(a=>a?r.environments.map(i=>l(e,`${s}.environments.env`,i,y.supportedEnvs)):!1)]),r.type){case"toggle":n.push(l(e,`${s}.value`,r.value,"boolean"));break;case"select":{let a=await l(e,`${s}.values`,r.values,"array");a&&(a=r.values.map(i=>l(e,`${s}.values.value`,i,"string"))),n.push(a);break}case"text":case"hotkey":n.push(l(e,`${s}.value`,r.value,"string"));break;case"number":case"color":n.push(l(e,`${s}.value`,r.value,r.type));break;case"file":{let a=await l(e,`${s}.extensions`,r.extensions,"array");a&&(a=r.extensions.map(i=>l(e,`${s}.extensions.extension`,i,"string"))),n.push(a);break}}}return n};async function Ae(e){let t=[l(e,"name",e.name,"string"),l(e,"id",e.id,"uuid"),l(e,"version",e.version,"semver"),kt(e),l(e,"description",e.description,"string"),l(e,"preview",e.preview,"file|url",{optional:!0}),Ct(e),Pt(e),Ot(e),Rt(e),Nt(e)];do t=await Promise.all(t.flat(1/0));while(t.some(n=>Array.isArray(n)));return t.every(n=>n)}"use strict";var je=["a6621988-551d-495a-97d8-3c568bca2e9e","0f0bf8b6-eae6-4273-b307-8fc43f2ee082","36a2ffc9-27ff-480e-84a7-c7700a7d232d"],qt=["linux","win32","darwin","extension"],Mt=["toggle","select","text","number","color","file","hotkey"],Ee=async()=>_.get(["currentprofile"],"default"),X=async()=>_.db(["profiles",await Ee()]),G,Q=[],Y=async(e=t=>!0)=>{G||(G=new Promise(async(n,r)=>{let s=[];for(let c of await u.getJSON("repo/registry.json"))try{let a={...await u.getJSON(`repo/${c}/mod.json`),_dir:c,_err:i=>Q.push({source:c,message:i})};await Ae(a)&&s.push(a)}catch{Q.push({source:c,message:"invalid mod.json"})}n(s)}));let t=[];for(let n of await G)await e(n)&&t.push(n);return t},Jt=async()=>(await Y(),Q),D=async e=>(await Y(t=>t.id===e))[0],zt=async e=>(await D(e)).environments.includes(E.name)?je.includes(e)?!0:(await X()).get(["_mods",e],!1):!1,Le=async(e,t)=>{let n=await D(e),r=n.options.find(s=>s.key===t);if(!!r)switch(r.type){case"toggle":case"text":case"number":case"color":case"hotkey":return r.value;case"select":return r.values[0];case"file":return}},Ut=async e=>{let t=await X();return _.db([e],async(n,r=void 0)=>(typeof n=="string"&&(n=[n]),n.length===2&&(r=await Le(e,n[1])??r),t.get(n,r)),t.set)};var o={};g(o,{addDocumentObserver:()=>Xt,addHotkeyListener:()=>It,copyToClipboard:()=>Ht,empty:()=>Wt,escape:()=>Te,html:()=>Ce,loadStylesheet:()=>Ft,queryParams:()=>Bt,raw:()=>ke,readFromClipboard:()=>Vt,removeDocumentObserver:()=>Gt,removeHotkeyListener:()=>Kt,render:()=>Pe,whenReady:()=>Zt});"use strict";var Se=!1,T=[],ee,J=[],te=[],Zt=(e=[])=>new Promise((t,n)=>{let r=()=>{let s=setInterval(c,100);function c(){!e.every(i=>document.querySelector(i))||(clearInterval(s),t(!0))}c()};document.readyState!=="complete"?document.addEventListener("readystatechange",s=>{document.readyState==="complete"&&r()}):r()}),Bt=()=>new URLSearchParams(window.location.search),Te=e=>e.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""").replace(/\\/g,"\"),ke=(e,...t)=>{let n=e.map(r=>r+(["string","number"].includes(typeof t[0])?t.shift():Te(JSON.stringify(t.shift(),null,2)??""))).join("");return n.includes("r.trim()).filter(r=>r.length).join(" ")},Ce=(e,...t)=>{let n=document.createRange().createContextualFragment(ke(e,...t));return n.children.length===1?n.children[0]:n.children},Pe=(e,...t)=>(t=t.map(n=>n instanceof HTMLCollection?[...n]:n).flat(1/0).filter(n=>n),e.append(...t),e),Wt=e=>{for(;e.firstChild&&e.removeChild(e.firstChild););return e},Ft=e=>{let t=Ce``;return Pe(document.head,t),t},Ht=async e=>{try{await navigator.clipboard.writeText(e)}catch{let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}},Vt=()=>navigator.clipboard.readText(),Oe=(e,t)=>{if(document.activeElement.nodeName==="INPUT"&&!t.listenInInput)return;t.keys.every(s=>{s=s.toLowerCase();let c={metaKey:["meta","os","win","cmd","command"],ctrlKey:["ctrl","control"],shiftKey:["shift"],altKey:["alt"]};for(let a in c)if(c[a].includes(s)&&e[a])return!0;if(s==="space"&&(s=" "),s==="plus"&&(s="+"),s===e.key.toLowerCase())return!0})&&t.callback(e)},It=(e,t,{listenInInput:n=!1,keydown:r=!1}={})=>{typeof e=="string"&&(e=e.split("+")),T.push({keys:e,callback:t,listenInInput:n,keydown:r}),Se||(Se=!0,document.addEventListener("keyup",s=>{for(let c of T.filter(({keydown:a})=>!a))Oe(s,c)}),document.addEventListener("keydown",s=>{for(let c of T.filter(({keydown:a})=>a))Oe(s,c)}))},Kt=e=>{T=T.filter(t=>t.callback!==e)},Xt=(e,t=[])=>{if(!ee){let n=r=>{for(;r.length;){let s=r.shift(),c=(i,d)=>i instanceof Element&&(i.matches(d)||i.matches(`${d} *`)||i.querySelector(d)),a=i=>s.target.matches(i)||s.target.matches(`${i} *`)||[...s.addedNodes].some(d=>c(d,i));for(let i of J)(!i.selectors.length||i.selectors.some(a))&&i.callback(s)}};ee=new MutationObserver((r,s)=>{te.length||requestIdleCallback(()=>n(te)),te.push(...r)}),ee.observe(document.body,{childList:!0,subtree:!0,attributes:!0})}J.push({callback:e,selectors:t})},Gt=e=>{J=J.filter(t=>t.callback!==e)};var N={};g(N,{addCornerAction:()=>Xe,addPanelView:()=>Ie,addTooltip:()=>Ne,feather:()=>qe});"use strict";var Re,p,Qt=e=>[...e.getClientRects()].reduce((t,n)=>t.some(r=>r.y===n.y)?t:[...t,n],[]).length,Yt=async(e,t,n)=>{p.style.top="0px",p.style.left="0px";let r=e.getBoundingClientRect(),{offsetWidth:s,offsetHeight:c}=p,a=6,i=r.x,d=Math.floor(r.y);if(["top","bottom"].includes(t)){t==="top"&&(d-=c+a),t==="bottom"&&(d+=r.height+a),i-=s/2-r.width/2,p.style.left=`${i}px`,p.style.top=`${d}px`;let x=()=>Qt(p.firstElementChild)>n,A=x();for(;x();)p.style.left=`${window.innerWidth-i>i?i++:i--}px`;A&&(i+=window.innerWidth-i>i?a:-a,p.style.left=`${i}px`),p.style.textAlign="center"}return["left","right"].includes(t)&&(d-=c/2-r.height/2,t==="left"&&(i-=s+a),t==="right"&&(i+=r.width+a),p.style.left=`${i}px`,p.style.top=`${d}px`,p.style.textAlign="auto"),!0},Ne=async(e,t,{delay:n=100,offsetDirection:r="bottom",maxLines:s=1}={})=>{Re||(Re=o.loadStylesheet("api/components/tooltip.css"),p=o.html`
`,o.render(document.body,p)),globalThis.markdownit||await import(u.localPath("dep/markdown-it.min.js"));let c=markdownit({linkify:!0});t instanceof Element||(t=o.html`
+ />`;return Pe(document.head,t),t},Ht=async e=>{try{await navigator.clipboard.writeText(e)}catch{let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}},Vt=()=>navigator.clipboard.readText(),Oe=(e,t)=>{if(document.activeElement.nodeName==="INPUT"&&!t.listenInInput)return;t.keys.every(s=>{s=s.toLowerCase();let c={metaKey:["meta","os","win","cmd","command"],ctrlKey:["ctrl","control"],shiftKey:["shift"],altKey:["alt"]};for(let a in c)if(c[a].includes(s)&&e[a])return!0;if(s==="space"&&(s=" "),s==="plus"&&(s="+"),s===e.key.toLowerCase())return!0})&&t.callback(e)},It=(e,t,{listenInInput:n=!1,keydown:r=!1}={})=>{typeof e=="string"&&(e=e.split("+")),T.push({keys:e,callback:t,listenInInput:n,keydown:r}),Se||(Se=!0,document.addEventListener("keyup",s=>{for(let c of T.filter(({keydown:a})=>!a))Oe(s,c)}),document.addEventListener("keydown",s=>{for(let c of T.filter(({keydown:a})=>a))Oe(s,c)}))},Kt=e=>{T=T.filter(t=>t.callback!==e)},Xt=(e,t=[])=>{if(!ee){let n=r=>{for(;r.length;){let s=r.shift(),c=(i,d)=>i instanceof Element&&(i.matches(d)||i.matches(`${d} *`)||i.querySelector(d)),a=i=>s.target.matches(i)||s.target.matches(`${i} *`)||[...s.addedNodes].some(d=>c(d,i));for(let i of J)(!i.selectors.length||i.selectors.some(a))&&i.callback(s)}};ee=new MutationObserver((r,s)=>{te.length||requestIdleCallback(()=>n(te)),te.push(...r)}),ee.observe(document.body,{childList:!0,subtree:!0,attributes:!0})}J.push({callback:e,selectors:t})},Gt=e=>{J=J.filter(t=>t.callback!==e)};var N={};g(N,{addCornerAction:()=>Xe,addPanelView:()=>Ie,addTooltip:()=>Ne,feather:()=>qe});"use strict";var Re,p,Qt=e=>[...e.getClientRects()].reduce((t,n)=>t.some(r=>r.y===n.y)?t:[...t,n],[]).length,Yt=async(e,t,n)=>{p.style.top="0px",p.style.left="0px";let r=e.getBoundingClientRect(),{offsetWidth:s,offsetHeight:c}=p,a=6,i=r.x,d=Math.floor(r.y);if(["top","bottom"].includes(t)){t==="top"&&(d-=c+a),t==="bottom"&&(d+=r.height+a),i-=s/2-r.width/2,p.style.left=`${i}px`,p.style.top=`${d}px`;let x=()=>Qt(p.firstElementChild)>n,A=x();for(;x();)p.style.left=`${window.innerWidth-i>i?i++:i--}px`;A&&(i+=window.innerWidth-i>i?a:-a,p.style.left=`${i}px`),p.style.textAlign="center"}return["left","right"].includes(t)&&(d-=c/2-r.height/2,t==="left"&&(i-=s+a),t==="right"&&(i+=r.width+a),p.style.left=`${i}px`,p.style.top=`${d}px`,p.style.textAlign="start"),!0},Ne=async(e,t,{delay:n=100,offsetDirection:r="bottom",maxLines:s=1}={})=>{Re||(Re=o.loadStylesheet("api/components/tooltip.css"),p=o.html`
`,o.render(document.body,p)),globalThis.markdownit||await import(u.localPath("dep/markdown-it.min.js"));let c=markdownit({linkify:!0});t instanceof Element||(t=o.html`
${t.split(` `).map(i=>c.renderInline(i)).join("
")}
`);let a;e.addEventListener("mouseover",async i=>{a||(a=setTimeout(async()=>{e.matches(":hover")&&p.style.display!=="block"&&(p.style.display="block",o.render(o.empty(p),t),Yt(e,r,s),await p.animate([{opacity:0},{opacity:1}],{duration:65}).finished),a=void 0},n))}),e.addEventListener("mouseout",async i=>{a=void 0,p.style.display==="block"&&!e.matches(":hover")&&(await p.animate([{opacity:1},{opacity:0}],{duration:65}).finished,p.style.display="")})};"use strict";var ne,qe=async(e,t={})=>(ne||(ne=o.html`${await u.getText("dep/feather-sprite.svg")}`),t.style=((t.style?t.style+";":"")+"stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;fill:none;").trim(),t.viewBox="0 0 24 24",``${o.escape(n)}="${o.escape(r)}"`).join(" ")}>${ne.getElementById(e)?.innerHTML}`);"use strict";var k=[],Dt=o.raw`