Restructured project

canary
WolverinDEV 2018-10-28 23:01:09 +01:00
parent 5ea3b2591f
commit 5cbaa747ba
51 changed files with 3375 additions and 178 deletions

6
.gitignore vendored
View File

@ -9,7 +9,9 @@ generated/
node_modules/
auth/certs/
auth/js/auth.js.map
.sass-cache/
.idea/
web/*-environment/
client-api/environment
.package-lock.json

View File

@ -1,4 +1,14 @@
# Changelog:
* **28.10.18**
- Restructured the project
- Added a lot of helper scripts
- Added a native client declaration export file to access the native methods
* **27.10.18**
- Added speaker select option (client only)
- Displaying version of the client
- Reworked on the audio setting menu
* **20.10.18**
- Project restructuring (forgot to update the changelog)
- Added a complete ban ui

View File

@ -14,4 +14,4 @@
*Delete me: If you dont follow this issue template, you may not get a response or the issue get instantly closed.*
*Delete me: If you don't follow this issue template, you may not get a response or the issue get instantly closed.*

11
auth/.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
#Nope :)
certs/
#A local link just for browsing the files
xf/
css/**/*.css
css/**/*.css.map
js/**/*.js
js/**/*.js.map

2
client-api/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
#My local environment to deploy the files directly
environment/

5
client/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
css/**/*.css
css/**/*.css.map
js/**/*.js
js/**/*.js.map

View File

@ -23,4 +23,3 @@ declare namespace audio.player {
function set_device(device_id?: string): Promise<void>;
function current_device(device_id?: string): Device;
}
declare function getUserMediaFunction(): (settings: any, success: any, fail: any) => void;

View File

@ -1,5 +1,3 @@
/// <reference path="../app-definitions/native_api.d.ts" />
const ipc = require("electron").ipcRenderer;
let callback_listener: (() => any)[] = [];

View File

@ -1,8 +0,0 @@
RewriteEngine On
<Files .htaccess>
Order allow,deny
Allow from all
</Files>
RedirectMatch 403 ^/certs/.*

View File

@ -1 +0,0 @@
../auth/auth.php

View File

@ -1 +0,0 @@
../auth/certs/

View File

@ -1 +0,0 @@
../css/

View File

@ -1 +0,0 @@
../img/

View File

@ -1 +0,0 @@
../index.php

View File

@ -1 +0,0 @@
../../asm/generated/

View File

@ -1 +0,0 @@
../auth/login.php

View File

@ -1 +0,0 @@
../templates.html

View File

@ -1 +0,0 @@
../vendor/

View File

