some updates

canary
WolverinDEV 2019-09-01 17:24:06 +02:00
parent 63683eadba
commit 469e5d25d2
28 changed files with 496 additions and 168 deletions

106
files.php
View File

@ -325,15 +325,16 @@
"path" => "./popup/certaccept/", "path" => "./popup/certaccept/",
"local-path" => "./shared/popup/certaccept/html/" "local-path" => "./shared/popup/certaccept/html/"
], ],
[ /* javascript loader (debug) */ [ /* javascript loader (debug) */
"type" => "js", "type" => "js",
"search-pattern" => "/.*\.js$/", "search-pattern" => "/(loader|certaccept)\.js$/",
"build-target" => "dev", "build-target" => "dev",
"path" => "./popup/certaccept/loader/", "path" => "./popup/certaccept/loader/",
"local-path" => "./shared/loader/" "local-path" => "./shared/loader/"
], ],
[ /* javascript loader for releases */ [ /* javascript loader (releases) */
"type" => "js", "type" => "js",
"search-pattern" => "/.*loader_certaccept.min.js$/", "search-pattern" => "/.*loader_certaccept.min.js$/",
"build-target" => "rel", "build-target" => "rel",
@ -342,13 +343,67 @@
"local-path" => "./shared/generated/" "local-path" => "./shared/generated/"
], ],
[ /* javascript imported from shared for debug */
"type" => "js",
"search-pattern" => "/^(BrowserIPC|log|proto|settings)\.js$/",
"build-target" => "dev",
"path" => "./popup/certaccept/js/",
"local-path" => "./shared/js/"
],
[ /* javascript for debug */ [ /* javascript for debug */
"type" => "js",
"search-pattern" => "/^certaccept\.min\.js$/",
"build-target" => "rel",
"path" => "./popup/certaccept/js/",
"local-path" => "./shared/generated/"
],
[ /* javascript for release */
"type" => "js", "type" => "js",
"search-pattern" => "/^.*\.js$/", "search-pattern" => "/^.*\.js$/",
"build-target" => "dev", "build-target" => "dev",
"path" => "./popup/certaccept/js/", "path" => "./popup/certaccept/js/",
"local-path" => "./shared/js/" "local-path" => "./shared/popup/certaccept/js/"
],
[ /* shared css files */
"type" => "css",
"search-pattern" => "/.*\.css$/",
"build-target" => "rel|dev",
"path" => "./popup/certaccept/css/loader/",
"local-path" => "./shared/css/loader/"
],
[ /* shared css files */
"type" => "css",
"search-pattern" => "/.*\.css$/",
"build-target" => "rel|dev",
"path" => "./popup/certaccept/css/static/",
"local-path" => "./shared/popup/certaccept/css/static/"
],
[ /* img files */
"type" => "img",
"search-pattern" => "/^(loading_error.*)\.(svg)$/",
"build-target" => "dev|rel",
"path" => "./popup/certaccept/img/",
"local-path" => "./shared/img/"
],
[ /* jquery vendor */
"type" => "js",
"search-pattern" => "/^jquery\/.*\.js$/",
"build-target" => "dev|rel",
"path" => "./popup/certaccept/vendor/",
"local-path" => "./vendor/"
], ],
]; ];
@ -461,7 +516,7 @@
foreach($files as $key => $value){ foreach($files as $key => $value){
$path = $base_dir.$dir.DIRECTORY_SEPARATOR.$value; $path = $base_dir.$dir.DIRECTORY_SEPARATOR.$value;
if(!is_dir($path)) { if(!is_dir($path)) {
if(!$match || preg_match($match, ($dir ? $dir.DIRECTORY_SEPARATOR : "").$value)) if(!$match || preg_match($match, ($dir ? $dir . DIRECTORY_SEPARATOR : "") . $value))
$results[] = ($dir ? $dir.DIRECTORY_SEPARATOR : "").$value; $results[] = ($dir ? $dir.DIRECTORY_SEPARATOR : "").$value;
} else if($value != "." && $value != "..") { } else if($value != "." && $value != "..") {
list_dir($base_dir, $match, $depth - 1, $results, ($dir ? $dir.DIRECTORY_SEPARATOR : "").$value); list_dir($base_dir, $match, $depth - 1, $results, ($dir ? $dir.DIRECTORY_SEPARATOR : "").$value);
@ -481,7 +536,25 @@
public $hash; public $hash;
} }
function find_files($flag = 0b11, $local_path_prefix = "." . DIRECTORY_SEPARATOR, $type = "dev", $args = []) { //TODO Use cache here! function normalizePath($path) {
return array_reduce(explode('/', $path), create_function('$a, $b', '
if($a === 0 && $b === ".")
return "./";
if($a === 0)
$a = "/";
if($b === "" || $b === ".")
return $a;
if($b === "..")
return dirname($a);
return preg_replace("/\/+/", "/", "$a/$b");
'), 0);
}
function find_files($flag = 0b11, $local_path_prefix = "." . DIRECTORY_SEPARATOR, $target_path_prefix = "." . DIRECTORY_SEPARATOR, $type = "dev", $args = []) { //TODO Use cache here!
global $APP_FILE_LIST; global $APP_FILE_LIST;
$result = []; $result = [];
@ -510,8 +583,8 @@
$file = new AppFile; $file = new AppFile;
$f_info = pathinfo($f_entry); $f_info = pathinfo($f_entry);
$file->target_path = realpath(systemify_path($entry["path"]) . DIRECTORY_SEPARATOR . $f_info["dirname"] . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $file->target_path = normalizePath($target_path_prefix . systemify_path($entry["path"]) . DIRECTORY_SEPARATOR . $f_info["dirname"]) . DIRECTORY_SEPARATOR;
$file->local_path = realpath(getcwd() . DIRECTORY_SEPARATOR . systemify_path($entry["local-path"]) . DIRECTORY_SEPARATOR . $f_info["dirname"] . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $file->local_path = normalizePath(getcwd() . DIRECTORY_SEPARATOR . systemify_path($entry["local-path"]) . DIRECTORY_SEPARATOR . $f_info["dirname"]) . DIRECTORY_SEPARATOR;
$file->name = $f_info["basename"]; $file->name = $f_info["basename"];
$file->type = $entry["type"]; $file->type = $entry["type"];
@ -561,10 +634,10 @@
if($_SERVER["argv"][3] == "dev" || $_SERVER["argv"][3] == "development") { if($_SERVER["argv"][3] == "dev" || $_SERVER["argv"][3] == "development") {
if ($_SERVER["argv"][2] == "web") { if ($_SERVER["argv"][2] == "web") {
$flagset = 0b01; $flagset = 0b01;
$environment = join_path("web", "environment", "development"); $environment = "." . DIRECTORY_SEPARATOR . join_path("web", "environment", "development");
} else if ($_SERVER["argv"][2] == "client") { } else if ($_SERVER["argv"][2] == "client") {
$flagset = 0b10; $flagset = 0b10;
$environment = join_path("client-api", "environment", "ui-files", "raw"); $environment = "." . DIRECTORY_SEPARATOR . join_path("client-api", "environment", "ui-files", "raw");
} else { } else {
error_log("Invalid type!"); error_log("Invalid type!");
goto help; goto help;
@ -573,10 +646,10 @@
$type = "rel"; $type = "rel";
if ($_SERVER["argv"][2] == "web") { if ($_SERVER["argv"][2] == "web") {
$flagset = 0b01; $flagset = 0b01;
$environment = join_path("web", "environment", "release"); $environment = "." . DIRECTORY_SEPARATOR . join_path("web", "environment", "release");
} else if ($_SERVER["argv"][2] == "client") { } else if ($_SERVER["argv"][2] == "client") {
$flagset = 0b10; $flagset = 0b10;
$environment = join_path("client-api", "environment", "ui-files", "raw"); $environment = "." . DIRECTORY_SEPARATOR . join_path("client-api", "environment", "ui-files", "raw");
} else { } else {
error_log("Invalid type!"); error_log("Invalid type!");
goto help; goto help;
@ -595,12 +668,7 @@
goto handle_error; goto handle_error;
} }
$files = find_files($flagset, "." . DIRECTORY_SEPARATOR, $type, array_slice($_SERVER["argv"], 4)); $files = find_files($flagset, "." . DIRECTORY_SEPARATOR, $environment . DIRECTORY_SEPARATOR, $type, array_slice($_SERVER["argv"], 4));
$original_path = realpath(".");
if(!chdir($environment)) {
error_log("Failed to enter directory " . $environment . "!");
exit(1);
}
/** @var AppFile $file */ /** @var AppFile $file */
foreach($files as $file) { foreach($files as $file) {
@ -612,10 +680,6 @@
if(create_link($output, $file->local_path . $file->name, $file->target_path . $file->name, $dry_run) === false) if(create_link($output, $file->local_path . $file->name, $file->target_path . $file->name, $dry_run) === false)
goto handle_error; goto handle_error;
} }
if(!chdir($original_path)) {
error_log("Failed to reset directory!");
exit(1);
}
echo "Generated!" . PHP_EOL; echo "Generated!" . PHP_EOL;
} }

View File

@ -41,8 +41,12 @@ replace_tribble client/declarations/exports.d.ts
echo "Generated client declarations" echo "Generated client declarations"
#Shared #Shared
npm run dtsgen -- --config shared/tsconfig/dtsconfig.json -v ./shared/generate_declarations.sh
replace_tribble shared/declarations/exports.d.ts [[ $? -ne 0 ]] && {
echo "Failed to generate shared"
}
#replace_tribble shared/declarations/exports.d.ts
echo "Generated shared declarations" echo "Generated shared declarations"
#Now build the merged declaration for the shared project #Now build the merged declaration for the shared project
@ -54,14 +58,10 @@ if [[ ! -d shared/declarations ]]; then
exit 1 exit 1
fi fi
fi fi
#The shared part has no access to the other parts, it just declares a abstract API
#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 #Last but not least the client imports
generate_link shared/declarations/exports.d.ts web/declarations/imports_shared.d.ts generate_link shared/declarations/exports_app.d.ts web/declarations/imports_shared.d.ts
generate_link shared/declarations/exports_loader_app.d.ts web/declarations/imports_shared_loader.d.ts generate_link shared/declarations/exports_loader_app.d.ts web/declarations/imports_shared_loader.d.ts
generate_link shared/declarations/exports.d.ts client/declarations/imports_shared.d.ts generate_link shared/declarations/exports_app.d.ts client/declarations/imports_shared.d.ts
generate_link shared/declarations/exports_loader_app.d.ts client/declarations/imports_shared_loader.d.ts generate_link shared/declarations/exports_loader_app.d.ts client/declarations/imports_shared_loader.d.ts

View File

@ -50,6 +50,16 @@ files=(
) )
target_file=`pwd`/../generated/static/base.css target_file=`pwd`/../generated/static/base.css
if [[ ! -d $(dirname ${target_file}) ]]; then
echo "Creating target path ($(dirname ${target_file}))"
mkdir -p $(dirname ${target_file})
if [[ $? -ne 0 ]]; then
echo "Failed to create target path!"
exit 1
fi
fi
echo "/* Auto generated merged CSS file */" > ${target_file} echo "/* Auto generated merged CSS file */" > ${target_file}
for file in "${files[@]}"; do for file in "${files[@]}"; do
if [[ ${file} =~ css/* ]]; then if [[ ${file} =~ css/* ]]; then

34
shared/generate_declarations.sh Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
cd "$BASEDIR"
source ../scripts/resolve_commands.sh
function generate_declaration() {
echo "Generating declarations for project $1 ($2)"
if [[ -e ${2} ]]; then
rm ${2}
if [[ $? -ne 0 ]]; then
echo "Failed to remove old declaration file ($2)!"
echo "This could be critical later!"
fi
fi
npm run dtsgen -- --config $(pwd)/tsconfig/$1 -v
if [[ ! -e $2 ]]; then
echo "Failed to generate definitions"
exit 1
fi
}
#Generate the loader definitions first
app_declaration="declarations/exports_app.d.ts"
loader_declaration_app="declarations/exports_loader_app.d.ts"
loader_declaration_certaccept="declarations/exports_loader_certaccept.d.ts"
generate_declaration dtsconfig_app.json ${app_declaration}
generate_declaration dtsconfig_loader_app.json ${loader_declaration_app}
generate_declaration dtsconfig_loader_certaccept.json ${loader_declaration_certaccept}
exit 0

View File

@ -3,28 +3,7 @@
BASEDIR=$(dirname "$0") BASEDIR=$(dirname "$0")
cd "$BASEDIR" cd "$BASEDIR"
source ../scripts/resolve_commands.sh source ../scripts/resolve_commands.sh
# The app loader
#Generate the loader definitions first
LOADER_FILE="declarations/exports_loader_app.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
npm run dtsgen -- --config $(pwd)/tsconfig/dtsconfig_loader_app.json -v
if [[ ! -e ${LOADER_FILE} ]]; then
echo "Failed to generate definitions"
exit 1
fi
npm run dtsgen -- --config $(pwd)/tsconfig/dtsconfig_packed.json -v
if [[ $? -ne 0 ]]; then
echo "Failed to generate definitions for the loader"
exit 1
fi
execute_ttsc -p tsconfig/tsconfig_packed_loader_app.json execute_ttsc -p tsconfig/tsconfig_packed_loader_app.json
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "Failed to generate packed loader file!" echo "Failed to generate packed loader file!"
@ -37,21 +16,37 @@ if [[ $? -ne 0 ]]; then
exit 1 exit 1
fi fi
# The popup certaccept loader
execute_ttsc -p tsconfig/tsconfig_packed_loader_certaccept.json
if [[ $? -ne 0 ]]; then
echo "Failed to generate packed loader file!"
exit 1
fi
npm run minify-web-rel-file `pwd`/generated/loader_certaccept.min.js `pwd`/generated/loader_certaccept.js
if [[ $? -ne 0 ]]; then
echo "Failed to minimize packed loader file!"
exit 1
fi
# The main shared source
execute_ttsc -p tsconfig/tsconfig_packed.json execute_ttsc -p tsconfig/tsconfig_packed.json
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "Failed to generate packed file!" echo "Failed to generate packed file!"
exit 1 exit 1
fi fi
#Now link the loader file # The certaccept source
if [[ ! -L generated/load.js ]]; then execute_ttsc -p tsconfig/tsconfig_packed_certaccept.json
rm generated/load.js 2>/dev/null if [[ $? -ne 0 ]]; then
ln -rs js/load.js generated/load.js echo "Failed to generate packed certaccept file!"
exit 1
fi fi
if [[ ! -d generated/static/ ]]; then npm run minify-web-rel-file `pwd`/generated/certaccept.min.js `pwd`/generated/certaccept.js
mkdir -p generated/static/ if [[ $? -ne 0 ]]; then
echo "Failed to minimize the certaccept file!"
exit 1
fi fi
# Create packed CSS file # Create packed CSS file

View File

@ -37,7 +37,7 @@
?> ?>
<!-- PHP generated properties --> <!-- PHP generated properties -->
<x-properties id="properties"> <x-properties id="properties" style="display: none">
<?php <?php
function spawn_property($name, $value, $element_id = null) function spawn_property($name, $value, $element_id = null)
{ {
@ -119,7 +119,8 @@
display: block; display: block;
} }
</style> </style>
</head>
<body>
<div id="style"> <div id="style">
<link rel="stylesheet" href="css/loader/loader.css"> <link rel="stylesheet" href="css/loader/loader.css">
</div> </div>
@ -130,8 +131,7 @@
<script type="application/javascript" src="loader/loader_app.js" defer></script> <script type="application/javascript" src="loader/loader_app.js" defer></script>
<script type="application/javascript" src="loader/loader.js?_<?php echo time() ?>" defer></script> <script type="application/javascript" src="loader/loader.js?_<?php echo time() ?>" defer></script>
</div> </div>
</head>
<body>
<!-- No javascript error --> <!-- No javascript error -->
<div class="fulloverlay no-js"> <div class="fulloverlay no-js">
<div class="container"> <div class="container">

View File

@ -1,3 +1,5 @@
//Used by CertAccept popup
interface Window { interface Window {
BroadcastChannel: BroadcastChannel; BroadcastChannel: BroadcastChannel;
} }

View File

@ -173,7 +173,6 @@ class ConnectionHandler {
if(this.serverConnection) if(this.serverConnection)
this.handleDisconnect(DisconnectReason.REQUESTED); this.handleDisconnect(DisconnectReason.REQUESTED);
let server_address: ServerAddress = { let server_address: ServerAddress = {
host: "", host: "",
port: -1 port: -1
@ -333,13 +332,13 @@ class ConnectionHandler {
connect_address: this.serverConnection.remote_address().host + (this.serverConnection.remote_address().port !== 9987 ? ":" + this.serverConnection.remote_address().port : "") connect_address: this.serverConnection.remote_address().host + (this.serverConnection.remote_address().port !== 9987 ? ":" + this.serverConnection.remote_address().port : "")
}; };
const build_url = props => { const build_url = (base: string, search: string, props: any) => {
const parameters: string[] = []; const parameters: string[] = [];
for(const key of Object.keys(props)) for(const key of Object.keys(props))
parameters.push(key + "=" + encodeURIComponent(props[key])); parameters.push(key + "=" + encodeURIComponent(props[key]));
let callback = document.location.origin + document.location.pathname + document.location.search; /* don't use document.URL because it may contains a #! */ let callback = base + search; /* don't use document.URL because it may contains a #! */
if(document.location.search.length == 0) if(!search)
callback += "?" + parameters.join("&"); callback += "?" + parameters.join("&");
else else
callback += "&" + parameters.join("&"); callback += "&" + parameters.join("&");
@ -378,7 +377,7 @@ class ConnectionHandler {
this.startConnection(properties.connect_address, profile, true, cprops); this.startConnection(properties.connect_address, profile, true, cprops);
}); });
const url = build_url(properties); const url = build_url(document.location.origin + document.location.pathname + "/popup/certaccept/", "", properties);
const features_string = [...Object.keys(features)].map(e => e + "=" + features[e]).reduce((a, b) => a + "," + b); const features_string = [...Object.keys(features)].map(e => e + "=" + features[e]).reduce((a, b) => a + "," + b);
popup = window.open(url, "TeaWeb certificate accept", features_string); popup = window.open(url, "TeaWeb certificate accept", features_string);
try { try {
@ -393,7 +392,7 @@ class ConnectionHandler {
} }
}); });
} else { } else {
tag.attr('href', build_url(properties)); tag.attr('href', build_url(document.location.origin + document.location.pathname, document.location.search, properties));
} }
return tag; return tag;
} }

