Skip to content

Commit

Permalink
Convert client entry point to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Jun 1, 2024
1 parent c53a1eb commit 85d6cff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion buildtools/ant_modules/dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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=""/>
Expand Down
29 changes: 21 additions & 8 deletions src/js/stendhal/main.js → src/js/stendhal/main.ts
Original file line number Diff line number Diff line change
@@ -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 *
Expand All @@ -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);
})();

0 comments on commit 85d6cff

Please sign in to comment.