@ -1,14 +1,16 @@
<?php
/* this file generates the final environment. All files have to be compiled before! */
$APP_FILE_LIST = [
[
/* shared part */
[ /* shared html and php files */
"type" => "html",
"search-pattern" => "/^([a-zA-Z]+)\.html$/",
"search-pattern" => "/^([a-zA-Z]+)\.(html|php)$/",
"build-target" => "dev|rel",
"path" => "./",
"local-path" => "./"
"local-path" => "./shared/html/"
],
[
[ /* shared javascript files (development mode only) */
"type" => "js",
"search-pattern" => "/.*\.js$/",
"search-exclude" => "/(.*\/)?workers\/.*/",
@ -17,7 +19,7 @@
"path" => "js/",
"local-path" => "./shared/js/"
],
[
[ /* shared generated worker codec */
"type" => "js",
"search-pattern" => "/WorkerCodec.js$/",
"build-target" => "dev|rel",
@ -25,7 +27,7 @@
"path" => "js/workers/",
"local-path" => "./shared/js/workers/"
],
[
[ /* shared css files */
"type" => "css",
"search-pattern" => "/.*\.css$/",
"build-target" => "dev|rel",
@ -33,7 +35,7 @@
"path" => "css/",
"local-path" => "./shared/css/"
],
[
[ /* shared image files */
"type" => "img",
"search-pattern" => "/.*\.(svg|png)/",
"build-target" => "dev|rel",
@ -41,7 +43,7 @@
"path" => "img/",
"local-path" => "./shared/img/"
],
[
[ /* generated assembly files */
"type" => "wasm",
"search-pattern" => "/.*\.(wasm)/",
"build-target" => "dev|rel",
@ -49,7 +51,7 @@
"path" => "wasm/",
"local-path" => "./asm/generated/"
],
[ /* useless? */
[ /* generated assembly javascript files */
"type" => "js",
"search-pattern" => "/.*\.(js)/",
"build-target" => "dev|rel",
@ -76,7 +78,7 @@
"local-path" => "./vendor/"
],
/* client specs */
/* client specific */
[
"client-only" => true,
"type" => "css",
@ -96,8 +98,8 @@
"local-path" => "./client/js/"
],
/* web specs */
[
/* web specific */
[ /* web javascript files (development mode only) */
"web-only" => true,
"type" => "js",
"search-pattern" => "/.*\.js$/",
@ -106,7 +108,26 @@
"path" => "js/",
"local-path" => "./web/js/"
],
[
[ /* web merged javascript files (shared inclusive) */
"web-only" => true,
"type" => "js",
"search-pattern" => "/.*\.js$/",
"build-target" => "rel",
"path" => "js/",
"local-path" => "./web/generated/"
],
[ /* Add the shared generated files. Exclude the shared file because we're including it already */
"web-only" => true,
"type" => "js",
"search-pattern" => "/.*\.js$/",
"search-exclude" => "/shared\.js(.map)?$/",
"build-target" => "rel",
"path" => "js/",
"local-path" => "./shared/generated/"
],
[ /* web css files */
"web-only" => true,
"type" => "css",
"search-pattern" => "/.*\.css$/",
@ -115,7 +136,7 @@
"path" => "css/",
"local-path" => "./web/css/"
],
[
[ /* web html files */
"web-only" => true,
"type" => "html",
"search-pattern" => "/.*\.(php|html)/",
@ -123,36 +144,7 @@
"path" => "./",
"local-path" => "./web/html/"
],
[
/* "web-only" => true, */ //Currently client as well
"type" => "html",
"search-pattern" => "/.*\.(php|html)/",
"search-exclude" => "/(files.php)/",
"search-depth" => 1,
"build-target" => "dev|rel",
"path" => "./",
"local-path" => "./"
],
[
"web-only" => true,
"type" => "js",
"search-pattern" => "/.*\.(js)/",
"build-target" => "rel",
"path" => "./",
"local-path" => "./generated/"
],
[
"web-only" => true,
"type" => "js",
"search-pattern" => "/load.js/",
"build-target" => "rel",
"path" => "./js/",
"local-path" => "./shared/js/"
],
]
];
function list_dir($base_dir, $match = null, $depth = -1, &$results = array(), $dir = "") {
@ -256,7 +248,7 @@
if($_SERVER["argv"][3] == "dev") {
if ($_SERVER["argv"][2] == "web") {
$flagset = 0b01;
$environment = "web/dev-environment";
$environment = "web/environment/development";
} else if ($_SERVER["argv"][2] == "client") {
$flagset = 0b10;
$environment = "client-api/environment/ui-files/raw";
@ -268,7 +260,7 @@
$type = "rel";
if ($_SERVER["argv"][2] == "web") {
$flagset = 0b01;
$environment = "web/rel-environment";
$environment = "web/environment/release";
} else if ($_SERVER["argv"][2] == "client") {
$flagset = 0b10;
$environment = "client-api/environment/ui-files/raw";

3067
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +0,0 @@
#!/usr/bin/env bash
npm run compile-sass
npm run build-worker
npm run build-web-app-release
npm run build-web-preload
#uglifyjs -c --source-map --verbose -o generated/js/client.min.js generated/js/client.js
cp generated/js/client.js generated/js/client.min.js

41
scripts/build_declarations.sh Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
function generate_link() {
if [ ! -L $2 ] || [ ${BASH_ARGV[0]} == "force" ]; then
if [ -e $2 ]; then
rm $2
fi
ln -rs $1 $2
fi
}
BASEDIR=$(dirname "$0")
cd "$BASEDIR/../"
#Easy going: Each "module" has it's exports and imports
#So lets first build the exports and ignore any errors
#Note: For the client we have to use the given file
#Web
tsc -p web/tsconfig/tsdeclaration.json
echo "Generated web declarations"
#Shared
tsc -p shared/tsconfig/tsdeclaration.json
echo "Generated shared declarations"
#Now build the merged declaration for the shared project
#Link the declaration files (All interface declarations should be equal!)
if [ ! -d shared/declarations ]; then
mkdir shared/declarations
if [ $? -ne 0 ]; then
echo "Failed to create directory shared/declarations"
exit 1
fi
fi
generate_link client/declarations/exports.d.ts shared/declarations/imports_client.d.ts
generate_link web/declarations/exports.d.ts shared/declarations/imports_web.d.ts
#Last but not least the client imports
generate_link shared/declarations/exports.d.ts web/declarations/imports_shared.d.ts

View File

@ -1,3 +1,5 @@
# Attention this guid is currently outdated! (Project got restructured)
Anyway most of this stuff is still relevant for the web client, just the last few steps may differ
# Environment setup
## Basic system requirements

11
shared/.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
#Generate the declarations by yourself with /scripts/build_declarations.sh
declarations/*.d.ts
#Ignore the generated mapped files
css/**/*.css
css/**/*.css.map
js/**/*.js
js/**/*.js.map
generated/*

View File

@ -1,5 +0,0 @@
interface Window {
displayCriticalError: typeof displayCriticalError;
}
declare function displayCriticalError(message: string);

32
shared/generate_packed.sh Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
cd "$BASEDIR"
#Generate the loader definitions first
LOADER_FILE="declarations/exports_loader.d.ts"
if [ -e ${LOADER_FILE} ]; then
rm ${LOADER_FILE}
if [ $? -ne 0 ]; then
echo "Failed to remove loader file!\nThis could be critical later!"
fi
fi
tsc -p tsconfig/tsdeclaration_loader.json &> /dev/null #We dont want the output!
if [ ! -e ${LOADER_FILE} ]; then
echo "Failed to generate definitions"
exit 1
fi
tsc -p tsconfig/tsconfig_packed.json
if [ $? -ne 0 ]; then
echo "Failed to generate packed file!"
exit 1
fi
#Now link the loader file
if [ ! -L generated/load.js ]; then
ln -rs js/load.js generated/load.js
fi
echo "Packed file generated!"
exit 0

View File

@ -98,7 +98,9 @@
</div>
</head>
<body>
<?php if($WEB_CLIENT) { ?>
<?php
if(true) {
?>
<!-- No javascript error -->
<div style="display: block; position: fixed; top: 0px; bottom: 0px; left: 0px; right: 0px; background-color: gray; z-index: 1000; text-align: center;" class="no-js">
<div style="position: relative; display: inline-block; top: 30%">

View File

@ -116,7 +116,7 @@ function loadDebug() {
app.type = app.Type.DEBUG;
console.log("Load for debug!");
let custom_scripts: string[] | string[][] = [];
let custom_scripts: (string | string[])[] = [];
if(!window.require) {
console.log("Adding browser audio player");

View File

@ -21,6 +21,12 @@ let forumIdentity: TeaForumIdentity;
const js_render = window.jsrender || $;
const native_client = window.require !== undefined;
function getUserMediaFunction() {
if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia)
return (settings, success, fail) => { navigator.mediaDevices.getUserMedia(settings).then(success).catch(fail); };
return navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
}
function setup_close() {
if(settings.static(Settings.KEY_DISABLE_UNLOAD_DIALOG, false)) return;

View File

@ -59,7 +59,7 @@ namespace Modals {
switch (select.value) {
case "ppt":
let keyCode: number = parseInt(settings.global("vad_ppt_key", JQuery.Key.T.toString()));
let keyCode: number = parseInt(settings.global("vad_ppt_key", String.fromCharCode(JQuery.Key.T)));
vad_tag.find(".vat_ppt_key").text(String.fromCharCode(keyCode));
break;
case "vad":

View File

@ -1,5 +1,3 @@
/// <reference path="../../exports/audio/AudioPlayer.d.ts" />
enum PlayerState {
PREBUFFERING,
PLAYING,
@ -207,6 +205,8 @@ class AudioController {
}
private applyVolume(buffer: AudioBuffer) {
if(this._volume == 1) return;
for(let channel = 0; channel < buffer.numberOfChannels; channel++) {
let data = buffer.getChannelData(channel);
for(let sample = 0; sample < data.length; sample++) {
@ -222,10 +222,4 @@ class AudioController {
this._codecCache.push(new CodecClientCache());
return this._codecCache[codec];
}
}
function getUserMediaFunction() {
if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia)
return (settings, success, fail) => { navigator.mediaDevices.getUserMedia(settings).then(success).catch(fail); };
return navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
}

View File

@ -120,7 +120,7 @@ class VoiceRecorder {
reinitialiseVAD() {
let type = settings.global("vad_type", "vad");
if(type == "ppt") {
let keyCode: number = parseInt(settings.global("vad_ppt_key", JQuery.Key.T.toString()));
let keyCode: number = parseInt(settings.global("vad_ppt_key", String.fromCharCode(JQuery.Key.T)));
if(!(this.getVADHandler() instanceof PushToTalkVAD))
this.setVADHandler(new PushToTalkVAD(keyCode));
else (this.getVADHandler() as PushToTalkVAD).key = keyCode;

View File

@ -0,0 +1,15 @@
/* general shared project config */
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"sourceMap": true
},
"exclude": [
"../js/workers"
],
"include": [
"../declarations/imports_*.d.ts",
"../js/**/*.ts"
]
}

View File

@ -0,0 +1,20 @@
/*
config for generating one single file
Note: loader declarations have to be generated first
*/
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "none",
"outFile": "../generated/shared.js"
},
"exclude": [
"../js/workers",
"../js/load.ts"
],
"include": [
"../declarations/imports_*.d.ts",
"../declarations/exports_loader.d.ts",
"../js/**/*.ts"
]
}

View File

@ -0,0 +1,19 @@
{
"compilerOptions": {
"listFiles": true,
"module": "system",
"target": "es6",
"declaration": true,
"emitDeclarationOnly": true,
"allowJs": false,
"checkJs": false,
"outFile": "../declarations/exports"
},
"include": [
"../js/**/*.ts"
],
"exclude": [
"../js/workers/**/*.ts"
]
}

View File

@ -0,0 +1,16 @@
{
"compilerOptions": {
"listFiles": true,
"module": "system",
"target": "es6",
"declaration": true,
"emitDeclarationOnly": true,
"allowJs": false,
"checkJs": false,
"outFile": "../declarations/exports_loader"
},
"include": [
"../js/load.ts"
]
}

View File

@ -1,3 +1,4 @@
/* General file with least possible errors. This is just for your IDE (PHP-Storm for example) */
{
"compilerOptions": {
"target": "es6",
@ -7,7 +8,8 @@
"exclude": [
"node_modules",
"js/workers",
"enviroment",
"tsconfig"
"shared/declarations/**/*.d.ts",
"web/declarations/**/*.d.ts",
"vendor/**/*.ts"
]
}

View File

@ -1,5 +0,0 @@
declare namespace app {
let loadedListener: (() => any)[]
}
declare function displayCriticalError(message: string);

View File

@ -1,32 +0,0 @@
declare class StaticSettings {
static instance : StaticSettings;
static?<T>(key: string, _default?: T) : T;
deleteStatic(key: string);
}
declare type BodyCreator = (() => JQuery | JQuery[] | string) | string | JQuery | JQuery[];
declare class ModalProperties {
header: BodyCreator;
body: BodyCreator;
footer: BodyCreator;
closeListener: (() => void) | (() => void)[];
registerCloseListener(listener: () => void): this;
width: number | string;
hight: number | string;
closeable: boolean;
triggerClose();
}
declare function createErrorModal(header: BodyCreator, message: BodyCreator, props: ModalProperties | any);
declare function displayCriticalError(message: string);
declare interface Window {
$: JQuery;
displayCriticalError: typeof displayCriticalError;
}

View File

@ -1,7 +0,0 @@
{
"compilerOptions": {
"module": "none",
"target": "es6",
"sourceMap": true,
}
}

View File

@ -1,18 +0,0 @@
{
"extends": "./tsconfig_shared.json",
"compilerOptions": {
/* because were excluding load.ts we have to define its types */
"typeRoots" : ["../node_modules/@types/", "./@types/"],
"types" : ["exports", "jquery", "webassembly-js-api", "node", "emscripten"]
},
"exclude": [
"../node_modules",
"../shared/js/load.ts",
"../shared/js/codec/workers",
"../shared/js/workers"
],
"include": [
"../shared/js/**/*",
"../web/js/**/*"
]
}

View File

@ -1,6 +0,0 @@
{
"extends": "./tsconfig_web_app.json",
"compilerOptions": {
"outFile": "../generated/js/client.js",
}
}

View File

@ -1,12 +0,0 @@
{
"extends": "./tsconfig_shared.json",
"compilerOptions": {
/* because were excluding load.ts we have to define its types */
"typeRoots" : ["../node_modules/@types/", "./@types/"],
"types" : ["imports", "jquery", "webassembly-js-api", "node", "emscripten"]
},
"include": [
"../shared/js/load.ts",
"../shared/js/proto.ts"
]
}

9
web/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
environment/
generated/
declarations/
css/**/*.css
css/**/*.css.map
js/**/*.js
js/**/*.js.map

22
web/generate_packed.sh Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
cd "$BASEDIR"
if [ ! -e declarations/imports_shared.d.ts ]; then
echo "generate the declarations first!"
echo "Execute: /scripts/build_declarations.sh"
exit 1
fi
if [ ! -e ../shared/generated/shared.js ]; then
echo "generate the shared packed file first!"
echo "Execute: /shared/generate_packed.sh"
exit 1
fi
tsc -p tsconfig/tsconfig_packed.json
if [ $? -ne 0 ]; then
echo "Failed to build file"
exit 1
fi

View File

5
web/js/index.ts Normal file
View File

@ -0,0 +1,5 @@
interface Window {
displayCriticalError: typeof displayCriticalError;
}
declare function displayCriticalError(message: string); /* fun fact: is implemented within loader.js, but only because we cant override that file */

View File

@ -0,0 +1,12 @@
/* general web project config */
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"sourceMap": true
},
"include": [
"../declarations/imports_*.d.ts",
"../js/**/*.ts"
]
}

View File

@ -0,0 +1,14 @@
/* packed web project config */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "none",
"outFile": "../generated/client.js",
"allowJs": true
},
"include": [
"../declarations/imports_*.d.ts",
"../js/**/*.ts",
"../../shared/generated/shared.js"
]
}

View File

@ -8,7 +8,7 @@
"allowJs": false,
"checkJs": false,
"outFile": "declarations/web_api"
"outFile": "declarations/exports"
},
"include": [
"js/**/*.ts"