1
0
mirror of https://github.com/zumbiepig/MineXLauncher.git synced 2025-06-08 04:34:47 +00:00
This commit is contained in:
zumbiepig 2024-09-01 16:11:00 -07:00
parent 0a58472584
commit dd0b28c755
No known key found for this signature in database
GPG Key ID: 17C891BE28B953DE
20 changed files with 75 additions and 96 deletions

View File

@ -1,11 +1,6 @@
# MineXLauncher
## Variables to update when changing version number
- `cacheVersion` in [sw.ts](/src/sw.ts) and [sw-full.ts](/src/sw-full.ts)
- `launcherVersion` in [main.ts](/src/resources/scripts/main.ts)
- Changelog in [main.ts](/src/resources/scripts/main.ts)
- Changelog on [updates page](/public/updates/index.html)
### Update data in [updates.json](/public/resources/data/updates.json)
## Client versions

View File

@ -3,7 +3,9 @@ import tseslint from 'typescript-eslint';
export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.eslintRecommended,
...tseslint.configs.strict,
// ...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
languageOptions: {

View File

@ -17,7 +17,7 @@
</div>
<div class="launcher">
<div class="title-bar">
<span>MineXLauncher 1.5</span>
<span id="title-bar-text">MineXLauncher</span>
</div>
<div class="content">
<div class="main-panel">

View File

@ -16,7 +16,7 @@
</div>
<div class="launcher">
<div class="title-bar">
<span>MineXLauncher 1.6.0</span>
<span id="title-bar-text">MineXLauncher</span>
</div>
<div class="content">
<div class="sidebar">

View File

@ -16,7 +16,7 @@
</div>
<div class="launcher">
<div class="title-bar">
<span>MineXLauncher 1.6.0</span>
<span id="title-bar-text">MineXLauncher</span>
</div>
<div class="content">
<div class="sidebar">

View File

@ -16,7 +16,7 @@
</div>
<div class="launcher">
<div class="title-bar">
<span>MineXLauncher 1.6.0</span>
<span id="title-bar-text">MineXLauncher</span>
</div>
<div class="content">
<div class="sidebar">

View File

@ -16,7 +16,7 @@
</div>
<div class="launcher">
<div class="title-bar">
<span>MineXLauncher 1.6.0</span>
<span id="title-bar-text">MineXLauncher</span>
</div>
<div class="content">
<div class="sidebar">

View File

@ -16,7 +16,7 @@
/>
<meta property="og:title" content="MineXLauncher" />
<meta property="og:type" content="website" />
<meta property="og:image" content="/resources/images/icons/favicon.webp" />
<meta property="og:image" content="/resources/images/icons/minexlauncher.webp" />
<meta property="og:url" content="https://launcher.orionzleon.me/" />
<meta property="og:description" content="MineXLauncher is a custom launcher for Eaglercraft that has many versions and clients." />
<meta property="og:locale" content="en-US" />

View File

@ -13,7 +13,7 @@
<body>
<div class="launcher">
<div class="title-bar">
<span>MineXLauncher 1.6.0</span>
<span id="title-bar-text">MineXLauncher</span>
</div>
<div class="content">
<div class="sidebar">

View File

@ -16,7 +16,7 @@
</div>
<div class="launcher">
<div class="title-bar">
<span>MineXLauncher 1.6.0</span>
<span id="title-bar-text">MineXLauncher</span>
</div>
<div class="content">
<div class="sidebar">

View File

@ -16,7 +16,7 @@
</div>
<div class="launcher">
<div class="title-bar">
<span>MineXLauncher 1.6.0</span>
<span id="title-bar-text">MineXLauncher</span>
</div>
<div class="content">
<div class="sidebar">

View File

@ -17,7 +17,7 @@
</div>
<div class="launcher">
<div class="title-bar">
<span>MineXLauncher 1.6.0</span>
<span id="title-bar-text">MineXLauncher</span>
</div>
<div class="content">
<div class="main-panel">

View File

@ -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!"
]

View File

@ -16,7 +16,7 @@
</div>
<div class="launcher">
<div class="title-bar">
<span>MineXLauncher 1.6.0</span>
<span id="title-bar-text">MineXLauncher</span>
</div>
<div class="content">
<div class="sidebar">

View File

@ -16,7 +16,7 @@
</div>
<div class="launcher">
<div class="title-bar">
<span>MineXLauncher 1.6.0</span>
<span id="title-bar-text">MineXLauncher</span>
</div>
<div class="content">
<div class="sidebar">

View File

@ -16,7 +16,7 @@
</div>
<div class="launcher">
<div class="title-bar">
<span>MineXLauncher 1.6.0</span>
<span id="title-bar-text">MineXLauncher</span>
</div>
<div class="content">
<div class="sidebar">

View File

@ -14,7 +14,7 @@
<body>
<div class="launcher">
<div class="title-bar">
<span>MineXLauncher 1.6.0</span>
<span id="title-bar-text">MineXLauncher</span>
</div>
<div class="content">
<div class="main-panel">

View File

@ -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 = `<div class="mod-icon"><img loading="lazy" src="/resources/mods/icons/${mod.id}.webp" /></div><div class="mod-details"><h3 class="mod-name">${mod.name}</h3><p class="mod-author">By <a href="${mod.authorLink}" target="_blank">${mod.author}</a></p><p class="mod-description">${mod.description}</p><div class="mod-links"><a href="${mod.source}" class="mod-link" target="_blank">Source</a><a href="/resources/mods/downloads/${mod.id}.${modExt}" class="mod-link" download>Download</a></div></div>`;
@ -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]);
}

View File

@ -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) => {

View File

@ -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})`);
}