Merge pull request #152 from SideQuestVR/open_new_window_links_system_browser

Electron upgrade and several other fixes
This commit is contained in:
emulamer
2021-11-19 13:02:42 -05:00
committed by GitHub
23 changed files with 2336 additions and 924 deletions
+4 -2
View File
@@ -7,10 +7,12 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: "Install dependencies"
run: yarn
- name: "Build application"
+69
View File
@@ -49,6 +49,57 @@
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
},
"test": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test.ts"
}
],
"optimization": false,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false
},
"test2": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test2.ts"
}
],
"optimization": false,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false
},
"local": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.local.ts"
}
],
"optimization": false,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false
}
}
},
@@ -60,6 +111,15 @@
"configurations": {
"production": {
"browserTarget": "desktop-app:build:production"
},
"test": {
"browserTarget": "desktop-app:build:test"
},
"test2": {
"browserTarget": "desktop-app:build:test2"
},
"local": {
"browserTarget": "desktop-app:build:local"
}
}
},
@@ -113,6 +173,15 @@
"configurations": {
"production": {
"devServerTarget": "desktop-app:serve:production"
},
"test": {
"devServerTarget": "desktop-app:serve:test"
},
"test2": {
"devServerTarget": "desktop-app:serve:test2"
},
"local": {
"devServerTarget": "desktop-app:serve:local"
}
}
},
+7 -1
View File
@@ -4,10 +4,16 @@
"scripts": {
"ng": "ng",
"start": "ng serve",
"start:test": "ng serve -c test",
"start:test2": "ng serve -c test2",
"start:local": "ng serve -c local",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
"e2e": "ng e2e",
"e2e:test": "ng e2e -c test",
"e2e:local": "ng e2e -c test2",
"e2e:test2": "ng e2e -c local"
},
"private": true,
"dependencies": {
+19 -10
View File
@@ -372,18 +372,27 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u
});
}
isAdbDownloaded() {
let downloaded = true;
if (!this.doesFileExist(this.adbPath)) {
try {
let downloaded = true;
if (!this.doesFileExist(this.adbPath)) {
return false;
}
let source_files = this.appService.fs.readdirSync(this.appService.getPlatformToolsSeedPath());
if (source_files === null) {
return false;
}
let dest_files = this.appService.fs.readdirSync(this.adbPath);
source_files.forEach(d => {
if (dest_files.indexOf(d) === -1) {
downloaded = false;
}
});
return downloaded; // this.doesFileExist(this.appService.path.join(this.adbPath, this.getAdbBinary()));
} catch (e) {
console.error('Error checking for ADB being installed', e);
return false;
}
let source_files = this.appService.fs.readdirSync(this.appService.path.join(process.cwd(), 'build', 'platform-tools'));
let dest_files = this.appService.fs.readdirSync(this.adbPath);
source_files.forEach(d => {
if (dest_files.indexOf(d) === -1) {
downloaded = false;
}
});
return downloaded; // this.doesFileExist(this.appService.path.join(this.adbPath, this.getAdbBinary()));
}
setPermission(packageName: string, permission: string, isRevoke?: boolean) {
return this.adbCommand('shell', {
+2 -2
View File
@@ -5,7 +5,7 @@
<app-loading-spinner #spinner></app-loading-spinner>
<app-status-bar #status (getHelp)="getHelpModal.openModal(); helpStatus = $event; setExterHelp()"></app-status-bar>
<webview id="mainWebView" #webview httpreferrer="https://sdiequestvr.com" src="https://sidequestvr.com" allowpopups [ngStyle]="{'left':webService.isWebviewOpen?'0':'-100%'}" class="bsaber-webview" ></webview>
<webview id="mainWebView" #webview httpreferrer="https://sdiequestvr.com" [attr.src]="webUrl" allowpopups [ngStyle]="{'left':webService.isWebviewOpen?'0':'-100%'}" class="bsaber-webview" ></webview>
<mz-modal #getHelpModal [fixedFooter]="true">
<mz-modal-header>
@@ -21,7 +21,7 @@
<br><br>
<div class="center-align">
<div class="btn pink-button waves-effect waves-light" (click)="statusService.copyStatus();statusService.showStatus('Copied to your clipboard!')">Copy To Clipboard</div><br><br>
<div class="btn btn-flat waves-effect waves-dark" (click)="appService.opn('https://sdq.st/support')">Open Service Desk</div><br><br>
<div class="btn btn-flat waves-effect waves-dark" (click)="appService.opn((shortenerUrl||'https://sdq.st')+'/support')">Open Service Desk</div><br><br>
</div>
</mz-modal-content>
<mz-modal-footer>
+4
View File
@@ -6,6 +6,8 @@ import { WebviewService } from './webview.service';
import { DragAndDropService } from './drag-and-drop.service';
import { ElectronService } from './electron.service';
import { AdbClientService } from './adb-client.service';
import { environment } from '../environments/environment';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
@@ -18,6 +20,8 @@ export class AppComponent implements OnInit, AfterViewInit {
helpStatus: string;
extraHelpStatus: string;
devMode: boolean;
webUrl = environment.configuration.web_url;
shortenerUrl = environment.configuration.shortenerUrl;
constructor(
private spinnerService: LoadingSpinnerService,
public statusService: StatusBarService,
+36 -8
View File
@@ -74,8 +74,8 @@ export class AppService {
this.semver = (<any>window).require('semver');
this.crypto = (<any>window).require('crypto');
this.electron = (<any>window).require('electron');
this.remote = this.electron.remote;
this.nativeApp = this.electron.remote.app;
this.remote = (<any>window).require('@electron/remote');
this.nativeApp = this.remote.app;
this.appData = this.path.join(this.nativeApp.getPath('appData'), 'SideQuest');
this.exec = (<any>window).require('child_process').exec;
this.execSync = (<any>window).require('child_process').execSync;
@@ -225,11 +225,36 @@ export class AppService {
break;
}
}
private foundSeedToolsPath: string | null = null;
getPlatformToolsSeedPath() {
if (this.foundSeedToolsPath !== null) {
return this.foundSeedToolsPath;
}
let ogSourcesPath = this.path.join(process.resourcesPath, 'build', 'platform-tools');
let sourcesPath = ogSourcesPath;
if (!this.doesFileExist(sourcesPath)) {
sourcesPath = sourcesPath.replace('app.asar', 'app.asar.unpacked');
}
if (!this.doesFileExist(sourcesPath)) {
sourcesPath = this.path.join(process.resourcesPath, 'app.asar.unpacked', 'build', 'platform-tools');
}
if (!this.doesFileExist(sourcesPath)) {
sourcesPath = this.path.join(process.cwd(), 'build', 'platform-tools');
}
if (!this.doesFileExist(sourcesPath)) {
return null;
}
this.foundSeedToolsPath = sourcesPath;
return sourcesPath;
}
seedPlatformTools() {
return new Promise(async resolve => {
let sourcesPath = this.path.join(__dirname, '..', 'platform-tools');
if (!this.fs.existsSync(sourcesPath)) {
sourcesPath = this.path.join(process.cwd(), 'build', 'platform-tools');
return new Promise<void>(async resolve => {
let sourcesPath = this.getPlatformToolsSeedPath();
if (sourcesPath == null) {
console.error('Unable to locate platform tools! Try reinstalling sidequest.');
resolve();
return;
}
await this.mkdir(this.path.join(this.appData, 'platform-tools'));
try {
@@ -247,7 +272,10 @@ export class AppService {
} else {
setTimeout(() => resolve(), 5000);
}
} catch (e) {}
} catch (e) {
console.error('Error seeding platform tools! ', e);
resolve();
}
});
}
makeFolders() {
@@ -262,7 +290,7 @@ export class AppService {
});
}
setExecutable(path) {
return new Promise(resolve => {
return new Promise<void>(resolve => {
const ls = this.spawn('chmod', ['+x', path]);
ls.stdout.on('data', res => {
console.log(res);
@@ -1,6 +1,6 @@
<div *ngIf="isConnected()" class="top-bar">
<nav class="pink lighten-2 breadcrumb-wrapper ">
<div class="nav-wrapper container">
<nav class="pink lighten-2 breadcrumb-wrapper ">
<div class="nav-wrapper container">
<div class="col s12 truncate">
<a *ngFor="let breadcrumb of breadcrumbs; let i = index" href="javascript:void(0)" class="breadcrumb"
(click)="open('/'+breadcrumb.path)">{{breadcrumb.name}}<span *ngIf="i === breadcrumbs.length-1 && folderSize"> ({{folderSize}})</span> </a>
@@ -26,9 +26,11 @@
<div *ngFor="let file of files" class="vertical-align cursor"
[ngClass]="{'text-dark-theme':appService.currentTheme === 'dark','text-light-theme':appService.currentTheme === 'light'}">
<div class="file" (click)="selectFile($event, file); $event.stopPropagation()">
<div class="right">
<div class="right">
<span *ngIf="file.icon !== 'folder'">{{file.size|number:'1.2-2'}}MB | </span>{{file.time|date:'short'}}
<i class="material-icons cursor white-text drag-indicator save-icon"
title="Copy full file path to the clipboard" (click)="copyPathToClipboard(file.filePath)">content_copy</i>
<i class="material-icons cursor white-text drag-indicator save-icon"
(click)="filesToBeSaved = [file]; filesModal.openModal();">save</i>
<i class="material-icons cursor orange-text drag-indicator right delete"
+7 -3
View File
@@ -110,6 +110,10 @@ export class FilesComponent implements OnInit {
this.selectedFiles.length = 0;
}
}
copyPathToClipboard(path = null) {
this.appService.electron.clipboard.writeText(path || this.currentPath);
this.statusService.showStatus(`Copied file path to your clipboard!`);
}
async uploadFolder(folder, files, task) {
task.status = 'Restoring Folder... ' + folder;
if (this.appService.fs.existsSync(folder)) {
@@ -184,7 +188,7 @@ export class FilesComponent implements OnInit {
}
}
async uploadFiles() {
let res = await this.appService.electron.remote.dialog.showOpenDialog({
let res = await this.appService.remote.dialog.showOpenDialog({
properties: ['openFile', 'multiSelections'],
defaultPath: this.adbService.savePath,
});
@@ -277,7 +281,7 @@ export class FilesComponent implements OnInit {
});
}
async pickLocation() {
let res = await this.appService.electron.remote.dialog.showOpenDialog({
let res = await this.appService.remote.dialog.showOpenDialog({
properties: ['openDirectory'],
defaultPath: this.adbService.savePath,
});
@@ -334,7 +338,7 @@ export class FilesComponent implements OnInit {
});
}
openSaveLocation() {
this.appService.electron.remote.shell.openItem(this.adbService.savePath);
this.appService.remote.shell.openItem(this.adbService.savePath);
}
async readdir(path: string) {
let dirContents: FileFolderListing[];
@@ -79,7 +79,7 @@
</div>
<div class="user-menu browser-menu" #browserMenu>
<div class="btn-flat waves-light waves-light full-width center-align white-text truncate"
(click)="browserMenu.style.display = 'none';browserMenuBack.style.display = 'none';webService.loadUrl('https://sidequestvr.com')"
(click)="browserMenu.style.display = 'none';browserMenuBack.style.display = 'none';webService.loadUrl(webUrl || 'https://sidequestvr.com')"
routerLink="/webview"><i class="material-icons left">home</i>Home</div><br>
<div class="btn-flat waves-light waves-light full-width center-align white-text"
@@ -99,7 +99,7 @@
</div>
<div class="user-menu" #userMenu>
<div class="btn-flat waves-light waves-light full-width center-align white-text"
(click)="userMenu.style.display = 'none';userMenuBack.style.display = 'none';webService.loadUrl('https://sidequestvr.com')"
(click)="userMenu.style.display = 'none';userMenuBack.style.display = 'none';webService.loadUrl(webUrl || 'https://sidequestvr.com')"
routerLink="/webview"><i class="material-icons left">home</i>Home</div><br>
<div class="btn-flat waves-light waves-light full-width center-align white-text"
*ngIf="isConnected()&&osPlatform === 'win32'"
@@ -140,7 +140,7 @@
(click)="userMenu.style.display = 'block';userMenuBack.style.display = 'block'">
arrow_drop_down
</i>
<i mz-tooltip routerLink="/webview" (click)="webService.back()"
<i mz-tooltip routerLink="/webview" (click)="doBack()"
class="material-icons white-text no-outline" position="bottom" tooltip="Back">
arrow_back
</i>
@@ -312,7 +312,7 @@
</mz-modal-content>
<mz-modal-footer>
<button mz-button [flat]="true" mz-modal-close routerLink="/webview" (click)="webService.loadUrl('https://sidequestvr.com');" >SideQuest Home</button>
<button mz-button [flat]="true" mz-modal-close routerLink="/webview" (click)="webService.loadUrl(webUrl || 'https://sidequestvr.com');" >SideQuest Home</button>
<button mz-button [flat]="true" mz-modal-close>Close</button>
</mz-modal-footer>
</mz-modal>
+21 -4
View File
@@ -10,6 +10,8 @@ import { DragAndDropService } from '../drag-and-drop.service';
import { Router } from '@angular/router';
import { ProcessBucketService } from '../process-bucket.service';
import { Subscription } from 'rxjs/Subscription';
import { environment } from '../../environments/environment';
interface ReplaceText {
key: string;
value: string;
@@ -45,6 +47,7 @@ export class HeaderComponent implements OnInit {
adbCommandToRun: string;
osPlatform: string;
saveLogcatPath: string;
webUrl = environment.configuration.web_url;
favourites: {
browserFavourites: FavouriteItem[];
fileFavourites: FavouriteItem[];
@@ -98,7 +101,8 @@ export class HeaderComponent implements OnInit {
public statusService: StatusBarService,
public beatonService: BeatOnService,
public dragAndDropService: DragAndDropService,
public processService: ProcessBucketService
public processService: ProcessBucketService,
private router: Router
) {
this.osPlatform = this.appService.os.platform();
console.log('Platform: ' + this.osPlatform);
@@ -107,6 +111,19 @@ export class HeaderComponent implements OnInit {
this.resetFavourites('commandFavourites');
this.appService.headerComponent = this;
}
doBack() {
if (
this.appService.isTasksOpen ||
this.appService.isFilesOpen ||
this.appService.isPackagesOpen ||
this.appService.isSettingsOpen
) {
this.router.navigateByUrl('/webview');
return;
} else {
this.webService.back();
}
}
resetFavourites(type: string) {
let defaultFavs;
switch (type) {
@@ -182,7 +199,7 @@ export class HeaderComponent implements OnInit {
}
updateAvailable() {
this.appService.opn('https://sidequestvr.com/download');
this.appService.opn(`${environment.configuration.web_url || 'https://sidequestvr.com'}/download`);
}
startLogcat() {
@@ -215,7 +232,7 @@ export class HeaderComponent implements OnInit {
this.saveLogcatPath = null;
}
async selectLogcatOutput() {
const res = await this.appService.electron.remote.dialog.showOpenDialog({
const res = await this.appService.remote.dialog.showOpenDialog({
properties: ['openDirectory'],
defaultPath: this.adbService.savePath,
});
@@ -300,7 +317,7 @@ export class HeaderComponent implements OnInit {
this.appService.remote.getCurrentWindow().toggleDevTools();
}
async selectAppToInstall() {
let files = await this.appService.electron.remote.dialog.showOpenDialog({
let files = await this.appService.remote.dialog.showOpenDialog({
properties: ['openFile', 'multiSelections'],
defaultPath: this.adbService.savePath,
});
@@ -80,7 +80,7 @@ export class PackagesComponent implements OnInit {
}
async pickBackupLocation() {
const res = await this.appService.electron.remote.dialog.showOpenDialog({
const res = await this.appService.remote.dialog.showOpenDialog({
properties: ['openDirectory'],
defaultPath: this.appService.backupPath,
});
+2 -1
View File
@@ -1,5 +1,6 @@
import { Injectable, isDevMode } from '@angular/core';
import { AppService } from './app.service';
import { environment } from '../environments/environment';
@Injectable({
providedIn: 'root',
@@ -7,7 +8,7 @@ import { AppService } from './app.service';
export class WebviewService {
webView: any;
isWebviewOpen: boolean;
currentAddress: string = 'https://sidequestvr.com';
currentAddress: string = environment.configuration.web_url || 'https://sidequestvr.com';
isWebviewLoading: boolean = false;
isLoaded = () => {};
constructor(private appService: AppService) {
@@ -0,0 +1,10 @@
export const environment = {
production: false,
configuration: {
web_url: 'https://sidequestvr.local',
ws_url: 'wss://ws.sidetestvr.local',
http_url: 'https://api.sidetestvr.local',
cdnUrl: 'https://cdn.sidetestvr.local',
shortenerUrl: 'https://links.sidetestvr.local',
},
};
@@ -1,4 +1,10 @@
export const environment = {
production: true,
safeSideApiUrl: 'https://sdq.st',
configuration: {
web_url: 'https://sidequestvr.com',
ws_url: 'wss://ws.sidequestvr.com',
http_url: 'https://api.sidequestvr.com',
cdnUrl: 'https://cdn.sidequestvr.com',
shortenerUrl: 'https://sdq.st',
},
};
@@ -0,0 +1,10 @@
export const environment = {
production: false,
configuration: {
web_url: 'https://sidetestvr.com',
ws_url: 'wss://ws.sidetestvr.com',
http_url: 'https://api.sidetestvr.com',
cdnUrl: 'https://cdn.sidetestvr.com',
shortenerUrl: 'https://links.sidetestvr.com',
},
};
@@ -0,0 +1,10 @@
export const environment = {
production: false,
configuration: {
web_url: 'https://test.side.quest',
ws_url: 'wss://testws.side.quest',
http_url: 'https://api.sidequestvr.com',
cdnUrl: 'https://cdn.sidequestvr.com',
shortenerUrl: 'https://sdq.st',
},
};
+7 -1
View File
@@ -4,7 +4,13 @@
export const environment = {
production: false,
safeSideApiUrl: 'https://sdq.st',
configuration: {
web_url: 'https://sidequestvr.com',
ws_url: 'wss://ws.sidequestvr.com',
http_url: 'https://api.sidequestvr.com',
cdnUrl: 'https://cdn.sidequestvr.com',
shortenerUrl: 'https://sdq.st',
},
};
/*
+82 -63
View File
@@ -1,6 +1,8 @@
import { app, protocol, ipcMain, Menu, MenuItemConstructorOptions, BrowserWindow, shell } from 'electron';
import { app, protocol, ipcMain, Menu, MenuItemConstructorOptions, BrowserWindow, shell, HandlerDetails } from 'electron';
import { StateStorage, EnvironmentConfig } from './state-storage';
import { AppWindow } from './window';
import { getEnvCfg } from './env-config';
const path = require('path');
const { autoUpdater } = require('electron-updater');
const download = require('./download');
@@ -13,6 +15,15 @@ const exec = require('child_process').exec;
const crypto = require('crypto');
const request = require('request');
const progress = require('request-progress');
const OPEN_IN_SYSTEM_BROWSER_DOMAINS = [
'www.oculus.com',
'oculus.com',
'facebook.com',
'www.facebook.com',
'twitter.com',
'www.twitter.com',
];
// const Readable = require('stream').Readable;
import { SetPropertiesCommand } from './setproperties';
let has_port = process.argv.indexOf('--port');
@@ -32,7 +43,7 @@ class ADB {
}
async checkAPK(updateStatus: (string) => void, filePath: string): Promise<boolean> {
const hash = await this.computeFileHash(updateStatus, filePath);
const url = `https://sdq.st/check-app-hash/${hash}`;
const url = `${getEnvCfg().shortenerUrl || 'https://sdq.st'}/check-app-hash/${hash}`;
updateStatus('Checking APK against blacklist...');
return new Promise((resolve, reject) => {
let options = {
@@ -41,7 +52,7 @@ class ADB {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Origin: 'https://sidequestvr.com',
Origin: getEnvCfg().web_url,
},
rejectUnauthorized: process.env.NODE_ENV !== 'dev',
};
@@ -102,12 +113,12 @@ class ADB {
}
installFromToken(token, cb, ecb) {
let options = {
url: 'https://api.sidequestvr.com/install-from-key',
url: `${getEnvCfg().http_url || 'https://api.sidequestvr.com'}/install-from-key`,
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Origin: 'https://sidequestvr.com',
Origin: getEnvCfg().web_url || 'https://sidequestvr.com',
},
rejectUnauthorized: process.env.NODE_ENV !== 'dev',
json: { token: token },
@@ -451,52 +462,8 @@ function parseOpenUrl(argv: string[]) {
setTimeout(() => mainWindow.webContents.send('open-url', argv[1].toString()), 5000);
}
}
function createWindow() {
appWindow = new AppWindow(config);
mainWindow = appWindow.window;
if (process.env.NODE_ENV === 'dev') {
mainWindow.loadURL('http://localhost:4205');
mainWindow.webContents.openDevTools();
} else {
mainWindow.loadFile('build/app/index.html');
}
mainWindow.on('closed', function() {
mainWindow = undefined;
});
setupMenu();
mainWindow.webContents.once('dom-ready', async _e => {
parseOpenUrl(process.argv);
autoUpdater.autoDownload = false;
if (process.platform !== 'linux') autoUpdater.checkForUpdates();
});
protocol.registerBufferProtocol(
'beatsaver',
(request, _callback) => {
mainWindow.webContents.send(
'open-url',
'sidequest://bsaber/#https://beatsaver.com/api/download/key/' + request.url.replace('beatsaver://', '')
);
},
error => {
if (error) console.error('Failed to register protocol');
}
);
protocol.registerStringProtocol(
'sidequest',
(request, _callback) => {
mainWindow.webContents.send('open-url', request.url);
},
error => {
if (error) console.error('Failed to register protocol');
}
);
mainWindow.webContents.on('did-fail-load', () => mainWindow.loadURL(mainWindow.webContents.getURL()));
mainWindow.webContents.session.on('will-download', (_evt, item, _webContents) => {
function addWindowDownloadHandler(window) {
window.webContents.session.on('will-download', (_evt, item, _webContents) => {
let url = item.getURL();
let urls = item.getURLChain();
let name = item.getFilename();
@@ -532,6 +499,69 @@ function createWindow() {
item.cancel();
});
}
function createWindow() {
appWindow = new AppWindow(config);
mainWindow = appWindow.window;
require('@electron/remote/main').enable(mainWindow.webContents);
if (process.env.NODE_ENV === 'dev') {
mainWindow.loadURL('http://localhost:4205');
mainWindow.webContents.openDevTools();
} else {
mainWindow.loadFile('build/app/index.html');
}
mainWindow.on('closed', function() {
mainWindow = undefined;
});
setupMenu();
mainWindow.webContents.once('dom-ready', async _e => {
parseOpenUrl(process.argv);
autoUpdater.autoDownload = false;
if (process.platform !== 'linux') autoUpdater.checkForUpdates();
});
protocol.registerBufferProtocol('beatsaver', (request, _callback) => {
mainWindow.webContents.send(
'open-url',
'sidequest://bsaber/#https://beatsaver.com/api/download/key/' + request.url.replace('beatsaver://', '')
);
});
protocol.registerStringProtocol('sidequest', (request, _callback) => {
mainWindow.webContents.send('open-url', request.url);
});
mainWindow.webContents.on('did-fail-load', () => mainWindow.loadURL(mainWindow.webContents.getURL()));
addWindowDownloadHandler(mainWindow);
const handleOpenWindow: (details: HandlerDetails) => { action: 'allow' } | { action: 'deny' } = e => {
if (!e.postBody) {
try {
const extUrl = new URL(e.url).host.toLowerCase();
if (OPEN_IN_SYSTEM_BROWSER_DOMAINS.includes(extUrl)) {
shell.openExternal(e.url);
return { action: 'deny' };
}
} catch {}
}
return { action: 'allow' };
};
let handleWindow;
handleWindow = (child: BrowserWindow) => {
child.webContents.on('did-attach-webview', (z, wc) => {
wc.setWindowOpenHandler(handleOpenWindow);
wc.on('did-create-window', child => {
handleWindow(child);
});
});
child.webContents.setWindowOpenHandler(handleOpenWindow);
child.webContents.on('did-create-window', child => {
console.log('did create window fired');
handleWindow(child);
});
};
handleWindow(mainWindow);
mainWindow.webContents.session.setUserAgent(mainWindow.webContents.session.getUserAgent() + ' SQ/' + app.getVersion());
}
function setupMenu() {
const template: MenuItemConstructorOptions[] = [
@@ -596,6 +626,7 @@ function setupMenu() {
}
function setupApp() {
require('@electron/remote/main').initialize();
app.on('second-instance', (_event, commandLine, _workingDirectory) => {
parseOpenUrl(commandLine);
if (mainWindow) {
@@ -631,18 +662,6 @@ function setupApp() {
event.preventDefault();
});
app.on('web-contents-created', (e, contents) => {
if (contents.getType() === 'webview') {
// contents.on('new-window', (e : any, url) => {
// popupWindow = new BrowserWindow({show: false})
// popupWindow.once('ready-to-show', () => popupWindow.show())
// popupWindow.loadURL(url);
// e.newGuest = popupWindow;
// e.preventDefault();
// });
}
});
app.on('browser-window-blur', () => {
if (appWindow) {
appWindow.saveWindowState();
+36
View File
@@ -0,0 +1,36 @@
export function getEnvCfg() {
switch (process.env['SQ_ENV_CFG']) {
case 'test':
return {
web_url: 'https://sidetestvr.com',
ws_url: 'wss://ws.sidetestvr.com',
http_url: 'https://api.sidetestvr.com',
cdnUrl: 'https://cdn.sidetestvr.com',
shortenerUrl: 'https://links.sidetestvr.com',
};
case 'test2':
return {
web_url: 'https://test.side.quest',
ws_url: 'wss://testws.side.quest',
http_url: 'https://testapi.side.quest',
cdnUrl: 'https://testcdn.sidequestvr.com',
shortenerUrl: 'https://testlinks.side.quest',
};
case 'local':
return {
web_url: 'https://sidequestvr.local',
ws_url: 'wss://ws.sidetestvr.local',
http_url: 'https://api.sidetestvr.local',
cdnUrl: 'https://cdn.sidetestvr.local',
shortenerUrl: 'https://links.sidetestvr.local',
};
default:
return {
web_url: 'https://sidequestvr.com',
ws_url: 'wss://ws.sidequestvr.com',
http_url: 'https://api.sidequestvr.com',
cdnUrl: 'https://cdn.sidequestvr.com',
shortenerUrl: 'https://sdq.st',
};
}
}
+1
View File
@@ -61,6 +61,7 @@ export class AppWindow {
webPreferences: {
webviewTag: true,
nodeIntegration: true,
contextIsolation: false,
},
};
this._window = new BrowserWindow(options);
+23 -7
View File
@@ -10,10 +10,19 @@
"scripts": {
"concurrently": "concurrently",
"start": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev electron .\" \"cd desktop-app && ng serve --port 4205\"",
"start:test": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev SQ_ENV_CFG=test electron .\" \"cd desktop-app && ng serve -c test --port 4205\"",
"start:test2": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev SQ_ENV_CFG=test2 electron .\" \"cd desktop-app && ng serve -c test2 --port 4205\"",
"start:local": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev SQ_ENV_CFG=local electron .\" \"cd desktop-app && ng serve -c local --port 4205\"",
"postinstall": "electron-builder install-app-deps && cd desktop-app && yarn install",
"dist": "yarn electron-build && yarn platform-tools && yarn app-build && electron-builder",
"angular": "cd desktop-app && ng serve --port 4205",
"angular:test": "cd desktop-app && ng serve -c test --port 4205",
"angular:test2": "cd desktop-app && ng serve -c test2 --port 4205",
"angular:local": "cd desktop-app && ng serve -c local --port 4205",
"electron-dev": "yarn platform-tools && cross-env NODE_ENV=dev electron .",
"electron-dev:test": "yarn platform-tools && cross-env NODE_ENV=dev SQ_ENV_CFG=test electron .",
"electron-dev:test2": "yarn platform-tools && cross-env NODE_ENV=dev SQ_ENV_CFG=test2 electron .",
"electron-dev:local": "yarn platform-tools && cross-env NODE_ENV=dev SQ_ENV_CFG=local electron .",
"electron": "yarn electron-build && yarn electron-dev",
"app-build": "cd desktop-app && ng build --prod --aot && cd ..",
"platform-tools": "node build-electron/platform-tools.js",
@@ -25,9 +34,13 @@
"appId": "com.sidequestvr.app",
"mac": {
"category": "public.app-category.utilities",
"target": [
"dmg"
]
"target": {
"target": "dmg",
"arch": [
"arm64",
"x64"
]
}
},
"win": {
"artifactName": "${productName}-${version}-${arch}-${os}.${ext}",
@@ -54,7 +67,8 @@
"build-electron/download.js",
"build-electron/setproperties.js",
"build-electron/state-storage.js",
"build-electron/window.js"
"build-electron/window.js",
"build-electron/env-config.js"
],
"asarUnpack": [
"build/**/*"
@@ -78,13 +92,15 @@
"trailingComma": "es5"
},
"dependencies": {
"@electron/remote": "^2.0.1",
"@types/electron": "^1.6.10",
"adbkit": "^2.11.1",
"adm-zip": "^0.4.14",
"bytenode": "^1.1.6",
"concurrently": "^4.1.0",
"cross-env": "^5.2.0",
"crypto": "^1.0.1",
"electron-updater": "^4.1.2",
"electron-updater": "^4.3.7",
"express": "^4.17.1",
"extract-zip": "^1.6.7",
"md5": "^2.2.1",
@@ -101,8 +117,8 @@
},
"devDependencies": {
"@angular/cli": "^8.0.3",
"electron": "7.2.4",
"electron-builder": "^22.4.0",
"electron": "13.5.1",
"electron-builder": "22.10.5",
"electron-notarize": "^0.1.1",
"husky": "^2.3.0",
"prettier": "1.17.1",
+1969 -813
View File
File diff suppressed because it is too large Load Diff