View File

@ -102,7 +102,7 @@ class RequestFileUpload {
this.transfer_key = key; this.transfer_key = key;
} }
async put_data(data: BlobPart | File) { async put_data(data: BlobPart | File) : Promise<void> {
const form_data = new FormData(); const form_data = new FormData();
if(data instanceof File) { if(data instanceof File) {
@ -125,7 +125,7 @@ class RequestFileUpload {
await this.try_put(form_data, "https://" + this.transfer_key.peer.hosts[0] + ":" + this.transfer_key.peer.port); await this.try_put(form_data, "https://" + this.transfer_key.peer.hosts[0] + ":" + this.transfer_key.peer.port);
} }
async try_put(data: FormData, url: string) : Promise<void> { private async try_put(data: FormData, url: string) : Promise<void> {
const response = await fetch(url, { const response = await fetch(url, {
method: 'POST', method: 'POST',
cache: "no-cache", cache: "no-cache",

View File

@ -72,7 +72,7 @@ namespace bookmarks {
export interface DirectoryBookmark { export interface DirectoryBookmark {
type: /* BookmarkType.DIRECTORY */ BookmarkType; type: /* BookmarkType.DIRECTORY */ BookmarkType;
readonly parent: DirectoryBookmark; /* readonly */ parent: DirectoryBookmark;
readonly content: (Bookmark | DirectoryBookmark)[]; readonly content: (Bookmark | DirectoryBookmark)[];
unique_id: string; unique_id: string;

View File

@ -1,3 +1,5 @@
//Used by CertAccept popup
enum LogCategory { enum LogCategory {
CHANNEL, CHANNEL,
CHANNEL_PROPERTIES, /* separating channel and channel properties because on channel init logging is a big bottleneck */ CHANNEL_PROPERTIES, /* separating channel and channel properties because on channel init logging is a big bottleneck */
@ -238,4 +240,6 @@ namespace log {
this._log_prefix = prefix; this._log_prefix = prefix;
} }
} }
} }
import LogType = log.LogType;

View File

@ -1,8 +1,6 @@
/// <reference path="../ConnectionHandler.ts" /> /// <reference path="../ConnectionHandler.ts" />
/// <reference path="../connection/ConnectionBase.ts" /> /// <reference path="../connection/ConnectionBase.ts" />
import LogType = log.LogType;
enum PermissionType { enum PermissionType {
B_SERVERINSTANCE_HELP_VIEW = "b_serverinstance_help_view", /* Permission ID: 1 */ B_SERVERINSTANCE_HELP_VIEW = "b_serverinstance_help_view", /* Permission ID: 1 */
B_SERVERINSTANCE_VERSION_VIEW = "b_serverinstance_version_view", /* Permission ID: 2 */ B_SERVERINSTANCE_VERSION_VIEW = "b_serverinstance_version_view", /* Permission ID: 2 */

View File

@ -1,3 +1,5 @@
//Used by CertAccept popup
interface Array<T> { interface Array<T> {
remove(elem?: T): boolean; remove(elem?: T): boolean;
last?(): T; last?(): T;

View File

@ -1,3 +1,5 @@
//Used by CertAccept popup
if(typeof(customElements) !== "undefined") { if(typeof(customElements) !== "undefined") {
try { try {
class X_Properties extends HTMLElement {} class X_Properties extends HTMLElement {}

View File

@ -620,7 +620,7 @@ class ChannelEntry {
invalidPermission: !channelCreate, invalidPermission: !channelCreate,
callback: () => this.channelTree.spawnCreateChannel() callback: () => this.channelTree.spawnCreateChannel()
}, },
contextmenu.Entry.CLOSE(() => (trigger_close ? on_close : () => {})()) contextmenu.Entry.CLOSE(() => trigger_close ? on_close() : {})
); );
} }

View File

@ -605,7 +605,7 @@ class ClientEntry {
visible: this._audio_muted, visible: this._audio_muted,
callback: () => this.set_muted(false, true) callback: () => this.set_muted(false, true)
}, },
contextmenu.Entry.CLOSE(() => (trigger_close ? on_close : (() => {}))()) contextmenu.Entry.CLOSE(() => trigger_close ? on_close() : {})
); );
} }

View File

@ -1990,14 +1990,14 @@ test
else else
entry.html_element.insertAfter(this._view_older_messages.html_element); /* last element is already the current element */ entry.html_element.insertAfter(this._view_older_messages.html_element); /* last element is already the current element */
if(_new_message && (typeof(this._scroll_position) === "number" || this.handle.current_channel() !== this.channel_id)) { if(_new_message && (typeof(this._scroll_position) === "number" || this.handle.current_channel() !== this.channel_id || this.handle.handle.content_type() !== FrameContent.CHANNEL_CHAT)) {
if(typeof(this._first_unread_message) === "undefined") if(typeof(this._first_unread_message) === "undefined")
this._first_unread_message = entry; this._first_unread_message = entry;
this._first_unread_message_pointer.html_element.insertBefore(entry.html_element); this._first_unread_message_pointer.html_element.insertBefore(entry.html_element);
this._container_messages.trigger('scroll'); /* updates the new message stuff */ this._container_messages.trigger('scroll'); /* updates the new message stuff */
} }
if(update_view) if(typeof(update_view) !== "boolean" || update_view)
this.fix_scroll(true); this.fix_scroll(true);
} }
@ -2564,6 +2564,8 @@ test
html_tag() : JQuery { return this._html_tag; } html_tag() : JQuery { return this._html_tag; }
info_frame() : InfoFrame { return this._info_frame; } info_frame() : InfoFrame { return this._info_frame; }
content_type() : FrameContent { return this._content_type; }
destroy() { destroy() {
this._html_tag && this._html_tag.remove(); this._html_tag && this._html_tag.remove();
this._html_tag = undefined; this._html_tag = undefined;

View File

@ -249,12 +249,12 @@ namespace Modals {
}); });
button_connect_tab.on('click', event => { button_connect_tab.on('click', event => {
bookmarks.boorkmak_connect(selected_bookmark, true); bookmarks.boorkmak_connect(selected_bookmark as bookmarks.Bookmark, true);
modal.close(); modal.close();
}).toggle(!settings.static_global(Settings.KEY_DISABLE_MULTI_SESSION)); }).toggle(!settings.static_global(Settings.KEY_DISABLE_MULTI_SESSION));
button_connect.on('click', event => { button_connect.on('click', event => {
bookmarks.boorkmak_connect(selected_bookmark, false); bookmarks.boorkmak_connect(selected_bookmark as bookmarks.Bookmark, false);
modal.close(); modal.close();
}); });
} }
@ -293,8 +293,19 @@ namespace Modals {
update_connect_info(); update_connect_info();
} }
}); });
input_connect_profile.on('change', event => {
const id = input_connect_profile.val() as string;
const profile = profiles.profiles().find(e => e.id === id);
if(profile) {
(selected_bookmark as bookmarks.Bookmark).connect_profile = id;
} else {
log.warn(LogCategory.GENERAL, tr("Failed to change connect profile for profile %s to %s"), selected_bookmark.unique_id, id);
}
})
} }
update_bookmark_list(); update_bookmark_list();
update_buttons(); update_buttons();

