11 lines
276 KiB
JavaScript
11 lines
276 KiB
JavaScript
|
var marketplace=(()=>{var T,_=Object.create,j=Object.defineProperty,M=Object.defineProperties,D=Object.getOwnPropertyDescriptor,$=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertyNames,B=Object.getOwnPropertySymbols,U=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,K=(e,t,r)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,l=(e,t)=>{for(var r in t=t||{})G.call(t,r)&&K(e,r,t[r]);if(B)for(var r of B(t))z.call(t,r)&&K(e,r,t[r]);return e},J=(e,t)=>M(e,$(t)),e=(e,t)=>function(){return t||(0,e[F(e)[0]])((t={exports:{}}).exports,t),t.exports},W=(t,r,n,a)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let e of F(r))G.call(t,e)||e===n||j(t,e,{get:()=>r[e],enumerable:!(a=D(r,e))||a.enumerable});return t},t=(e,t,r)=>(r=null!=e?_(U(e)):{},W(!t&&e&&e.__esModule?r:j(r,"default",{value:e,enumerable:!0}),e)),b=e({"external-global-plugin:react"(e,t){t.exports=Spicetify.React}}),X=e({"node_modules/void-elements/index.js"(e,t){t.exports={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}}}),Y=e({"node_modules/semver/internal/constants.js"(e,t){var r=Number.MAX_SAFE_INTEGER||9007199254740991;t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_INTEGER:r,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}}),Q=e({"node_modules/semver/internal/debug.js"(e,t){var r="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};t.exports=r}}),Z=e({"node_modules/semver/internal/re.js"(e,t){var r=Y()["MAX_SAFE_COMPONENT_LENGTH"],a=Q(),o=(e=t.exports={}).re=[],i=e.src=[],s=e.t={},l=0,t=(e,t,r)=>{var n=l++;a(e,n,t),s[e]=n,i[n]=t,o[n]=new RegExp(t,r?"g":void 0)};t("NUMERICIDENTIFIER","0|[1-9]\\d*"),t("NUMERICIDENTIFIERLOOSE","[0-9]+"),t("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),t("MAINVERSION",`(${i[s.NUMERICIDENTIFIER]})\\.(${i[s.NUMERICIDENTIFIER]})\\.(${i[s.NUMERICIDENTIFIER]})`),t("MAINVERSIONLOOSE",`(${i[s.NUMERICIDENTIFIERLOOSE]})\\.(${i[s.NUMERICIDENTIFIERLOOSE]})\\.(${i[s.NUMERICIDENTIFIERLOOSE]})`),t("PRERELEASEIDENTIFIER",`(?:${i[s.NUMERICIDENTIFIER]}|${i[s.NONNUMERICIDENTIFIER]})`),t("PRERELEASEIDENTIFIERLOOSE",`(?:${i[s.NUMERICIDENTIFIERLOOSE]}|${i[s.NONNUMERICIDENTIFIER]})`),t("PRERELEASE",`(?:-(${i[s.PRERELEASEIDENTIFIER]}(?:\\.${i[s.PRERELEASEIDENTIFIER]})*))`),t("PRERELEASELOOSE",`(?:-?(${i[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${i[s.PRERELEASEIDENTIFIERLOOSE]})*))`),t("BUILDIDENTIFIER","[0-9A-Za-z-]+"),t("BUILD",`(?:\\+(${i[s.BUILDIDENTIFIER]}(?:\\.${i[s.BUILDIDENTIFIER]})*))`),t("FULLPLAIN",`v?${i[s.MAINVERSION]}${i[s.PRERELEASE]}?${i[s.BUILD]}?`),t("FULL",`^${i[s.FULLPLAIN]}$`),t("LOOSEPLAIN",`[v=\\s]*${i[s.MAINVERSIONLOOSE]}${i[s.PRERELEASELOOSE]}?${i[s.BUILD]}?`),t("LOOSE",`^${i[s.LOOSEPLAIN]}$`),t("GTLT","((?:<|>)?=?)"),t("XRANGEIDENTIFIERLOOSE",i[s.NUMERICIDENTIFIERLOOSE]+"|x|X|\\*"),t("XRANGEIDENTIFIER",i[s.NUMERICIDENTIFIER]+"|x|X|\\*"),t("XRANGEPLAIN",`[v=\\s]*(${i[s.XRANGEIDENTIFIER]})(?:\\.(${i[s.XRANGEIDENTIFIER]})(?:\\.(${i[s.XRANGEIDENTIFIER]})(?:${i[s.PRERELEASE]})?${i[s.BUILD]}?)?)?`),t("XRANGEPLAINLOOSE",`[v=\\s]*(${i[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${i[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${i[s.XRANGEIDENTIFIERLOOSE]})(?:${i[s.PRERELEASELOOSE]})?${i[s.BUILD]}?)?)?`),t("XRANGE",`^${i[s.GTLT]}\\s*${i[s.XRANGEPLAIN]}$`),t("XRANGELOOSE",`^${i[s.GTLT]}\\s*${i[s.XRANGEPLAINLOOSE]}$`),t("COERCE",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?(?:$|[^\\d])`),t("COERCERTL",i[s.COERCE],!0),t("LONETILDE","(?:~>?)"),t("TILDETRIM",`(\\s*)${i[s.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",t("TILDE",`^${i[s.LONETILDE]}${i[s.XRANGEPLAIN]}$`),t("TILDELOOSE",`^${i[s.LONETILDE]}${i[s.XRANGEPLAINLOOSE]}$`),t("LONECARET","(?:\\^)"),t("CARETTRIM",`(\\s*)${i[s.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",t("CARET",`^${i[s.LONECARET]}${i[s.XRANGEPLAIN]}$`),t("CARETLOOSE",`
|
||
|
`)+t.code+`
|
||
|
`,"");t.innerHTML=e,t.classList.add("marketplaceSnippets"),document.body.appendChild(t)},vn=(e,t)=>{let r=[];return e&&0<e.length?r=e.map(e=>({name:e.name,url:Cn(e.url)})):r.push({name:t,url:"https://github.com/"+t}),r},bn=e=>e?Object.keys(e).map(e=>({key:e,value:e})):[],yn=(...e)=>{console.debug("Resetting Marketplace");const t=[];0===e.length&&Object.keys(localStorage).forEach(e=>{e.startsWith("marketplace:")&&t.push(e)}),e.forEach(e=>{"extensions"===e?(t.push(...E(v.installedExtensions,[])),t.push(v.installedExtensions)):"snippets"===e?(t.push(...E(v.installedSnippets,[])),t.push(v.installedSnippets)):"theme"===e&&(t.push(...E(v.installedThemes,[])),t.push(v.installedThemes),t.push(v.themeInstalled))}),t.forEach(e=>{localStorage.removeItem(e),console.debug("Removed "+e)}),console.debug("Marketplace has been reset"),location.reload()},En=r=>{var e=document.querySelector("style.marketplaceCSS.marketplaceScheme");if(e&&e.remove(),r){e=document.createElement("style");e.classList.add("marketplaceCSS"),e.classList.add("marketplaceScheme");let t=":root {";Object.keys(r).forEach(e=>{t=(t+=`--spice-${e}: #${r[e]};`)+`--spice-rgb-${e}: ${(e=>{if(3===e.length)e=e.split("").map(e=>e+e).join("");else{if(6!=e.length)throw"Only 3- or 6-digit hex colours are allowed.";if(e.match(/[^0-9a-f]/i))throw"Only hex colours are allowed."}e=e.match(/.{1,2}/g);if(e&&3===e.length)return[parseInt(e[0],16),parseInt(e[1],16),parseInt(e[2],16)];throw"Could not parse hex colour."})(r[e])};`}),t+="}",e.innerHTML=t,document.body.appendChild(e)}},wn=e=>{try{var t,r,n=document.querySelector("link[href='user.css']"),a=(n&&n.remove(),document.querySelector("style.marketplaceCSS.marketplaceUserCSS"));a&&a.remove(),e?((t=document.createElement("style")).classList.add("marketplaceCSS"),t.classList.add("marketplaceUserCSS"),t.innerHTML=e,document.body.appendChild(t)):((r=document.createElement("link")).setAttribute("rel","stylesheet"),r.setAttribute("href","user.css"),r.classList.add("userCSS"),document.body.appendChild(r))}catch(e){console.warn(e)}},Sn=async e=>{if(!e.cssURL)throw new Error("No CSS URL provided");var e=(e=>{const t=new URL(e);return t.host,t.host==="raw.githubusercontent.com"})(e.cssURL)?`https://cdn.jsdelivr.net/gh/${e.user}/${e.repo}@${e.branch}/`+e.manifest.usercss:e.cssURL,t=e.replace("/user.css","/assets/");console.debug("Parsing CSS: ",e);let r=await fetch(e+"?time="+Date.now()).then(e=>e.text());for(const o of r.matchAll(new RegExp(`url\\(['|"](?<path>.+?)['|"]\\)`,"gm"))||[]){var n,a=null==(a=null==o?void 0:o.groups)?void 0:a.path;!a||a.startsWith("http")||a.startsWith("data")||(n=t+a.replace(/\.\//g,""),r=r.replace(a,n))}return r};async function kn(e,t,r){try{var n={text:e,context:t+"/"+r,mode:"gfm"},a=await fetch("https://api.github.com/markdown",{method:"POST",body:JSON.stringify(n)});if(a.ok)return await a.text();throw Spicetify.showNotification(`Error parsing markdown (HTTP ${a.status})`,!0)}catch(e){return null}}function On(e){var t,r="snippet"===e.type?"snippet:":`${e.item.user}/${e.item.repo}/`;let n;switch(e.type){case"snippet":n=e.item.title.replaceAll(" ","-");break;case"theme":n=(null==(t=e.item.manifest)?void 0:t.usercss)||"";break;case"extension":n=(null==(t=e.item.manifest)?void 0:t.main)||"";break;case"app":n=(null==(t=null==(t=e.item.manifest)?void 0:t.name)?void 0:t.replaceAll(" ","-"))||""}return"marketplace:installed:"+r+n}var Cn=e=>{var t=decodeURI(e).trim().toLowerCase();return t.startsWith("javascript:")||t.startsWith("data:")||t.startsWith("vbscript:")?"about:blank":e},Nn=t(b()),w=t(b()),xn=t(Ue()),In=t(Ge()),Ln=(Be=Prism,r=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/,Be.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+r.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},u
|
||
|
`;for(const n in e[r])Object.prototype.hasOwnProperty.call(e[r],n)&&(t+=`${n}=${e[r][n]}
|
||
|
`)}else t+=`${r}=${e[r]}
|
||
|
`;return t})(ra.schemes):g("devTools.noThemeInstalled"));return C.default.createElement("div",{id:"marketplace-theme-dev-tools-container",className:"marketplace-theme-dev-tools-container"},C.default.createElement("div",{className:"devtools-column"},C.default.createElement("label",{htmlFor:"color-ini-editor"},C.default.createElement("h2",{className:"devtools-heading"},g("devTools.colorIniEditor"))),C.default.createElement("div",{className:"marketplace-code-editor-wrapper marketplace-code-editor"},C.default.createElement(Zn.default,{value:r,onValueChange:e=>t(e),highlight:e=>(0,ea.highlight)(e,ea.languages.ini),textareaId:"color-ini-editor",textareaClassName:"color-ini-editor",readOnly:!ra,placeholder:g("devTools.colorIniEditorPlaceholder"),style:{fontFamily:"monospace",resize:"none"}})),C.default.createElement(S,{onClick:()=>{var e=r;{var t;ta?(t=mn(e),ra.schemes=t,localStorage.setItem(ta,JSON.stringify(ra))):Spicetify.showNotification(g("devTools.noThemeManifest"),!0)}}},g("save"))),C.default.createElement("div",{className:"devtools-column"},C.default.createElement("h2",{className:"devtools-heading"},g("devTools.invalidCSS")),C.default.createElement("div",{className:"marketplace-code-editor-wrapper marketplace-code-editor"},function(){var e=null==(e=document.querySelector("body > style.marketplaceCSS.marketplaceUserCSS"))?void 0:e.innerHTML,t=new RegExp(".-?[_a-zA-Z]+[_a-zA-Z0-9-]*\\s*{","g");if(!e)return["Error: Class name list not found; please create an issue"];var r=[];for(const o of e.matchAll(t)){var n=o[0].replace(/{/g,"").trim(),a=n.split(" ");let t;for(let e=0;e<a.length;e++){try{t=document.querySelector(""+a[e])}catch(e){t=document.getElementsByClassName(""+n)}t||r.push(n)}}return r}().map((e,t)=>C.default.createElement("div",{key:t,className:"invalid-css-text"},e)))))},N=t(b()),aa=t(Ue()),oa=t(Ge()),ia=(Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,()=>{const[e,t]=N.default.useState("");const r=t=>{if(t){let e;try{e=JSON.parse(t)}catch(e){return void Spicetify.showNotification(g("backupModal.invalidJSON"))}var r;r=e,console.debug("Importing Marketplace"),yn(),Object.keys(r).forEach(e=>{localStorage.setItem(e,r[e]),console.debug("Imported "+e)}),location.reload()}else Spicetify.showNotification(g("backupModal.noDataPasted"))};return N.default.createElement("div",{id:"marketplace-backup-container"},N.default.createElement("div",{className:"marketplace-backup-input-container"},N.default.createElement("label",{htmlFor:"marketplace-backup"},g("backupModal.inputLabel")),N.default.createElement("div",{className:"marketplace-code-editor-wrapper marketplace-code-editor"},N.default.createElement(aa.default,{value:e,onValueChange:e=>t(e),highlight:e=>(0,oa.highlight)(e,oa.languages.css),textareaId:"marketplace-import-text",textareaClassName:"import-textarea",readOnly:!1,className:"marketplace-code-editor-textarea",placeholder:g("backupModal.inputPlaceholder"),style:{}}))),N.default.createElement(N.default.Fragment,null,N.default.createElement(S,{classes:["marketplace-backup-button"],onClick:()=>{var e=(()=>{const t={};return Object.keys(localStorage).forEach(e=>{e.startsWith("marketplace:")&&(t[e]=localStorage.getItem(e))}),t})();Spicetify.Platform.ClipboardAPI.copy(JSON.stringify(e)),Spicetify.showNotification(g("backupModal.settingsCopied")),Spicetify.PopupModal.hide()}},g("backupModal.exportBtn")),N.default.createElement(S,{classes:["marketplace-backup-button"],onClick:()=>{r(e)}},g("backupModal.importBtn")),N.default.createElement(S,{classes:["marketplace-backup-button"],onClick:async()=>{var e=await(await(await window.showOpenFilePicker())[0].getFile()).text();r(e)}},g("backupModal.fileImportBtn"))))}),sa=(e,t,r,n,a)=>{
|
||
|
#whats-new-content-wrapper ul, #whats-new-content-wrapper ol {
|
||
|
list-style: inherit;
|
||
|
margin-left: 1em;
|
||
|
}
|
||
|
`,Ha.default.render(e,t),t.appendChild(r),t}(e.content)},Spicetify.PopupModal.display(n))}catch(e){Spicetify.LocalStorage.set(t,r)}},qa=async()=>{var e=await fetch(fn).then(e=>e.json()).then(e=>{e=e.message?null:e.body;return e&&kn(e,"spicetify","spicetify-marketplace")}).catch(e=>(console.error(e),null));e&&Va("marketplace",un,{title:"✨ Marketplace v0.8.6",content:Ua.default.createElement("div",{dangerouslySetInnerHTML:{__html:e}}),isLarge:!0})},za=window.Spicetify,r=class extends f.default.Component{constructor(e){super(e),this.endOfList=!1,this.lastScroll=0,this.requestQueue=[],this.requestPage=0,this.cardList=[],Object.assign(this,e),this.updateAppConfig=e.updateAppConfig.bind(this),this.sortConfig={by:E(v.sortBy,"top")},this.state={version:un,newUpdate:!1,searchValue:"",cards:[],tabs:e.CONFIG.tabs,rest:!0,endOfList:!1,schemes:e.CONFIG.theme.schemes,activeScheme:e.CONFIG.theme.activeScheme,activeThemeKey:e.CONFIG.theme.activeThemeKey}}getInstalledTheme(){var e=localStorage.getItem(v.themeInstalled);return(e=e&&localStorage.getItem(e))?JSON.parse(e):null}newRequest(e){this.cardList=[];var t=[];this.requestQueue.unshift(t),this.loadAmount(t,e)}appendCard(e,t){e=f.default.createElement(Ba,{item:e,key:this.props.CONFIG.activeTab+":"+e.title,CONFIG:this.CONFIG,visual:this.props.CONFIG.visual,type:t,activeThemeKey:this.state.activeThemeKey,updateColourSchemes:this.updateColourSchemes.bind(this),updateActiveTheme:this.setActiveTheme.bind(this)});this.cardList.push(e),this.setState({cards:this.cardList})}updateSort(e){e&&(this.sortConfig.by=e,localStorage.setItem(v.sortBy,e)),this.requestPage=0,this.cardList=[],this.setState({cards:[],rest:!1,endOfList:!1}),this.endOfList=!1,this.newRequest(dn)}updateTabs(){this.setState({tabs:[...this.props.CONFIG.tabs]})}updatePostsVisual(){this.cardList=this.cardList.map((e,t)=>f.default.createElement(Ba,J(l({},e.props),{key:t.toString(),CONFIG:this.CONFIG}))),this.setState({cards:[...this.cardList]})}switchTo(e){this.CONFIG.activeTab=e.value,localStorage.setItem(v.activeTab,e.value),this.cardList=[],this.requestPage=0,this.setState({cards:[],rest:!1,endOfList:!1}),this.endOfList=!1,this.newRequest(dn)}async loadPage(t){switch(this.CONFIG.activeTab){case"Extensions":var e=await ca("spicetify-extensions",this.requestPage,this.BLACKLIST);for(const c of e.items){var r=await pa(c.contents_url,c.default_branch,c.stargazers_count,this.CONFIG.visual.hideInstalled);if(1<this.requestQueue.length&&t!==this.requestQueue[0])return-1;r&&r.length&&r.forEach(e=>{Object.assign(e,{lastUpdated:c.pushed_at}),this.appendCard(e,"extension")})}var n=-1<this.requestPage&&this.requestPage?this.requestPage:1,a=dn*(n-1)+e.page_count,o=e.total_count-a;if(console.debug(`Parsed ${a}/${e.total_count} extensions`),0<o)return n+1;console.debug("No more extension results");break;case"Installed":var i={theme:E(v.installedThemes,[]),extension:E(v.installedExtensions,[]),snippet:E(v.installedSnippets,[])};for(const u in i)i[u].length&&i[u].forEach(async e=>{e=E(e);if(1<this.requestQueue.length&&t!==this.requestQueue[0])return-1;this.appendCard(e,u)});break;case"Themes":a=await ca("spicetify-themes",this.requestPage,this.BLACKLIST);for(const p of a.items){var s=await da(p.contents_url,p.default_branch,p.stargazers_count);if(1<this.requestQueue.length&&t!==this.requestQueue[0])return-1;s&&s.length&&s.forEach(e=>{Object.assign(e,{lastUpdated:p.pushed_at}),this.appendCard(e,"theme")})}e=-1<this.requestPage&&this.requestPage?this.requestPage:1,o=dn*(e-1)+a.page_count,n=a.total_count-o;if(console.debug(`Parsed ${o}/${a.total_count} themes`),0<n)return e+1;console.debug("No more theme results");break;case"Apps":o=await ca("spicetify-apps",this.requestPage,this.BLACKLIST);for(const d of o.items){var l=await ha(d.contents_url,d.default_branch,d.stargazers_count);if(1<this.requestQueue.length&&t!==this.requestQueue[0])return-1;l&&l.length&&l.forEach(e=>{Object.assign(e,{lastUpdated:d.pushed_at}),this.appendCard(e,"app")})}a=-1<this.requestPage&&this.requestPage?this.requestPage:1,n=dn*(a-1)+o.page_count,e=o.total_count-n;if(con
|