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

View File

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

66
src/dynmap.d.ts vendored
View File

@ -14,9 +14,6 @@
* limitations under the License. * 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"; import {LiveAtlasArea, LiveAtlasCircle, LiveAtlasLine, LiveAtlasMarker} from "@/index";
declare global { declare global {
@ -36,59 +33,6 @@ type DynmapUrlConfig = {
markers: string; 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 { interface DynmapMarkerSetUpdates {
markerUpdates: Array<DynmapMarkerUpdate> markerUpdates: Array<DynmapMarkerUpdate>
areaUpdates: Array<DynmapAreaUpdate> areaUpdates: Array<DynmapAreaUpdate>
@ -131,13 +75,3 @@ interface DynmapTileUpdate {
name: string name: string
timestamp: number 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 {DynmapUrlConfig} from "@/dynmap";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition"; import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
import {PathOptions, PointTuple, PolylineOptions} from "leaflet"; 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" { declare module "*.png" {
const value: any; const value: any;
@ -226,3 +229,64 @@ interface HeadQueueEntry {
size: string; size: string;
image: HTMLImageElement; 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 { import {
HeadQueueEntry, HeadQueueEntry,
LiveAtlasArea, LiveAtlasArea, LiveAtlasChat,
LiveAtlasCircle, LiveAtlasCircle, LiveAtlasComponentConfig,
LiveAtlasDimension, LiveAtlasDimension,
LiveAtlasLine, LiveAtlasLine,
LiveAtlasMarker, LiveAtlasMarker,
LiveAtlasMarkerSet, LiveAtlasMarkerSet,
LiveAtlasPlayer, LiveAtlasPlayer, LiveAtlasServerConfig,
LiveAtlasServerDefinition, LiveAtlasServerDefinition,
LiveAtlasServerMessageConfig, LiveAtlasServerMessageConfig,
LiveAtlasWorldDefinition LiveAtlasWorldDefinition
} from "@/index"; } from "@/index";
import { import {
DynmapChat, DynmapMarkerSetUpdates, DynmapTileUpdate, DynmapUpdate
DynmapComponentConfig,
DynmapMarkerSetUpdates, DynmapServerConfig, DynmapTileUpdate, DynmapUpdate
} from "@/dynmap"; } from "@/dynmap";
import {useStore} from "@/store"; import {useStore} from "@/store";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition"; import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
@ -54,7 +52,7 @@ export default class DynmapMapProvider extends MapProvider {
super(config); super(config);
} }
private static buildServerConfig(response: any): DynmapServerConfig { private static buildServerConfig(response: any): LiveAtlasServerConfig {
return { return {
grayHiddenPlayers: response.grayplayerswhenhidden || false, grayHiddenPlayers: response.grayplayerswhenhidden || false,
defaultMap: response.defaultmap || undefined, defaultMap: response.defaultmap || undefined,
@ -144,8 +142,8 @@ export default class DynmapMapProvider extends MapProvider {
return Array.from(worlds.values()); return Array.from(worlds.values());
} }
private buildComponents(response: any): DynmapComponentConfig { private buildComponents(response: any): LiveAtlasComponentConfig {
const components: DynmapComponentConfig = { const components: LiveAtlasComponentConfig = {
markers: { markers: {
showLabels: false, showLabels: false,
}, },
@ -402,7 +400,7 @@ export default class DynmapMapProvider extends MapProvider {
const updates = { const updates = {
markerSets: new Map<string, DynmapMarkerSetUpdates>(), markerSets: new Map<string, DynmapMarkerSetUpdates>(),
tiles: [] as DynmapTileUpdate[], tiles: [] as DynmapTileUpdate[],
chat: [] as DynmapChat[], chat: [] as LiveAtlasChat[],
}, },
dropped = { dropped = {
stale: 0, stale: 0,

View File

@ -18,10 +18,8 @@ import {MutationTree} from "vuex";
import {MutationTypes} from "@/store/mutation-types"; import {MutationTypes} from "@/store/mutation-types";
import {State} from "@/store/state"; import {State} from "@/store/state";
import { import {
DynmapComponentConfig,
DynmapMarkerSetUpdates, DynmapMarkerSetUpdates,
DynmapServerConfig, DynmapTileUpdate, DynmapTileUpdate
DynmapChat
} from "@/dynmap"; } from "@/dynmap";
import { import {
Coordinate, Coordinate,
@ -37,7 +35,12 @@ import {
LiveAtlasPlayer, LiveAtlasPlayer,
LiveAtlasCircle, LiveAtlasCircle,
LiveAtlasLine, LiveAtlasLine,
LiveAtlasArea, LiveAtlasMarker, LiveAtlasMarkerSet, LiveAtlasServerDefinition LiveAtlasArea,
LiveAtlasMarker,
LiveAtlasMarkerSet,
LiveAtlasServerDefinition,
LiveAtlasComponentConfig,
LiveAtlasServerConfig, LiveAtlasChat
} from "@/index"; } from "@/index";
import DynmapMapProvider from "@/providers/DynmapMapProvider"; import DynmapMapProvider from "@/providers/DynmapMapProvider";
@ -48,20 +51,20 @@ export type CurrentMapPayload = {
export type Mutations<S = State> = { export type Mutations<S = State> = {
[MutationTypes.INIT](state: S, config: LiveAtlasGlobalConfig): void [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.SET_SERVER_CONFIGURATION_HASH](state: S, hash: number): void
[MutationTypes.CLEAR_SERVER_CONFIGURATION_HASH](state: S): void [MutationTypes.CLEAR_SERVER_CONFIGURATION_HASH](state: S): void
[MutationTypes.SET_SERVER_MESSAGES](state: S, messages: LiveAtlasServerMessageConfig): void [MutationTypes.SET_SERVER_MESSAGES](state: S, messages: LiveAtlasServerMessageConfig): void
[MutationTypes.SET_WORLDS](state: S, worlds: Array<LiveAtlasWorldDefinition>): void [MutationTypes.SET_WORLDS](state: S, worlds: Array<LiveAtlasWorldDefinition>): void
[MutationTypes.CLEAR_WORLDS](state: S): 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.SET_MARKER_SETS](state: S, worlds: Map<string, LiveAtlasMarkerSet>): void
[MutationTypes.CLEAR_MARKER_SETS](state: S): void [MutationTypes.CLEAR_MARKER_SETS](state: S): void
[MutationTypes.ADD_WORLD](state: S, world: LiveAtlasWorldDefinition): void [MutationTypes.ADD_WORLD](state: S, world: LiveAtlasWorldDefinition): void
[MutationTypes.SET_WORLD_STATE](state: S, worldState: LiveAtlasWorldState): void [MutationTypes.SET_WORLD_STATE](state: S, worldState: LiveAtlasWorldState): void
[MutationTypes.ADD_MARKER_SET_UPDATES](state: S, updates: Map<string, DynmapMarkerSetUpdates>): 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_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_MARKER_UPDATES](state: S, payload: {markerSet: string, amount: number}): void
[MutationTypes.POP_AREA_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 // 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); 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 //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); 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 //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); state.chat.messages.unshift(...chat);
}, },

View File

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