Skip to content

Commit

Permalink
idek man. fuck rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Jun 24, 2024
1 parent a86c995 commit d291976
Show file tree
Hide file tree
Showing 30 changed files with 75 additions and 79 deletions.
Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"ci": "bun run lint && bun run test && bun run build",
"lint": "eslint .",
"clean": "rimraf dist",
"build": "bun run clean && rollup -c && tsc --declaration true --emitDeclarationOnly true --declarationMap",
"build": "bun run clean && rollup -c",
"docs": "typedoc --options typedoc.json",
"test": "vitest run --pool=forks --config ./vitest.config.ts",
"test-browser": "vitest run --browser.name=chrome --browser.headless --config ./vitest.config.ts"
Expand Down Expand Up @@ -66,6 +66,7 @@
"eslint-plugin-named-import-spacing": "^1.0.3",
"rimraf": "^5.0.1",
"rollup": "^3.28.1",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^5.0.0",
"rollup-plugin-polyfill-node": "^0.12.0",
"rollup-plugin-typescript-paths": "^1.4.0",
Expand Down
22 changes: 11 additions & 11 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import commonjs from '@rollup/plugin-commonjs'
import { typescriptPaths } from 'rollup-plugin-typescript-paths'

import nodePolyfills from 'rollup-plugin-polyfill-node'
//import dts from 'rollup-plugin-dts'
import dts from 'rollup-plugin-dts'

const generatedCode = {
arrowFunctions: true,
Expand Down Expand Up @@ -38,22 +38,22 @@ const source = {
external: [...Object.keys(pkg.dependencies)],
output: [esm, umd],
plugins: [
typescriptPaths({ preserveExtensions: true }),
json(),
nodePolyfills(),
typescriptPaths({ preserveExtensions: true }),
resolve({ preferBuiltins: true }),
commonjs({ requireReturnsDefault: 'auto' }),
esbuild({ exclude: ["**/*.test.ts"] })
]
}

// const types = {
// input: 'src/types/index.ts',
// output: [{
// file: 'dist/types.d.ts',
// format: 'es'
// }],
// plugins: [dts()]
// }
const types = {
input: 'src/types/index.ts',
output: [{
file: pkg.types,
format: 'es'
}],
plugins: [dts()]
}

export default [source]
export default [source, types]
6 changes: 3 additions & 3 deletions src/OAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import type {
OAPINation,
RawServerInfoV2,
RawServerInfoV3
} from 'types'
} from './types'

import { townyData } from 'utils/endpoint.js'
import { FetchError } from 'utils/errors.js'
import { townyData } from './utils/endpoint.js'
import { FetchError } from './utils/errors.js'

const parseResident = (res: RawResident) => {
const obj: any = {}
Expand Down
4 changes: 2 additions & 2 deletions src/api/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { StrictPoint2D, Point2D, TownBounds } from "types"
import { hypot, safeParseInt, strictFalsy } from "utils/functions.js"
import type { StrictPoint2D, Point2D, TownBounds } from ".././types"
import { hypot, safeParseInt, strictFalsy } from ".././utils/functions.js"

type LocOrNation = Partial<Point2D & {
capital: Point2D
Expand Down
6 changes: 3 additions & 3 deletions src/api/dynmap/Dynmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type {
MapResponse, PlayersResponse,
Point2D, TownBounds,
DynmapMap
} from 'types'
} from '../../types'

import DataHandler from 'helpers/DataHandler.js'
import DataHandler from '../../helpers/DataHandler.js'

import Towns from './Towns.js'
import Nations from './Nations.js'
Expand All @@ -14,7 +14,7 @@ import GPS from './GPS.js'

import {
editPlayerProps
} from 'utils/functions.js'
} from '../../utils/functions.js'

import { withinBounds, withinTown } from '../common.js'

Expand Down
4 changes: 2 additions & 2 deletions src/api/dynmap/GPS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import type Dynmap from './Dynmap.js'
import {
type Route, Routes, type RouteInfo,
type Location, type Nation, type Player
} from 'types'
} from '../../types'

import Mitt from '../../helpers/EventEmitter.js'
import { manhattan, safeParseInt, strictFalsy } from 'utils/functions.js'
import { manhattan, safeParseInt, strictFalsy } from '../../utils/functions.js'

class GPS extends Mitt {
#map: Dynmap
Expand Down
8 changes: 4 additions & 4 deletions src/api/dynmap/Nations.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type {
Nation, StrictPoint2D, Town
} from 'types'
} from '../../types'

