From 1cf3a8f94d8235f2016297347424f2cfa9ad4e7a Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 25 Jun 2024 16:28:06 +0100 Subject: [PATCH] use nodenext for compat (but bring back yucky extensions) --- src/OAPI.ts | 2 +- src/api/common.ts | 2 +- src/api/dynmap/Dynmap.ts | 2 +- src/api/dynmap/GPS.ts | 2 +- src/api/dynmap/Nations.ts | 2 +- src/api/dynmap/Players.ts | 2 +- src/api/dynmap/Residents.ts | 2 +- src/api/dynmap/Towns.ts | 2 +- src/api/squaremap/GPS.ts | 2 +- src/api/squaremap/Nations.ts | 2 +- src/api/squaremap/Players.ts | 2 +- src/api/squaremap/Residents.ts | 2 +- src/api/squaremap/Squaremap.ts | 2 +- src/api/squaremap/Towns.ts | 2 +- src/api/squaremap/parser.ts | 2 +- src/helpers/DataHandler.ts | 2 +- src/helpers/EventEmitter.ts | 1 + src/main.ts | 2 +- src/types/dynmap.ts | 2 +- src/types/nation.ts | 2 +- src/types/oapi.ts | 2 +- src/types/player.ts | 2 +- src/types/squaremap.ts | 2 +- src/utils/endpoint.ts | 2 +- src/utils/functions.ts | 2 +- tsconfig.json | 4 ++-- 26 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/OAPI.ts b/src/OAPI.ts index 770fad4..b39d7f7 100644 --- a/src/OAPI.ts +++ b/src/OAPI.ts @@ -7,7 +7,7 @@ import type { OAPINation, RawServerInfoV2, RawServerInfoV3 -} from './types' +} from './types/index.js' import { townyData } from './utils/endpoint.js' import { FetchError } from './utils/errors.js' diff --git a/src/api/common.ts b/src/api/common.ts index b32b73e..efae3fb 100644 --- a/src/api/common.ts +++ b/src/api/common.ts @@ -1,4 +1,4 @@ -import type { StrictPoint2D, Point2D, TownBounds } from ".././types" +import type { StrictPoint2D, Point2D, TownBounds } from ".././types/index.js" import { hypot, safeParseInt, strictFalsy } from ".././utils/functions.js" type LocOrNation = Partial { diff --git a/src/api/squaremap/GPS.ts b/src/api/squaremap/GPS.ts index 9ec6cba..7bd91c7 100644 --- a/src/api/squaremap/GPS.ts +++ b/src/api/squaremap/GPS.ts @@ -1,7 +1,7 @@ import { type Route, Routes, type RouteInfo, type Location, type Nation, type Player -} from '../../types' +} from '../../types/index.js' import Mitt from '../../helpers/EventEmitter.js' import { manhattan, safeParseInt, strictFalsy } from '../../utils/functions.js' diff --git a/src/api/squaremap/Nations.ts b/src/api/squaremap/Nations.ts index 0e82d8e..e5ee69c 100644 --- a/src/api/squaremap/Nations.ts +++ b/src/api/squaremap/Nations.ts @@ -2,7 +2,7 @@ import type Squaremap from "./Squaremap.js" import { FetchError, type NotFoundError } from "../../utils/errors.js" import type { EntityApi } from "../../helpers/EntityApi.js" -import type { Nation, SquaremapTown, StrictPoint2D } from "../../types" +import type { Nation, SquaremapTown, StrictPoint2D } from "../../types/index.js" import { getExisting, sqr } from "../../utils/functions.js" diff --git a/src/api/squaremap/Players.ts b/src/api/squaremap/Players.ts index fdca38e..486a191 100644 --- a/src/api/squaremap/Players.ts +++ b/src/api/squaremap/Players.ts @@ -5,7 +5,7 @@ import type { EntityApi } from "../../helpers/EntityApi.js" -import type { OnlinePlayer, Player, StrictPoint2D } from "../../types" +import type { OnlinePlayer, Player, StrictPoint2D } from "../../types/index.js" import { FetchError, type NotFoundError } from "../../utils/errors.js" import { getExisting } from "../../utils/functions.js" import { parseInfoString } from "./parser.js" diff --git a/src/api/squaremap/Residents.ts b/src/api/squaremap/Residents.ts index ba0538e..f48bb05 100644 --- a/src/api/squaremap/Residents.ts +++ b/src/api/squaremap/Residents.ts @@ -1,6 +1,6 @@ import type Squaremap from "./Squaremap.js" -import type { Resident, SquaremapTown } from "../../types" +import type { Resident, SquaremapTown } from "../../types/index.js" import type { EntityApi } from "../../helpers/EntityApi.js" import { InvalidError, type NotFoundError } from "../../utils/errors.js" diff --git a/src/api/squaremap/Squaremap.ts b/src/api/squaremap/Squaremap.ts index e673d3a..4607b8b 100644 --- a/src/api/squaremap/Squaremap.ts +++ b/src/api/squaremap/Squaremap.ts @@ -4,7 +4,7 @@ import type { SquaremapMapResponse, SquaremapPlayersResponse, TownBounds -} from "../../types" +} from "../../types/index.js" import DataHandler from "../../helpers/DataHandler.js" diff --git a/src/api/squaremap/Towns.ts b/src/api/squaremap/Towns.ts index 305e150..18a6e75 100644 --- a/src/api/squaremap/Towns.ts +++ b/src/api/squaremap/Towns.ts @@ -1,5 +1,5 @@ import type Squaremap from "./Squaremap.js" -import type { Nation, SquaremapTown, StrictPoint2D } from "../../types" +import type { Nation, SquaremapTown, StrictPoint2D } from "../../types/index.js" import type { EntityApi } from "../../helpers/EntityApi.js" import { parseTowns } from "./parser.js" diff --git a/src/api/squaremap/parser.ts b/src/api/squaremap/parser.ts index b85a6f1..5a715ee 100644 --- a/src/api/squaremap/parser.ts +++ b/src/api/squaremap/parser.ts @@ -11,7 +11,7 @@ import type { SquaremapRawPlayer, SquaremapTown, StrictPoint2D -} from '../../types' +} from '../../types/index.js' /** * Parses the tooltip on a marker - removing white space, new lines and HTML tags. diff --git a/src/helpers/DataHandler.ts b/src/helpers/DataHandler.ts index 4194964..689baf4 100644 --- a/src/helpers/DataHandler.ts +++ b/src/helpers/DataHandler.ts @@ -1,7 +1,7 @@ import * as endpoint from '../utils/endpoint.js' import { Mutex } from 'async-mutex' -import type { AnyMap } from '../types' +import type { AnyMap } from '../types/index.js' class DataHandler { #map: AnyMap diff --git a/src/helpers/EventEmitter.ts b/src/helpers/EventEmitter.ts index 8341dd4..558f502 100644 --- a/src/helpers/EventEmitter.ts +++ b/src/helpers/EventEmitter.ts @@ -15,6 +15,7 @@ export default class Mitt { protected emit: any constructor() { + //@ts-ignore const emitter = mitt() Object.keys(emitter).forEach(() => { diff --git a/src/main.ts b/src/main.ts index 7939fdf..12f39c2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,7 @@ import Squaremap from './api/squaremap/Squaremap.js' import MCAPI from "mojang-lib" import { OAPIV2, OAPIV3 } from './OAPI.js' -import type { PlayersResponse } from './types' +import type { PlayersResponse } from './types/index.js' const Aurora = new Squaremap('aurora') const Nova = new Dynmap('nova') diff --git a/src/types/dynmap.ts b/src/types/dynmap.ts index 3cdf2b3..0014bcc 100644 --- a/src/types/dynmap.ts +++ b/src/types/dynmap.ts @@ -3,7 +3,7 @@ import type { StringContainedWithin, HexString, Opacity -} from '../types' +} from '../types/index.js' export type MapResponse = { timestamp: number diff --git a/src/types/nation.ts b/src/types/nation.ts index 5f473bd..bcdbda8 100644 --- a/src/types/nation.ts +++ b/src/types/nation.ts @@ -3,7 +3,7 @@ import type { RawEntitySpawn, RawEntityStats, RawEntityStatus -} from "../types" +} from "../types/index.js" import type { Prettify } from "./util.js" diff --git a/src/types/oapi.ts b/src/types/oapi.ts index f19d619..1d5d92f 100644 --- a/src/types/oapi.ts +++ b/src/types/oapi.ts @@ -2,7 +2,7 @@ import type { Location, NestedOmit, Prettify -} from '../types' +} from '../types/index.js' //#region V2 //#region Parsed diff --git a/src/types/player.ts b/src/types/player.ts index c2649ab..e040221 100644 --- a/src/types/player.ts +++ b/src/types/player.ts @@ -1,4 +1,4 @@ -import type { Location, Resident } from '../types' +import type { Location, Resident } from '../types/index.js' export type OnlinePlayer = Location & { name: string diff --git a/src/types/squaremap.ts b/src/types/squaremap.ts index cc9ab25..3a74902 100644 --- a/src/types/squaremap.ts +++ b/src/types/squaremap.ts @@ -4,7 +4,7 @@ import type { Opacity, Prettify, StrictPoint2D -} from '../types' +} from '../types/index.js' export interface SquaremapPlayersResponse { max: number diff --git a/src/utils/endpoint.ts b/src/utils/endpoint.ts index a49401a..873e9e4 100644 --- a/src/utils/endpoint.ts +++ b/src/utils/endpoint.ts @@ -1,7 +1,7 @@ import endpoints from '../endpoints.json' import { request, type Dispatcher } from "undici" -import type { AnyMap } from "../types" +import type { AnyMap } from "../types/index.js" import { genRandomString } from './functions.js' diff --git a/src/utils/functions.ts b/src/utils/functions.ts index faad0d8..01e9bce 100644 --- a/src/utils/functions.ts +++ b/src/utils/functions.ts @@ -5,7 +5,7 @@ import type { Point2D, RawPlayer, Player, Town, BaseTown, BaseNation -} from '../types' +} from '../types/index.js' import { NotFound } from './errors.js' diff --git a/tsconfig.json b/tsconfig.json index 02ad2d1..2c611e6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { - "module": "ESNext", - "moduleResolution": "bundler", + "module": "NodeNext", + "moduleResolution": "NodeNext", "moduleDetection": "force", "target": "ES2017", "lib": ["ES2023"],