This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48d4fff
commit 45e31d7
Showing
13 changed files
with
419 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
node_modules/ | ||
out/ | ||
build/**/*.js | ||
Terabit*/ | ||
Terabit*/ | ||
|
||
dist/ | ||
node_modules/ | ||
coverage/ | ||
npm-debug.log | ||
yarn-error.log | ||
app/node_modules/ | ||
.DS_Store | ||
.awcache | ||
.idea/ | ||
.vs/ | ||
.vscode/*.log | ||
.eslintcache | ||
*.iml | ||
.envrc | ||
junit*.xml | ||
*.swp | ||
tslint-rules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
build/ | ||
content/ | ||
node_modules/ | ||
src/res/ | ||
*.json | ||
**/*.md |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,53 @@ | ||
import { app } from 'electron' | ||
import { AssignProtocolHandler } from './tbd/ProtocolHandler'; | ||
import { Window } from './tbd/ui/Window'; | ||
import { AppInfo, Version } from './tbd/Version'; | ||
import {OperatingSystem} from "./tbd/OperatingSystem"; | ||
import {Logging} from "./tbd/Logging"; | ||
import { app } from "electron"; | ||
import { AssignProtocolHandler } from "./tbd/ProtocolHandler"; | ||
import { Window } from "./tbd/ui/Window"; | ||
import { AppInfo, Version } from "./tbd/Version"; | ||
import { OperatingSystem } from "./tbd/OperatingSystem"; | ||
import { Logging } from "./tbd/Logging"; | ||
|
||
let SplashWindow: Window; | ||
let ParentWindow: Window; | ||
|
||
|
||
app.whenReady().then(() => { | ||
Logging.Info(`Loading: ${AppInfo.APP_NAME} | v${Version.VERSION_MAJOR}.${Version.VERSION_MINOR}.${Version.VERSION_BUILD} - '${Version.VERSION_CODENAME}'...`); | ||
Logging.Info(`Running on '${OperatingSystem.GetHumanFriendlyOS()}' (${OperatingSystem.CurrentArch}).`); | ||
// --------------------------------- Splash Screen --------------------------------- | ||
SplashWindow = new Window(undefined, 620, 300, true); | ||
SplashWindow.Get()?.loadFile(`${__dirname}/splash.html`).catch((result) => { | ||
Logging.Error(`There was an error getting 'splash.html'. ${result}`); | ||
Logging.Info( | ||
`Loading: ${AppInfo.APP_NAME} | v${Version.VERSION_MAJOR}.${Version.VERSION_MINOR}.${Version.VERSION_BUILD} - '${Version.VERSION_CODENAME}'...`, | ||
); | ||
Logging.Info( | ||
`Running on '${OperatingSystem.GetHumanFriendlyOS()}' (${OperatingSystem.CurrentArch}).`, | ||
); | ||
// --------------------------------- Splash Screen --------------------------------- | ||
SplashWindow = new Window(undefined, 620, 300, true); | ||
SplashWindow.Get() | ||
?.loadFile(`${__dirname}/splash.html`) | ||
.catch((result) => { | ||
Logging.Error(`There was an error getting 'splash.html'. ${result}`); | ||
}); | ||
// --------------------------------------------------------------------------------- | ||
SplashWindow.Show(); | ||
AssignProtocolHandler(); | ||
// StartWindow(); | ||
ParentWindow = new Window(undefined, 1366, 720); | ||
ParentWindow.Load(); | ||
ParentWindow.Show(); | ||
SplashWindow.Close(); | ||
// --------------------------------------------------------------------------------- | ||
SplashWindow.Show(); | ||
AssignProtocolHandler(); | ||
|
||
// StartWindow(); | ||
ParentWindow = new Window(undefined, 1366, 720); | ||
ParentWindow.Load(); | ||
ParentWindow.Show(); | ||
SplashWindow.Close(); | ||
}); | ||
|
||
app.on('web-contents-created', (event, contents) => { | ||
contents.on('will-navigate', (event, navigationUrl) => { | ||
const parsedUrl = new URL(navigationUrl) | ||
const allowedOrigins = ['terabit.io', 'discord.com', 'terabit.io:8080']; // Allow Discord for the Discord invite, Allow Terabit.io for the main site and the admin panel. | ||
allowedOrigins.forEach(element => { | ||
if (!parsedUrl.origin.endsWith(element)) { | ||
Logging.Warn(`${element} lead to a URL outside of the allowed origin.`); | ||
event.preventDefault(); // Stops any urls with origins outside terabit.io or discord.com from loading. | ||
} | ||
}); | ||
app.on("web-contents-created", (event, contents) => { | ||
contents.on("will-navigate", (event, navigationUrl) => { | ||
const parsedUrl = new URL(navigationUrl); | ||
const allowedOrigins = ["terabit.io", "discord.com", "terabit.io:8080"]; // Allow Discord for the Discord invite, Allow Terabit.io for the main site and the admin panel. | ||
allowedOrigins.forEach((element) => { | ||
if (!parsedUrl.origin.endsWith(element)) { | ||
Logging.Warn(`${element} lead to a URL outside of the allowed origin.`); | ||
event.preventDefault(); // Stops any urls with origins outside terabit.io or discord.com from loading. | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
app.on('window-all-closed', () => { | ||
if (process.platform !== 'darwin') { | ||
app.quit(); | ||
} | ||
}); | ||
app.on("window-all-closed", () => { | ||
if (process.platform !== "darwin") { | ||
app.quit(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Terabit Desktop</title> | ||
</head> | ||
<body> | ||
<menu></menu> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,39 @@ | ||
import { BrowserWindow, app } from "electron"; | ||
const { dialog } = require('electron'); | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import {Logging} from "./Logging"; | ||
const { dialog } = require("electron"); | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import { Logging } from "./Logging"; | ||
|
||
export class FactorySettings { | ||
static ResetApplication(): void { | ||
dialog | ||
.showMessageBox(BrowserWindow.getAllWindows()[0], { | ||
type: "warning", | ||
buttons: ["Reset Terabit Desktop", "Cancel"], | ||
defaultId: 0, | ||
title: "Reset Terabit Desktop", | ||
message: "Are you sure you wish to reset Terabit Desktop?", | ||
detail: | ||
"Are you sure you wish to reset Terabit Desktop? You'll need to login again after the reset.", | ||
}) | ||
.then((result) => { | ||
if (result.response === 0) { | ||
const getAppPath = path.join(app.getPath("appData"), app.getName()); | ||
|
||
static ResetApplication(): void { | ||
dialog.showMessageBox(BrowserWindow.getAllWindows()[0], { | ||
type: 'warning', | ||
buttons: ['Reset Terabit Desktop', 'Cancel'], | ||
defaultId: 0, | ||
title: 'Reset Terabit Desktop', | ||
message: 'Are you sure you wish to reset Terabit Desktop?', | ||
detail: "Are you sure you wish to reset Terabit Desktop? You'll need to login again after the reset.", | ||
}).then((result) => { | ||
if (result.response === 0) { | ||
const getAppPath = path.join(app.getPath('appData'), app.getName()); | ||
fs.unlink(getAppPath, () => { | ||
Logging.Info( | ||
"The cache has been cleared successfully. We just need to relaunch to apply any needed changes.", | ||
); | ||
app.relaunch(); | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
fs.unlink(getAppPath, () => { | ||
Logging.Info("The cache has been cleared successfully. We just need to relaunch to apply any needed changes."); | ||
app.relaunch(); | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
public static ResetCache() | ||
{ | ||
BrowserWindow.getAllWindows().forEach(element => { | ||
element.webContents.session.clearCache(); | ||
element.webContents.reloadIgnoringCache(); | ||
}); | ||
} | ||
} | ||
public static ResetCache() { | ||
BrowserWindow.getAllWindows().forEach((element) => { | ||
element.webContents.session.clearCache(); | ||
element.webContents.reloadIgnoringCache(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
import { } from 'electron'; | ||
import {} from "electron"; | ||
|
||
export class Logging { | ||
public static Debug(Message: string) { if (process.argv.includes("--verbose")) { console.log(`[DEBUG]: ${Message}`); } } | ||
public static Info(Message: string) { console.log(`[INFO]: ${Message}`); } | ||
public static Warn(Message: string) { console.log(`[WARN]: ${Message}`); } | ||
public static Error(Message: string) { console.log(`[ERROR]: ${Message}`); } | ||
} | ||
public static Debug(Message: string) { | ||
if (process.argv.includes("--verbose")) { | ||
console.log(`[DEBUG]: ${Message}`); | ||
} | ||
} | ||
public static Info(Message: string) { | ||
console.log(`[INFO]: ${Message}`); | ||
} | ||
public static Warn(Message: string) { | ||
console.log(`[WARN]: ${Message}`); | ||
} | ||
public static Error(Message: string) { | ||
console.log(`[ERROR]: ${Message}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
import process from 'process'; | ||
import process from "process"; | ||
|
||
export class OperatingSystem | ||
{ | ||
public static readonly CurrentOS: string = process.platform; | ||
public static readonly CurrentArch: string = process.arch; | ||
export class OperatingSystem { | ||
public static readonly CurrentOS: string = process.platform; | ||
public static readonly CurrentArch: string = process.arch; | ||
|
||
public static GetHumanFriendlyOS() { | ||
switch (process.platform) { | ||
case 'win32': | ||
return "Windows"; | ||
case 'linux': | ||
return "Linux"; | ||
case 'darwin': | ||
return "MacOS"; | ||
default: | ||
return "Unknown"; | ||
} | ||
public static GetHumanFriendlyOS() { | ||
switch (process.platform) { | ||
case "win32": | ||
return "Windows"; | ||
case "linux": | ||
return "Linux"; | ||
case "darwin": | ||
return "MacOS"; | ||
default: | ||
return "Unknown"; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { app } from 'electron'; | ||
import path from 'path' | ||
import { app } from "electron"; | ||
import path from "path"; | ||
|
||
export function AssignProtocolHandler() | ||
{ | ||
if (process.defaultApp) | ||
if (process.argv.length >= 2) | ||
app.setAsDefaultProtocolClient('terabit', process.execPath, [path.resolve(process.argv[1])]) | ||
else | ||
app.setAsDefaultProtocolClient('terabit') | ||
} | ||
export function AssignProtocolHandler() { | ||
if (process.defaultApp) | ||
if (process.argv.length >= 2) | ||
app.setAsDefaultProtocolClient("terabit", process.execPath, [ | ||
path.resolve(process.argv[1]), | ||
]); | ||
else app.setAsDefaultProtocolClient("terabit"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
export class Version { | ||
static VERSION_MAJOR = 1; | ||
static VERSION_MINOR = 0; | ||
static VERSION_BUILD = 1; | ||
static VERSION_CODENAME = "Creek"; | ||
static VERSION_MAJOR = 1; | ||
static VERSION_MINOR = 0; | ||
static VERSION_BUILD = 1; | ||
static VERSION_CODENAME = "Creek"; | ||
} | ||
|
||
export class AppInfo { | ||
static APP_NAME: string = "Terabit Desktop"; | ||
} | ||
static APP_NAME: string = "Terabit Desktop"; | ||
} |
Oops, something went wrong.