Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mono-manifest #256

Closed
wants to merge 60 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
0599159
🚧 Initial support for mono-manifest themes (no stars yet)
theRealPadster Jun 25, 2022
8fb8e5f
Merge branch 'main' into feat/mono-manifest
theRealPadster Jun 25, 2022
711695d
Fix some linting
theRealPadster Jun 25, 2022
f2595ae
🚧 Initial mono-manifest support for custom apps
theRealPadster Jun 25, 2022
1f1f8a2
Fix some type errors
theRealPadster Jun 25, 2022
e39df53
Naming
theRealPadster Jun 25, 2022
256254f
Fix type errors
theRealPadster Jun 25, 2022
74ed0d7
More type fixes
theRealPadster Jun 25, 2022
b72291c
Merge branch 'main' into feat/mono-manifest
theRealPadster Jun 25, 2022
ea7b22a
Change to use ES2021
CharlieS1103 Jun 25, 2022
73498af
Begin implementing github topic fetch option
CharlieS1103 Jun 25, 2022
316ba74
Resolve linting errors
CharlieS1103 Jun 25, 2022
41827f7
Finish implementing optionality for themes
CharlieS1103 Jun 25, 2022
f5c90e8
Change card type
CharlieS1103 Jun 25, 2022
96d65df
Add logic to check if enabled before calling loadPageRecursive()
CharlieS1103 Jun 25, 2022
d8565c6
Fill in documentation links
CharlieS1103 Jun 25, 2022
f0a6acd
Remove unnecessary conditional
CharlieS1103 Jun 25, 2022
86e5c7a
Remove unnecessary imports
CharlieS1103 Jun 25, 2022
be885d4
Patch multimanifest support
CharlieS1103 Jun 25, 2022
451e2f2
🔥 ♻️ Remove some duplicated code and do some cleanup
theRealPadster Jun 26, 2022
f0573d1
♻️ Use `buildThemeCardData` for topic and mono-manifest flow
theRealPadster Jun 26, 2022
7cb545a
♻️ Code deduplication for `buildAppCardData`
theRealPadster Jun 26, 2022
7cc8bae
♻️ Consolidate getMonoManifest functions
theRealPadster Jun 26, 2022
cf09e54
Add `buildExtensionCardData`
theRealPadster Jun 26, 2022
c186d61
🚧 Add extension mono-manifest handling (not implemented)
theRealPadster Jun 26, 2022
aa04101
Normalize the marketplace controls colors
CharlieS1103 Jun 28, 2022
f0ce736
refactor(FetchRemotes): use lookups
kyrie25 Jun 28, 2022
798e6d4
feat(Settings): add annotation
kyrie25 Jun 28, 2022
c225f80
feat(Grid): allow switching fetch method for Apps
kyrie25 Jun 28, 2022
1538241
refactor(Grid): merge duplicate functions
kyrie25 Jun 28, 2022
337bb25
Make order of extension/theme/app functions consistent with tabs
theRealPadster Jun 28, 2022
531bc66
♻️ 🚧 Refactor `fetchMonoManifest` temporarily to be more efficient
theRealPadster Jun 28, 2022
3f5fb6f
Use same spice-text var for dropdown hover
theRealPadster Jun 29, 2022
a284f93
Add arrow-parens rule, Rearrange extensions/themes/apps to line up wi…
theRealPadster Jun 29, 2022
4de06a4
Forgot the rule
theRealPadster Jun 29, 2022
0c9e261
Make really long function params more readable, arrow-parens
theRealPadster Jun 29, 2022
3869c57
Add classes for some inline css
theRealPadster Jun 29, 2022
ed14b2a
Missed an arrow-parens
theRealPadster Jun 29, 2022
d0f4dc1
♻️ Move icons to single file
theRealPadster Jun 29, 2022
e34d368
feat: use synchronous fetch method & assert type
kyrie25 Jun 29, 2022
a9ead9a
chore: remove unnecessary type assertion
kyrie25 Jun 29, 2022
6791dd9
fix: wait until item is fetched completely
kyrie25 Jun 29, 2022
97d882d
🔀 Merge branch 'main' into feat/mono-manifest
theRealPadster Jun 30, 2022
80bb41b
Merge branch 'main' into feat/mono-manifest
theRealPadster Jun 30, 2022
6ab8049
Merge branch 'main' into feat/mono-manifest
theRealPadster Jun 30, 2022
ba6659f
For some reason it didn't put this in
theRealPadster Jun 30, 2022
cf6eb53
🔧 Add EOF ESLint rule
theRealPadster Jun 30, 2022
a70a362
Revert "For some reason it didn't put this in"
theRealPadster Jun 30, 2022
0fed49c
Merge branch 'main' into feat/mono-manifest
kyrie25 Jul 2, 2022
fe45603
Merge branch 'main' into feat/mono-manifest
kyrie25 Jul 4, 2022
4631df1
Merge branch 'main' into feat/mono-manifest
kyrie25 Jul 11, 2022
7188a54
refactor(utils)
kyrie25 Jul 11, 2022
15a07d6
Merge branch 'main' into feat/mono-manifest
kyrie25 Jul 14, 2022
494c322
Merge branch 'main' into feat/mono-manifest
kyrie25 Aug 4, 2022
4bddf46
chore: remove duplicate identifier
kyrie25 Aug 4, 2022
71035c2
Merge branch 'main' into feat/mono-manifest
kyrie25 Aug 4, 2022
f2d5bda
🔀 Merge branch 'main' into feat/mono-manifest
theRealPadster Nov 21, 2022
bffac96
Fix some types/merge stuff
theRealPadster Nov 21, 2022
5c2e628
Linting
theRealPadster Nov 21, 2022
e403d60
🚧 Start fetch-stars script
theRealPadster Dec 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions resources/manifests/apps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default [
{
"name": "Name That Tune!!1",
"description": "Heardle.app made for Spicetify",

// TODO: Get the image working (once there is a repo?)
"preview": "https://github.com/theRealPadster/name-that-tune/raw/main/docs/preview.png",
// TODO: Get the readme working (once there is a repo?)
"readme": "README.md",

"authors": [
{
"name": "theRealPadster",
"url": "https://github.com/theRealPadster",
},
],
"tags": [
"game",
"beta",
],
},
];
68 changes: 21 additions & 47 deletions src/components/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { LOCALSTORAGE_KEYS, ITEMS_PER_REQUEST, MARKETPLACE_VERSION, LATEST_RELEA
import { openModal } from "../logic/LaunchModals";
import {
getTaggedRepos,
fetchExtensionManifest, fetchThemeManifest, fetchAppManifest,
fetchCssSnippets, getBlacklist,
fetchExtensionManifest,
fetchCssSnippets, fetchBlacklist,
getThemesMonoManifest, buildThemeCardData,
getAppsMonoManifest, buildAppCardData,
} from "../logic/FetchRemotes";
import LoadMoreIcon from "./Icons/LoadMoreIcon";
import LoadingIcon from "./Icons/LoadingIcon";
Expand Down Expand Up @@ -241,70 +243,42 @@ export default class Grid extends React.Component<
// Don't need to return a page number because
// installed extension do them all in one go, since it's local
} case "Themes": {
const pageOfRepos = await getTaggedRepos("spicetify-themes", this.requestPage, this.BLACKLIST, query);
for (const repo of pageOfRepos.items) {
const allThemes = await getThemesMonoManifest();
console.log(allThemes);

const themes = await fetchThemeManifest(
repo.contents_url,
repo.default_branch,
repo.stargazers_count,
);
for (const theme of allThemes) {
const cardData = await buildThemeCardData(theme);

// TODO: do we need this queue stuff any more?
// I believe this stops the requests when switching tabs?
if (this.requestQueue.length > 1 && queue !== this.requestQueue[0]) {
// Stop this queue from continuing to fetch and append to cards list
return -1;
}

if (themes && themes.length) {
themes.forEach((theme) => {
Object.assign(theme, { lastUpdated: repo.pushed_at });
this.appendCard(theme, "theme");
});
}
if (cardData) this.appendCard(cardData, "theme");
}

// First request is null, so coerces to 1
const currentPage = this.requestPage > -1 && this.requestPage ? this.requestPage : 1;
// -1 because the page number is 1-indexed
const soFarResults = ITEMS_PER_REQUEST * (currentPage - 1) + pageOfRepos.page_count;
const remainingResults = pageOfRepos.total_count - soFarResults;

console.log(`Parsed ${soFarResults}/${pageOfRepos.total_count} themes`);
if (remainingResults > 0) return currentPage + 1;
else console.log("No more theme results");
console.log("Parsed themes");
break;
} case "Apps": {
const pageOfRepos = await getTaggedRepos("spicetify-apps", this.requestPage, this.BLACKLIST, query);
for (const repo of pageOfRepos.items) {
const allApps = await getAppsMonoManifest();
console.log(allApps);

const apps = await fetchAppManifest(
repo.contents_url,
repo.default_branch,
repo.stargazers_count,
);
for (const app of allApps) {
const cardData = await buildAppCardData(app);

// TODO: do we need this queue stuff any more?
// I believe this stops the requests when switching tabs?
if (this.requestQueue.length > 1 && queue !== this.requestQueue[0]) {
// Stop this queue from continuing to fetch and append to cards list
return -1;
}

if (apps && apps.length) {
apps.forEach((app) => {
Object.assign(app, { lastUpdated: repo.pushed_at });
this.appendCard(app, "app");
});
}
if (cardData) this.appendCard(cardData, "app");
}

// First request is null, so coerces to 1
const currentPage = this.requestPage > -1 && this.requestPage ? this.requestPage : 1;
// -1 because the page number is 1-indexed
const soFarResults = ITEMS_PER_REQUEST * (currentPage - 1) + pageOfRepos.page_count;
const remainingResults = pageOfRepos.total_count - soFarResults;

console.log(`Parsed ${soFarResults}/${pageOfRepos.total_count} apps`);
if (remainingResults > 0) return currentPage + 1;
else console.log("No more app results");
console.log("Parsed apps");
break;
} case "Snippets": {
const snippets = await fetchCssSnippets();
Expand Down Expand Up @@ -441,7 +415,7 @@ export default class Grid extends React.Component<
}

// Load blacklist
this.BLACKLIST = await getBlacklist();
this.BLACKLIST = await fetchBlacklist();
this.newRequest(ITEMS_PER_REQUEST);
}

Expand Down
1 change: 1 addition & 0 deletions src/components/Modals/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const SettingsModal = ({ CONFIG, updateAppConfig } : Props) => {
<ConfigRow name='Theme developer tools' storageKey='themeDevTools' modalConfig={modalConfig} updateConfig={updateConfig} />
<ConfigRow name='Hide installed when browsing' storageKey='hideInstalled' modalConfig={modalConfig} updateConfig={updateConfig} />
<ConfigRow name='Shift colors every minute' storageKey='colorShift' modalConfig={modalConfig} updateConfig={updateConfig} />
<ConfigRow name='Use Github topics to fetch cards' storageKey='githubTopics' modalConfig={modalConfig} updateConfig={updateConfig} />
<h2>Tabs</h2>
<div className="tabs-container">
{modalConfig.tabs.map(({ name }, index) => {
Expand Down
3 changes: 3 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const LOCALSTORAGE_KEYS = {
// Theme installed store the localsorage key of the theme (e.g. marketplace:installed:NYRI4/Comfy-spicetify/user.css)
"themeInstalled": "marketplace:theme-installed",
"colorShift": "marketplace:colorShift",
"githubTopics": "marketplace:githubTopics",
};

// Initalize topbar tabs
Expand All @@ -34,6 +35,8 @@ export const CUSTOM_APP_PATH = "/marketplace";
// Used in Card.tsx
export const MAX_TAGS = 4;

export const THEMES_URL = "https://raw.githubusercontent.com/spicetify/spicetify-themes/generated-manifest/manifest.json";

export const SNIPPETS_PAGE_URL = "https://github.com/spicetify/spicetify-marketplace/blob/main/resources/snippets.ts";

export const BLACKLIST_URL = "https://raw.githubusercontent.com/spicetify/spicetify-marketplace/main/resources/blacklist.json";
Expand Down
48 changes: 26 additions & 22 deletions src/extensions/extension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ import {
sleep,
} from "../logic/Utils";
import {
getBlacklist,
fetchThemeManifest,
fetchBlacklist,
buildThemeCardData,
fetchExtensionManifest,
} from "../logic/FetchRemotes";
import {
fetchThemeManifestFromTopic,
fetchExtensionManifestFromTopic
} from "../logic/FetchTopicRemotes";

(async () => {
while (!(Spicetify?.LocalStorage && Spicetify?.showNotification)) {
Expand Down Expand Up @@ -171,6 +175,8 @@ async function queryRepos(type: RepoType, pageNum = 1) {
*/
async function loadPageRecursive(type: RepoType, pageNum: number) {
const pageOfRepos = await queryRepos(type, pageNum);
console.log(pageOfRepos);
// TODO: Once we migrate to the mono-manifest repo, implement the option for enabling topics search here
appendInformationToLocalStorage(pageOfRepos, type);

// Sets the amount of items that have thus been fetched
Expand All @@ -187,38 +193,36 @@ async function loadPageRecursive(type: RepoType, pageNum: number) {
(async function initializePreload() {
console.log("Preloading extensions and themes...");
window.sessionStorage.clear();
const BLACKLIST = await getBlacklist();
const BLACKLIST = await fetchBlacklist();
window.sessionStorage.setItem("marketplace:blacklist", JSON.stringify(BLACKLIST));

// TODO: does this work?
// The recursion isn't super clean...

// Begin by getting the themes and extensions from github
// const [extensionReposArray, themeReposArray] = await Promise.all([
await Promise.all([
loadPageRecursive("extension", 1),
loadPageRecursive("theme", 1),
]);

// let extensionsNextPage = 1;
// let themesNextPage = 1;
// do {
// extensionReposArray = await loadPage("extension", extensionsNextPage);
// appendInformationToLocalStorage(extensionReposArray, "extension");
// } while (extensionsNextPage);

// do {
// themeReposArray = await loadPage("theme", themesNextPage);
// appendInformationToLocalStorage(themeReposArray, "theme");
// } while (themesNextPage);
// TODO: re-enable this once everything works with mono-manifest...
await Promise.all([
CharlieS1103 marked this conversation as resolved.
Show resolved Hide resolved
loadPageRecursive("extension", 1),
loadPageRecursive("theme", 1),
]);
})();

async function appendInformationToLocalStorage(array, type: RepoType) {
// This system should make it so themes and extensions are stored concurrently
for (const repo of array.items) {
if(LOCALSTORAGE_KEYS.githubTopics){
for (const repo of array.items) {
// console.log(repo);
const data = (type === "theme")
? await fetchThemeManifest(repo.contents_url, repo.default_branch, repo.stargazers_count)
? await fetchThemeManifestFromTopic(repo.contents_url, repo.default_branch, repo.stargazers_count)
: await fetchExtensionManifestFromTopic(repo.contents_url, repo.default_branch, repo.stargazers_count);
if (data) {
addToSessionStorage(data);
await sleep(5000);
}
}
}
const data = (type === "theme")
? await buildThemeCardData(repo.contents_url, repo.default_branch, repo.stargazers_count)
: await fetchExtensionManifest(repo.contents_url, repo.default_branch, repo.stargazers_count);
if (data) {
addToSessionStorage(data);
Expand Down
Loading