import type { Dynmap } from "./Dynmap.js"
import type { EntityApi } from 'helpers/EntityApi.js'
import type { EntityApi } from '../../helpers/EntityApi.js'

import {
FetchError,
type NotFoundError
} from "utils/errors.js"
} from "../../utils/errors.js"

import {
getNearest
Expand All @@ -17,7 +17,7 @@ import {
import {
sqr, getExisting,
fastMergeUnique
} from 'utils/functions.js'
} from '../../utils/functions.js'

//import OfficialAPI from '../OAPI.js'

Expand Down
10 changes: 5 additions & 5 deletions src/api/dynmap/Players.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import type {
MapResponse,
OnlinePlayer, Player,
StrictPoint2D
} from 'types'
} from '../../types'

import * as fn from 'utils/functions.js'
import * as endpoint from 'utils/endpoint.js'
import { FetchError, type NotFoundError } from "utils/errors.js"
import type { EntityApi } from 'helpers/EntityApi.js'
import * as fn from '../../utils/functions.js'
import * as endpoint from '../../utils/endpoint.js'
import { FetchError, type NotFoundError } from "../../utils/errors.js"
import type { EntityApi } from '../../helpers/EntityApi.js'
import { getNearest } from '../common.js'

class Players implements EntityApi<Player | NotFoundError> {
Expand Down
6 changes: 3 additions & 3 deletions src/api/dynmap/Residents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import type Dynmap from "./Dynmap.js"

import type {
Resident, Town
} from 'types'
} from '../../types'

import {
FetchError,
InvalidError,
type NotFoundError
} from "utils/errors.js"
} from "../../utils/errors.js"

import type { EntityApi } from 'helpers/EntityApi.js'
import type { EntityApi } from '../../helpers/EntityApi.js'

class Residents implements EntityApi<Resident | NotFoundError> {
#map: Dynmap
Expand Down
8 changes: 4 additions & 4 deletions src/api/dynmap/Towns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import {
calcArea, range,
getExisting,
isInvitable
} from 'utils/functions.js'
} from '../../utils/functions.js'

import {
FetchError,
InvalidError,
NotFoundError
} from "utils/errors.js"
} from "../../utils/errors.js"

import type { EntityApi } from 'helpers/EntityApi.js'
import type { Nation, StrictPoint2D, Town } from 'types'
import type { EntityApi } from '../../helpers/EntityApi.js'
import type { Nation, StrictPoint2D, Town } from '../../types'
import { getNearest } from '../common.js'

class Towns implements EntityApi<Town | NotFoundError> {
Expand Down
8 changes: 4 additions & 4 deletions src/api/squaremap/Nations.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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 { FetchError, type NotFoundError } from "../../utils/errors.js"
import type { EntityApi } from "../../helpers/EntityApi.js"
import type { Nation, SquaremapTown, StrictPoint2D } from "../../types"

import { getExisting, sqr } from "utils/functions.js"
import { getExisting, sqr } from "../../utils/functions.js"

import { getNearest } from "../common.js"
import { parseNations } from "./parser.js"
Expand Down
8 changes: 4 additions & 4 deletions src/api/squaremap/Players.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import type Squaremap from "./Squaremap.js"

import type {
EntityApi
} from "helpers/EntityApi.js"
} from "../../helpers/EntityApi.js"

import type { OnlinePlayer, Player, StrictPoint2D } from "types"
import { FetchError, type NotFoundError } from "utils/errors.js"
import { getExisting } from "utils/functions.js"
import type { OnlinePlayer, Player, StrictPoint2D } from "../../types"
import { FetchError, type NotFoundError } from "../../utils/errors.js"
import { getExisting } from "../../utils/functions.js"
import { parseInfoString } from "./parser.js"
import { getNearest } from "../common.js"

Expand Down
9 changes: 5 additions & 4 deletions src/api/squaremap/Residents.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type Squaremap from "./Squaremap.js"

import type { EntityApi } from "helpers/EntityApi.js"
import type { Resident, SquaremapTown } from "types"
import { InvalidError, type NotFoundError } from "utils/errors.js"
import { getExisting } from "utils/functions.js"
import type { Resident, SquaremapTown } from "../../types"

