Many more fixes...
This commit is contained in:
@@ -653,10 +653,13 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u
|
||||
deleteAfter?: boolean,
|
||||
name?: string
|
||||
) {
|
||||
console.log("Starting install of APK", filePath, isLocal, shouldUninstall, number, total, deleteAfter, name)
|
||||
return this.processService.addItem(
|
||||
'apk_install',
|
||||
task => {
|
||||
if (this.deviceStatus !== ConnectionStatus.CONNECTED) {
|
||||
console.log("Task APK", filePath, isLocal, shouldUninstall, number, total, deleteAfter, name)
|
||||
|
||||
if (this.deviceStatus !== ConnectionStatus.CONNECTED) {
|
||||
return Promise.reject(name + 'Apk install failed - No device connected!');
|
||||
}
|
||||
const showTotal = number && total ? '(' + number + '/' + total + ') ' : '';
|
||||
|
||||
@@ -42,8 +42,6 @@ export class AppService {
|
||||
remote: any;
|
||||
electron: any;
|
||||
os: any;
|
||||
request: any;
|
||||
progress: any;
|
||||
Readable: any;
|
||||
opn: any;
|
||||
spawn: any;
|
||||
@@ -67,8 +65,6 @@ export class AppService {
|
||||
constructor(private spinnerService: LoadingSpinnerService, private router: Router) {
|
||||
this.path = (<any>window).require('path');
|
||||
this.fs = (<any>window).require('fs');
|
||||
this.request = (<any>window).require('request');
|
||||
this.progress = (<any>window).require('request-progress');
|
||||
this.os = (<any>window).require('os');
|
||||
this.Readable = (<any>window).require('stream').Readable;
|
||||
this.opn = (<any>window).require('opn');
|
||||
@@ -372,11 +368,13 @@ export class AppService {
|
||||
break;
|
||||
}
|
||||
let downloadPath = getPath(downloadUrl);
|
||||
return this.downloadFileAPI(downloadUrl, this.path.dirname(downloadPath), this.path.basename(downloadPath), task).then(
|
||||
return this.downloadFileAPI(downloadUrl, this.path.dirname(downloadPath), this.path.basename(downloadPath), {}, task).then(
|
||||
() => downloadPath
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
downloadFileAPI(url, directory, filename, task?) {
|
||||
downloadFileAPI(url, directory, filename, options, task?): Promise<string> {
|
||||
// Send request to application thread to download a file. Store the callback for the response.
|
||||
return new Promise((resolve, reject) => {
|
||||
let token = this.uuidv4();
|
||||
@@ -389,10 +387,29 @@ export class AppService {
|
||||
resolve,
|
||||
reject,
|
||||
};
|
||||
this.electron.ipcRenderer.send('download-url', { token, url, directory, filename });
|
||||
this.electron.ipcRenderer.send('download-url', { token, url, directory, filename, options });
|
||||
});
|
||||
}
|
||||
getUserAgent() {
|
||||
|
||||
uploadFileAPI(url, filename, options, task?): Promise<string> {
|
||||
// Send request to application thread to upload a file. Store the callback for the response.
|
||||
return new Promise((resolve, reject) => {
|
||||
let token = this.uuidv4();
|
||||
this.downloadResolves[token] = {
|
||||
scb: stats => {
|
||||
if (task) {
|
||||
task.status = (task.app_name ? task.app_name + ': ' : '') + 'Uploading... ' + stats + '%';
|
||||
}
|
||||
},
|
||||
resolve,
|
||||
reject,
|
||||
};
|
||||
this.electron.ipcRenderer.send('upload-url', { token, url, filename, options });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getUserAgent() {
|
||||
const nodeString = `NodeJs/${(<any>window).process.version}`;
|
||||
const packageString = 'OpenStoreVR';
|
||||
const computerString = `Hostname/${this.os.hostname()} Platform/${this.os.platform()} PlatformVersion/${this.os.release()}`;
|
||||
|
||||
@@ -19,51 +19,34 @@ export class AudicaService {
|
||||
|
||||
downloadSong(downloadUrl, adbService) {
|
||||
return this.processService.addItem('song_download', async (task) : Promise<void> => {
|
||||
let parts = downloadUrl.split('/');
|
||||
|
||||
let zipPath = this.appService.path.join(this.appService.appData, this.appService.path.basename(downloadUrl));
|
||||
let ws = this.appService.fs.createWriteStream(zipPath);
|
||||
const requestOptions = {
|
||||
timeout: 30000,
|
||||
'User-Agent': this.appService.getUserAgent(),
|
||||
useContentDispositionFilename: true
|
||||
};
|
||||
task.status = 'Saving to Audica...';
|
||||
return new Promise((resolve, reject) => {
|
||||
let request = this.appService
|
||||
.progress(this.appService.request(downloadUrl, requestOptions), { throttle: 50 })
|
||||
.on('error', error => {
|
||||
task.failed = true;
|
||||
task.status = 'Failed to save item... ' + error.toString();
|
||||
reject(error);
|
||||
})
|
||||
.on('progress', state => {
|
||||
task.status = 'Saving to Audica... ' + Math.round(state.percent * 100) + '%';
|
||||
})
|
||||
.on('response', response => {
|
||||
var regexp = /filename=\"(.*)\"/gi;
|
||||
var _regResult = regexp.exec(response.headers['content-disposition']);
|
||||
if (_regResult && _regResult.length) {
|
||||
zipPath = this.appService.path.join(this.appService.appData, _regResult[1]);
|
||||
}
|
||||
request.pipe(this.appService.fs.createWriteStream(zipPath));
|
||||
})
|
||||
.on('end', async () => {
|
||||
let ext = this.appService.path.extname(zipPath).toLowerCase();
|
||||
let basename = this.appService.path.basename(zipPath);
|
||||
await adbService.uploadFile(
|
||||
[
|
||||
{
|
||||
name: zipPath,
|
||||
savePath: '/sdcard/Audica/' + basename,
|
||||
},
|
||||
],
|
||||
task
|
||||
);
|
||||
task.status = 'Saved! ' + basename;
|
||||
this.appService.fs.unlink(zipPath, err => {
|
||||
if (err) console.warn(err);
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
this.appService.downloadFileAPI( downloadUrl, null, zipPath, requestOptions, task).then( async (fileName) => {
|
||||
let ext = this.appService.path.extname(fileName).toLowerCase();
|
||||
let basename = this.appService.path.basename(fileName);
|
||||
await adbService.uploadFile([ {
|
||||
name: fileName,
|
||||
savePath: '/sdcard/Audica/' + basename,
|
||||
}], task);
|
||||
task.status = 'Saved! ' + basename;
|
||||
this.appService.fs.unlink(fileName, err => {
|
||||
if (err) console.warn(err);
|
||||
});
|
||||
resolve();
|
||||
}).catch((error) => {
|
||||
task.failed = true;
|
||||
task.status = 'Failed to save item... ' + error.toString();
|
||||
reject(error);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ export class BeatOnService {
|
||||
let zipPath = this.appService.path.join(this.appService.appData, this.appService.uuidv4() + '.zip');
|
||||
const requestOptions = {
|
||||
timeout: 30000,
|
||||
'User-Agent': this.appService.getUserAgent(),
|
||||
'User-Agent': this.appService.getUserAgent()
|
||||
};
|
||||
task.status = 'Saving to BMBF...';
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -223,65 +223,19 @@ export class BeatOnService {
|
||||
this.beatOnPID &&
|
||||
this.beatOnStatus.CurrentStatus === 'ModInstalled'
|
||||
) {
|
||||
this.appService
|
||||
.progress(this.appService.request(downloadUrl, requestOptions), { throttle: 50 })
|
||||
.on('error', error => {
|
||||
task.failed = true;
|
||||
task.status = 'Failed to save song... ' + error.toString();
|
||||
reject(error);
|
||||
})
|
||||
.on('progress', state => {
|
||||
task.status = 'Saving to BMBF... ' + Math.round(state.percent * 100) + '%';
|
||||
})
|
||||
.on('end', () => {
|
||||
let formData = {
|
||||
file: {
|
||||
value: this.appService.fs.createReadStream(zipPath),
|
||||
options: {
|
||||
filename: parts[parts.length - 1],
|
||||
contentType: 'application/zip',
|
||||
},
|
||||
},
|
||||
};
|
||||
let options = {
|
||||
url: 'http://' + adbService.deviceIp + ':50000/host/beatsaber/upload',
|
||||
method: 'POST',
|
||||
formData: formData,
|
||||
};
|
||||
let timeoutCheck = setTimeout(() => {
|
||||
if (task.fail_once) {
|
||||
task.fail_once = false;
|
||||
task.failed = true;
|
||||
task.status = 'Failed to save song... Timeout';
|
||||
reject(task.status);
|
||||
} else {
|
||||
task.fail_once = true;
|
||||
task.running = false;
|
||||
task.status = 'Waiting...';
|
||||
resolve();
|
||||
}
|
||||
}, 30000);
|
||||
this.appService
|
||||
.progress(this.appService.request(options), { throttle: 50 })
|
||||
.on('error', error => {
|
||||
clearTimeout(timeoutCheck);
|
||||
task.failed = true;
|
||||
task.status = 'Failed to save song... ' + error.toString();
|
||||
reject(error);
|
||||
})
|
||||
.on('progress', state => {
|
||||
clearTimeout(timeoutCheck);
|
||||
task.status = 'Uploading To Beat On... ' + Math.round(state.percent * 100) + '%';
|
||||
})
|
||||
.on('end', () => {
|
||||
clearTimeout(timeoutCheck);
|
||||
this.appService.fs.unlink(zipPath, err => {
|
||||
task.status = 'Saved! ' + downloadUrl;
|
||||
resolve(parts[parts.length - 1].split('.')[0]);
|
||||
});
|
||||
});
|
||||
})
|
||||
.pipe(this.appService.fs.createWriteStream(zipPath));
|
||||
this.appService.downloadFileAPI( downloadUrl, null, zipPath, requestOptions, task).then( async (fileName) => {
|
||||
let url = 'http://' + adbService.deviceIp + ':50000/host/beatsaber/upload';
|
||||
return this.appService.uploadFileAPI( url, zipPath, {contentType: 'application/zip', fileName: parts[parts.length -1], method: "post"}, task).then( async () => {
|
||||
this.appService.fs.unlink(zipPath, err => {
|
||||
task.status = 'Saved! ' + downloadUrl;
|
||||
resolve(parts[parts.length - 1].split('.')[0]);
|
||||
});
|
||||
});
|
||||
}).catch((error) => {
|
||||
task.failed = true;
|
||||
task.status = 'Failed to save song... ' + error.toString();
|
||||
reject(error);
|
||||
});
|
||||
} else {
|
||||
reject(
|
||||
new Error(
|
||||
|
||||
@@ -64,7 +64,9 @@ export class ElectronService {
|
||||
}
|
||||
|
||||
async installFromToken(token) {
|
||||
console.log("Install from token", token)
|
||||
let res = await this.adbService.adbCommand('installFromToken', { token });
|
||||
console.log("IT: res", res)
|
||||
res.forEach((l, i) => {
|
||||
switch (l.type) {
|
||||
case 'Mod':
|
||||
@@ -121,6 +123,7 @@ export class ElectronService {
|
||||
}
|
||||
});
|
||||
this.appService.electron.ipcRenderer.on('open-url', async (event, data) => {
|
||||
console.log("Open URL", data);
|
||||
if (data) {
|
||||
let url = data.split('#');
|
||||
switch (url[0]) {
|
||||
@@ -143,6 +146,7 @@ export class ElectronService {
|
||||
this.adbService.uninstallAPK(url[1]);
|
||||
break;
|
||||
case 'sidequest://sideload-multi/':
|
||||
console.log("SQM", data)
|
||||
try {
|
||||
let urls = JSON.parse(
|
||||
data
|
||||
|
||||
@@ -50,10 +50,10 @@ export class HeaderBannerComponent implements OnInit {
|
||||
|
||||
async getLatestApk() {
|
||||
|
||||
const request = (await fetch(environment.configuration.http_url + '/v2/apps/get-sidequest-apk', {
|
||||
const request = await fetch(environment.configuration.http_url + '/v2/apps/get-sidequest-apk', {
|
||||
body: JSON.stringify({ package_name: 'quest.side.vr' }), method: 'POST',
|
||||
headers: { "Content-Type": "application/json" }
|
||||
}));
|
||||
});
|
||||
|
||||
let json = await request.json();
|
||||
this.appId = json.app_id;
|
||||
@@ -69,23 +69,12 @@ export class HeaderBannerComponent implements OnInit {
|
||||
}
|
||||
|
||||
console.log('downloadAPK', this.appId);
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const requestOptions = {
|
||||
timeout: 30000,
|
||||
const requestOptions = {
|
||||
timeout: 60000,
|
||||
'User-Agent': this.appService.getUserAgent(),
|
||||
};
|
||||
this.appService
|
||||
.request(this.apkDownloadPath, requestOptions)
|
||||
.on('error', error => {
|
||||
console.log(`Request Error ${error}`);
|
||||
reject(error);
|
||||
})
|
||||
.on('progress', state => {})
|
||||
.on('end', () => {
|
||||
return resolve();
|
||||
})
|
||||
.pipe(this.appService.fs.createWriteStream(this.appService.path.join(this.appService.appData, 'experimental.apk')));
|
||||
});
|
||||
};
|
||||
const fileName = this.appService.path.join(this.appService.appData, 'experimental.apk');
|
||||
return this.appService.downloadFileAPI(this.apkDownloadPath, null, fileName, requestOptions, null);
|
||||
}
|
||||
|
||||
useBundledAPK() {
|
||||
|
||||
@@ -283,23 +283,22 @@ export class HeaderComponent implements OnInit {
|
||||
this.bookmarksModal.closeModal();
|
||||
}
|
||||
}
|
||||
addCurrentFavourite() {
|
||||
this.appService.request(
|
||||
'https://i.olsh.me/allicons.json?url=' + this.webService.currentAddress,
|
||||
(error, response, body) => {
|
||||
let json: any = {};
|
||||
try {
|
||||
json = JSON.parse(response.body);
|
||||
} catch (e) {}
|
||||
this.favourites.browserFavourites.unshift({
|
||||
async addCurrentFavourite() {
|
||||
const request = await fetch( 'https://i.olsh.me/allicons.json?url=' + this.webService.currentAddress, {
|
||||
method: 'GET',
|
||||
headers: { "Content-Type": "application/json" }
|
||||
});
|
||||
|
||||
let json = await request.json();
|
||||
|
||||
this.favourites.browserFavourites.unshift({
|
||||
name: this.webService.getTitle(),
|
||||
uri: this.webService.currentAddress,
|
||||
icon: json && json.icons && json.icons.length ? json.icons[0].url : '',
|
||||
});
|
||||
this.saveFavourites('browserFavourites');
|
||||
}
|
||||
);
|
||||
});
|
||||
this.saveFavourites('browserFavourites');
|
||||
}
|
||||
|
||||
async selectAppToInstall() {
|
||||
let files = await this.appService.remote.dialog.showOpenDialog({
|
||||
properties: ['openFile', 'multiSelections'],
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AppService } from '../app.service';
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -10,25 +11,23 @@ export class PackageService {
|
||||
constructor(private appService: AppService) {
|
||||
this.getAppIndex();
|
||||
}
|
||||
getAppIndex() {
|
||||
this.appService.request(this.indexUrl);
|
||||
return new Promise((resolve, reject) => {
|
||||
this.appService.request(this.indexUrl + 'app-index.json', (error, response, body) => {
|
||||
if (error) {
|
||||
return reject(error);
|
||||
} else {
|
||||
try {
|
||||
let body = JSON.parse(response.body);
|
||||
Object.keys(body).forEach(packageName => {
|
||||
this.allApps[packageName] = body[packageName];
|
||||
this.allApps[packageName].icon = this.indexUrl + this.allApps[packageName].icon;
|
||||
});
|
||||
resolve(true);
|
||||
} catch (e) {
|
||||
return reject('JSON parse Error');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
async getAppIndex() {
|
||||
const request = await fetch(this.indexUrl, {
|
||||
method: 'GET',
|
||||
headers: { "Content-Type": "application/json" }
|
||||
});
|
||||
|
||||
let json = await request.json();
|
||||
const request2 = await fetch(this.indexUrl + 'app-index.json', {
|
||||
method: 'GET',
|
||||
headers: { "Content-Type": "application/json" }
|
||||
});
|
||||
let body = await request2.json();
|
||||
|
||||
Object.keys(body).forEach(packageName => {
|
||||
this.allApps[packageName] = body[packageName];
|
||||
this.allApps[packageName].icon = this.indexUrl + this.allApps[packageName].icon;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,20 +56,13 @@ export class SongBeaterService {
|
||||
let name = parts[parts.length - 1].split('.')[0];
|
||||
const requestOptions = {
|
||||
timeout: 30000,
|
||||
'User-Agent': this.appService.getUserAgent(),
|
||||
'User-Agent': this.appService.getUserAgent()
|
||||
};
|
||||
return this.processService.addItem('song_download', async (task) : Promise<void> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.appService
|
||||
.progress(this.appService.request(downloadUrl, requestOptions), { throttle: 300 })
|
||||
.on('error', error => {
|
||||
reject(error);
|
||||
})
|
||||
.on('progress', state => {
|
||||
this.spinnerService.setMessage('Saving to SongBeater... ' + Math.round(state.percent * 100) + '%');
|
||||
})
|
||||
.on('end', () => {
|
||||
let dir = this.appService.path.join(this.appService.appData, 'temp', name);
|
||||
this.spinnerService.setMessage('Saving to SongBeater... ');
|
||||
this.appService.downloadFileAPI( downloadUrl, null, zipPath, requestOptions, task).then( async (fileName) => {
|
||||
let dir = this.appService.path.join(this.appService.appData, 'temp', name);
|
||||
this.appService.fs.mkdir(dir, () => {
|
||||
this.appService.extract(zipPath, { dir: dir }, error => {
|
||||
this.appService.fs.unlink(zipPath, err => {
|
||||
@@ -88,7 +81,6 @@ export class SongBeaterService {
|
||||
});
|
||||
});
|
||||
})
|
||||
.pipe(this.appService.fs.createWriteStream(zipPath));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,35 +19,16 @@ export class SynthriderService {
|
||||
|
||||
downloadSong(downloadUrl, adbService) {
|
||||
return this.processService.addItem('song_download', async (task) : Promise<void> => {
|
||||
let parts = downloadUrl.split('/');
|
||||
let zipPath = this.appService.path.join(this.appService.appData, this.appService.path.basename(downloadUrl));
|
||||
let ws = this.appService.fs.createWriteStream(zipPath);
|
||||
//let name = parts[parts.length - 1].split('.')[0];
|
||||
const requestOptions = {
|
||||
timeout: 30000,
|
||||
'User-Agent': this.appService.getUserAgent(),
|
||||
useContentDispositionFilename: true,
|
||||
};
|
||||
task.status = 'Saving to SynthRiders...';
|
||||
return new Promise((resolve, reject) => {
|
||||
let request = this.appService
|
||||
.progress(this.appService.request(downloadUrl, requestOptions), { throttle: 50 })
|
||||
.on('error', error => {
|
||||
task.failed = true;
|
||||
task.status = 'Failed to save item... ' + error.toString();
|
||||
reject(error);
|
||||
})
|
||||
.on('progress', state => {
|
||||
task.status = 'Saving to SynthRiders... ' + Math.round(state.percent * 100) + '%';
|
||||
})
|
||||
.on('response', response => {
|
||||
var regexp = /filename=\"(.*)\"/gi;
|
||||
var _regResult = regexp.exec(response.headers['content-disposition']);
|
||||
if (_regResult && _regResult.length) {
|
||||
zipPath = this.appService.path.join(this.appService.appData, decodeURIComponent(_regResult[1]));
|
||||
}
|
||||
request.pipe(this.appService.fs.createWriteStream(zipPath));
|
||||
})
|
||||
.on('end', async () => {
|
||||
this.appService.downloadFileAPI( downloadUrl, null, zipPath, requestOptions, task).then( async (fileName) => {
|
||||
let zipPath = fileName;
|
||||
let ext = this.appService.path.extname(zipPath).toLowerCase();
|
||||
let basename = this.appService.path.basename(zipPath);
|
||||
await adbService.uploadFile(
|
||||
@@ -73,6 +54,10 @@ export class SynthriderService {
|
||||
if (err) console.warn(err);
|
||||
});
|
||||
resolve();
|
||||
}).catch((error) => {
|
||||
task.failed = true;
|
||||
task.status = 'Failed to save item... ' + error.toString();
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -208,6 +208,16 @@
|
||||
resolved "https://registry.yarnpkg.com/@angular/language-service/-/language-service-17.2.2.tgz#17e3f09d8fd29fc777c99b04eb58990ac496a995"
|
||||
integrity sha512-nIOuXcrVipPZD4YoAkJAx20R9yf9vfEd+OTAGp/1iu4/as55sHOl0uc+jBqEMMjwdT6xeWCMj4BS85lm5kVwdg==
|
||||
|
||||
"@angular/localize@17.2.2":
|
||||
version "17.2.2"
|
||||
resolved "https://registry.yarnpkg.com/@angular/localize/-/localize-17.2.2.tgz#dbb84165a4990e49150cc338969beee569ee84d2"
|
||||
integrity sha512-VK4tjRXihJlFIccmplmwnWJfSByXbP+scCt8DvBRcbgxgF4eX/sJHx3UC1u7NIfBwDHV6dHXTJQVHKgD/RwOqw==
|
||||
dependencies:
|
||||
"@babel/core" "7.23.9"
|
||||
"@types/babel__core" "7.20.5"
|
||||
fast-glob "3.3.2"
|
||||
yargs "^17.2.1"
|
||||
|
||||
"@angular/platform-browser-dynamic@^17.2.2":
|
||||
version "17.2.2"
|
||||
resolved "https://registry.yarnpkg.com/@angular/platform-browser-dynamic/-/platform-browser-dynamic-17.2.2.tgz#01b6dc901af05341a07c3d0454d9790eb7f9ce94"
|
||||
@@ -493,6 +503,11 @@
|
||||
chalk "^2.4.2"
|
||||
js-tokens "^4.0.0"
|
||||
|
||||
"@babel/parser@^7.1.0", "@babel/parser@^7.20.7":
|
||||
version "7.24.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.24.0.tgz#26a3d1ff49031c53a97d03b604375f028746a9ac"
|
||||
integrity sha512-QuP/FxEAzMSjXygs8v4N9dvdXzEHN4W1oF3PxuWAtPo08UdM17u89RDMgjLn/mlc56iM0HlLmVkO/wgR+rDgHg==
|
||||
|
||||
"@babel/parser@^7.14.7", "@babel/parser@^7.23.9":
|
||||
version "7.23.9"
|
||||
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.23.9.tgz#7b903b6149b0f8fa7ad564af646c4c38a77fc44b"
|
||||
@@ -1186,6 +1201,15 @@
|
||||
debug "^4.3.1"
|
||||
globals "^11.1.0"
|
||||
|
||||
"@babel/types@^7.0.0", "@babel/types@^7.20.7":
|
||||
version "7.24.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.24.0.tgz#3b951f435a92e7333eba05b7566fd297960ea1bf"
|
||||
integrity sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==
|
||||
dependencies:
|
||||
"@babel/helper-string-parser" "^7.23.4"
|
||||
"@babel/helper-validator-identifier" "^7.22.20"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@babel/types@^7.22.15", "@babel/types@^7.22.19", "@babel/types@^7.22.5", "@babel/types@^7.23.0", "@babel/types@^7.23.6", "@babel/types@^7.23.9":
|
||||
version "7.23.9"
|
||||
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.23.9.tgz#1dd7b59a9a2b5c87f8b41e52770b5ecbf492e002"
|
||||
@@ -1824,6 +1848,44 @@
|
||||
"@tufjs/canonical-json" "2.0.0"
|
||||
minimatch "^9.0.3"
|
||||
|
||||
"@tweenjs/tween.js@^23.1.1":
|
||||
version "23.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@tweenjs/tween.js/-/tween.js-23.1.1.tgz#0ae28ed9c635805557f78c2626464018d5f1b5e2"
|
||||
integrity sha512-ZpboH7pCPPeyBWKf8c7TJswtCEQObFo3bOBYalm99NzZarATALYCo5OhbCa/n4RQyJyHfhkdx+hNrdL5ByFYDw==
|
||||
|
||||
"@types/babel__core@7.20.5":
|
||||
version "7.20.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017"
|
||||
integrity sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==
|
||||
dependencies:
|
||||
"@babel/parser" "^7.20.7"
|
||||
"@babel/types" "^7.20.7"
|
||||
"@types/babel__generator" "*"
|
||||
"@types/babel__template" "*"
|
||||
"@types/babel__traverse" "*"
|
||||
|
||||
"@types/babel__generator@*":
|
||||
version "7.6.8"
|
||||
resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.6.8.tgz#f836c61f48b1346e7d2b0d93c6dacc5b9535d3ab"
|
||||
integrity sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==
|
||||
dependencies:
|
||||
"@babel/types" "^7.0.0"
|
||||
|
||||
"@types/babel__template@*":
|
||||
version "7.4.4"
|
||||
resolved "https://registry.yarnpkg.com/@types/babel__template/-/babel__template-7.4.4.tgz#5672513701c1b2199bc6dad636a9d7491586766f"
|
||||
integrity sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==
|
||||
dependencies:
|
||||
"@babel/parser" "^7.1.0"
|
||||
"@babel/types" "^7.0.0"
|
||||
|
||||
"@types/babel__traverse@*":
|
||||
version "7.20.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.20.5.tgz#7b7502be0aa80cc4ef22978846b983edaafcd4dd"
|
||||
integrity sha512-WXCyOcRtH37HAUkpXhUduaxdm82b4GSlyTqajXviN4EfiuPgNYR109xMCKvpl6zPIpua0DGlMEDCq+g8EdoheQ==
|
||||
dependencies:
|
||||
"@babel/types" "^7.20.7"
|
||||
|
||||
"@types/body-parser@*":
|
||||
version "1.19.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.5.tgz#04ce9a3b677dc8bd681a17da1ab9835dc9d3ede4"
|
||||
|
||||
+19
-4
@@ -6,6 +6,7 @@ import { getEnvCfg } from './env-config';
|
||||
const path = require('path');
|
||||
const { autoUpdater } = require('electron-updater');
|
||||
const download = require('./download');
|
||||
const upload = require('./upload');
|
||||
const extract = require('extract-zip');
|
||||
|
||||
const Readable = require('stream').Readable;
|
||||
@@ -160,9 +161,11 @@ class ADB {
|
||||
rejectUnauthorized: process.env.NODE_ENV !== 'dev',
|
||||
json: { token: token },
|
||||
};
|
||||
console.log("IFT:", options)
|
||||
request(options.url, options, (error, response, body) => {
|
||||
if (!error && body.data && body.data.apps && body.data.apps.length) {
|
||||
let tasks = [];
|
||||
console.log("IFT Body", body);
|
||||
for (let i = 0; i < body.data.apps.length; i++) {
|
||||
let app = body.data.apps[i];
|
||||
if (Number(app.app_categories_id) === 1) {
|
||||
@@ -861,13 +864,23 @@ function setupApp() {
|
||||
|
||||
const adb = new ADB();
|
||||
|
||||
ipcMain.on('download-url', async (event, { url, token, directory, filename }) => {
|
||||
download(url, path.join(directory, filename), stats => {
|
||||
ipcMain.on('download-url', async (event, { url, token, directory, filename, options }) => {
|
||||
download(url, directory ? path.join(directory, filename) : filename, stats => {
|
||||
return event.sender.send('download-progress', { stats, token });
|
||||
})
|
||||
.then(() => event.sender.send('download-url', { token }))
|
||||
}, options)
|
||||
.then((fileName) => event.sender.send('download-url', { token, fileName }))
|
||||
.catch(e => event.sender.send('download-url-fail', { e, token }));
|
||||
});
|
||||
|
||||
ipcMain.on('upload-url', async (event, { url, token, filename, options }) => {
|
||||
upload(url, filename, stats => {
|
||||
return event.sender.send('download-progress', { stats, token });
|
||||
}, options)
|
||||
.then((fileName) => event.sender.send('download-url', { token, fileName }))
|
||||
.catch(e => event.sender.send('download-url-fail', { e, token }));
|
||||
|
||||
});
|
||||
|
||||
ipcMain.on('extract-file', async (event, { token, directory, filename }) => {
|
||||
extract(
|
||||
filename,
|
||||
@@ -890,6 +903,7 @@ function setupApp() {
|
||||
}, 5000);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('adb-command', (event, arg) => {
|
||||
const success = d => {
|
||||
//console.log(" ", arg.command, "Success", d)
|
||||
@@ -912,6 +926,7 @@ function setupApp() {
|
||||
try {
|
||||
switch (arg.command) {
|
||||
case 'installFromToken':
|
||||
console.log("E-IFT", arg.settings.token)
|
||||
adb.installFromToken(arg.settings.token, success, reject);
|
||||
break;
|
||||
case 'setupAdb':
|
||||
|
||||
+39
-14
@@ -1,33 +1,57 @@
|
||||
const https = require('https');
|
||||
const http = require('http');
|
||||
const _fs = require('fs');
|
||||
const { basename } = require('path');
|
||||
const https = require('node:https');
|
||||
const http = require('node:http');
|
||||
const nodeFS = require('node:fs');
|
||||
const nodePath = require('node:path');
|
||||
const Url = require('url');
|
||||
const electron = require('electron');
|
||||
|
||||
const TIMEOUT = 60000;
|
||||
|
||||
module.exports = function(url, path, progress) {
|
||||
module.exports = function(url, filePath, progress, options) {
|
||||
const uri = Url.parse(url);
|
||||
if (!path) {
|
||||
path = basename(uri.path);
|
||||
if (!filePath) {
|
||||
filePath = nodePath.basename(uri.path);
|
||||
}
|
||||
const file = _fs.createWriteStream(path);
|
||||
|
||||
let file, fileName = filePath;
|
||||
function get(url, callback) {
|
||||
let request = (uri.protocol === 'https:' ? https : http).get(url, function(response) {
|
||||
if (response.headers.location) {
|
||||
get(response.headers.location, callback);
|
||||
} else {
|
||||
if (options && options.useContentDispositionFilename) {
|
||||
const contentDisposition = response.headers['content-disposition'];
|
||||
if (contentDisposition) {
|
||||
const appData = nodePath.join(electron.app.getPath('appData'), 'SideQuest');
|
||||
const match = contentDisposition.match(/filename="(.+)"/);
|
||||
if (match && match.length > 1) {
|
||||
fileName = nodePath.join(appData, match[1]);
|
||||
file = nodeFS.createWriteStream(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!file) {
|
||||
file = nodeFS.createWriteStream(filePath);
|
||||
}
|
||||
callback(null, response);
|
||||
}
|
||||
});
|
||||
request.on('error', function(err) {
|
||||
callback(err);
|
||||
});
|
||||
request.setTimeout(TIMEOUT, function() {
|
||||
request.abort();
|
||||
callback(new Error(`request timeout after ${TIMEOUT / 1000.0}s`));
|
||||
});
|
||||
if (options && options.timeout !== undefined) {
|
||||
if (options.timeout > 0) {
|
||||
request.setTimeout(TIMEOUT, function() {
|
||||
request.abort();
|
||||
callback(new Error(`request timeout after ${options.timeout / 1000.0}s`));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
request.setTimeout(TIMEOUT, function() {
|
||||
request.abort();
|
||||
callback(new Error(`request timeout after ${TIMEOUT / 1000.0}s`));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
@@ -35,7 +59,8 @@ module.exports = function(url, path, progress) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
const len = parseInt(res.headers['content-length'], 10);
|
||||
let len = parseInt(res.headers['content-length'], 10);
|
||||
if (isNaN(len) || len <= 0) { len = 1; }
|
||||
let downloaded = 0;
|
||||
let percent = 0;
|
||||
res.on('data', function(chunk) {
|
||||
@@ -46,7 +71,7 @@ module.exports = function(url, path, progress) {
|
||||
})
|
||||
.on('end', function() {
|
||||
file.end();
|
||||
resolve(true);
|
||||
resolve(fileName);
|
||||
})
|
||||
.on('error', function(err) {
|
||||
reject(err);
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
const _fs = require('fs');
|
||||
const _path = require('path');
|
||||
const request = require('request');
|
||||
const progress = require('request-progress');
|
||||
|
||||
|
||||
module.exports = function(url, filePath, progressCallback, options?) {
|
||||
|
||||
let contentType = 'application/zip';
|
||||
if (options && options.contentType) {
|
||||
contentType = options.contentType;
|
||||
}
|
||||
let fileName = _path.basename(filePath);
|
||||
if (options && options.fileName) {
|
||||
fileName = options.fileName;
|
||||
}
|
||||
|
||||
const formData = {
|
||||
file: {
|
||||
value: _fs.createReadStream(filePath),
|
||||
options: {
|
||||
filename: fileName,
|
||||
contentType: contentType,
|
||||
},
|
||||
},
|
||||
};
|
||||
const requestOptions = {
|
||||
url: url,
|
||||
method: 'POST',
|
||||
formData: formData,
|
||||
};
|
||||
return new Promise(function(resolve, reject) {
|
||||
progress(request(url, requestOptions), { throttle: 1000 })
|
||||
.on('error', error => {
|
||||
reject(error);
|
||||
})
|
||||
.on('progress', state => {
|
||||
progressCallback(state.percent);
|
||||
})
|
||||
.on('end', () => {
|
||||
resolve(true);
|
||||
});
|
||||
});
|
||||
};
|
||||
+12
-9
@@ -39,7 +39,7 @@
|
||||
"platform-tools": "node build-electron/platform-tools.js",
|
||||
"electron-build": "tsc",
|
||||
"reset": "rm -rf node_modules && rm -rf desktop-app/node_modules && yarn install && cd desktop-app && yarn install"
|
||||
},
|
||||
},
|
||||
"build": {
|
||||
"productName": "SideQuest",
|
||||
"appId": "com.sidequestvr.app",
|
||||
@@ -56,14 +56,16 @@
|
||||
"win": {
|
||||
"artifactName": "${productName}-${version}-${arch}-${os}.${ext}",
|
||||
"sign": "./build/windows-codesign.js",
|
||||
"publish": ["github"],
|
||||
"publish": [
|
||||
"github"
|
||||
],
|
||||
"target": [
|
||||
"nsis"
|
||||
]
|
||||
},
|
||||
"linux": {
|
||||
"target": [
|
||||
"tar.xz"
|
||||
"tar.xz"
|
||||
]
|
||||
},
|
||||
"nsis": {
|
||||
@@ -88,7 +90,7 @@
|
||||
"build/**/*"
|
||||
],
|
||||
"afterSign": "build/notarize.js"
|
||||
},
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "pretty-quick --staged --pattern \"**/*.*(js|jsx|ts|tsx)\"",
|
||||
@@ -107,16 +109,17 @@
|
||||
"trailingComma": "es5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@devicefarmer/adbkit": "^3.2.6",
|
||||
"@electron/remote": "^2.1.2",
|
||||
"@types/electron": "^1.6.10",
|
||||
"@devicefarmer/adbkit": "^3.2.6",
|
||||
"adm-zip": "^0.5.10",
|
||||
"bytenode": "^1.5.3",
|
||||
"crypto": "^1.0.1",
|
||||
"electron-updater": "^6.1.8",
|
||||
"express": "^4.17.3",
|
||||
"env-cmd": "^10.1.0",
|
||||
"express": "^4.17.3",
|
||||
"extract-zip": "^2.0.1",
|
||||
"got": "11.8.6",
|
||||
"md5": "^2.3.0",
|
||||
"mkdirp": "^3.0.1",
|
||||
"node-stream-zip": "^1.15.0",
|
||||
@@ -131,12 +134,12 @@
|
||||
"yauzl": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"concurrently": "^8.2.2",
|
||||
"@angular/cli": "^17.1.3",
|
||||
"@electron/notarize": "^2.2.1",
|
||||
"concurrently": "^8.2.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"electron": "28.2.4",
|
||||
"electron-builder": "24.12.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"@electron/notarize": "^2.2.1",
|
||||
"husky": "^9.0.11",
|
||||
"prettier": "3.2.5",
|
||||
"pretty-quick": "^4.0.0",
|
||||
|
||||
Reference in New Issue
Block a user