Replaced tabs with spaces
This commit is contained in:
parent
c4575b21b5
commit
1a78bf8d57
6 changed files with 244 additions and 202 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -4,3 +4,6 @@
|
||||||
[submodule "web/native-codec/libraries/opus"]
|
[submodule "web/native-codec/libraries/opus"]
|
||||||
path = web/native-codec/libraries/opus
|
path = web/native-codec/libraries/opus
|
||||||
url = https://github.com/xiph/opus.git
|
url = https://github.com/xiph/opus.git
|
||||||
|
[submodule "vendor/TeaEventBus"]
|
||||||
|
path = vendor/TeaEventBus
|
||||||
|
url = https://github.com/WolverinDEV/TeaEventBus.git
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Created by PhpStorm.
|
* Created by PhpStorm.
|
||||||
* User: WolverinDEV
|
* User: WolverinDEV
|
||||||
* Date: 04.10.18
|
* Date: 04.10.18
|
||||||
* Time: 16:42
|
* Time: 16:42
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$UI_BASE_PATH = "ui-files/";
|
$UI_BASE_PATH = "ui-files/";
|
||||||
$CLIENT_BASE_PATH = "files/";
|
$CLIENT_BASE_PATH = "files/";
|
||||||
|
|
||||||
function errorExit($message) {
|
function errorExit($message) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
die(json_encode([
|
die(json_encode([
|
||||||
"success" => false,
|
"success" => false,
|
||||||
"msg" => $message
|
"msg" => $message
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
function verifyPostSecret() {
|
function verifyPostSecret() {
|
||||||
if(!isset($_POST["secret"])) {
|
if(!isset($_POST["secret"])) {
|
||||||
errorExit("Missing required information!");
|
errorExit("Missing required information!");
|
||||||
}
|
}
|
||||||
|
@ -36,159 +36,159 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleRequest() {
|
function handleRequest() {
|
||||||
if(isset($_GET) && isset($_GET["type"])) {
|
if(isset($_GET) && isset($_GET["type"])) {
|
||||||
if ($_GET["type"] == "update-info") {
|
if ($_GET["type"] == "update-info") {
|
||||||
global $CLIENT_BASE_PATH;
|
global $CLIENT_BASE_PATH;
|
||||||
$raw_versions = file_get_contents($CLIENT_BASE_PATH . "/version.json");
|
$raw_versions = file_get_contents($CLIENT_BASE_PATH . "/version.json");
|
||||||
if($raw_versions === false) {
|
if($raw_versions === false) {
|
||||||
errorExit("Missing file!");
|
errorExit("Missing file!");
|
||||||
}
|
}
|
||||||
|
|
||||||
$versions = json_decode($raw_versions, true);
|
$versions = json_decode($raw_versions, true);
|
||||||
$versions["success"] = true;
|
$versions["success"] = true;
|
||||||
|
|
||||||
die(json_encode($versions));
|
die(json_encode($versions));
|
||||||
}
|
}
|
||||||
else if ($_GET["type"] == "update-download") {
|
else if ($_GET["type"] == "update-download") {
|
||||||
global $CLIENT_BASE_PATH;
|
global $CLIENT_BASE_PATH;
|
||||||
|
|
||||||
$path = $CLIENT_BASE_PATH . $_GET["channel"] . DIRECTORY_SEPARATOR . $_GET["version"] . DIRECTORY_SEPARATOR;
|
$path = $CLIENT_BASE_PATH . $_GET["channel"] . DIRECTORY_SEPARATOR . $_GET["version"] . DIRECTORY_SEPARATOR;
|
||||||
$raw_release_info = file_get_contents($path . "info.json");
|
$raw_release_info = file_get_contents($path . "info.json");
|
||||||
if($raw_release_info === false) {
|
if($raw_release_info === false) {
|
||||||
errorExit("missing info file (version and/or channel missing. Path was " . $path . ")");
|
errorExit("missing info file (version and/or channel missing. Path was " . $path . ")");
|
||||||
}
|
}
|
||||||
$release_info = json_decode($raw_release_info);
|
$release_info = json_decode($raw_release_info);
|
||||||
|
|
||||||
foreach($release_info as $platform) {
|
foreach($release_info as $platform) {
|
||||||
if($platform->platform != $_GET["platform"]) continue;
|
if($platform->platform != $_GET["platform"]) continue;
|
||||||
if($platform->arch != $_GET["arch"]) continue;
|
if($platform->arch != $_GET["arch"]) continue;
|
||||||
|
|
||||||
http_response_code(200);
|
http_response_code(200);
|
||||||
header("Cache-Control: public"); // needed for internet explorer
|
header("Cache-Control: public"); // needed for internet explorer
|
||||||
header("Content-Type: application/binary");
|
header("Content-Type: application/binary");
|
||||||
header("Content-Transfer-Encoding: Binary");
|
header("Content-Transfer-Encoding: Binary");
|
||||||
header("Content-Length:".filesize($path . $platform->update));
|
header("Content-Length:".filesize($path . $platform->update));
|
||||||
header("Content-Disposition: attachment; filename=update.tar.gz");
|
header("Content-Disposition: attachment; filename=update.tar.gz");
|
||||||
header("info-version: 1");
|
header("info-version: 1");
|
||||||
readfile($path . $platform->update);
|
readfile($path . $platform->update);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
errorExit("Missing platform, arch or file");
|
errorExit("Missing platform, arch or file");
|
||||||
}
|
}
|
||||||
else if ($_GET["type"] == "ui-info") {
|
else if ($_GET["type"] == "ui-info") {
|
||||||
global $UI_BASE_PATH;
|
global $UI_BASE_PATH;
|
||||||
|
|
||||||
$version_info = file_get_contents($UI_BASE_PATH . "info.json");
|
$version_info = file_get_contents($UI_BASE_PATH . "info.json");
|
||||||
if($version_info === false) $version_info = array();
|
if($version_info === false) $version_info = array();
|
||||||
else $version_info = json_decode($version_info, true);
|
else $version_info = json_decode($version_info, true);
|
||||||
|
|
||||||
$info = array();
|
$info = array();
|
||||||
$info["success"] = true;
|
$info["success"] = true;
|
||||||
$info["versions"] = array();
|
$info["versions"] = array();
|
||||||
|
|
||||||
foreach($version_info as $channel => $data) {
|
foreach($version_info as $channel => $data) {
|
||||||
if(!isset($data["latest"])) continue;
|
if(!isset($data["latest"])) continue;
|
||||||
|
|
||||||
$channel_info = [
|
$channel_info = [
|
||||||
"timestamp" => $data["latest"]["timestamp"],
|
"timestamp" => $data["latest"]["timestamp"],
|
||||||
"version" => $data["latest"]["version"],
|
"version" => $data["latest"]["version"],
|
||||||
"git-ref" => $data["latest"]["git-ref"],
|
"git-ref" => $data["latest"]["git-ref"],
|
||||||
"channel" => $channel,
|
"channel" => $channel,
|
||||||
"required_client" => $data["latest"]["required_client"]
|
"required_client" => $data["latest"]["required_client"]
|
||||||
];
|
];
|
||||||
array_push($info["versions"], $channel_info);
|
array_push($info["versions"], $channel_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
die(json_encode($info));
|
die(json_encode($info));
|
||||||
} else if ($_GET["type"] == "ui-download") {
|
} else if ($_GET["type"] == "ui-download") {
|
||||||
global $UI_BASE_PATH;
|
global $UI_BASE_PATH;
|
||||||
|
|
||||||
if(!isset($_GET["channel"]) || !isset($_GET["version"]))
|
if(!isset($_GET["channel"]) || !isset($_GET["version"]))
|
||||||
errorExit("missing required parameters");
|
errorExit("missing required parameters");
|
||||||
|
|
||||||
if($_GET["version"] !== "latest" && !isset($_GET["git-ref"]))
|
if($_GET["version"] !== "latest" && !isset($_GET["git-ref"]))
|
||||||
errorExit("missing required parameters");
|
errorExit("missing required parameters");
|
||||||
|
|
||||||
$version_info = file_get_contents($UI_BASE_PATH . "info.json");
|
$version_info = file_get_contents($UI_BASE_PATH . "info.json");
|
||||||
if($version_info === false) $version_info = array();
|
if($version_info === false) $version_info = array();
|
||||||
else $version_info = json_decode($version_info, true);
|
else $version_info = json_decode($version_info, true);
|
||||||
|
|
||||||
$channel_data = $version_info[$_GET["channel"]];
|
$channel_data = $version_info[$_GET["channel"]];
|
||||||
if(!isset($channel_data))
|
if(!isset($channel_data))
|
||||||
errorExit("channel unknown");
|
errorExit("channel unknown");
|
||||||
|
|
||||||
$ui_pack = false;
|
$ui_pack = false;
|
||||||
if($_GET["version"] === "latest") {
|
if($_GET["version"] === "latest") {
|
||||||
$ui_pack = $channel_data["latest"];
|
$ui_pack = $channel_data["latest"];
|
||||||
} else {
|
} else {
|
||||||
foreach ($channel_data["history"] as $entry) {
|
foreach ($channel_data["history"] as $entry) {
|
||||||
if($entry["version"] == $_GET["version"] && $entry["git-ref"] == $_GET["git-ref"]) {
|
if($entry["version"] == $_GET["version"] && $entry["git-ref"] == $_GET["git-ref"]) {
|
||||||
$ui_pack = $entry;
|
$ui_pack = $entry;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($ui_pack === false)
|
if($ui_pack === false)
|
||||||
errorExit("missing version");
|
errorExit("missing version");
|
||||||
|
|
||||||
|
|
||||||
header("Cache-Control: public"); // needed for internet explorer
|
header("Cache-Control: public"); // needed for internet explorer
|
||||||
header("Content-Type: application/binary");
|
header("Content-Type: application/binary");
|
||||||
header("Content-Transfer-Encoding: Binary");
|
header("Content-Transfer-Encoding: Binary");
|
||||||
header("Content-Disposition: attachment; filename=ui.tar.gz");
|
header("Content-Disposition: attachment; filename=ui.tar.gz");
|
||||||
header("info-version: 1");
|
header("info-version: 1");
|
||||||
|
|
||||||
header("x-ui-timestamp: " . $ui_pack["timestamp"]);
|
header("x-ui-timestamp: " . $ui_pack["timestamp"]);
|
||||||
header("x-ui-version: " . $ui_pack["version"]);
|
header("x-ui-version: " . $ui_pack["version"]);
|
||||||
header("x-ui-git-ref: " . $ui_pack["git-ref"]);
|
header("x-ui-git-ref: " . $ui_pack["git-ref"]);
|
||||||
header("x-ui-required_client: " . $ui_pack["required_client"]);
|
header("x-ui-required_client: " . $ui_pack["required_client"]);
|
||||||
|
|
||||||
$read = readfile($ui_pack["file"]);
|
$read = readfile($ui_pack["file"]);
|
||||||
header("Content-Length:" . $read);
|
header("Content-Length:" . $read);
|
||||||
|
|
||||||
if($read === false) errorExit("internal error: Failed to read file!");
|
if($read === false) errorExit("internal error: Failed to read file!");
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if($_POST["type"] == "deploy-build") {
|
else if($_POST["type"] == "deploy-build") {
|
||||||
global $CLIENT_BASE_PATH;
|
global $CLIENT_BASE_PATH;
|
||||||
|
|
||||||
if(!isset($_POST["version"]) || !isset($_POST["platform"]) || !isset($_POST["arch"]) || !isset($_POST["update_suffix"]) || !isset($_POST["installer_suffix"])) {
|
if(!isset($_POST["version"]) || !isset($_POST["platform"]) || !isset($_POST["arch"]) || !isset($_POST["update_suffix"]) || !isset($_POST["installer_suffix"])) {
|
||||||
errorExit("Missing required information!");
|
errorExit("Missing required information!");
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyPostSecret();
|
verifyPostSecret();
|
||||||
|
|
||||||
if(!isset($_FILES["update"])) {
|
if(!isset($_FILES["update"])) {
|
||||||
errorExit("Missing update file");
|
errorExit("Missing update file");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_FILES["update"]["error"] !== UPLOAD_ERR_OK) {
|
if($_FILES["update"]["error"] !== UPLOAD_ERR_OK) {
|
||||||
errorExit("Upload for update failed!");
|
errorExit("Upload for update failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($_FILES["installer"])) {
|
if(!isset($_FILES["installer"])) {
|
||||||
errorExit("Missing installer file");
|
errorExit("Missing installer file");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_FILES["installer"]["error"] !== UPLOAD_ERR_OK) {
|
if($_FILES["installer"]["error"] !== UPLOAD_ERR_OK) {
|
||||||
errorExit("Upload for installer failed!");
|
errorExit("Upload for installer failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
$json_version = json_decode($_POST["version"], true);
|
$json_version = json_decode($_POST["version"], true);
|
||||||
$version = $json_version["major"] . "." . $json_version["minor"] . "." . $json_version["patch"] . ($json_version["build"] > 0 ? "-" . $json_version["build"] : "");
|
$version = $json_version["major"] . "." . $json_version["minor"] . "." . $json_version["patch"] . ($json_version["build"] > 0 ? "-" . $json_version["build"] : "");
|
||||||
$path = $CLIENT_BASE_PATH . DIRECTORY_SEPARATOR . $_POST["channel"] . DIRECTORY_SEPARATOR . $version . DIRECTORY_SEPARATOR;
|
$path = $CLIENT_BASE_PATH . DIRECTORY_SEPARATOR . $_POST["channel"] . DIRECTORY_SEPARATOR . $version . DIRECTORY_SEPARATOR;
|
||||||
exec("mkdir -p " . $path);
|
exec("mkdir -p " . $path);
|
||||||
//mkdir($path, 777, true);
|
//mkdir($path, 777, true);
|
||||||
|
|
||||||
|
|
||||||
$filename_update = "TeaClient-" . $_POST["platform"] . "_" . $_POST["arch"] . "." . $_POST["update_suffix"];
|
$filename_update = "TeaClient-" . $_POST["platform"] . "_" . $_POST["arch"] . "." . $_POST["update_suffix"];
|
||||||
$filename_install = "TeaClient-" . $_POST["platform"] . "_" . $_POST["arch"] . "." . $_POST["installer_suffix"];
|
$filename_install = "TeaClient-" . $_POST["platform"] . "_" . $_POST["arch"] . "." . $_POST["installer_suffix"];
|
||||||
|
|
||||||
{
|
{
|
||||||
$version_info = file_get_contents($path . "info.json");
|
$version_info = file_get_contents($path . "info.json");
|
||||||
if($version_info === false) {
|
if($version_info === false) {
|
||||||
$version_info = array();
|
$version_info = array();
|
||||||
} else {
|
} else {
|
||||||
$version_info = json_decode($version_info, true);
|
$version_info = json_decode($version_info, true);
|
||||||
|
@ -197,26 +197,26 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for($index = 0; $index < count($version_info); $index++) {
|
for($index = 0; $index < count($version_info); $index++) {
|
||||||
if($version_info[$index]["platform"] == $_POST["platform"] && $version_info[$index]["arch"] == $_POST["arch"]) {
|
if($version_info[$index]["platform"] == $_POST["platform"] && $version_info[$index]["arch"] == $_POST["arch"]) {
|
||||||
array_splice($version_info, $index, 1);
|
array_splice($version_info, $index, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$info = array();
|
$info = array();
|
||||||
$info["platform"] = $_POST["platform"];
|
$info["platform"] = $_POST["platform"];
|
||||||
$info["arch"] = $_POST["arch"];
|
$info["arch"] = $_POST["arch"];
|
||||||
$info["update"] = $filename_update;
|
$info["update"] = $filename_update;
|
||||||
$info["install"] = $filename_install;
|
$info["install"] = $filename_install;
|
||||||
array_push($version_info, $info);
|
array_push($version_info, $info);
|
||||||
file_put_contents($path . "info.json", json_encode($version_info));
|
file_put_contents($path . "info.json", json_encode($version_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
$filename = $CLIENT_BASE_PATH . DIRECTORY_SEPARATOR . "version.json";
|
$filename = $CLIENT_BASE_PATH . DIRECTORY_SEPARATOR . "version.json";
|
||||||
$indexes = file_get_contents($filename);
|
$indexes = file_get_contents($filename);
|
||||||
if($indexes === false) {
|
if($indexes === false) {
|
||||||
$indexes = array();
|
$indexes = array();
|
||||||
} else {
|
} else {
|
||||||
$indexes = json_decode($indexes, true);
|
$indexes = json_decode($indexes, true);
|
||||||
|
@ -225,52 +225,52 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$index = &$indexes[$_POST["channel"]];
|
$index = &$indexes[$_POST["channel"]];
|
||||||
if(!isset($index)) {
|
if(!isset($index)) {
|
||||||
$index = array();
|
$index = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
for($idx = 0; $idx < count($index); $idx++) {
|
for($idx = 0; $idx < count($index); $idx++) {
|
||||||
if($index[$idx]["platform"] == $_POST["platform"] && $index[$idx]["arch"] == $_POST["arch"]) {
|
if($index[$idx]["platform"] == $_POST["platform"] && $index[$idx]["arch"] == $_POST["arch"]) {
|
||||||
array_splice($index, $idx, 1);
|
array_splice($index, $idx, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$info = array();
|
$info = array();
|
||||||
$info["platform"] = $_POST["platform"];
|
$info["platform"] = $_POST["platform"];
|
||||||
$info["arch"] = $_POST["arch"];
|
$info["arch"] = $_POST["arch"];
|
||||||
$info["version"] = $json_version;
|
$info["version"] = $json_version;
|
||||||
array_push($index, $info);
|
array_push($index, $info);
|
||||||
|
|
||||||
file_put_contents($filename, json_encode($indexes));
|
file_put_contents($filename, json_encode($indexes));
|
||||||
}
|
}
|
||||||
|
|
||||||
move_uploaded_file($_FILES["installer"]["tmp_name"],$path . $filename_install);
|
move_uploaded_file($_FILES["installer"]["tmp_name"],$path . $filename_install);
|
||||||
move_uploaded_file($_FILES["update"]["tmp_name"],$path . $filename_update);
|
move_uploaded_file($_FILES["update"]["tmp_name"],$path . $filename_update);
|
||||||
|
|
||||||
die(json_encode([
|
die(json_encode([
|
||||||
"success" => true
|
"success" => true
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
else if($_POST["type"] == "deploy-ui-build") {
|
else if($_POST["type"] == "deploy-ui-build") {
|
||||||
global $UI_BASE_PATH;
|
global $UI_BASE_PATH;
|
||||||
|
|
||||||
if(!isset($_POST["channel"]) || !isset($_POST["version"]) || !isset($_POST["git_ref"]) || !isset($_POST["required_client"])) {
|
if(!isset($_POST["channel"]) || !isset($_POST["version"]) || !isset($_POST["git_ref"]) || !isset($_POST["required_client"])) {
|
||||||
errorExit("Missing required information!");
|
errorExit("Missing required information!");
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyPostSecret();
|
verifyPostSecret();
|
||||||
|
|
||||||
$path = $UI_BASE_PATH . DIRECTORY_SEPARATOR;
|
$path = $UI_BASE_PATH . DIRECTORY_SEPARATOR;
|
||||||
$channeled_path = $UI_BASE_PATH . DIRECTORY_SEPARATOR . $_POST["channel"];
|
$channeled_path = $UI_BASE_PATH . DIRECTORY_SEPARATOR . $_POST["channel"];
|
||||||
$filename = "TeaClientUI-" . $_POST["version"] . "_" . $_POST["git_ref"] . ".tar.gz";
|
$filename = "TeaClientUI-" . $_POST["version"] . "_" . $_POST["git_ref"] . ".tar.gz";
|
||||||
exec("mkdir -p " . $path);
|
exec("mkdir -p " . $path);
|
||||||
exec("mkdir -p " . $channeled_path);
|
exec("mkdir -p " . $channeled_path);
|
||||||
|
|
||||||
{
|
{
|
||||||
$info = file_get_contents($path . "info.json");
|
$info = file_get_contents($path . "info.json");
|
||||||
if($info === false) {
|
if($info === false) {
|
||||||
$info = array();
|
$info = array();
|
||||||
} else {
|
} else {
|
||||||
$info = json_decode($info, true);
|
$info = json_decode($info, true);
|
||||||
|
@ -279,36 +279,36 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$channel_info = &$info[$_POST["channel"]];
|
$channel_info = &$info[$_POST["channel"]];
|
||||||
if(!$channel_info) {
|
if(!$channel_info) {
|
||||||
$channel_info = array();
|
$channel_info = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = [
|
$entry = [
|
||||||
"timestamp" => time(),
|
"timestamp" => time(),
|
||||||
"file" => $channeled_path . DIRECTORY_SEPARATOR . $filename,
|
"file" => $channeled_path . DIRECTORY_SEPARATOR . $filename,
|
||||||
"version" => $_POST["version"],
|
"version" => $_POST["version"],
|
||||||
"git-ref" => $_POST["git_ref"],
|
"git-ref" => $_POST["git_ref"],
|
||||||
"required_client" => $_POST["required_client"]
|
"required_client" => $_POST["required_client"]
|
||||||
];
|
];
|
||||||
|
|
||||||
$channel_info["latest"] = $entry;
|
$channel_info["latest"] = $entry;
|
||||||
if(!$channel_info["history"]) $channel_info["history"] = array();
|
if(!$channel_info["history"]) $channel_info["history"] = array();
|
||||||
array_push($channel_info["history"], $entry);
|
array_push($channel_info["history"], $entry);
|
||||||
|
|
||||||
file_put_contents($path . "info.json", json_encode($info));
|
file_put_contents($path . "info.json", json_encode($info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
move_uploaded_file($_FILES["file"]["tmp_name"],$channeled_path . DIRECTORY_SEPARATOR . $filename);
|
move_uploaded_file($_FILES["file"]["tmp_name"],$channeled_path . DIRECTORY_SEPARATOR . $filename);
|
||||||
die(json_encode([
|
die(json_encode([
|
||||||
"success" => true
|
"success" => true
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
else die(json_encode([
|
else die(json_encode([
|
||||||
"success" => false,
|
"success" => false,
|
||||||
"error" => "invalid action!"
|
"error" => "invalid action!"
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRequest();
|
handleRequest();
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
"tc-backend/web/*": ["web/app/*"], /* specific web part */
|
"tc-backend/web/*": ["web/app/*"], /* specific web part */
|
||||||
"tc-backend/*": ["shared/backend.d/*"],
|
"tc-backend/*": ["shared/backend.d/*"],
|
||||||
"tc-loader": ["loader/exports/loader.d.ts"],
|
"tc-loader": ["loader/exports/loader.d.ts"],
|
||||||
|
"tc-events": ["vendor/TeaEventBus/src/index.ts"],
|
||||||
|
"tc-services": ["vendor/TeaClientServices/src/index.ts"],
|
||||||
|
|
||||||
"svg-sprites/*": ["shared/svg-sprites/*"],
|
"svg-sprites/*": ["shared/svg-sprites/*"],
|
||||||
"vendor/xbbcode/*": ["vendor/xbbcode/src/*"]
|
"vendor/xbbcode/*": ["vendor/xbbcode/src/*"]
|
||||||
|
|
34
vendor/TeaClientServices/src/Action.ts
vendored
Normal file
34
vendor/TeaClientServices/src/Action.ts
vendored
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import {MessageCommandErrorResult} from "./Messages";
|
||||||
|
import {clientServiceLogger} from "./Logging";
|
||||||
|
|
||||||
|
export type ActionResult<T> = {
|
||||||
|
unwrap() : T;
|
||||||
|
} & ({
|
||||||
|
status: "success",
|
||||||
|
result: T
|
||||||
|
} | {
|
||||||
|
status: "error",
|
||||||
|
result: MessageCommandErrorResult
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
export function createErrorResult<T>(result: MessageCommandErrorResult) : ActionResult<T> {
|
||||||
|
return {
|
||||||
|
status: "error",
|
||||||
|
result: result,
|
||||||
|
unwrap(): T {
|
||||||
|
clientServiceLogger.logError("Tried to unwrap an action which failed: %o", result);
|
||||||
|
throw "action failed with " + result.type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createResult<T>(result: T) : ActionResult<T> {
|
||||||
|
return {
|
||||||
|
status: "success",
|
||||||
|
result: result,
|
||||||
|
unwrap(): T {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1
vendor/TeaEventBus
vendored
Submodule
1
vendor/TeaEventBus
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 9caad3399af830606e25e66f51ee40239bc3b457
|
|
@ -230,7 +230,9 @@ export const config = async (target: "web" | "client"): Promise<Configuration> =
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.tsx', '.ts', '.js', ".scss", ".css", ".wasm"],
|
extensions: ['.tsx', '.ts', '.js', ".scss", ".css", ".wasm"],
|
||||||
alias: {
|
alias: {
|
||||||
"vendor/xbbcode": path.resolve(__dirname, "vendor/xbbcode/src")
|
"vendor/xbbcode": path.resolve(__dirname, "vendor/xbbcode/src"),
|
||||||
|
"tc-events": path.resolve(__dirname, "vendor/TeaEventBus/src/index.ts"),
|
||||||
|
"tc-services": path.resolve(__dirname, "vendor/TeaClientServices/src/index.ts"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
externals: [
|
externals: [
|
||||||
|
|
Loading…
Add table
Reference in a new issue