diff --git a/public/home/archive/index.html b/public/home/archive/index.html
index 6012dff..f00216a 100644
--- a/public/home/archive/index.html
+++ b/public/home/archive/index.html
@@ -16,7 +16,7 @@
- MineXLauncher 1.6.0
+ MineXLauncher
diff --git a/public/home/clients/index.html b/public/home/clients/index.html
index 51b22ea..d8d3e01 100644
--- a/public/home/clients/index.html
+++ b/public/home/clients/index.html
@@ -16,7 +16,7 @@
- MineXLauncher 1.6.0
+ MineXLauncher
diff --git a/public/home/downloads/index.html b/public/home/downloads/index.html
index 477a17e..1765b17 100644
--- a/public/home/downloads/index.html
+++ b/public/home/downloads/index.html
@@ -16,7 +16,7 @@
- MineXLauncher 1.6.0
+ MineXLauncher
diff --git a/public/home/game/index.html b/public/home/game/index.html
index 823676f..643e682 100644
--- a/public/home/game/index.html
+++ b/public/home/game/index.html
@@ -16,7 +16,7 @@
- MineXLauncher 1.6.0
+ MineXLauncher
diff --git a/public/index.html b/public/index.html
index e1edd88..e570c26 100644
--- a/public/index.html
+++ b/public/index.html
@@ -16,7 +16,7 @@
/>
-
+
diff --git a/public/mobile/index.html b/public/mobile/index.html
index 679bcd6..fd44a5d 100644
--- a/public/mobile/index.html
+++ b/public/mobile/index.html
@@ -13,7 +13,7 @@
- MineXLauncher 1.6.0
+ MineXLauncher
diff --git a/public/mods/mods/index.html b/public/mods/mods/index.html
index 1c27279..2a00007 100644
--- a/public/mods/mods/index.html
+++ b/public/mods/mods/index.html
@@ -16,7 +16,7 @@
- MineXLauncher 1.6.0
+ MineXLauncher
diff --git a/public/mods/resourcepacks/index.html b/public/mods/resourcepacks/index.html
index d9422c8..5ee2e27 100644
--- a/public/mods/resourcepacks/index.html
+++ b/public/mods/resourcepacks/index.html
@@ -16,7 +16,7 @@
- MineXLauncher 1.6.0
+ MineXLauncher
diff --git a/public/offline.html b/public/offline.html
index 9ebc3c1..881e9a6 100644
--- a/public/offline.html
+++ b/public/offline.html
@@ -17,7 +17,7 @@
- MineXLauncher 1.6.0
+ MineXLauncher
diff --git a/public/resources/data/updates.json b/public/resources/data/updates.json
index 67cc5c6..3b71d61 100644
--- a/public/resources/data/updates.json
+++ b/public/resources/data/updates.json
@@ -1,18 +1,18 @@
[
{
- "version": "1.6.0",
+ "version": "1.6",
"changelog": [
"You can now install mods directly from the mods list"
]
},
{
- "version": "1.5.0",
+ "version": "1.5",
"changelog": [
"You can now install the launcher as a PWA web app"
]
},
{
- "version": "1.4.0",
+ "version": "1.4",
"changelog": [
"Added Starlike Client",
"Added welcome and setup screen",
@@ -24,14 +24,14 @@
]
},
{
- "version": "1.3.0",
+ "version": "1.3",
"changelog": [
"Redesigned archive page",
"Added offline page"
]
},
{
- "version": "1.2.0",
+ "version": "1.2",
"changelog": [
"Added Eaglercraft 1.2.5",
"Added more mods and resource packs",
@@ -39,7 +39,7 @@
]
},
{
- "version": "1.1.0",
+ "version": "1.1",
"changelog": [
"Added a mods and resource packs list",
"Temporary workaround for keyboard not working in the game",
@@ -51,7 +51,7 @@
]
},
{
- "version": "1.0.0",
+ "version": "1.0",
"changelog": [
"Major rewrite, check it out yourself!"
]
diff --git a/public/servers/index.html b/public/servers/index.html
index 2a47565..a0caa4d 100644
--- a/public/servers/index.html
+++ b/public/servers/index.html
@@ -16,7 +16,7 @@
- MineXLauncher 1.6.0
+ MineXLauncher
diff --git a/public/settings/index.html b/public/settings/index.html
index a0fa7d9..78bbe33 100644
--- a/public/settings/index.html
+++ b/public/settings/index.html
@@ -16,7 +16,7 @@
- MineXLauncher 1.6.0
+ MineXLauncher
diff --git a/public/updates/index.html b/public/updates/index.html
index 0df55ab..d2a38b0 100644
--- a/public/updates/index.html
+++ b/public/updates/index.html
@@ -16,7 +16,7 @@
- MineXLauncher 1.6.0
+ MineXLauncher
diff --git a/public/welcome/index.html b/public/welcome/index.html
index 7f17293..e2da8fe 100644
--- a/public/welcome/index.html
+++ b/public/welcome/index.html
@@ -14,7 +14,7 @@
- MineXLauncher 1.6.0
+ MineXLauncher
diff --git a/src/resources/scripts/main.ts b/src/resources/scripts/main.ts
index 17c155c..d567c01 100644
--- a/src/resources/scripts/main.ts
+++ b/src/resources/scripts/main.ts
@@ -1,10 +1,6 @@
-import { SemVer, gt } from 'semver';
+import { gt, coerce } from 'semver';
-let selectedVersion: string | undefined;
-
-// Update `cacheVersion` in sw.js too
-const launcherVersion: SemVer = new SemVer('1.6.0-beta.1');
-const releaseNotes = ['You can now install mods directly from the mods list'];
+let selectedVersion: string;
const theme = {
load: function (themeToLoad?: string) {
@@ -14,7 +10,7 @@ const theme = {
themeElement.href = `/resources/styles/themes/${themeToLoad}.css`;
} else {
const savedTheme = storage.local.get('theme');
- if (savedTheme !== null) {
+ if (savedTheme) {
themeElement.href = `/resources/styles/themes/${savedTheme}.css`;
}
}
@@ -157,8 +153,8 @@ const navigate = {
},
};
-const cookie = {
- set: function (key: string, value: string, days: number) {
+/*const cookie = {
+ set: function (key: string, value: string | number | object | [] | boolean | null | undefined, days: number) {
let maxAge;
if (days) {
maxAge = days * 60 * 60 * 24;
@@ -167,20 +163,19 @@ const cookie = {
}
document.cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)}; Max-Age=${maxAge}; Path=/; SameSite=Lax; Secure`;
},
- get: function (key: string): string | null {
+ get: function (key: string) {
for (const cookie of document.cookie.split('; ')) {
const cookiePair = cookie.split('=');
if (encodeURIComponent(key) === cookiePair[0]) {
- // @ts-expect-error
return decodeURIComponent(cookiePair[1]);
}
}
- return null;
+ return undefined;
},
delete: function (key: string) {
document.cookie = `${encodeURIComponent(key)}=; Max-Age=0; Path=/`;
},
-};
+};*/
const storage = {
local: {
@@ -190,14 +185,12 @@ const storage = {
const json = JSON.parse(item);
if (json[key] !== undefined) {
return json[key];
- } else {
- return null;
}
- } else {
- return null;
+ return undefined;
}
+ return undefined;
},
- set: function (key: string, value: string | number | object | [] | boolean | null) {
+ set: function (key: string, value: string | number | object | boolean | null | undefined) {
let item = localStorage.getItem('minexlauncher');
if (item === null) {
item = '{}';
@@ -206,14 +199,6 @@ const storage = {
json[key] = value;
localStorage.setItem('minexlauncher', JSON.stringify(json));
},
- delete: function (key: string) {
- const item = localStorage.getItem('minexlauncher');
- if (item !== null) {
- const json = JSON.parse(item);
- json[key] = undefined;
- localStorage.setItem('minexlauncher', JSON.stringify(json));
- }
- },
},
session: {
get: function (key: string) {
@@ -222,14 +207,12 @@ const storage = {
const json = JSON.parse(item);
if (json[key] !== undefined) {
return json[key];
- } else {
- return null;
}
- } else {
- return null;
+ return undefined;
}
+ return undefined;
},
- set: function (key: string, value: string | number | object | [] | boolean | null) {
+ set: function (key: string, value: string | number | object | boolean | null | undefined) {
let item = sessionStorage.getItem('minexlauncher');
if (item === null) {
item = '{}';
@@ -238,14 +221,6 @@ const storage = {
json[key] = value;
sessionStorage.setItem('minexlauncher', JSON.stringify(json));
},
- delete: function (key: string) {
- const item = sessionStorage.getItem('minexlauncher');
- if (item !== null) {
- const json = JSON.parse(item);
- json[key] = undefined;
- sessionStorage.setItem('minexlauncher', JSON.stringify(json));
- }
- },
},
};
@@ -322,15 +297,24 @@ const serviceworker = {
},
};
+theme.load();
+
+if (detect.mobile()) {
+ const link = document.createElement('link');
+ link.rel = 'stylesheet';
+ link.href = '/resources/styles/mobile.css';
+ document.head.appendChild(link);
+}
+
if (window.location.pathname === '/') {
const lastPage = storage.session.get('lastPage');
const isMobile = detect.mobile();
const iframe = document.createElement('iframe');
iframe.id = 'main_frame';
- if (storage.local.get('lastVersion') === null) {
+ if (!storage.local.get('lastVersion')) {
iframe.src = '/welcome/';
- } else if (lastPage !== null) {
+ } else if (lastPage && typeof lastPage === 'string') {
iframe.src = lastPage;
} else if (isMobile) {
iframe.src = '/mobile/';
@@ -349,7 +333,7 @@ if (window.location.pathname === '/') {
}
});
- /* if (storage.local.get('offlineCache') === true) {
+ /* if (storage.local.get('offlineCache')) {
serviceworker.register('/sw-full.js');
} else {
serviceworker.register('/sw.js');
@@ -374,32 +358,30 @@ if (window.location.pathname === '/') {
}
});
}
-
- document.addEventListener('DOMContentLoaded', () => {
+ document.addEventListener('DOMContentLoaded', async () => {
const profileName = document.getElementById('profile-name');
if (profileName) {
profileName.textContent = storage.local.get('username');
}
+
+ const titleBarText = document.getElementById('title-bar-text');
+ if (titleBarText) {
+ titleBarText.textContent += ` ${(await (await fetch('/resources/data/updates.json')).json())[0].version}`;
+ }
});
- document.addEventListener('DOMContentLoaded', () => {
+ document.addEventListener('DOMContentLoaded', async () => {
const lastVersion = storage.local.get('lastVersion');
- if (lastVersion !== null && gt(launcherVersion, lastVersion)) {
- alert(`MineXLauncher has been updated to v${launcherVersion}!\n\nChanges in v${launcherVersion}:\n${releaseNotes.map((item) => ` - ${item}`).join('\n')}`);
- storage.local.set('lastVersion', launcherVersion);
+ const currentVersion = (await (await fetch('/resources/data/updates.json')).json())[0].version;
+ const changelog = (await (await fetch('/resources/data/updates.json')).json())[0].changelog.map((change: string) => ` - ${change}`).join('\n');
+ // @ts-expect-error
+ if (lastVersion && gt(coerce(currentVersion, { includePrerelease: true }), coerce(lastVersion, { includePrerelease: true }))) {
+ alert(`MineXLauncher has been updated to v${currentVersion}!\n\nChanges in v${currentVersion}:\n${changelog}`);
+ storage.local.set('lastVersion', currentVersion);
}
});
}
-if (detect.mobile()) {
- const link = document.createElement('link');
- link.rel = 'stylesheet';
- link.href = '/resources/styles/mobile.css';
- document.head.appendChild(link);
-}
-
-theme.load();
-
if (window.location.pathname === '/settings/') {
document.addEventListener('DOMContentLoaded', () => {
const profileName = document.getElementById('profile-name');
@@ -463,7 +445,7 @@ if (window.location.pathname === '/settings/') {
theme.load(themeSelect.value);
});
- setupForm.addEventListener('submit', (event) => {
+ setupForm.addEventListener('submit', async (event) => {
event.preventDefault();
let username = usernameInput.value.replace(/[^A-Za-z0-9]/g, '_').substring(0, 16);
@@ -482,7 +464,7 @@ if (window.location.pathname === '/settings/') {
// storage.local.set('offlineCache', offlineCheckbox.checked);
storage.local.set('showAds', true);
storage.local.set('mods', []);
- storage.local.set('lastVersion', launcherVersion);
+ storage.local.set('lastVersion', (await (await fetch('/resources/data/updates.json')).json())[0].version);
/* if (offlineCheckbox.checked) {
serviceworker.register('/sw-full.js');
@@ -519,8 +501,8 @@ if (window.location.pathname === '/settings/') {
break;
}
- const mods = await (await fetch('/resources/data/mods.json')).json();
- mods[modType].forEach((mod: { id: string; name: string; description: string; author: string; authorLink: string; source: string }) => {
+ const modData = await (await fetch('/resources/data/mods.json')).json();
+ modData[modType].forEach((mod: { id: string; name: string; description: string; author: string; authorLink: string; source: string }) => {
const modItem = document.createElement('div');
modItem.classList.add('mod-item');
modItem.innerHTML = `
`;
@@ -532,9 +514,8 @@ if (window.location.pathname === '/settings/') {
} else if (window.location.pathname === '/updates/') {
document.addEventListener('DOMContentLoaded', async () => {
const updatesContainer = document.getElementById('updates-container');
- const updates = await (await fetch('/resources/data/updates.json')).json();
-
- updates.forEach((update: { version: string; changelog: string[] }) => {
+ const updateData: { version: string; changelog: string[] }[] = await (await fetch('/resources/data/updates.json')).json();
+ updateData.forEach((update) => {
const versionHeader = document.createElement('strong');
versionHeader.textContent = `MineXLauncher ${update.version}`;
updatesContainer?.appendChild(versionHeader);
@@ -553,5 +534,5 @@ if (window.location.pathname === '/settings/') {
if (window.location.hostname === null) {
// Stop the minifier from removing these functions
- console.debug([navigate, cookie, query, versionSelector, game, mods]);
+ console.debug([navigate, query, versionSelector, game, mods]);
}
diff --git a/src/sw-full.ts b/src/sw-full.ts
index 2427c10..12b34e5 100644
--- a/src/sw-full.ts
+++ b/src/sw-full.ts
@@ -1,5 +1,5 @@
// @ts-nocheck
-const cacheVersion = '1.6.0';
+const cacheVersion = '1.6';
const cacheName = `minexlauncher-full-v${cacheVersion}`;
self.addEventListener('install', (event) => {
diff --git a/src/sw.ts b/src/sw.ts
index 3edca29..ff9b655 100644
--- a/src/sw.ts
+++ b/src/sw.ts
@@ -1,8 +1,8 @@
// @ts-nocheck
-const cacheVersion = '1.6.0';
+const cacheVersion = '1.6';
const cacheName = `minexlauncher-v${cacheVersion}`;
const offlineUrl = '/offline.html';
-const cacheAssets = [
+const cacheAssets: string[] = [
offlineUrl,
'/resources/images/icons/favicon.webp',
'/resources/scripts/google-tag.js',
@@ -35,7 +35,8 @@ self.addEventListener('install', (event) => {
for (const asset of cacheAssets) {
await cache.add(asset);
- const progress = `${++cachedAssets}/${totalAssets}`;
+ ++cachedAssets;
+ const progress = `${cachedAssets.toString()}/${totalAssets.toString()}`;
console.log(`Cached: ${asset} (${progress})`);
}