View File

@ -252,7 +252,7 @@ class ServerEntry {
name: tr("View avatars"), name: tr("View avatars"),
callback: () => Modals.spawnAvatarList(this.channelTree.client) callback: () => Modals.spawnAvatarList(this.channelTree.client)
}, },
contextmenu.Entry.CLOSE(() => (trigger_close ? on_close : (() => {}))()) contextmenu.Entry.CLOSE(() => trigger_close ? on_close() : {})
); );
} }

View File

@ -428,47 +428,6 @@ async function load_templates() {
} }
} }
//FUN: loader_ignore_age=0&loader_default_duration=1500&loader_default_age=5000
let _fadeout_warned = false;
function fadeoutLoader(duration = undefined, minAge = undefined, ignoreAge = undefined) {
if(typeof($) === "undefined") {
if(!_fadeout_warned)
console.warn("Could not fadeout loader screen. Missing jquery functions.");
_fadeout_warned = true;
return;
}
let settingsDefined = typeof(StaticSettings) !== "undefined";
if(!duration) {
if(settingsDefined)
duration = StaticSettings.instance.static("loader_default_duration", 750);
else duration = 750;
}
if(!minAge) {
if(settingsDefined)
minAge = StaticSettings.instance.static("loader_default_age", 1750);
else minAge = 750;
}
if(!ignoreAge) {
if(settingsDefined)
ignoreAge = StaticSettings.instance.static("loader_ignore_age", false);
else ignoreAge = false;
}
/*
let age = Date.now() - app.appLoaded;
if(age < minAge && !ignoreAge) {
setTimeout(() => fadeoutLoader(duration, 0, true), minAge - age);
return;
}
*/
$(".loader .bookshelf_wrapper").animate({top: 0, opacity: 0}, duration);
$(".loader .half").animate({width: 0}, duration, () => {
$(".loader").detach();
});
}
/* register tasks */ /* register tasks */
loader.register_task(loader.Stage.INITIALIZING, { loader.register_task(loader.Stage.INITIALIZING, {
name: "safari fix", name: "safari fix",
@ -629,7 +588,7 @@ loader.register_task(loader.Stage.SETUP, {
loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, { loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
name: "log enabled initialisation", name: "log enabled initialisation",
function: async () => log.initialize(app.type === app.Type.CLIENT_DEBUG || app.type === app.Type.WEB_DEBUG ? LogType.TRACE : LogType.INFO), function: async () => log.initialize(app.type === app.Type.CLIENT_DEBUG || app.type === app.Type.WEB_DEBUG ? log.LogType.TRACE : log.LogType.INFO),
priority: 150 priority: 150
}); });

View File

@ -1,5 +1,110 @@
/// <reference path="loader.ts" /> /// <reference path="loader.ts" />
let is_debug = false;
/* all javascript loaders */
const loader_javascript = {
detect_type: async () => {
/* test if js/proto.js is available. If so we're in debug mode */
const request = new XMLHttpRequest();
request.open('GET', 'js/proto.js', true);
await new Promise((resolve, reject) => {
request.onreadystatechange = () => {
if (request.readyState === 4){
is_debug = request.status !== 404;
resolve();
}
};
request.onerror = () => {
reject("Failed to detect app type");
};
request.send();
});
},
load_scripts: async () => {
await loader.load_script(["vendor/jquery/jquery.min.js"]);
if(!is_debug) {
loader.register_task(loader.Stage.JAVASCRIPT, {
name: "scripts release",
priority: 20,
function: loader_javascript.load_release
});
} else {
loader.register_task(loader.Stage.JAVASCRIPT, {
name: "scripts debug",
priority: 20,
function: loader_javascript.load_scripts_debug
});
}
},
load_scripts_debug: async () => {
await loader.load_scripts([
["js/proto.js"],
["js/log.js"],
["js/BrowserIPC.js"],
["js/settings.js"],
["js/main.js"]
]);
},
load_release: async () => {
await loader.load_scripts([
["js/certaccept.min.js", "js/certaccept.js"]
]);
}
};
const loader_style = {
load_style: async () => {
if(is_debug) {
await loader_style.load_style_debug();
} else {
await loader_style.load_style_release();
}
},
load_style_debug: async () => {
await loader.load_styles([
"css/static/main.css",
]);
},
load_style_release: async () => {
await loader.load_styles([
"css/static/main.css",
]);
}
};
loader.register_task(loader.Stage.INITIALIZING, {
name: "app type test",
function: loader_javascript.detect_type,
priority: 20
});
loader.register_task(loader.Stage.JAVASCRIPT, {
name: "javascript",
function: loader_javascript.load_scripts,
priority: 10
});
loader.register_task(loader.Stage.STYLE, {
name: "style",
function: loader_style.load_style,
priority: 10
});
loader.register_task(loader.Stage.LOADED, {
name: "loaded handler",
function: async () => {
fadeoutLoader();
},
priority: 0
});
/* register tasks */ /* register tasks */
loader.register_task(loader.Stage.INITIALIZING, { loader.register_task(loader.Stage.INITIALIZING, {
name: "safari fix", name: "safari fix",
@ -18,9 +123,22 @@ loader.register_task(loader.Stage.INITIALIZING, {
priority: 50 priority: 50
}); });
loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
name: "settings initialisation",
function: async () => Settings.initialize(),
priority: 200
});
loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
name: "bipc initialisation",
function: async () => bipc.setup(),
priority: 100
});
loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, { loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
name: "log enabled initialisation", name: "log enabled initialisation",
function: async () => log.initialize(app.type === app.Type.CLIENT_DEBUG || app.type === app.Type.WEB_DEBUG ? LogType.TRACE : LogType.INFO), function: async () => log.initialize(is_debug ? log.LogType.TRACE : log.LogType.INFO),
priority: 150 priority: 150
}); });

