More type renaming

This commit is contained in:
James Lyne 2021-07-25 14:53:45 +01:00
parent 5fb0a3e2f4
commit 9e2caa6f63
7 changed files with 101 additions and 99 deletions

View File

@ -24,15 +24,15 @@
<script lang="ts">
import {defineComponent, ref, onMounted, computed} from "@vue/runtime-core";
import {DynmapChat} from "@/dynmap";
import {getMinecraftHead} from '@/util';
import {useStore} from "@/store";
import defaultImage from '@/assets/images/player_face.png';
import {LiveAtlasChat} from "@/index";
export default defineComponent({
props: {
message: {
type: Object as () => DynmapChat,
type: Object as () => LiveAtlasChat,
required: true,
}
},

View File

@ -17,11 +17,10 @@
<script lang="ts">
import {defineComponent, computed, ref, onMounted, onUnmounted} from "@vue/runtime-core";
import {LayerGroup} from 'leaflet';
import {DynmapChat} from "@/dynmap";
import {useStore} from "@/store";
import {PlayerMarker} from "@/leaflet/marker/PlayerMarker";
import {Popup} from "leaflet";
import {LiveAtlasPlayer} from "@/index";
import {LiveAtlasChat, LiveAtlasPlayer} from "@/index";
export default defineComponent({
props: {
@ -80,7 +79,7 @@ export default defineComponent({
//Chat messages to show in the popup
playerChat = computed(() => {
const messages: DynmapChat[] = [];
const messages: LiveAtlasChat[] = [];
if(!chatBalloonsEnabled.value) {
return messages;
@ -219,7 +218,7 @@ export default defineComponent({
}
},
},
playerChat(newValue: DynmapChat[]) {
playerChat(newValue: LiveAtlasChat[]) {
if(!this.chatBalloonsEnabled || !this.markerVisible || !newValue.length) {
return;
}

66
src/dynmap.d.ts vendored
View File

@ -14,9 +14,6 @@
* limitations under the License.
*/
import {CoordinatesControlOptions} from "@/leaflet/control/CoordinatesControl";
import {LogoControlOptions} from "@/leaflet/control/LogoControl";
import {ClockControlOptions} from "@/leaflet/control/ClockControl";
import {LiveAtlasArea, LiveAtlasCircle, LiveAtlasLine, LiveAtlasMarker} from "@/index";
declare global {
@ -36,59 +33,6 @@ type DynmapUrlConfig = {
markers: string;
}
interface DynmapServerConfig {
defaultMap?: string;
defaultWorld?: string;
defaultZoom: number;
followMap?: string;
followZoom: number;
title: string;
maxPlayers: number;
grayHiddenPlayers: boolean;
expandUI: boolean;
}
interface DynmapComponentConfig {
markers: DynmapMarkersConfig;
playerMarkers?: DynmapPlayerMarkersConfig;
coordinatesControl?: CoordinatesControlOptions;
clockControl ?: ClockControlOptions;
linkControl: boolean;
layerControl: boolean;
logoControls: Array<LogoControlOptions>;
chatBox?: DynmapChatBoxConfig;
chatSending?: DynmapChatSendingConfig;
chatBalloons: boolean;
login: boolean;
}
interface DynmapMarkersConfig {
showLabels: boolean
}
interface DynmapPlayerMarkersConfig {
hideByDefault: boolean;
layerName: string;
layerPriority: number;
showBodies: boolean;
showSkinFaces: boolean;
showHealth: boolean;
smallFaces: boolean;
}
interface DynmapChatBoxConfig {
allowUrlName: boolean;
showPlayerFaces: boolean;
messageLifetime: number;
messageHistory: number;
}
interface DynmapChatSendingConfig {
loginRequired: boolean;
maxLength: number;
cooldown: number;
}
interface DynmapMarkerSetUpdates {
markerUpdates: Array<DynmapMarkerUpdate>
areaUpdates: Array<DynmapAreaUpdate>
@ -131,13 +75,3 @@ interface DynmapTileUpdate {
name: string
timestamp: number
}
interface DynmapChat {
type: 'chat' | 'playerjoin' | 'playerleave';
playerAccount?: string;
playerName?: string;
channel?: string;
message?: string;
source?: string;
timestamp: number;
}

64
src/index.d.ts vendored
View File

@ -2,6 +2,9 @@ import {State} from "@/store";
import {DynmapUrlConfig} from "@/dynmap";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
import {PathOptions, PointTuple, PolylineOptions} from "leaflet";
import {CoordinatesControlOptions} from "@/leaflet/control/CoordinatesControl";
import {ClockControlOptions} from "@/leaflet/control/ClockControl";
import {LogoControlOptions} from "@/leaflet/control/LogoControl";
declare module "*.png" {
const value: any;
@ -226,3 +229,64 @@ interface HeadQueueEntry {
size: string;
image: HTMLImageElement;
}
interface LiveAtlasServerConfig {
defaultMap?: string;
defaultWorld?: string;
defaultZoom: number;
followMap?: string;
followZoom: number;
title: string;
maxPlayers: number;
grayHiddenPlayers: boolean;
expandUI: boolean;
}
interface LiveAtlasComponentConfig {
markers: {
showLabels: boolean;
};
playerMarkers?: LiveAtlasPlayerMarkerConfig;
coordinatesControl?: CoordinatesControlOptions;
clockControl?: ClockControlOptions;
linkControl: boolean;
layerControl: boolean;
logoControls: Array<LogoControlOptions>;
chatBox?: LiveAtlasChatBoxConfig;
chatSending?: LiveAtlasChatSendingConfig;
chatBalloons: boolean;
login: boolean;
}
interface LiveAtlasPlayerMarkerConfig {
hideByDefault: boolean;
layerName: string;
layerPriority: number;
showBodies: boolean;
showSkinFaces: boolean;
showHealth: boolean;
smallFaces: boolean;
}
interface LiveAtlasChatBoxConfig {
allowUrlName: boolean;
showPlayerFaces: boolean;
messageLifetime: number;
messageHistory: number;
}
interface LiveAtlasChatSendingConfig {
loginRequired: boolean;
maxLength: number;
cooldown: number;
}
interface LiveAtlasChat {
type: 'chat' | 'playerjoin' | 'playerleave';
playerAccount?: string;
playerName?: string;
channel?: string;
message?: string;
source?: string;
timestamp: number;
}

View File

@ -16,21 +16,19 @@
import {
HeadQueueEntry,
LiveAtlasArea,
LiveAtlasCircle,
LiveAtlasArea, LiveAtlasChat,
LiveAtlasCircle, LiveAtlasComponentConfig,
LiveAtlasDimension,
LiveAtlasLine,
LiveAtlasMarker,
LiveAtlasMarkerSet,
LiveAtlasPlayer,
LiveAtlasPlayer, LiveAtlasServerConfig,
LiveAtlasServerDefinition,
LiveAtlasServerMessageConfig,
LiveAtlasWorldDefinition
} from "@/index";
import {
DynmapChat,
DynmapComponentConfig,
DynmapMarkerSetUpdates, DynmapServerConfig, DynmapTileUpdate, DynmapUpdate
DynmapMarkerSetUpdates, DynmapTileUpdate, DynmapUpdate
} from "@/dynmap";
import {useStore} from "@/store";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
@ -54,7 +52,7 @@ export default class DynmapMapProvider extends MapProvider {
super(config);
}
private static buildServerConfig(response: any): DynmapServerConfig {
private static buildServerConfig(response: any): LiveAtlasServerConfig {
return {
grayHiddenPlayers: response.grayplayerswhenhidden || false,
defaultMap: response.defaultmap || undefined,
@ -144,8 +142,8 @@ export default class DynmapMapProvider extends MapProvider {
return Array.from(worlds.values());
}
private buildComponents(response: any): DynmapComponentConfig {
const components: DynmapComponentConfig = {
private buildComponents(response: any): LiveAtlasComponentConfig {
const components: LiveAtlasComponentConfig = {
markers: {
showLabels: false,
},
@ -402,7 +400,7 @@ export default class DynmapMapProvider extends MapProvider {
const updates = {
markerSets: new Map<string, DynmapMarkerSetUpdates>(),
tiles: [] as DynmapTileUpdate[],
chat: [] as DynmapChat[],
chat: [] as LiveAtlasChat[],
},
dropped = {
stale: 0,

View File

@ -18,10 +18,8 @@ import {MutationTree} from "vuex";
import {MutationTypes} from "@/store/mutation-types";
import {State} from "@/store/state";
import {
DynmapComponentConfig,
DynmapMarkerSetUpdates,
DynmapServerConfig, DynmapTileUpdate,
DynmapChat
DynmapTileUpdate
} from "@/dynmap";
import {
Coordinate,
@ -37,7 +35,12 @@ import {
LiveAtlasPlayer,
LiveAtlasCircle,
LiveAtlasLine,
LiveAtlasArea, LiveAtlasMarker, LiveAtlasMarkerSet, LiveAtlasServerDefinition
LiveAtlasArea,
LiveAtlasMarker,
LiveAtlasMarkerSet,
LiveAtlasServerDefinition,
LiveAtlasComponentConfig,
LiveAtlasServerConfig, LiveAtlasChat
} from "@/index";
import DynmapMapProvider from "@/providers/DynmapMapProvider";
@ -48,20 +51,20 @@ export type CurrentMapPayload = {
export type Mutations<S = State> = {
[MutationTypes.INIT](state: S, config: LiveAtlasGlobalConfig): void
[MutationTypes.SET_SERVER_CONFIGURATION](state: S, config: DynmapServerConfig): void
[MutationTypes.SET_SERVER_CONFIGURATION](state: S, config: LiveAtlasServerConfig): void
[MutationTypes.SET_SERVER_CONFIGURATION_HASH](state: S, hash: number): void
[MutationTypes.CLEAR_SERVER_CONFIGURATION_HASH](state: S): void
[MutationTypes.SET_SERVER_MESSAGES](state: S, messages: LiveAtlasServerMessageConfig): void
[MutationTypes.SET_WORLDS](state: S, worlds: Array<LiveAtlasWorldDefinition>): void
[MutationTypes.CLEAR_WORLDS](state: S): void
[MutationTypes.SET_COMPONENTS](state: S, worlds: DynmapComponentConfig): void
[MutationTypes.SET_COMPONENTS](state: S, worlds: LiveAtlasComponentConfig): void
[MutationTypes.SET_MARKER_SETS](state: S, worlds: Map<string, LiveAtlasMarkerSet>): void
[MutationTypes.CLEAR_MARKER_SETS](state: S): void
[MutationTypes.ADD_WORLD](state: S, world: LiveAtlasWorldDefinition): void
[MutationTypes.SET_WORLD_STATE](state: S, worldState: LiveAtlasWorldState): void
[MutationTypes.ADD_MARKER_SET_UPDATES](state: S, updates: Map<string, DynmapMarkerSetUpdates>): void
[MutationTypes.ADD_TILE_UPDATES](state: S, updates: Array<DynmapTileUpdate>): void
[MutationTypes.ADD_CHAT](state: State, chat: Array<DynmapChat>): void
[MutationTypes.ADD_CHAT](state: State, chat: Array<LiveAtlasChat>): void
[MutationTypes.POP_MARKER_UPDATES](state: S, payload: {markerSet: string, amount: number}): void
[MutationTypes.POP_AREA_UPDATES](state: S, payload: {markerSet: string, amount: number}): void
@ -156,7 +159,7 @@ export const mutations: MutationTree<State> & Mutations = {
},
// Sets configuration options from the initial config fetch
[MutationTypes.SET_SERVER_CONFIGURATION](state: State, config: DynmapServerConfig) {
[MutationTypes.SET_SERVER_CONFIGURATION](state: State, config: LiveAtlasServerConfig) {
state.configuration = Object.assign(state.configuration, config);
},
@ -220,7 +223,7 @@ export const mutations: MutationTree<State> & Mutations = {
},
//Sets the state and settings of optional components, from the initial config fetch
[MutationTypes.SET_COMPONENTS](state: State, components: DynmapComponentConfig) {
[MutationTypes.SET_COMPONENTS](state: State, components: LiveAtlasComponentConfig) {
state.components = Object.assign(state.components, components);
},
@ -354,7 +357,7 @@ export const mutations: MutationTree<State> & Mutations = {
},
//Adds chat messages from an update fetch to the chat history
[MutationTypes.ADD_CHAT](state: State, chat: Array<DynmapChat>) {
[MutationTypes.ADD_CHAT](state: State, chat: Array<LiveAtlasChat>) {
state.chat.messages.unshift(...chat);
},

View File

@ -15,9 +15,8 @@
*/
import {
DynmapComponentConfig, DynmapMarkerSetUpdates,
DynmapServerConfig, DynmapTileUpdate,
DynmapChat
DynmapMarkerSetUpdates,
DynmapTileUpdate
} from "@/dynmap";
import {
Coordinate,
@ -28,17 +27,22 @@ import {
LiveAtlasUIElement,
LiveAtlasWorldDefinition,
LiveAtlasParsedUrl,
LiveAtlasMessageConfig, LiveAtlasMapProvider, LiveAtlasPlayer, LiveAtlasMarkerSet
LiveAtlasMessageConfig,
LiveAtlasMapProvider,
LiveAtlasPlayer,
LiveAtlasMarkerSet,
LiveAtlasComponentConfig,
LiveAtlasServerConfig, LiveAtlasChat
} from "@/index";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
export type State = {
version: string;
servers: Map<string, LiveAtlasServerDefinition>;
configuration: DynmapServerConfig;
configuration: LiveAtlasServerConfig;
configurationHash: number | undefined;
messages: LiveAtlasMessageConfig;
components: DynmapComponentConfig;
components: LiveAtlasComponentConfig;
loggedIn: boolean;
@ -50,7 +54,7 @@ export type State = {
chat: {
unread: number;
messages: DynmapChat[];
messages: LiveAtlasChat[];
};
pendingSetUpdates: Map<string, DynmapMarkerSetUpdates>;