[Bulk] Several various changes, see CHANGELOG.md changes for details

pull/36/head
Oj18 3 years ago
parent 759b22bc0d
commit fa2a82e1be

@ -1,16 +1,28 @@
# GooseMod Changelog
## v7.3.0-dev [2021-03-2X]
## v8.0.0-dev [2021-04-XX]
- ### Patcher API Additions
- Added commands API, allows easy custom commands
- Added internal message API, allows easy sending of internal (Clyde-like) messages
- ### i18n
- Added partial i18n support
- ### Backend Improvements
- New logging console output
- Made injection init much more async / desynced from other components
- Show toast when getting a repo fails instead of locking up injection
- Fixed some usage of window scope instead of local internally
- ### Backend Removements
- Removed v6 to v7 migration fix
- Removed adding PC theme repo when updating to v7.2.0 for the first time
- Removed checking if hash and version matches latest online record
- ### Fixes
- Fixed stored repo urls not being removed on goosemod.remove
## v7.2.0 [2021-03-19]

@ -18,7 +18,7 @@ export const updateCache = (lang, hash, goosemodStrings) => {
localStorage.setItem('goosemodi18nCache', JSON.stringify(cache));
};
export const getJSForModule = async (lang) => {
export const geti18nData = async (lang) => {
const cache = getCache();
if (cache[lang]) { // && moduleInfo.hash === cache[lang].hash) {
@ -27,8 +27,8 @@ export const getJSForModule = async (lang) => {
const goosemodStrings = await goosemodScope.i18n.geti18nData(lang);
const newHash = await sha512(JSON.stringify(goosemodStrings));
updateCache(moduleName, newHash, js);
updateCache(lang, newHash, goosemodStrings);
return js;
return goosemodStrings;
}
};

@ -29,7 +29,9 @@ const checkForNewLang = async () => {
if (code === lastLangCode) return; // Lang not changed
lastLangCode = code;
goosemodStrings = await geti18nData();
goosemodScope.showToast(`New lang detected`);
goosemodStrings = await Cache.geti18nData();
const { _proxyContext: { messages } } = goosemodScope.webpackModules.findByProps('chosenLocale', 'languages');

@ -85,7 +85,7 @@ const importsToAssign = {
const init = async function () {
while (document.querySelectorAll('.flex-1xMQg5.flex-1O1GKY.horizontal-1ae9ci.horizontal-2EEEnY.flex-1O1GKY.directionRow-3v3tfG.justifyStart-2NDFzi.alignStretch-DpGPf3.noWrap-3jynv6 > [type="button"]:last-child').length === 0 || window.webpackJsonp === undefined) {
await sleep(50);
await sleep(10);
}
Object.assign(this, importsToAssign);
@ -100,7 +100,7 @@ const init = async function () {
};
this.versioning = {
version: '7.3.0-dev',
version: '8.0.0-dev',
hash: '<hash>', // Hash of built final js file is inserted here via build script
lastUsedVersion: localStorage.getItem('goosemodLastVersion')
@ -108,22 +108,33 @@ const init = async function () {
this.versioning.isDeveloperBuild = this.versioning.hash === '<hash>';
localStorage.setItem('goosemodLastVersion', this.versioning.version);
this.logger.debug('import.version.goosemod', `${this.versioning.version} (${this.versioning.hash})`);
if (window.DiscordNative !== undefined) this.logger.debug('import.version.discord', `${DiscordNative.app.getReleaseChannel()} ${DiscordNative.app.getVersion()}`);
if (window.gmUntethered) {
this.untetheredVersion = window.gmUntethered.slice();
}
this.startLoadingScreen();
this.updateLoadingScreen('Getting i18n data...');
this.updateLoadingScreen('Initialising internals...');
// this.updateLoadingScreen('Getting i18n data...');
// Wait for i18n to load
await new Promise(async (res) => {
(new Promise(async (res) => {
while (!this.i18n.goosemodStrings || !this.i18n.discordStrings) {
await sleep(100);
await sleep(10);
}
res();
})).then(() => {
this.moduleStoreAPI.updateStoreSetting();
this.settings.makeGooseModSettings();
});
this.updateLoadingScreen('Initialising internals...');
this.settings.makeGooseModSettings();
this.moduleStoreAPI.initRepoURLs();
this.removed = false;
@ -131,47 +142,55 @@ const init = async function () {
this.modules = {};
this.disabledModules = {};
fetch(`${this.moduleStoreAPI.apiBaseURL}/injectVersion.json`).then((x) => x.json().then((latestInjectVersionInfo) => {
if (latestInjectVersionInfo.version !== this.versioning.version) {
this.showToast('Warning: Version number does not match latest public release', { timeout: 3000, type: 'danger' });
}
this.moduleStoreAPI.modules = JSON.parse(localStorage.getItem('goosemodCachedModules')) || [];
if (latestInjectVersionInfo.hash !== this.versioning.hash) {
this.showToast('Warning: Version hash does not match latest public release', { timeout: 3000, type: 'danger' });
}
}));
this.initialImport = true;
let toInstallModules = Object.keys(JSON.parse(localStorage.getItem('goosemodModules')) || {});
let toInstallIsDefault = false;
if (toInstallModules.length === 0) {
toInstallIsDefault = true;
}
toInstallModules = toInstallModules.filter((m) => this.moduleStoreAPI.modules.find((x) => x.name === m) !== undefined);
let themeModule = toInstallModules.find((x) => x.toLowerCase().includes('theme'));
if (themeModule) {
toInstallModules.unshift(toInstallModules.splice(toInstallModules.indexOf(themeModule), 1)[0]);
}
let hardcodedColorFixerModule = toInstallModules.find((x) => x === 'Hardcoded Color Fixer');
if (hardcodedColorFixerModule) {
toInstallModules.unshift(toInstallModules.splice(toInstallModules.indexOf(hardcodedColorFixerModule), 1)[0]);
}
if (this.lastVersion && this.lastVersion !== this.versioning.version) {
if (this.versioning.version === '7.2.0' && localStorage.getItem('goosemodRepos')) { // Adding new PC themes repo
const current = JSON.parse(localStorage.getItem('goosemodRepos'));
console.log(toInstallModules);
if (!current.find((x) => x.url === `https://store.goosemod.com/pcthemes.json`)) current.push({
url: `https://store.goosemod.com/pcthemes.json`,
enabled: true
});
if (toInstallIsDefault) {
await this.packModal.ask();
} else {
this.updateLoadingScreen('Importing modules from Module Store...');
localStorage.setItem('goosemodRepos', JSON.stringify(current));
const importPromises = [];
this.moduleStoreAPI.initRepoURLs();
for (let m of toInstallModules) {
this.updateLoadingScreen(`${m}\n${toInstallModules.indexOf(m) + 1}/${toInstallModules.length}`);
this.showToast(`Added new PC Themes Repo (v7.2.0 update)`);
// await this.moduleStoreAPI.importModule(m);
importPromises.push(this.moduleStoreAPI.importModule(m, this.moduleSettingsStore.checkDisabled(m)));
}
this.goosemodChangelog.show();
await Promise.all(importPromises);
}
localStorage.setItem('goosemodLastVersion', this.versioning.version);
this.logger.debug('import.version.goosemod', `${this.versioning.version} (${this.versioning.hash})`);
if (window.DiscordNative !== undefined) this.logger.debug('import.version.discord', `${DiscordNative.app.getReleaseChannel()} ${DiscordNative.app.getVersion()}`);
if (window.gmUntethered) {
this.untetheredVersion = window.gmUntethered.slice();
// delete window.gmUntethered;
}
delete this.initialImport;
this.updateLoadingScreen(`Loading saved module settings...`);
await this.moduleSettingsStore.loadSavedModuleSettings();
this.messageEasterEggs.interval = setInterval(this.messageEasterEggs.check, 1000);
@ -185,6 +204,10 @@ const init = async function () {
clearInterval(this.i18nCheckNewLangInterval);
localStorage.removeItem('goosemodLastVersion');
localStorage.removeItem('goosemodGMSettings');
localStorage.removeItem('goosemodRepos');
localStorage.remoevItem('goosemodCachedModules');
this.moduleSettingsStore.clearSettings();
this.moduleStoreAPI.jsCache.purgeCache();
@ -211,77 +234,6 @@ const init = async function () {
return;
}
this.initialImport = true;
let toInstallModules = Object.keys(JSON.parse(localStorage.getItem('goosemodModules')) || {});
let toInstallIsDefault = false;
if (toInstallModules.length === 0) {
toInstallIsDefault = true;
}
const needToMigrateFromV6 = toInstallModules.some((m) => this.moduleStoreAPI.modules.find((x) => x.name === m) === undefined);
if (needToMigrateFromV6) {
this.updateLoadingScreen('Migrating stored module names to MS2...');
const oldModules = (await (await fetch(`${this.moduleStoreAPI.apiBaseURL}/modules.json?_=${Date.now()}`)).json());
console.log(oldModules);
toInstallModules = toInstallModules.map((m) => oldModules.find((x) => x.filename === m)?.name || m);
let moduleSettings = JSON.parse(localStorage.getItem('goosemodModules'));
for (const oldName of Object.keys(moduleSettings)) {
const newName = oldModules.find((x) => x.filename === oldName)?.name;
if (!newName) continue;
Object.defineProperty(moduleSettings, newName, Object.getOwnPropertyDescriptor(moduleSettings, oldName));
delete moduleSettings[oldName];
}
localStorage.setItem('goosemodModules', JSON.stringify(moduleSettings));
}
toInstallModules = toInstallModules.filter((m) => this.moduleStoreAPI.modules.find((x) => x.name === m) !== undefined);
let themeModule = toInstallModules.find((x) => x.toLowerCase().includes('theme'));
if (themeModule) {
toInstallModules.unshift(toInstallModules.splice(toInstallModules.indexOf(themeModule), 1)[0]);
}
let hardcodedColorFixerModule = toInstallModules.find((x) => x === 'Hardcoded Color Fixer');
if (hardcodedColorFixerModule) {
toInstallModules.unshift(toInstallModules.splice(toInstallModules.indexOf(hardcodedColorFixerModule), 1)[0]);
}
if (toInstallIsDefault) {
await this.packModal.ask();
} else {
this.updateLoadingScreen('Importing modules from Module Store...');
const importPromises = [];
for (let m of toInstallModules) {
this.updateLoadingScreen(`${m}\n${toInstallModules.indexOf(m) + 1}/${toInstallModules.length}`);
// await this.moduleStoreAPI.importModule(m);
importPromises.push(this.moduleStoreAPI.importModule(m, this.moduleSettingsStore.checkDisabled(m)));
}
await Promise.all(importPromises);
}
delete this.initialImport;
this.updateLoadingScreen(`Loading saved module settings...`);
await this.moduleSettingsStore.loadSavedModuleSettings();
this.stopLoadingScreen();
if (this.settings.isSettingsOpen()) { // If settings are open, reopen to inject new GooseMod options

@ -1,4 +1,5 @@
import { sha512 } from '../util/hash';
import sleep from '../util/sleep';
const JSCache = require('./jsCache');
@ -88,6 +89,7 @@ export default {
localStorage.setItem('goosemodRepos', JSON.stringify(goosemodScope.moduleStoreAPI.repoURLs));
localStorage.setItem('goosemodCachedModules', JSON.stringify(goosemodScope.moduleStoreAPI.modules));
},
importModule: async (moduleName, disabled = false) => {
@ -114,13 +116,22 @@ export default {
await goosemodScope.modules[moduleName].goosemodHandlers.onLoadingFinished();
}
let settingItem = goosemodScope.settings.items.find((x) => x[1] === goosemodScope.moduleStoreAPI.getSettingItemName(moduleInfo));
let settingItem, item;
let item = settingItem[2].find((x) => x.subtext === moduleInfo.description);
(new Promise(async (res) => {
settingItem = goosemodScope.settings.items.find((x) => x[1] === goosemodScope.moduleStoreAPI.getSettingItemName(moduleInfo));
if (settingItem) item = settingItem[2].find((x) => x.subtext === moduleInfo.description);
item.buttonType = 'danger';
item.buttonText = goosemodScope.i18n.discordStrings.REMOVE;
item.showToggle = true;
while (!goosemodScope.i18n.goosemodStrings || !goosemodScope.i18n.discordStrings || !settingItem || !item) {
await sleep(50);
}
res();
})).then(() => {
item.buttonType = 'danger';
item.buttonText = goosemodScope.i18n.discordStrings.REMOVE;
item.showToggle = true;
});
// if (goosemodScope.settings.isSettingsOpen() && !goosemodScope.initialImport) goosemodScope.settings.createFromItems();
} catch (e) {

@ -14,7 +14,7 @@ export const startLoadingScreen = () => {
loadingEl.style.left = '50%';
loadingEl.style.top = '60px';
loadingEl.style.zIndex = '10';
loadingEl.style.zIndex = '9999';
loadingEl.style.backgroundColor = 'var(--background-floating)';
loadingEl.style.opacity = '0.9';

@ -64,13 +64,11 @@ export const openSettingItem = (name) => {
export const reopenSettings = async () => {
goosemodScope.settings.closeSettings();
await sleep(1000);
await sleep(500);
goosemodScope.settings.openSettings();
await sleep(200);
goosemodScope.settings.openSettingItem('Module Store');
await sleep(100);
};
// Settings UI stuff
@ -1448,8 +1446,130 @@ export const makeGooseModSettings = () => {
return sections;
}));
let oldItems = goosemodScope.settings.items;
goosemodScope.settings.items = [];
goosemodScope.settings.createHeading('GooseMod');
const gmSettings = JSON.parse(localStorage.getItem('goosemodGMSettings')) || {
changelog: true,
separators: true,
devchannel: false
};
const changeSetting = async (key, value) => {
switch (key) {
case 'changelog': {
if (value) {
goosemodScope.settings.createItem(goosemodScope.i18n.discordStrings.CHANGE_LOG, [""], async () => {
GoosemodChangelog.show();
});
} else {
goosemodScope.settings.items.splice(goosemodScope.settings.items.indexOf(goosemodScope.settings.items.find(x => x[1] === 'Change Log')), 1);
}
await goosemodScope.settings.reopenSettings();
goosemodScope.settings.openSettingItem('Settings');
break;
}
case 'devchannel': {
if (value) {
localStorage.setItem('goosemodUntetheredBranch', 'dev');
} else {
localStorage.removeItem('goosemodUntetheredBranch');
}
break;
}
case 'separators': {
if (value) {
goosemod.settings.items.splice(2, 0, ['separator']);
if (gmSettings.changelog) goosemod.settings.items.splice(4, 0, ['separator']);
} else {
let main = true;
goosemodScope.settings.items = goosemodScope.settings.items.filter((x, i) => {
if (goosemodScope.settings.items[i + 1] && goosemodScope.settings.items[i + 1][1] && goosemodScope.settings.items[i + 1][1] === 'GooseMod Modules') main = false;
return !(x[0] === 'separator' && main);
});
}
await goosemodScope.settings.reopenSettings();
goosemodScope.settings.openSettingItem('Settings');
break;
}
}
gmSettings[key] = value;
localStorage.setItem('goosemodGMSettings', JSON.stringify(gmSettings));
};
goosemodScope.settings.createItem(goosemodScope.i18n.discordStrings.SETTINGS, ['',
{
type: 'header',
text: 'Settings'
},
{
type: 'toggle',
text: 'GooseMod Change Log',
subtext: 'Show GooseMod "Change Log" setting',
onToggle: (c) => changeSetting('changelog', c),
isToggled: () => gmSettings['changelog']
},
{
type: 'toggle',
text: 'Main Separators',
subtext: 'Show separators between main GooseMod settings',
onToggle: (c) => changeSetting('separators', c),
isToggled: () => gmSettings['separators']
},
{
type: 'header',
text: 'Internals'
},
{
type: 'toggle',
text: '🧪 Development Channel',
subtext: 'Use experimental development GooseMod builds',
onToggle: (c) => changeSetting('devchannel', c),
isToggled: () => gmSettings['devchannel']
},
{
type: 'text-and-danger-button',
text: 'Reset GooseMod',
subtext: 'Resets GooseMod completely: removes all preferences and modules; like a first-time install',
buttonText: 'Reset',
onClick: async () => {
if (await goosemodScope.confirmDialog('Reset', 'Reset GooseMod', 'Confirming will completely reset GooseMod, removing all preferences and modules. It will be like a new install.')) {
goosemodScope.remove();
window.location.reload();
}
}
}
]);
if (gmSettings.separators) goosemodScope.settings.createSeparator();
const updateModuleStoreUI = (parentEl, cards) => {
const inp = parentEl.querySelector('[contenteditable=true]').innerText.replace('\n', '');
@ -1802,9 +1922,13 @@ export const makeGooseModSettings = () => {
}
]));
goosemodScope.settings.createItem(goosemodScope.i18n.discordStrings.CHANGE_LOG, [""], async () => {
GoosemodChangelog.show();
});
if (gmSettings.changelog) {
if (gmSettings.separators) goosemodScope.settings.createSeparator();
goosemodScope.settings.createItem(goosemodScope.i18n.discordStrings.CHANGE_LOG, [""], async () => {
GoosemodChangelog.show();
});
}
/* goosemodScope.settings.createItem('Uninstall', [""], async () => {
if (await goosemodScope.confirmDialog('Uninstall', 'Uninstall GooseMod', 'Are you sure you want to uninstall GooseMod? This is a quick uninstall, it may leave some code behind but there should be no remaining noticable changes.')) {
@ -1830,6 +1954,10 @@ export const makeGooseModSettings = () => {
goosemodScope.settings.createHeading(goosemodScope.i18n.goosemodStrings.settings.itemNames.goosemodModules);
console.log(goosemodScope.settings.items, oldItems);
goosemodScope.settings.items = goosemodScope.settings.items.concat(oldItems);
addToContextMenu();
};
@ -1850,6 +1978,7 @@ const addToContextMenu = () => {
goosemodScope.settingsUninjects.push(goosemodScope.patcher.contextMenu.patch('user-settings-cog', {
label: 'GooseMod',
sub: [
basicSettingItem(goosemodScope.i18n.discordStrings.SETTINGS),
basicSettingItem(goosemodScope.i18n.goosemodStrings.settings.itemNames.plugins),
basicSettingItem(goosemodScope.i18n.goosemodStrings.settings.itemNames.themes),
basicSettingItem(goosemodScope.i18n.discordStrings.CHANGE_LOG)

Loading…
Cancel
Save