2020-08-07 19:03:54 -04:00
|
|
|
/* --------------- bootstrap --------------- */
|
|
|
|
import * as RequireProxy from "../renderer/RequireProxy";
|
|
|
|
import * as path from "path";
|
2020-10-01 04:56:22 -04:00
|
|
|
RequireProxy.initialize(path.join(__dirname, "backend-impl"), "modal-external");
|
2020-08-23 15:26:27 -04:00
|
|
|
|
2020-08-07 19:03:54 -04:00
|
|
|
/* --------------- entry point --------------- */
|
|
|
|
import * as loader from "tc-loader";
|
|
|
|
import {Stage} from "tc-loader";
|
2020-10-01 04:56:22 -04:00
|
|
|
import {Arguments, processArguments} from "../shared/process-arguments";
|
2020-08-07 19:03:54 -04:00
|
|
|
import {remote} from "electron";
|
|
|
|
|
2020-10-01 04:56:22 -04:00
|
|
|
export function initialize() {
|
|
|
|
console.log("Initializing native client");
|
2020-08-07 19:03:54 -04:00
|
|
|
|
|
|
|
const _impl = message => {
|
2020-10-01 04:56:22 -04:00
|
|
|
if(!processArguments.has_flag(Arguments.DEBUG)) {
|
2020-08-07 19:03:54 -04:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-10-01 04:56:22 -04:00
|
|
|
if(window.impl_display_critical_error) {
|
2020-08-07 19:03:54 -04:00
|
|
|
window.impl_display_critical_error = _impl;
|
2020-10-01 04:56:22 -04:00
|
|
|
} else {
|
2020-08-07 19:03:54 -04:00
|
|
|
window.displayCriticalError = _impl;
|
2020-10-01 04:56:22 -04:00
|
|
|
}
|
2020-08-07 19:03:54 -04:00
|
|
|
|
|
|
|
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'));
|
2020-08-07 19:03:54 -04:00
|
|
|
},
|
|
|
|
priority: 80
|
|
|
|
});
|
|
|
|
|
|
|
|
loader.register_task(Stage.JAVASCRIPT_INITIALIZING, {
|
|
|
|
name: "handler initialize",
|
2020-10-01 04:56:22 -04:00
|
|
|
priority: 80,
|
2020-08-07 19:03:54 -04:00
|
|
|
function: async () => {
|
|
|
|
await import("../renderer/Logger");
|
|
|
|
await import("../renderer/PersistentLocalStorage");
|
2020-10-01 04:56:22 -04:00
|
|
|
await import("../renderer/ContextMenu");
|
2020-08-07 19:03:54 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|