2020-07-13 11:29:16 +02:00
|
|
|
import "./shared";
|
2020-04-01 15:36:37 +02:00
|
|
|
import * as loader from "../loader/loader";
|
2021-03-17 13:28:27 +01:00
|
|
|
import {ApplicationLoader} from "../loader/loader";
|
2020-07-20 19:08:13 +02:00
|
|
|
import {loadManifest, loadManifestTarget} from "../maifest";
|
2019-08-30 23:06:39 +02:00
|
|
|
|
|
|
|
loader.register_task(loader.Stage.INITIALIZING, {
|
|
|
|
name: "secure tester",
|
|
|
|
function: async () => {
|
|
|
|
/* we need https or localhost to use some things like the storage API */
|
2021-03-18 18:59:06 +01:00
|
|
|
if(typeof isSecureContext === "undefined") {
|
2021-03-17 13:28:27 +01:00
|
|
|
(window as any)["isSecureContext"] = location.protocol !== 'https:' || location.hostname === 'localhost';
|
2021-03-18 18:59:06 +01:00
|
|
|
}
|
2019-08-30 23:06:39 +02:00
|
|
|
|
|
|
|
if(!isSecureContext) {
|
|
|
|
loader.critical_error("TeaWeb cant run on unsecured sides.", "App requires to be loaded via HTTPS!");
|
|
|
|
throw "App requires a secure context!"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
priority: 20
|
|
|
|
});
|
|
|
|
|
|
|
|
loader.register_task(loader.Stage.JAVASCRIPT, {
|
2021-03-18 18:59:06 +01:00
|
|
|
name: "manifest",
|
|
|
|
function: async taskId => {
|
|
|
|
loader.setCurrentTaskName(taskId, "manifest");
|
|
|
|
await loadManifest();
|
|
|
|
await loadManifestTarget(__build.entry_chunk_name, taskId);
|
|
|
|
},
|
2019-08-30 23:06:39 +02:00
|
|
|
priority: 10
|
|
|
|
});
|
|
|
|
|
2019-08-31 18:31:01 +02:00
|
|
|
loader.register_task(loader.Stage.SETUP, {
|
|
|
|
name: "page setup",
|
|
|
|
function: async () => {
|
|
|
|
const body = document.body;
|
2020-10-05 12:50:50 +02:00
|
|
|
|
2019-08-31 18:31:01 +02:00
|
|
|
/* template containers */
|
|
|
|
{
|
|
|
|
const container = document.createElement("div");
|
|
|
|
container.setAttribute('id', "templates");
|
|
|
|
body.append(container);
|
|
|
|
}
|
2020-10-05 12:50:50 +02:00
|
|
|
|
2019-08-31 18:31:01 +02:00
|
|
|
/* sounds container */
|
|
|
|
{
|
|
|
|
const container = document.createElement("div");
|
|
|
|
container.setAttribute('id', "sounds");
|
|
|
|
body.append(container);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
priority: 10
|
|
|
|
});
|
|
|
|
|
2019-09-19 01:25:57 +02:00
|
|
|
/* test if we're getting loaded within a TeaClient preview window */
|
|
|
|
loader.register_task(loader.Stage.SETUP, {
|
|
|
|
name: "TeaClient tester",
|
|
|
|
function: async () => {
|
|
|
|
if(typeof __teaclient_preview_notice !== "undefined" && typeof __teaclient_preview_error !== "undefined") {
|
|
|
|
loader.critical_error("Why you're opening TeaWeb within the TeaSpeak client?!");
|
|
|
|
throw "we're already a TeaClient!";
|
|
|
|
}
|
|
|
|
},
|
|
|
|
priority: 100
|
|
|
|
});
|
|
|
|
|
2020-07-20 19:08:13 +02:00
|
|
|
export default class implements ApplicationLoader {
|
|
|
|
execute() {
|
2020-10-04 20:47:19 +02:00
|
|
|
loader.execute_managed(true);
|
2020-03-30 13:44:18 +02:00
|
|
|
}
|
2019-08-30 23:06:39 +02:00
|
|
|
}
|