View File

@ -601,6 +601,48 @@ namespace loader {
} }
} }
//FUN: loader_ignore_age=0&loader_default_duration=1500&loader_default_age=5000
let _fadeout_warned = false;
function fadeoutLoader(duration = undefined, minAge = undefined, ignoreAge = undefined) {
if(typeof($) === "undefined") {
if(!_fadeout_warned)
console.warn("Could not fadeout loader screen. Missing jquery functions.");
_fadeout_warned = true;
return;
}
let settingsDefined = typeof(StaticSettings) !== "undefined";
if(!duration) {
if(settingsDefined)
duration = StaticSettings.instance.static("loader_default_duration", 750);
else duration = 750;
}
if(!minAge) {
if(settingsDefined)
minAge = StaticSettings.instance.static("loader_default_age", 1750);
else minAge = 750;
}
if(!ignoreAge) {
if(settingsDefined)
ignoreAge = StaticSettings.instance.static("loader_ignore_age", false);
else ignoreAge = false;
}
/*
let age = Date.now() - app.appLoaded;
if(age < minAge && !ignoreAge) {
setTimeout(() => fadeoutLoader(duration, 0, true), minAge - age);
return;
}
*/
$(".loader .bookshelf_wrapper").animate({top: 0, opacity: 0}, duration);
$(".loader .half").animate({width: 0}, duration, () => {
$(".loader").detach();
});
}
/* set a timeout here, so if this script is merged with the actual loader (like in rel mode) the actual could load this manually here */ /* set a timeout here, so if this script is merged with the actual loader (like in rel mode) the actual could load this manually here */
setTimeout(() => { setTimeout(() => {
if(loader.running()) { if(loader.running()) {
@ -654,6 +696,3 @@ setTimeout(() => {
loader.execute_managed(); loader.execute_managed();
}, 0); }, 0);

View File

@ -0,0 +1,66 @@
body {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: 0;
padding: 0;
background-color: #212529;
}
#container-success {
height: 100%;
display: flex;
flex-direction: column;
justify-content: stretch;
.container {
flex-grow: 0;
flex-shrink: 0;
align-self: center;
color: #999999;
background-color: #19191b;
border-radius: 5px;
overflow: hidden;
margin: 1em;
max-width: 80%;
width: 40em;
.content {
padding: 1em;
border-left: 2px solid #00d400;
a {
display: block;
font-size: 1.2em;
}
}
}
.spacer-top {
flex-shrink: 1;
flex-grow: 1;
height: 10%;
min-height: 0;
}
.spacer-bottom {
flex-shrink: 1;
flex-grow: 4;
height: 10%;
min-height: 0;
}
}

View File

@ -5,16 +5,7 @@
<title>Certificate callback</title> <title>Certificate callback</title>
<div id="style">
<link rel="stylesheet" href="css/loader/loader.css">
</div>
<meta name="app-loader-target" content="certaccept"> <meta name="app-loader-target" content="certaccept">
<div id="scripts">
<script type="application/javascript" src="loader/loader_certaccept.min.js" defer></script>
<script type="application/javascript" src="loader/loader_certaccept.js" defer></script>
<script type="application/javascript" src="loader/loader.js?_<?php echo time() ?>" defer></script>
</div>
<!-- required static style for the critical page and the enable javascript page --> <!-- required static style for the critical page and the enable javascript page -->
<style> <style>
@ -60,8 +51,20 @@
} }
} }
</style> </style>
<x-properties id="properties" style="display: none"> </x-properties>
</head> </head>
<body> <body>
<div id="style">
<link rel="stylesheet" href="css/loader/loader.css">
</div>
<div id="scripts">
<script type="application/javascript" src="loader/loader_certaccept.min.js" defer></script>
<script type="application/javascript" src="loader/loader_certaccept.js" defer></script>
<script type="application/javascript" src="loader/loader.js?_<?php echo time() ?>" defer></script>
</div>
<!-- Loading screen --> <!-- Loading screen -->
<div class="loader" id="loader-overlay"> <div class="loader" id="loader-overlay">
<div class="half right"></div> <div class="half right"></div>
@ -87,5 +90,23 @@
<h3 class="detail" style="margin-top: .5em"></h3> <h3 class="detail" style="margin-top: .5em"></h3>
</div> </div>
</div> </div>
<!-- success window -->
<div id="container-success">
<div class="spacer-top"></div>
<div class="container">
<div class="content">
<h1>Success!</h1>
<p>
<a>You've successfully accepted the certificate.</a>
<a>You will now connecting to the target server in the original tab.</a>
</p>
<p>
<a>This window will close automatically in <span id="time-left">X</span> seconds!</a>
</p>
</div>
</div>
<div class="spacer-bottom"></div>
</div>
</body> </body>
</html> </html>

