mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 11:42:14 -08:00
Compare commits
2 Commits
f119985211
...
c6221e2afe
Author | SHA1 | Date | |
---|---|---|---|
|
c6221e2afe | ||
|
f0121e9597 |
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
||||
- name: Install Node.js, NPM and Yarn
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 14
|
||||
|
||||
- name: Build/release Electron app
|
||||
uses: samuelmeuli/action-electron-builder@v1
|
||||
|
@ -83,7 +83,7 @@ This section details the setup of a basic developmentment environment.
|
||||
|
||||
**System Requirements**
|
||||
|
||||
* [Node.js][nodejs] v16
|
||||
* [Node.js][nodejs] v14
|
||||
|
||||
---
|
||||
|
||||
|
@ -5,7 +5,6 @@ const child_process = require('child_process')
|
||||
const crypto = require('crypto')
|
||||
const EventEmitter = require('events')
|
||||
const fs = require('fs-extra')
|
||||
const StreamZip = require('node-stream-zip')
|
||||
const path = require('path')
|
||||
const Registry = require('winreg')
|
||||
const request = require('request')
|
||||
@ -223,6 +222,42 @@ class JavaGuard extends EventEmitter {
|
||||
this.mcVersion = mcVersion
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @typedef OracleJREData
|
||||
// * @property {string} uri The base uri of the JRE.
|
||||
// * @property {{major: string, update: string, build: string}} version Object containing version information.
|
||||
// */
|
||||
|
||||
// /**
|
||||
// * Resolves the latest version of Oracle's JRE and parses its download link.
|
||||
// *
|
||||
// * @returns {Promise.<OracleJREData>} Promise which resolved to an object containing the JRE download data.
|
||||
// */
|
||||
// static _latestJREOracle(){
|
||||
|
||||
// const url = 'https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html'
|
||||
// const regex = /https:\/\/.+?(?=\/java)\/java\/jdk\/([0-9]+u[0-9]+)-(b[0-9]+)\/([a-f0-9]{32})?\/jre-\1/
|
||||
|
||||
// return new Promise((resolve, reject) => {
|
||||
// request(url, (err, resp, body) => {
|
||||
// if(!err){
|
||||
// const arr = body.match(regex)
|
||||
// const verSplit = arr[1].split('u')
|
||||
// resolve({
|
||||
// uri: arr[0],
|
||||
// version: {
|
||||
// major: verSplit[0],
|
||||
// update: verSplit[1],
|
||||
// build: arr[2]
|
||||
// }
|
||||
// })
|
||||
// } else {
|
||||
// resolve(null)
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
|
||||
/**
|
||||
* @typedef OpenJDKData
|
||||
* @property {string} uri The base uri of the JRE.
|
||||
@ -246,41 +281,30 @@ class JavaGuard extends EventEmitter {
|
||||
if(process.platform === 'darwin') {
|
||||
return this._latestCorretto(major)
|
||||
} else {
|
||||
return this._latestAdoptium(major)
|
||||
return this._latestAdoptOpenJDK(major)
|
||||
}
|
||||
}
|
||||
|
||||
static _latestAdoptium(major) {
|
||||
static _latestAdoptOpenJDK(major) {
|
||||
|
||||
const majorNum = Number(major)
|
||||
const sanitizedOS = process.platform === 'win32' ? 'windows' : (process.platform === 'darwin' ? 'mac' : process.platform)
|
||||
const url = `https://api.adoptium.net/v3/assets/latest/${major}/hotspot?vendor=eclipse`
|
||||
|
||||
const url = `https://api.adoptopenjdk.net/v2/latestAssets/nightly/openjdk${major}?os=${sanitizedOS}&arch=x64&heap_size=normal&openjdk_impl=hotspot&type=jre`
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
request({url, json: true}, (err, resp, body) => {
|
||||
if(!err && body.length > 0){
|
||||
|
||||
const targetBinary = body.find(entry => {
|
||||
return entry.version.major === majorNum
|
||||
&& entry.binary.os === sanitizedOS
|
||||
&& entry.binary.image_type === 'jdk'
|
||||
&& entry.binary.architecture === 'x64'
|
||||
resolve({
|
||||
uri: body[0].binary_link,
|
||||
size: body[0].binary_size,
|
||||
name: body[0].binary_name
|
||||
})
|
||||
|
||||
if(targetBinary != null) {
|
||||
resolve({
|
||||
uri: targetBinary.binary.package.link,
|
||||
size: targetBinary.binary.package.size,
|
||||
name: targetBinary.binary.package.name
|
||||
})
|
||||
} else {
|
||||
resolve(null)
|
||||
}
|
||||
} else {
|
||||
resolve(null)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
static _latestCorretto(major) {
|
||||
@ -815,7 +839,6 @@ class JavaGuard extends EventEmitter {
|
||||
pathSet1 = new Set([
|
||||
...pathSet1,
|
||||
...(await JavaGuard._scanFileSystem('C:\\Program Files\\Java')),
|
||||
...(await JavaGuard._scanFileSystem('C:\\Program Files\\Eclipse Foundation')),
|
||||
...(await JavaGuard._scanFileSystem('C:\\Program Files\\AdoptOpenJDK'))
|
||||
])
|
||||
}
|
||||
@ -1560,7 +1583,21 @@ class AssetGuard extends EventEmitter {
|
||||
this.java = new DLTracker([jre], jre.size, (a, self) => {
|
||||
if(verData.name.endsWith('zip')){
|
||||
|
||||
this._extractJdkZip(a.to, dataDir, self)
|
||||
const zip = new AdmZip(a.to)
|
||||
const pos = path.join(dataDir, zip.getEntries()[0].entryName)
|
||||
zip.extractAllToAsync(dataDir, true, (err) => {
|
||||
if(err){
|
||||
console.log(err)
|
||||
self.emit('complete', 'java', JavaGuard.javaExecFromRoot(pos))
|
||||
} else {
|
||||
fs.unlink(a.to, err => {
|
||||
if(err){
|
||||
console.log(err)
|
||||
}
|
||||
self.emit('complete', 'java', JavaGuard.javaExecFromRoot(pos))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
// Tar.gz
|
||||
@ -1601,31 +1638,67 @@ class AssetGuard extends EventEmitter {
|
||||
|
||||
}
|
||||
|
||||
async _extractJdkZip(zipPath, runtimeDir, self) {
|
||||
|
||||
const zip = new StreamZip.async({
|
||||
file: zipPath,
|
||||
storeEntries: true
|
||||
})
|
||||
// _enqueueOracleJRE(dataDir){
|
||||
// return new Promise((resolve, reject) => {
|
||||
// JavaGuard._latestJREOracle().then(verData => {
|
||||
// if(verData != null){
|
||||
|
||||
let pos = ''
|
||||
try {
|
||||
const entries = await zip.entries()
|
||||
pos = path.join(runtimeDir, Object.keys(entries)[0])
|
||||
// const combined = verData.uri + PLATFORM_MAP[process.platform]
|
||||
|
||||
// const opts = {
|
||||
// url: combined,
|
||||
// headers: {
|
||||
// 'Cookie': 'oraclelicense=accept-securebackup-cookie'
|
||||
// }
|
||||
// }
|
||||
|
||||
// request.head(opts, (err, resp, body) => {
|
||||
// if(err){
|
||||
// resolve(false)
|
||||
// } else {
|
||||
// dataDir = path.join(dataDir, 'runtime', 'x64')
|
||||
// const name = combined.substring(combined.lastIndexOf('/')+1)
|
||||
// const fDir = path.join(dataDir, name)
|
||||
// const jre = new Asset(name, null, parseInt(resp.headers['content-length']), opts, fDir)
|
||||
// this.java = new DLTracker([jre], jre.size, (a, self) => {
|
||||
// let h = null
|
||||
// fs.createReadStream(a.to)
|
||||
// .on('error', err => console.log(err))
|
||||
// .pipe(zlib.createGunzip())
|
||||
// .on('error', err => console.log(err))
|
||||
// .pipe(tar.extract(dataDir, {
|
||||
// map: (header) => {
|
||||
// if(h == null){
|
||||
// h = header.name
|
||||
// }
|
||||
// }
|
||||
// }))
|
||||
// .on('error', err => console.log(err))
|
||||
// .on('finish', () => {
|
||||
// fs.unlink(a.to, err => {
|
||||
// if(err){
|
||||
// console.log(err)
|
||||
// }
|
||||
// if(h.indexOf('/') > -1){
|
||||
// h = h.substring(0, h.indexOf('/'))
|
||||
// }
|
||||
// const pos = path.join(dataDir, h)
|
||||
// self.emit('complete', 'java', JavaGuard.javaExecFromRoot(pos))
|
||||
// })
|
||||
// })
|
||||
|
||||
// })
|
||||
// resolve(true)
|
||||
// }
|
||||
// })
|
||||
|
||||
console.log('Extracting jdk..')
|
||||
await zip.extract(null, runtimeDir)
|
||||
console.log('Cleaning up..')
|
||||
await fs.remove(zipPath)
|
||||
console.log('Jdk extraction complete.')
|
||||
// } else {
|
||||
// resolve(false)
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
|
||||
} catch(err) {
|
||||
console.log(err)
|
||||
} finally {
|
||||
zip.close()
|
||||
self.emit('complete', 'java', JavaGuard.javaExecFromRoot(pos))
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
// _enqueueMojangJRE(dir){
|
||||
// return new Promise((resolve, reject) => {
|
||||
|
@ -4,8 +4,7 @@
|
||||
// Requirements
|
||||
const cp = require('child_process')
|
||||
const crypto = require('crypto')
|
||||
const { URL } = require('url')
|
||||
const { getServerStatus } = require('helios-core')
|
||||
const {URL} = require('url')
|
||||
|
||||
// Internal Requirements
|
||||
const DiscordWrapper = require('./assets/js/discordwrapper')
|
||||
@ -226,11 +225,11 @@ const refreshServerStatus = async function(fade = false){
|
||||
|
||||
try {
|
||||
const serverURL = new URL('my://' + serv.getAddress())
|
||||
|
||||
const servStat = await getServerStatus(47, serverURL.hostname, Number(serverURL.port))
|
||||
console.log(servStat)
|
||||
pLabel = 'PLAYERS'
|
||||
pVal = servStat.players.online + '/' + servStat.players.max
|
||||
const servStat = await ServerStatus.getStatus(serverURL.hostname, serverURL.port)
|
||||
if(servStat.online){
|
||||
pLabel = 'PLAYERS'
|
||||
pVal = servStat.onlinePlayers + '/' + servStat.maxPlayers
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
loggerLanding.warn('Unable to refresh server status, assuming offline.')
|
||||
@ -324,7 +323,7 @@ function asyncSystemScan(mcVersion, launchAfter = true){
|
||||
// Show this information to the user.
|
||||
setOverlayContent(
|
||||
'No Compatible<br>Java Installation Found',
|
||||
'In order to join WesterosCraft, you need a 64-bit installation of Java 8. Would you like us to install a copy?',
|
||||
'In order to join WesterosCraft, you need a 64-bit installation of Java 8. Would you like us to install a copy? By installing, you accept <a href="http://www.oracle.com/technetwork/java/javase/terms/license/index.html">Oracle\'s license agreement</a>.',
|
||||
'Install Java',
|
||||
'Install Manually'
|
||||
)
|
||||
|
@ -85,7 +85,7 @@ bindFileSelectors()
|
||||
/**
|
||||
* Bind value validators to the settings UI elements. These will
|
||||
* validate against the criteria defined in the ConfigManager (if
|
||||
* any). If the value is invalid, the UI will reflect this and saving
|
||||
* and). If the value is invalid, the UI will reflect this and saving
|
||||
* will be disabled until the value is corrected. This is an automated
|
||||
* process. More complex UI may need to be bound separately.
|
||||
*/
|
||||
|
10
index.js
10
index.js
@ -1,5 +1,4 @@
|
||||
const remoteMain = require('@electron/remote/main')
|
||||
remoteMain.initialize()
|
||||
require('@electron/remote/main').initialize()
|
||||
|
||||
// Requirements
|
||||
const { app, BrowserWindow, ipcMain, Menu } = require('electron')
|
||||
@ -88,6 +87,9 @@ ipcMain.on('distributionIndexDone', (event, res) => {
|
||||
// https://electronjs.org/docs/tutorial/offscreen-rendering
|
||||
app.disableHardwareAcceleration()
|
||||
|
||||
// https://github.com/electron/electron/issues/18397
|
||||
app.allowRendererProcessReuse = true
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
let win
|
||||
@ -102,11 +104,11 @@ function createWindow() {
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'app', 'assets', 'js', 'preloader.js'),
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
contextIsolation: false,
|
||||
enableRemoteModule: true
|
||||
},
|
||||
backgroundColor: '#171614'
|
||||
})
|
||||
remoteMain.enable(win.webContents)
|
||||
|
||||
ejse.data('bkid', Math.floor((Math.random() * fs.readdirSync(path.join(__dirname, 'app', 'assets', 'images', 'backgrounds')).length)))
|
||||
|
||||
|
6706
package-lock.json
generated
6706
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@ -20,30 +20,28 @@
|
||||
"lint": "eslint --config .eslintrc.json ."
|
||||
},
|
||||
"engines": {
|
||||
"node": "16.x.x"
|
||||
"node": "14.x.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"@electron/remote": "^2.0.1",
|
||||
"adm-zip": "^0.5.9",
|
||||
"async": "^3.2.1",
|
||||
"@electron/remote": "^1.2.0",
|
||||
"adm-zip": "^0.5.5",
|
||||
"async": "^3.2.0",
|
||||
"discord-rpc": "^3.2.0",
|
||||
"ejs": "^3.1.6",
|
||||
"ejs-electron": "^2.1.1",
|
||||
"electron-updater": "^4.3.9",
|
||||
"fs-extra": "^10.0.0",
|
||||
"github-syntax-dark": "^0.5.0",
|
||||
"helios-core": "^0.1.0-alpha.3",
|
||||
"jquery": "^3.6.0",
|
||||
"node-stream-zip": "^1.15.0",
|
||||
"request": "^2.88.2",
|
||||
"semver": "^7.3.5",
|
||||
"tar-fs": "^2.1.1",
|
||||
"winreg": "^1.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^15.2.0",
|
||||
"electron-builder": "^22.13.1",
|
||||
"eslint": "^8.0.1"
|
||||
"electron": "^13.1.4",
|
||||
"electron-builder": "^22.11.7",
|
||||
"eslint": "^7.29.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
Loading…
Reference in New Issue
Block a user