[Dump] v7.0.0-dev

pull/36/head
Oj18 3 years ago
parent 18a939b74c
commit d05de1c295

@ -1,5 +1,14 @@
# GooseMod Changelog
## v7.0.0-dev [2021-0X-XX]
- ### Features
- New Module Store API
- ### UI Improvements
- Stopped authors with discriminators being separated with just author name
## v6.0.1 [2021-01-22]
- ### Fixes

14
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

@ -105,7 +105,7 @@ const init = async function () {
this.disabledModules = {};
this.lastVersion = localStorage.getItem('goosemodLastVersion');
this.version = '6.0.1';
this.version = '7.0.0-dev';
this.versionHash = '<hash>'; // Hash of built final js file is inserted here via build script
fetch(`${this.moduleStoreAPI.apiBaseURL}/injectVersion.json`).then((x) => x.json().then((latestInjectVersionInfo) => {
@ -186,7 +186,7 @@ const init = async function () {
// toInstallModules = await this.packModal.ask(); // ['hardcodedColorFixer', 'draculaTheme', 'fucklytics', 'visualTweaks', 'wysiwygMessages', 'customSounds', 'devMode', 'twitchEmotes', 'noMessageDeletion'];
}
toInstallModules = toInstallModules.filter((m) => this.moduleStoreAPI.modules.find((x) => x.filename === m) !== undefined);
toInstallModules = toInstallModules.filter((m) => this.moduleStoreAPI.modules.find((x) => x.name === m) !== undefined);
let themeModule = toInstallModules.find((x) => x.toLowerCase().includes('theme'));
@ -208,7 +208,7 @@ const init = async function () {
const importPromises = [];
for (let m of toInstallModules) {
this.updateLoadingScreen(`${this.moduleStoreAPI.modules.find((x) => x.filename === m).name} - ${toInstallModules.indexOf(m) + 1}/${toInstallModules.length}`);
this.updateLoadingScreen(`${this.moduleStoreAPI.modules.find((x) => x.name === m).name} - ${toInstallModules.indexOf(m) + 1}/${toInstallModules.length}`);
// await this.moduleStoreAPI.importModule(m);
importPromises.push(this.moduleStoreAPI.importModule(m));

@ -7,7 +7,7 @@ export const setThisScope = (scope) => {
};
export const importModule = async (f, isLocal = false) => {
let field = f.filename.split('.').slice(0, -1).join('.'); // Get name of module via filename (taking away the file extension)
let field = f.name;
goosemodScope.logger.debug('import', `Importing module: "${field}"`);
@ -25,7 +25,7 @@ export const importModule = async (f, isLocal = false) => {
f.data = ab2str(f.data);
}
goosemodScope.modules[field] = eval(f.data); // Set goosemodScope.modules.<module_name> to the return value of the module (an object containing handlers)
goosemodScope.modules[field] = Object.assign(eval(f.data), f.metadata); // Set goosemodScope.modules.<module_name> to the return value of the module (an object containing handlers)
goosemodScope.logger.debug(`import.load.module.${field}`, `Evaled module JS`);
@ -40,7 +40,7 @@ export const importModule = async (f, isLocal = false) => {
if (isLocal) {
const toggleObj = {
type: 'text-and-danger-button',
text: `${goosemodScope.modules[field].name} <span class="description-3_Ncsb">by</span> ${goosemodScope.modules[field].author} <span class="description-3_Ncsb">(v${goosemodScope.modules[field].version})</span>`,
text: `${goosemodScope.modules[field].name} <span class="description-3_Ncsb">by</span> ${goosemodScope.modules[field].authors} <span class="description-3_Ncsb">(v${goosemodScope.modules[field].version})</span>`,
buttonText: 'Remove',
subtext: goosemodScope.modules[field].description,
onclick: (el) => {

@ -13,17 +13,18 @@ export default {
modules: [],
apiBaseURL: 'https://api.goosemod.com',
storeApiBaseURL: 'https://store.goosemod.com',
jsCache: JSCache,
updateModules: async () => {
goosemodScope.moduleStoreAPI.modules = (await (await fetch(`${goosemodScope.moduleStoreAPI.apiBaseURL}/modules.json?_=${Date.now()}`)).json())
goosemodScope.moduleStoreAPI.modules = (await (await fetch(`${goosemodScope.moduleStoreAPI.storeApiBaseURL}/modules.json?_=${Date.now()}`)).json())
.sort((a, b) => a.name.localeCompare(b.name));
},
importModule: async (moduleName) => {
try {
const moduleInfo = goosemodScope.moduleStoreAPI.modules.find((x) => x.filename === moduleName);
const moduleInfo = goosemodScope.moduleStoreAPI.modules.find((x) => x.name === moduleName);
const jsCode = await goosemodScope.moduleStoreAPI.jsCache.getJSForModule(moduleName);
@ -36,8 +37,9 @@ export default {
}
await goosemodScope.importModule({
filename: `${moduleInfo.filename}.js`,
data: jsCode
name: moduleName,
data: jsCode,
metadata: moduleInfo
});
if (goosemodScope.modules[moduleName].goosemodHandlers.onLoadingFinished !== undefined) {
@ -96,79 +98,59 @@ export default {
item[2] = item[2].slice(0, 5);
let sortedCategories = goosemodScope.moduleStoreAPI.modules.reduce((cats, o) => cats.includes(o.category) ? cats : cats.concat(o.category), []).sort((a, b) => a.localeCompare(b));
for (const m of goosemodScope.moduleStoreAPI.modules.sort((a, b) => a.name.localeCompare(b.name))) {
item[2].push({
type: 'card',
tags: m.tags,
let arr = Object.entries(goosemodScope.moduleStoreAPI.modules.reduce((cats, o) => {
if (!cats[o.category]) cats[o.category]=[];
cats[o.category].push(o);
return cats;
},{})).sort((a, b) => a[0].localeCompare(b[0])).map(o => o[1]);
buttonType: goosemodScope.modules[m.name] ? 'danger' : 'brand',
showToggle: goosemodScope.modules[m.name],
let funIndex = sortedCategories.indexOf('fun');
text: `${m.name} <span class="description-3_Ncsb">by</span> ${await goosemodScope.moduleStoreAPI.parseAuthors(m.authors)}`, // ` <span class="description-3_Ncsb">(v${m.version})</span>`,
subtext: m.description,
subtext2: `v${m.version}`,
sortedCategories.push(sortedCategories.splice(funIndex, 1)[0]);
arr.push(arr.splice(funIndex, 1)[0]);
buttonText: goosemodScope.modules[m.name] ? 'Remove' : 'Import',
onclick: async (el) => {
if (goosemodScope.modules[m.name]) {
el.textContent = 'Removing...';
for (let i = 0; i < arr.length; i++) {
/*item[2].push({
type: 'header',
text: sortedCategories[i].replace(/\-/g, ' ')
});*/
goosemodScope.settings.removeModuleUI(m.name, 'Module Store');
for (let m of arr[i]) {
item[2].push({
type: 'card',
class: m.category,
return;
}
buttonType: goosemodScope.modules[m.filename] ? 'danger' : 'brand',
showToggle: goosemodScope.modules[m.filename],
el.textContent = 'Importing...';
text: `${m.name} <span class="description-3_Ncsb">by</span> ${await goosemodScope.moduleStoreAPI.parseAuthors(m.author)}`, // ` <span class="description-3_Ncsb">(v${m.version})</span>`,
subtext: m.description,
subtext2: `v${m.version}`,
await goosemodScope.moduleStoreAPI.importModule(m.name);
buttonText: goosemodScope.modules[m.filename] ? 'Remove' : 'Import',
onclick: async (el) => {
if (goosemodScope.modules[m.filename]) {
el.textContent = 'Removing...';
goosemodScope.settings.openSettingItem('Module Store');
},
isToggled: () => goosemodScope.modules[m.name] !== undefined,
onToggle: async (checked) => {
if (checked) {
goosemodScope.modules[m.name] = Object.assign({}, goosemodScope.disabledModules[m.name]);
delete goosemodScope.disabledModules[m.name];
goosemodScope.settings.removeModuleUI(m.filename, 'Module Store');
await goosemodScope.modules[m.name].goosemodHandlers.onImport();
return;
if (goosemodScope.modules[m.name].goosemodHandlers.onLoadingFinished !== undefined) {
await goosemodScope.modules[m.name].goosemodHandlers.onLoadingFinished();
}
el.textContent = 'Importing...';
await goosemodScope.moduleStoreAPI.importModule(m.filename);
goosemodScope.settings.openSettingItem('Module Store');
},
isToggled: () => goosemodScope.modules[m.filename] !== undefined,
onToggle: async (checked) => {
if (checked) {
goosemodScope.modules[m.filename] = Object.assign({}, goosemodScope.disabledModules[m.filename]);
delete goosemodScope.disabledModules[m.filename];
await goosemodScope.modules[m.filename].goosemodHandlers.onImport();
if (goosemodScope.modules[m.filename].goosemodHandlers.onLoadingFinished !== undefined) {
await goosemodScope.modules[m.filename].goosemodHandlers.onLoadingFinished();
}
goosemodScope.loadSavedModuleSetting(m.filename);
} else {
goosemodScope.disabledModules[m.filename] = Object.assign({}, goosemodScope.modules[m.filename]);
goosemodScope.loadSavedModuleSetting(m.name);
} else {
goosemodScope.disabledModules[m.name] = Object.assign({}, goosemodScope.modules[m.name]);
goosemodScope.modules[m.filename].goosemodHandlers.onRemove();
goosemodScope.modules[m.name].goosemodHandlers.onRemove();
delete goosemodScope.modules[m.filename];
}
goosemodScope.settings.openSettingItem('Module Store');
delete goosemodScope.modules[m.name];
}
});
}
goosemodScope.settings.openSettingItem('Module Store');
}
});
}
}
}

@ -16,13 +16,13 @@ export const updateCache = (moduleName, hash, js) => {
};
export const getJSForModule = async (moduleName) => {
const moduleInfo = goosemodScope.moduleStoreAPI.modules.find((x) => x.filename === moduleName);
const moduleInfo = goosemodScope.moduleStoreAPI.modules.find((x) => x.name === moduleName);
const cache = goosemodScope.moduleStoreAPI.jsCache.getCache();
if (cache[moduleName] && moduleInfo.hash === cache[moduleName].hash) {
return cache[moduleName].js;
} else {
const js = await (await fetch(`${moduleInfo.codeURL}?_=${Date.now()}`)).text();
const js = await (await fetch(`${goosemodScope.moduleStoreAPI.storeApiBaseURL}/module/${moduleName}.js?_=${Date.now()}`)).text();
goosemodScope.moduleStoreAPI.jsCache.updateCache(moduleName, moduleInfo.hash, js);

@ -6,7 +6,7 @@ export const setThisScope = (scope) => {
let themes = [
{
name: 'draculaTheme',
name: 'Dracula Theme',
css: `html > body {
--background-primary: #181920;
--background-secondary: #1C1D25;
@ -31,7 +31,7 @@ let themes = [
}`
},
{
name: 'darkestTheme',
name: 'Darkest Theme',
css: `html > body {
--background-primary: #000;
--background-secondary: #050505;
@ -46,7 +46,7 @@ let themes = [
}`
},
{
name: 'solarizedDarkTheme',
name: 'Solarized Dark Theme',
css: `html > body {
--background-primary: #002b36;
--background-secondary: #073642;
@ -71,7 +71,7 @@ let themes = [
}`
},
{
name: 'slateTheme',
name: 'Slate Theme',
css: ''
}
];
@ -205,7 +205,7 @@ const selectionModal = (title, options) => {
const installModules = async (modules) => {
for (let m of modules) {
goosemodScope.updateLoadingScreen(`${goosemodScope.moduleStoreAPI.modules.find((x) => x.filename === m).name} - ${modules.indexOf(m) + 1}/${modules.length}`);
goosemodScope.updateLoadingScreen(`${goosemodScope.moduleStoreAPI.modules.find((x) => x.name === m).name} - ${modules.indexOf(m) + 1}/${modules.length}`);
await goosemodScope.moduleStoreAPI.importModule(m);
}
@ -222,7 +222,7 @@ export const ask = () => {
await installModules(packModules);
let themesOptions = themes.map((x) => {
let mod = goosemodScope.moduleStoreAPI.modules.find((y) => y.filename === x.name);
let mod = goosemodScope.moduleStoreAPI.modules.find((y) => y.name === x.name);
let el;

@ -686,7 +686,9 @@ export const _createItem = (panelName, content) => {
case 'card': {
el = document.createElement('div');
if (e.class) el.classList.add(e.class);
if (e.tags) e.tags.forEach((x) => el.classList.add(x.replace(/ /g, '|')));
//if (e.class) el.classList.add(e.class);
el.style.backgroundColor = 'var(--background-secondary)';
@ -1290,7 +1292,7 @@ export const makeGooseModSettings = () => {
goosemodScope.settings.createHeading('GooseMod');
goosemodScope.settings.createItem('Local Modules', ['',
/* goosemodScope.settings.createItem('Local Modules', ['',
{
type: 'button',
text: 'Import Local Module',
@ -1313,7 +1315,7 @@ export const makeGooseModSettings = () => {
type: 'header',
text: 'Imported Local Modules'
}
]);
]); */
const updateModuleStoreUI = (parentEl, cards) => {
const inp = parentEl.querySelector('[contenteditable=true]').innerText.replace('\n', '');
@ -1352,7 +1354,7 @@ export const makeGooseModSettings = () => {
for (let c of cards) {
const title = c.getElementsByClassName('title-31JmR4')[0];
const authors = [...title.getElementsByClassName('author')].map((x) => x.textContent.toLowerCase());
const authors = [...title.getElementsByClassName('author')].map((x) => x.textContent.split('#')[0].toLowerCase());
const name = title.childNodes[0].wholeText;
const description = c.getElementsByClassName('description-3_Ncsb')[1].innerText;
@ -1361,14 +1363,16 @@ export const makeGooseModSettings = () => {
const importedSelector = c.getElementsByClassName('control-2BBjec')[0] !== undefined ? 'imported' : 'not imported';
const tags = [...c.classList].map((t) => t.replace(/\|/g, ' '));
c.style.display = matches && (
(selectors[c.className] || noneSelectedArray[1]) &&
(tags.every((t) => selectors[t]) || noneSelectedArray[1]) &&
(authors.some((x) => selectors[x]) || noneSelectedArray[2]) &&
(selectors[importedSelector] || noneSelectedArray[0]))
? 'block' : 'none';
if (c.style.display !== 'none') {
counts[c.className].count++;
tags.forEach((t) => counts[t].count++);
authors.forEach((x) => counts[x].count++);
counts[importedSelector].count++;
}
@ -1430,17 +1434,22 @@ export const makeGooseModSettings = () => {
let final = [...cards.reduce((acc, e) => {
const x = e.getElementsByClassName('control-2BBjec')[0] !== undefined ? 'Imported' : 'Not Imported';
return acc.set(x, (acc.get(x) || 0) + (e.style.display !== 'none' ? 1 : 0));
}, new Map()).entries()].sort((a, b) => b[1] - a[1]);
}, new Map([
['Imported', 0],
['Not Imported', 0]
])).entries()].sort((a, b) => b[1] - a[1]);
final.push(['Categories', 0, 'divider']);
final.push(['Tags', 0, 'divider']);
final = final.concat([...cards.reduce((acc, e) => acc.set(e.className, (acc.get(e.className) || 0) + (e.style.display !== 'none' ? 1 : 0)), new Map()).entries()].sort((a, b) => b[1] - a[1]));
final = final.concat([...([].concat.apply([], cards.map((x) => (
[...x.classList].map((y) => [y.replace(/\|/g, ' '), x.style.display !== 'none'])
)))).reduce((acc, e) => acc.set(e[0], (acc.get(e[0]) || 0) + (e[1] ? 1 : 0)), new Map()).entries()].sort((a, b) => b[1] - a[1]));
final.push(['Authors', 0, 'divider']);
final = final.concat([...cards.reduce((acc, e) => {
for (let el of e.getElementsByClassName('author')) {
const x = el.textContent;
const x = el.textContent.split('#')[0];
acc.set(x, (acc.get(x) || 0) + (e.style.display !== 'none' ? 1 : 0));
}

Loading…
Cancel
Save