TeaSpeak-Client/modules/renderer-manifest/index.ts

60 lines
1.9 KiB
TypeScript
Raw Normal View History

/* --------------- bootstrap --------------- */
import * as RequireProxy from "../renderer/RequireProxy";
import * as path from "path";
2020-08-23 15:26:27 -04:00
RequireProxy.initialize(path.join(__dirname, "backend-impl"));
/* --------------- entry point --------------- */
import * as loader from "tc-loader";
import {Stage} from "tc-loader";
import {Arguments, process_args} from "../shared/process-arguments";
import {remote} from "electron";
export function initialize(manifestTarget: string) {
console.log("Initializing native client for manifest target %s", manifestTarget);
const _impl = message => {
if(!process_args.has_flag(Arguments.DEBUG)) {
console.error("Displaying critical error: %o", message);
message = message.replace(/<br>/i, "\n");
const win = remote.getCurrentWindow();
win.webContents.openDevTools();
remote.dialog.showMessageBox({
type: "error",
buttons: ["exit"],
title: "A critical error happened!",
message: message
});
} else {
console.error("Received critical error: %o", message);
console.error("Ignoring error due to the debug mode");
}
};
if(window.impl_display_critical_error)
window.impl_display_critical_error = _impl;
else
window.displayCriticalError = _impl;
loader.register_task(loader.Stage.JAVASCRIPT, {
name: "teaclient jquery",
function: async () => {
2020-08-23 05:35:52 -04:00
window.$ = require("jquery");
2020-08-22 15:33:30 -04:00
2020-08-23 05:35:52 -04:00
window.jQuery = window.$;
Object.assign(window.$, window.jsrender = require('jsrender'));
},
priority: 80
});
loader.register_task(Stage.JAVASCRIPT_INITIALIZING, {
name: "handler initialize",
priority: 100,
function: async () => {
await import("../renderer/Logger");
await import("../renderer/PersistentLocalStorage");
}
})
}