Rename some types

This commit is contained in:
James Lyne 2021-07-19 16:40:30 +01:00
parent e92ad7294e
commit 9bea4519c6
14 changed files with 111 additions and 111 deletions

View File

@ -29,13 +29,11 @@ import {
DynmapTileUpdate,
DynmapUpdate,
DynmapUpdateResponse,
DynmapUpdates,
DynmapWorld,
DynmapWorldMap
DynmapUpdates
} from "@/dynmap";
import {useStore} from "@/store";
import ChatError from "@/errors/ChatError";
import {LiveAtlasMessageConfig} from "@/index";
import {LiveAtlasMessageConfig, LiveAtlasWorld} from "@/index";
const titleColours = /§[0-9a-f]/ig;
@ -103,8 +101,8 @@ function buildMessagesConfig(response: any): LiveAtlasMessageConfig {
}
}
function buildWorlds(response: any): Array<DynmapWorld> {
const worlds: Map<string, DynmapWorld> = new Map<string, DynmapWorld>();
function buildWorlds(response: any): Array<LiveAtlasWorld> {
const worlds: Map<string, LiveAtlasWorld> = new Map<string, LiveAtlasWorld>();
//Get all the worlds first so we can handle append_to_world properly
(response.worlds || []).forEach((world: any) => {

View File

@ -44,11 +44,12 @@ import LinkControl from "@/components/map/control/LinkControl.vue";
import ChatControl from "@/components/map/control/ChatControl.vue";
import LogoControl from "@/components/map/control/LogoControl.vue";
import {MutationTypes} from "@/store/mutation-types";
import {Coordinate, DynmapPlayer} from "@/dynmap";
import {DynmapPlayer} from "@/dynmap";
import {ActionTypes} from "@/store/action-types";
import DynmapMap from "@/leaflet/DynmapMap";
import {LoadingControl} from "@/leaflet/control/LoadingControl";
import MapContextMenu from "@/components/map/MapContextMenu.vue";
import {Coordinate} from "@/index";
export default defineComponent({
components: {
@ -324,4 +325,4 @@ export default defineComponent({
}
}
}
</style>
</style>

View File

@ -16,13 +16,13 @@
<script lang="ts">
import {defineComponent, onUnmounted, computed, watch} from "@vue/runtime-core";
import {DynmapWorldMap} from "@/dynmap";
import {Map} from 'leaflet';
import {useStore} from "@/store";
import {MutationTypes} from "@/store/mutation-types";
import {ActionTypes} from "@/store/action-types";
import {getMinecraftTime} from "@/util";
import {DynmapTileLayer} from "@/leaflet/tileLayer/DynmapTileLayer";
import {LiveAtlasWorldMap} from "@/index";
export default defineComponent({
props: {
@ -31,7 +31,7 @@ export default defineComponent({
required: true
},
map: {
type: Object as () => DynmapWorldMap,
type: Object as () => LiveAtlasWorldMap,
required: true
},
leaflet: {

View File

@ -32,7 +32,6 @@
<script lang="ts">
import {useStore} from "@/store";
import {DynmapWorld, DynmapWorldMap} from "@/dynmap";
import {defineComponent} from 'vue';
import {MutationTypes} from "@/store/mutation-types";
import SvgIcon from "@/components/SvgIcon.vue";
@ -47,13 +46,14 @@ import "@/assets/icons/block_the_end_surface.svg";
import "@/assets/icons/block_other.svg";
import "@/assets/icons/block_other_flat.svg";
import "@/assets/icons/block_skylands.svg";
import {LiveAtlasWorld, LiveAtlasWorldMap} from "@/index";
export default defineComponent({
name: 'WorldListItem',
components: {SvgIcon},
props: {
world: {
type: Object as () => DynmapWorld,
type: Object as () => LiveAtlasWorld,
required: true
},
name: {
@ -75,7 +75,7 @@ export default defineComponent({
},
methods: {
getMapIcon(map: DynmapWorldMap): string {
getMapIcon(map: LiveAtlasWorldMap): string {
let worldType: string,
mapType: string;

63
src/dynmap.d.ts vendored
View File

@ -18,7 +18,7 @@ import {PathOptions, PointTuple, PolylineOptions} from "leaflet";
import {CoordinatesControlOptions} from "@/leaflet/control/CoordinatesControl";
import {LogoControlOptions} from "@/leaflet/control/LogoControl";
import {ClockControlOptions} from "@/leaflet/control/ClockControl";
import {LiveAtlasMessageConfig} from "@/index";
import {Coordinate, LiveAtlasLocation, LiveAtlasMessageConfig, LiveAtlasWorld, LiveAtlasWorldState} from "@/index";
declare global {
// noinspection JSUnusedGlobalSymbols
@ -94,63 +94,16 @@ interface DynmapChatSendingConfig {
cooldown: number;
}
interface DynmapWorld {
seaLevel: number;
name: string;
protected: boolean;
title: string;
height: number;
center: Coordinate;
maps: Map<string, DynmapWorldMap>;
}
interface DynmapWorldMap {
world: DynmapWorld;
name: string;
icon: string;
title: string;
background: string;
nightAndDay: boolean;
backgroundDay?: string;
backgroundNight?: string;
imageFormat: string;
prefix: string;
protected: boolean;
mapToWorld: [number, number, number, number, number, number, number, number, number];
worldToMap: [number, number, number, number, number, number, number, number, number];
nativeZoomLevels: number;
extraZoomLevels: number;
}
interface DynmapWorldState {
raining: boolean;
thundering: boolean;
timeOfDay: number;
}
interface Coordinate {
x: number;
y: number;
z: number;
}
interface DynmapLocation {
x: number;
y: number;
z: number;
world?: string;
}
interface DynmapConfigurationResponse {
config: DynmapServerConfig,
messages: LiveAtlasMessageConfig,
worlds: Array<DynmapWorld>,
worlds: Array<LiveAtlasWorld>,
components: DynmapComponentConfig,
loggedIn: boolean,
}
interface DynmapUpdateResponse {
worldState: DynmapWorldState;
worldState: LiveAtlasWorldState;
configHash: number;
playerCount: number;
players: Set<DynmapPlayer>;
@ -165,7 +118,7 @@ interface DynmapPlayer {
name: string;
sort: number;
hidden: boolean;
location: DynmapLocation;
location: LiveAtlasLocation;
}
interface DynmapMarkerSet {
@ -277,14 +230,6 @@ interface DynmapTileUpdate {
timestamp: number
}
interface DynmapParsedUrl {
world?: string;
map?: string;
location?: Coordinate;
zoom?: number;
legacy: boolean;
}
interface DynmapChat {
type: 'chat' | 'playerjoin' | 'playerleave';
playerAccount?: string;

61
src/index.d.ts vendored
View File

@ -1,5 +1,5 @@
import {State} from "@/store";
import {DynmapPlayer, DynmapUrlConfig} from "@/dynmap";
import {DynmapPlayer, DynmapUrlConfig, LiveAtlasWorldMap} from "@/dynmap";
declare module "*.png" {
const value: any;
@ -7,11 +7,24 @@ declare module "*.png" {
}
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
import type {DefineComponent} from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
interface Coordinate {
x: number;
y: number;
z: number;
}
interface LiveAtlasLocation {
x: number;
y: number;
z: number;
world?: string;
}
interface LiveAtlasServerDefinition {
id: string
label?: string
@ -69,3 +82,45 @@ export type LiveAtlasSidebarSection = 'servers' | 'players' | 'maps';
interface LiveAtlasSortedPlayers extends Array<DynmapPlayer> {
dirty?: boolean;
}
interface LiveAtlasWorld {
seaLevel: number;
name: string;
protected: boolean;
title: string;
height: number;
center: Coordinate;
maps: Map<string, LiveAtlasWorldMap>;
}
interface LiveAtlasWorldState {
raining: boolean;
thundering: boolean;
timeOfDay: number;
}
interface LiveAtlasWorldMap {
world: LiveAtlasWorld;
name: string;
icon: string;
title: string;
background: string;
nightAndDay: boolean;
backgroundDay?: string;
backgroundNight?: string;
imageFormat: string;
prefix: string;
protected: boolean;
mapToWorld: [number, number, number, number, number, number, number, number, number];
worldToMap: [number, number, number, number, number, number, number, number, number];
nativeZoomLevels: number;
extraZoomLevels: number;
}
interface LiveAtlasParsedUrl {
world?: string;
map?: string;
location?: Coordinate;
zoom?: number;
legacy: boolean;
}

View File

@ -19,7 +19,6 @@
import {ControlOptions, DomUtil, Util, Control} from 'leaflet';
import {getMinecraftTime} from '@/util';
import {DynmapWorldState} from "@/dynmap";
import {watch} from "@vue/runtime-core";
import {useStore} from "@/store";
@ -30,6 +29,7 @@ import "@/assets/icons/clock_moon_storm.svg";
import "@/assets/icons/clock_sun.svg";
import "@/assets/icons/clock_sun_rain.svg";
import "@/assets/icons/clock_sun_storm.svg";
import {LiveAtlasWorldState} from "@/index";
export interface ClockControlOptions extends ControlOptions {
showTimeOfDay: boolean;
@ -92,7 +92,7 @@ export class ClockControl extends Control {
}
}
_update(worldState: DynmapWorldState) {
_update(worldState: LiveAtlasWorldState) {
const timeOfDay = worldState.timeOfDay;
let sunAngle;
@ -170,4 +170,4 @@ export class ClockControl extends Control {
this._currentMoonIcon = icon;
}
}
}
}

View File

@ -19,7 +19,7 @@
import {ControlOptions, LeafletMouseEvent, Control, Map, DomUtil, Util} from 'leaflet';
import {useStore} from "@/store";
import {Coordinate} from "@/dynmap";
import {Coordinate} from "@/index";
const store = useStore();

View File

@ -18,7 +18,7 @@
*/
import {Util, LatLng, Class} from 'leaflet';
import {Coordinate} from "@/dynmap";
import {Coordinate} from "@/index";
export interface DynmapProjectionOptions {
mapToWorld: [number, number, number, number, number, number, number, number, number],

View File

@ -19,11 +19,11 @@
import {TileLayer, Coords, DoneCallback, TileLayerOptions, DomUtil, Util, LatLng} from 'leaflet';
import {DynmapProjection} from "@/leaflet/projection/DynmapProjection";
import {Coordinate, DynmapWorldMap} from "@/dynmap";
import {store} from "@/store";
import {Coordinate, LiveAtlasWorldMap} from "@/index";
export interface DynmapTileLayerOptions extends TileLayerOptions {
mapSettings: DynmapWorldMap;
mapSettings: LiveAtlasWorldMap;
errorTileUrl: string;
night?: boolean;
}
@ -31,7 +31,7 @@ export interface DynmapTileLayerOptions extends TileLayerOptions {
export interface DynmapTileLayer extends TileLayer {
options: DynmapTileLayerOptions;
_projection: DynmapProjection;
_mapSettings: DynmapWorldMap;
_mapSettings: LiveAtlasWorldMap;
_cachedTileUrls: Map<string, string>;
_namedTiles: Map<string, DynmapTileElement>;
_tileTemplate: DynmapTileElement;

View File

@ -25,9 +25,10 @@ import {
DynmapMarkerSet,
DynmapMarkerUpdate,
DynmapPlayer, DynmapTileUpdate,
DynmapUpdateResponse, DynmapWorld
DynmapUpdateResponse
} from "@/dynmap";
import {getAPI} from "@/util";
import {LiveAtlasWorld} from "@/index";
type AugmentedActionContext = {
commit<K extends keyof Mutations>(
@ -118,7 +119,7 @@ export const actions: ActionTree<State, State> & Actions = {
}
if(worldName) {
const world = state.worlds.get(worldName) as DynmapWorld;
const world = state.worlds.get(worldName) as LiveAtlasWorld;
// Use config default map if it exists
if(config.config.defaultMap && world.maps.has(config.config.defaultMap)) {

View File

@ -21,22 +21,21 @@ import {
DynmapArea,
DynmapCircle,
DynmapComponentConfig,
DynmapLine, Coordinate,
DynmapMarker,
DynmapLine, DynmapMarker,
DynmapMarkerSet,
DynmapMarkerSetUpdates,
DynmapPlayer,
DynmapServerConfig, DynmapTileUpdate,
DynmapWorld,
DynmapWorldState, DynmapParsedUrl, DynmapChat
DynmapChat
} from "@/dynmap";
import {DynmapProjection} from "@/leaflet/projection/DynmapProjection";
import {
Coordinate, LiveAtlasWorldState,
LiveAtlasMessageConfig,
LiveAtlasServerDefinition,
LiveAtlasSidebarSection,
LiveAtlasSortedPlayers,
LiveAtlasUIElement
LiveAtlasUIElement, LiveAtlasWorld, LiveAtlasParsedUrl
} from "@/index";
export type CurrentMapPayload = {
@ -51,13 +50,13 @@ export type Mutations<S = State> = {
[MutationTypes.SET_CONFIGURATION_HASH](state: S, hash: number): void
[MutationTypes.CLEAR_CONFIGURATION_HASH](state: S): void
[MutationTypes.SET_MESSAGES](state: S, messages: LiveAtlasMessageConfig): void
[MutationTypes.SET_WORLDS](state: S, worlds: Array<DynmapWorld>): void
[MutationTypes.SET_WORLDS](state: S, worlds: Array<LiveAtlasWorld>): void
[MutationTypes.CLEAR_WORLDS](state: S): void
[MutationTypes.SET_COMPONENTS](state: S, worlds: DynmapComponentConfig): void
[MutationTypes.SET_MARKER_SETS](state: S, worlds: Map<string, DynmapMarkerSet>): void
[MutationTypes.CLEAR_MARKER_SETS](state: S): void
[MutationTypes.ADD_WORLD](state: S, world: DynmapWorld): void
[MutationTypes.SET_WORLD_STATE](state: S, worldState: DynmapWorldState): void
[MutationTypes.ADD_WORLD](state: S, world: LiveAtlasWorld): void
[MutationTypes.SET_WORLD_STATE](state: S, worldState: LiveAtlasWorldState): void
[MutationTypes.SET_UPDATE_TIMESTAMP](state: S, time: Date): void
[MutationTypes.ADD_MARKER_SET_UPDATES](state: S, updates: Map<string, DynmapMarkerSetUpdates>): void
[MutationTypes.ADD_TILE_UPDATES](state: S, updates: Array<DynmapTileUpdate>): void
@ -78,7 +77,7 @@ export type Mutations<S = State> = {
[MutationTypes.SET_CURRENT_PROJECTION](state: S, payload: DynmapProjection): void
[MutationTypes.SET_CURRENT_LOCATION](state: S, payload: Coordinate): void
[MutationTypes.SET_CURRENT_ZOOM](state: S, payload: number): void
[MutationTypes.SET_PARSED_URL](state: S, payload: DynmapParsedUrl): void
[MutationTypes.SET_PARSED_URL](state: S, payload: LiveAtlasParsedUrl): void
[MutationTypes.CLEAR_PARSED_URL](state: S): void
[MutationTypes.CLEAR_CURRENT_MAP](state: S): void
[MutationTypes.SET_FOLLOW_TARGET](state: S, payload: DynmapPlayer): void
@ -136,7 +135,7 @@ export const mutations: MutationTree<State> & Mutations = {
},
//Sets the list of worlds, and their settings, from the initial config fetch
[MutationTypes.SET_WORLDS](state: State, worlds: Array<DynmapWorld>) {
[MutationTypes.SET_WORLDS](state: State, worlds: Array<LiveAtlasWorld>) {
state.worlds.clear();
state.maps.clear();
@ -205,12 +204,12 @@ export const mutations: MutationTree<State> & Mutations = {
state.pendingSetUpdates.clear();
},
[MutationTypes.ADD_WORLD](state: State, world: DynmapWorld) {
[MutationTypes.ADD_WORLD](state: State, world: LiveAtlasWorld) {
state.worlds.set(world.name, world);
},
//Sets the current world state an update fetch
[MutationTypes.SET_WORLD_STATE](state: State, worldState: DynmapWorldState) {
[MutationTypes.SET_WORLD_STATE](state: State, worldState: LiveAtlasWorldState) {
state.currentWorldState = Object.assign(state.currentWorldState, worldState);
},
@ -492,7 +491,7 @@ export const mutations: MutationTree<State> & Mutations = {
},
//Sets the result of parsing the current map url, if present and valid
[MutationTypes.SET_PARSED_URL](state: State, payload: DynmapParsedUrl) {
[MutationTypes.SET_PARSED_URL](state: State, payload: LiveAtlasParsedUrl) {
state.parsedUrl = payload;
},

View File

@ -15,19 +15,19 @@
*/
import {
DynmapComponentConfig,
DynmapWorldMap, DynmapMarkerSet, DynmapMarkerSetUpdates,
DynmapComponentConfig, DynmapMarkerSet, DynmapMarkerSetUpdates,
DynmapPlayer,
DynmapServerConfig, DynmapTileUpdate,
DynmapWorld, DynmapWorldState, Coordinate, DynmapParsedUrl, DynmapChat
DynmapChat
} from "@/dynmap";
import {DynmapProjection} from "@/leaflet/projection/DynmapProjection";
import {
Coordinate, LiveAtlasWorldState,
LiveAtlasMessageConfig,
LiveAtlasServerDefinition,
LiveAtlasSidebarSection,
LiveAtlasSortedPlayers,
LiveAtlasUIElement
LiveAtlasUIElement, LiveAtlasWorld, LiveAtlasWorldMap, LiveAtlasParsedUrl
} from "@/index";
export type State = {
@ -40,8 +40,8 @@ export type State = {
loggedIn: boolean;
worlds: Map<string, DynmapWorld>;
maps: Map<string, DynmapWorldMap>;
worlds: Map<string, LiveAtlasWorld>;
maps: Map<string, LiveAtlasWorldMap>;
players: Map<string, DynmapPlayer>;
sortedPlayers: LiveAtlasSortedPlayers;
markerSets: Map<string, DynmapMarkerSet>;
@ -58,9 +58,9 @@ export type State = {
panTarget?: DynmapPlayer;
currentServer?: LiveAtlasServerDefinition;
currentWorldState: DynmapWorldState;
currentWorld?: DynmapWorld;
currentMap?: DynmapWorldMap;
currentWorldState: LiveAtlasWorldState;
currentWorld?: LiveAtlasWorld;
currentMap?: LiveAtlasWorldMap;
currentLocation: Coordinate;
currentZoom: number;
currentProjection: DynmapProjection;
@ -78,7 +78,7 @@ export type State = {
}
};
parsedUrl: DynmapParsedUrl;
parsedUrl: LiveAtlasParsedUrl;
}
export const state: State = {

View File

@ -15,8 +15,9 @@
*/
import API from '@/api';
import {DynmapPlayer, DynmapWorld, DynmapWorldMap} from "@/dynmap";
import {DynmapPlayer} from "@/dynmap";
import {useStore} from "@/store";
import {LiveAtlasWorld, LiveAtlasWorldMap} from "@/index";
interface HeadQueueEntry {
cacheKey: string;
@ -214,7 +215,7 @@ export const getAPI = () => {
return API;
}
export const getUrlForLocation = (world: DynmapWorld, map: DynmapWorldMap, location: {
export const getUrlForLocation = (world: LiveAtlasWorld, map: LiveAtlasWorldMap, location: {
x: number,
y: number,
z: number }, zoom: number): string => {
@ -236,4 +237,4 @@ export const focus = (selector: string) => {
if(element) {
(element as HTMLElement).focus();
}
}
}