Move to ES6 module (#357)

* Redo imports and exports for lib

* Redo imports and exports for bim

* Redo imports and exports for games

* Remove remaining module.exports

* Use export default in lib

* Use export default in protocols

* Fix import in genreadme.js

* Make package module and solve __dirname

* Fix minecraft protocol imports

* Fix imports on games and make binary runnable

* Renamed protocol class exports to lowercase

* Export promises class as default

* Update README.md to use imports instead of require

* Update CHANGELOG to mention the changes.

* Remove Valve unused imports

* Fix iconv import
This commit is contained in:
CosminPerRam 2023-09-14 23:28:31 +03:00 committed by GitHub
parent b4f6e7fab6
commit ad9adff06c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 249 additions and 323 deletions

View file

@ -1,8 +1,8 @@
const Core = require('./core');
const MinecraftVanilla = require('./minecraftvanilla');
const MinecraftBedrock = require('./minecraftbedrock');
const Gamespy3 = require('./gamespy3');
const Results = require('../lib/Results');
import Core from './core.js';
import minecraftbedrock from "./minecraftbedrock.js";
import minecraftvanilla from "./minecraftvanilla.js";
import Gamespy3 from "./gamespy3.js";
import {Results} from "../lib/Results.js";
/*
Vanilla servers respond to minecraftvanilla only
@ -12,7 +12,7 @@ Some bedrock servers respond to minecraftbedrock only
Unsure if any bedrock servers respond to gamespy3 and minecraftbedrock
*/
class Minecraft extends Core {
export default class minecraft extends Core {
constructor() {
super();
this.srvRecord = "_minecraft._tcp";
@ -21,7 +21,7 @@ class Minecraft extends Core {
/** @type {Promise<Results>[]} */
const promises = [];
const vanillaResolver = new MinecraftVanilla();
const vanillaResolver = new minecraftvanilla();
vanillaResolver.options = this.options;
vanillaResolver.udpSocket = this.udpSocket;
promises.push((async () => {
@ -38,7 +38,7 @@ class Minecraft extends Core {
try { return await gamespyResolver.runOnceSafe(); } catch(e) {}
})());
const bedrockResolver = new MinecraftBedrock();
const bedrockResolver = new minecraftbedrock();
bedrockResolver.options = this.options;
bedrockResolver.udpSocket = this.udpSocket;
promises.push((async () => {
@ -97,5 +97,3 @@ class Minecraft extends Core {
state.name = state.name.replace(/\u00A7./g, '');
}
}
module.exports = Minecraft;