View File

@ -1,31 +1,27 @@
function tr(text: string) { return text; } function tr(text: string) { return text; }
const task_certificate_callback: loader.Task = { loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
name: "certificate accept tester", name: "certificate accept tester",
function: async () => { function: async () => {
Settings.initialize();
const certificate_accept = settings.static_global(Settings.KEY_CERTIFICATE_CALLBACK, undefined); const certificate_accept = settings.static_global(Settings.KEY_CERTIFICATE_CALLBACK, undefined);
const container_success = $("#container-success").hide();
if(!certificate_accept) { if(!certificate_accept) {
loader.critical_error("Missing certificate callback data"); loader.critical_error(tr("Missing certificate callback data"), tr("Please reconnect manually."));
throw "missing data"; throw "missing data";
} }
log.info(LogCategory.IPC, tr("Using this instance as certificate callback. ID: %s"), certificate_accept); log.info(LogCategory.IPC, tr("Using this instance as certificate callback. ID: %s"), certificate_accept);
try { try {
try { await bipc.get_handler().post_certificate_accpected(certificate_accept);
await bipc.get_handler().post_certificate_accpected(certificate_accept);
} catch(e) {} //FIXME remove!
log.info(LogCategory.IPC, tr("Other instance has acknowledged out work. Closing this window.")); log.info(LogCategory.IPC, tr("Other instance has acknowledged out work. Closing this window."));
const seconds_tag = $.spawn("a");
let seconds = 5; let seconds = 5;
let interval_id; let interval_id;
interval_id = setInterval(() => { interval_id = setInterval(() => {
seconds--; seconds--;
seconds_tag.text(seconds.toString()); $("#time-left").text(seconds.toString());
if(seconds <= 0) { if(seconds <= 0) {
clearTimeout(interval_id); clearTimeout(interval_id);
@ -35,25 +31,11 @@ const task_certificate_callback: loader.Task = {
} }
}, 1000); }, 1000);
const message = container_success.show();
"You've successfully accepted the certificate.{:br:}" +
"This page will close in {0} seconds.";
/*
createInfoModal(
tr("Certificate acccepted successfully"),
MessageHelper.formatMessage(tr(message), seconds_tag),
{
closeable: false,
footer: undefined
}
).open();
*/
//TODO!
return;
} catch(error) { } catch(error) {
log.warn(LogCategory.IPC, tr("Failed to successfully post certificate accept status: %o"), error); log.warn(LogCategory.IPC, tr("Failed to successfully post certificate accept status: %o"), error);
//TODO! loader.critical_error(tr("Failed to emit success!"), tr("Please reconnect manually."));
} }
}, },
priority: 10 priority: 10
}; });

