Convert client entry point to TypeScript

This commit is contained in:
Jordan Irwin 2024-05-31 23:02:05 -07:00
parent c53a1ebef7
commit 85d6cff21a
No known key found for this signature in database
GPG key ID: E3E358C2F44C290A
2 changed files with 22 additions and 9 deletions

View file

@ -731,7 +731,7 @@
<property name="js-files-ui3" value=""/>
<property name="js-files-main1" value=""/>
<property name="js-files-ui4" value=""/>
<property name="js-files-main2" value="${srcjs}/stendhal/main.js"/>
<property name="js-files-main2" value=""/>
<property name="js-files-main3" value=""/>
<property name="js-files-ts" value="build/ts/*.js build/ts/**/*.js"/>
<property name="js-files-ts2" value=""/>

View file

@ -1,5 +1,5 @@
/***************************************************************************
* (C) Copyright 2003-2023 - Stendhal *
* (C) Copyright 2003-2024 - Stendhal *
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
@ -9,14 +9,27 @@
* *
***************************************************************************/
"use strict";
import { Client } from "./Client";
var marauroa = window.marauroa = window.marauroa || {};
var stendhal = window.stendhal = window.stendhal || {};
declare var stendhal: any;
stendhal.main = require("../../../build/ts/Client").Client.get();
stendhal.main.init();
/**
* Initializes "stendhal" object.
*/
function initGlobals() {
const win = window as any;
//win.marauroa = win.marauroa || {}; // marauroa object should already be intialized
win.stendhal = win.stendhal || {};
stendhal.main = Client.get();
}
document.addEventListener('DOMContentLoaded', stendhal.main.startup);
window.addEventListener('error', stendhal.main.onerror);
// entry point
(function() {
initGlobals();
stendhal.main.init();
document.addEventListener('DOMContentLoaded', stendhal.main.startup);
window.addEventListener('error', stendhal.main.onerror);
})();