import type { EntityApi } from "../../helpers/EntityApi.js"
import { InvalidError, type NotFoundError } from "../../utils/errors.js"
import { getExisting } from "../../utils/functions.js"
import { parseResidents } from "./parser.js"

class Residents implements EntityApi<Resident | NotFoundError> {
Expand Down
4 changes: 2 additions & 2 deletions src/api/squaremap/Squaremap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import type {
SquaremapMapResponse,
SquaremapPlayersResponse,
TownBounds
} from "types"
} from "../../types"

import DataHandler from "helpers/DataHandler.js"
import DataHandler from "../../helpers/DataHandler.js"

import Towns from './Towns.js'
import Nations from './Nations.js'
Expand Down
8 changes: 4 additions & 4 deletions src/api/squaremap/Towns.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type Squaremap from "./Squaremap.js"
import type { Nation, SquaremapTown, StrictPoint2D } from "types"
import type { Nation, SquaremapTown, StrictPoint2D } from "../../types"

import type { EntityApi } from "helpers/EntityApi.js"
import type { EntityApi } from "../../helpers/EntityApi.js"
import { parseTowns } from "./parser.js"

import {
FetchError, InvalidError,
NotFoundError
} from "utils/errors.js"
} from "../../utils/errors.js"

import { getExisting, isInvitable } from "utils/functions.js"
import { getExisting, isInvitable } from "../../utils/functions.js"
import { getNearest } from "../common.js"

class Towns implements EntityApi<SquaremapTown | NotFoundError> {
Expand Down
4 changes: 2 additions & 2 deletions src/api/squaremap/parser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import striptags from 'striptags'
import { asBool, calcArea, fastMergeUnique, formatString, range, roundToNearest16 } from 'utils/functions.js'
import { asBool, calcArea, fastMergeUnique, formatString, range, roundToNearest16 } from '../../utils/functions.js'

import type {
Nation,
Expand All @@ -11,7 +11,7 @@ import type {
SquaremapRawPlayer,
SquaremapTown,
StrictPoint2D
} from 'types'
} from '../../types'

/**
* Parses the tooltip on a marker - removing white space, new lines and HTML tags.
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/DataHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as endpoint from 'utils/endpoint.js'
import * as endpoint from '../utils/endpoint.js'

import { Mutex } from 'async-mutex'
import type { AnyMap } from 'types'
import type { AnyMap } from '../types'

class DataHandler {
#map: AnyMap
Expand Down
1 change: 0 additions & 1 deletion src/helpers/EventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default class Mitt {
protected emit: any

constructor() {
// @ts-expect-error
const emitter = mitt()

Object.keys(emitter).forEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

const Aurora = new Squaremap('aurora')
const Nova = new Dynmap('nova')
Expand Down Expand Up @@ -60,6 +60,6 @@ export {
Dynmap, Squaremap
}

export * from "types"
export * from "./types/index.js"
export * from "./utils/errors.js"
export { formatString } from './utils/functions.js'
2 changes: 1 addition & 1 deletion src/types/dynmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
StringContainedWithin,
HexString,
Opacity
} from 'types'
} from '../types'

export type MapResponse = {
timestamp: number
Expand Down
2 changes: 1 addition & 1 deletion src/types/nation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
RawEntitySpawn,
RawEntityStats,
RawEntityStatus
} from "types"
} from "../types"

import type { Prettify } from "./util.js"

Expand Down
2 changes: 1 addition & 1 deletion src/types/oapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {
Location,
NestedOmit,
Prettify
} from 'types'
} from '../types'

//#region V2
//#region Parsed
Expand Down
2 changes: 1 addition & 1 deletion src/types/player.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Location, Resident } from 'types'
import type { Location, Resident } from '../types'

export type OnlinePlayer = Location & {
name: string
Expand Down
2 changes: 1 addition & 1 deletion src/types/squaremap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
Opacity,
Prettify,
StrictPoint2D
} from 'types'
} from '../types'

export interface SquaremapPlayersResponse {
max: number
Expand Down
2 changes: 1 addition & 1 deletion src/utils/endpoint.ts
Original file line number Diff line number Diff line change
@@ -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"

import { genRandomString } from './functions.js'

Expand Down
2 changes: 1 addition & 1 deletion src/utils/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
Point2D,
RawPlayer, Player, Town,
BaseTown, BaseNation
} from 'types'
} from '../types'

import { NotFound } from './errors.js'

Expand Down
Loading

0 comments on commit d291976

Please sign in to comment.