View File

@ -8,7 +8,7 @@
"include": [ "include": [
"../types", "../types",
"../declarations/imports_*.d.ts", "../declarations/imports_*.d.ts",
"../declarations/exports_packed.d.ts", "../declarations/exports_app.d.ts", /* lets include them because we require stuff like the log */
"../loader/loader.ts", "../loader/loader.ts",
"../loader/app.ts", "../loader/app.ts",
"../backend" "../backend"

View File

@ -8,6 +8,11 @@
"include": [ "include": [
"../types", "../types",
"../loader/loader.ts", "../loader/loader.ts",
"../loader/certaccept.ts" "../loader/certaccept.ts",
/*
Lets include them because we require stuff like the log.
More sense would it to make an extra d.ts file for that, but who cares
*/
"../declarations/exports_app.d.ts"
] ]
} }

View File

@ -137,8 +137,10 @@ function _generate(settings: _Settings, stack: StackParameters, layer: ts.Node[]
case SyntaxKind.EndOfFileToken: /* oh no, we're at the end */ case SyntaxKind.EndOfFileToken: /* oh no, we're at the end */
break; break;
default: default:
console.log("Unhandled type %s", SyntaxKind[node.kind]);
//node.forEachChild(n => _generate(settings, stack, layer, n)); //node.forEachChild(n => _generate(settings, stack, layer, n));
const sf = node.getSourceFile();
let { line, character } = sf ? sf.getLineAndCharacterOfPosition(node.getStart()) : {line: -1, character: -1};
console.log(`${(sf || {fileName: "unknown"}).fileName} (${line + 1},${character + 1}): Unhandled type %s`, SyntaxKind[node.kind]);
} }
} }
@ -409,11 +411,24 @@ generators[SyntaxKind.EnumDeclaration] = (settings, stack, node: ts.EnumDeclarat
return ts.createEnumDeclaration(undefined, append_export(append_declare(node.modifiers, !stack.flag_declare), stack.flag_namespace), node.name, members); return ts.createEnumDeclaration(undefined, append_export(append_declare(node.modifiers, !stack.flag_declare), stack.flag_namespace), node.name, members);
}; };
/* every variable in a block has no global scope! */ generators[SyntaxKind.HeritageClause] = (settings, stack, node: ts.HeritageClause) => {
generators[SyntaxKind.Block] = (settings, stack, node: ts.EnumMember) => {
return undefined; return undefined;
}; };
generators[SyntaxKind.IfStatement] = (settings, stack, node: ts.EnumMember) => { /* every variable in a block has no global scope! */
generators[SyntaxKind.Block] = (settings, stack, node: ts.Block) => {
return undefined;
};
generators[SyntaxKind.IfStatement] = (settings, stack, node: ts.IfStatement) => {
return undefined;
};
/* Example for an ExpressionStatement would be: Modul["text"] = "XXX"; */
generators[SyntaxKind.ExpressionStatement] = (settings, stack, node: ts.ExpressionStatement) => {
return undefined;
};
generators[SyntaxKind.SemicolonClassElement] = (settings, stack, node: ts.ExpressionStatement) => {
return undefined; return undefined;
}; };