2020-12-16 16:54:41 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2020 James Lyne
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2020-12-11 18:51:23 +00:00
|
|
|
import {PathOptions, PointTuple, PolylineOptions} from "leaflet";
|
2020-12-01 23:20:38 +00:00
|
|
|
import {CoordinatesControlOptions} from "@/leaflet/control/CoordinatesControl";
|
|
|
|
import {LogoControlOptions} from "@/leaflet/control/LogoControl";
|
|
|
|
import {ClockControlOptions} from "@/leaflet/control/ClockControl";
|
2021-07-20 20:12:08 +00:00
|
|
|
import {
|
|
|
|
Coordinate,
|
2021-07-24 01:27:25 +00:00
|
|
|
LiveAtlasPlayer,
|
2021-07-20 20:12:08 +00:00
|
|
|
LiveAtlasServerMessageConfig,
|
2021-07-23 19:32:15 +00:00
|
|
|
LiveAtlasWorldDefinition,
|
2021-07-20 20:12:08 +00:00
|
|
|
LiveAtlasWorldState
|
|
|
|
} from "@/index";
|
2020-11-23 12:13:28 +00:00
|
|
|
|
|
|
|
declare global {
|
2021-05-27 13:30:56 +00:00
|
|
|
// noinspection JSUnusedGlobalSymbols
|
2020-11-23 12:13:28 +00:00
|
|
|
interface Window {
|
2021-05-17 02:39:25 +00:00
|
|
|
config: { url: DynmapUrlConfig };
|
2020-11-23 12:13:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type DynmapUrlConfig = {
|
|
|
|
configuration: string;
|
|
|
|
update: string;
|
|
|
|
sendmessage: string;
|
|
|
|
login: string;
|
|
|
|
register: string;
|
|
|
|
tiles: string;
|
|
|
|
markers: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapServerConfig {
|
|
|
|
defaultMap?: string;
|
|
|
|
defaultWorld?: string;
|
2020-12-01 23:20:38 +00:00
|
|
|
defaultZoom: number;
|
2020-11-23 12:13:28 +00:00
|
|
|
followMap?: string;
|
2020-12-01 23:20:38 +00:00
|
|
|
followZoom: number;
|
2020-11-23 12:13:28 +00:00
|
|
|
title: string;
|
|
|
|
loginEnabled: boolean;
|
|
|
|
maxPlayers: number;
|
2020-12-18 16:04:06 +00:00
|
|
|
grayHiddenPlayers: boolean;
|
2021-01-24 15:46:34 +00:00
|
|
|
expandUI: boolean;
|
2020-11-23 12:13:28 +00:00
|
|
|
}
|
|
|
|
|
2020-11-24 01:56:03 +00:00
|
|
|
interface DynmapComponentConfig {
|
2020-12-01 23:20:38 +00:00
|
|
|
markers: DynmapMarkersConfig;
|
2020-11-24 01:56:03 +00:00
|
|
|
playerMarkers?: DynmapPlayerMarkersConfig;
|
2020-12-01 23:20:38 +00:00
|
|
|
coordinatesControl?: CoordinatesControlOptions;
|
|
|
|
clockControl ?: ClockControlOptions;
|
|
|
|
linkControl: boolean;
|
2021-07-24 03:03:36 +00:00
|
|
|
layerControl: boolean;
|
2020-12-01 23:20:38 +00:00
|
|
|
logoControls: Array<LogoControlOptions>;
|
2021-01-07 17:24:21 +00:00
|
|
|
chatBox?: DynmapChatBoxConfig;
|
|
|
|
chatSending?: DynmapChatSendingConfig;
|
2021-01-05 22:30:55 +00:00
|
|
|
chatBalloons: boolean;
|
2020-12-01 23:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapMarkersConfig {
|
|
|
|
showLabels: boolean
|
2020-11-24 01:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapPlayerMarkersConfig {
|
|
|
|
hideByDefault: boolean;
|
|
|
|
layerName: string;
|
|
|
|
layerPriority: number;
|
|
|
|
showBodies: boolean;
|
|
|
|
showSkinFaces: boolean;
|
|
|
|
showHealth: boolean;
|
|
|
|
smallFaces: boolean;
|
|
|
|
}
|
|
|
|
|
2021-01-07 17:24:21 +00:00
|
|
|
interface DynmapChatBoxConfig {
|
2020-12-17 14:50:12 +00:00
|
|
|
allowUrlName: boolean;
|
|
|
|
showPlayerFaces: boolean;
|
|
|
|
messageLifetime: number;
|
|
|
|
messageHistory: number;
|
|
|
|
}
|
|
|
|
|
2021-01-07 17:24:21 +00:00
|
|
|
interface DynmapChatSendingConfig {
|
|
|
|
loginRequired: boolean;
|
|
|
|
maxLength: number;
|
|
|
|
cooldown: number;
|
|
|
|
}
|
|
|
|
|
2020-11-23 12:13:28 +00:00
|
|
|
interface DynmapConfigurationResponse {
|
|
|
|
config: DynmapServerConfig,
|
2021-07-20 20:12:08 +00:00
|
|
|
messages: LiveAtlasServerMessageConfig,
|
2021-07-23 19:32:15 +00:00
|
|
|
worlds: Array<LiveAtlasWorldDefinition>,
|
2020-11-24 01:56:03 +00:00
|
|
|
components: DynmapComponentConfig,
|
2021-01-24 22:35:11 +00:00
|
|
|
loggedIn: boolean,
|
2020-11-23 12:13:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapUpdateResponse {
|
2021-07-19 15:40:30 +00:00
|
|
|
worldState: LiveAtlasWorldState;
|
2020-11-23 12:13:28 +00:00
|
|
|
configHash: number;
|
|
|
|
playerCount: number;
|
2021-07-24 01:27:25 +00:00
|
|
|
players: Set<LiveAtlasPlayer>;
|
2020-12-11 15:28:51 +00:00
|
|
|
updates: DynmapUpdates;
|
2020-11-23 12:13:28 +00:00
|
|
|
timestamp: number;
|
|
|
|
}
|
|
|
|
|
2020-12-01 23:20:38 +00:00
|
|
|
interface DynmapMarkerSet {
|
2020-12-11 15:28:51 +00:00
|
|
|
id: string,
|
2020-12-01 23:20:38 +00:00
|
|
|
label: string;
|
|
|
|
hidden: boolean;
|
|
|
|
priority: number;
|
|
|
|
minZoom?: number;
|
|
|
|
maxZoom?: number;
|
|
|
|
showLabels?: boolean;
|
|
|
|
markers: Map<string, DynmapMarker>;
|
|
|
|
areas: Map<string, DynmapArea>;
|
|
|
|
lines: Map<string, DynmapLine>;
|
|
|
|
circles: Map<string, DynmapCircle>;
|
|
|
|
}
|
2020-11-23 12:13:28 +00:00
|
|
|
|
2020-12-01 23:20:38 +00:00
|
|
|
interface DynmapMarker {
|
|
|
|
dimensions: PointTuple;
|
|
|
|
icon: string;
|
|
|
|
label: string;
|
|
|
|
isHTML: boolean;
|
|
|
|
location: Coordinate;
|
|
|
|
minZoom?: number;
|
|
|
|
maxZoom?: number;
|
|
|
|
popupContent?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapArea {
|
|
|
|
style: PolylineOptions;
|
|
|
|
label: string;
|
|
|
|
isHTML: boolean;
|
|
|
|
x: Array<number>;
|
|
|
|
y: PointTuple;
|
|
|
|
z: Array<number>;
|
|
|
|
minZoom?: number;
|
|
|
|
maxZoom?: number;
|
|
|
|
popupContent?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapLine {
|
|
|
|
x: Array<number>;
|
|
|
|
y: Array<number>;
|
|
|
|
z: Array<number>;
|
|
|
|
style: PolylineOptions;
|
|
|
|
label: string;
|
|
|
|
isHTML: boolean;
|
|
|
|
minZoom?: number;
|
|
|
|
maxZoom?: number;
|
|
|
|
popupContent?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapCircle {
|
|
|
|
location: Coordinate;
|
|
|
|
radius: PointTuple;
|
2020-12-10 02:23:22 +00:00
|
|
|
style: PathOptions;
|
2020-12-01 23:20:38 +00:00
|
|
|
label: string;
|
|
|
|
isHTML: boolean;
|
|
|
|
minZoom?: number;
|
|
|
|
maxZoom?: number;
|
|
|
|
popupContent?: string;
|
|
|
|
}
|
2020-12-11 15:28:51 +00:00
|
|
|
|
|
|
|
interface DynmapUpdates {
|
|
|
|
markerSets: Map<string, DynmapMarkerSetUpdates>,
|
2020-12-11 18:51:23 +00:00
|
|
|
tiles: Array<DynmapTileUpdate>,
|
2020-12-11 15:28:51 +00:00
|
|
|
chat: Array<any> //TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapMarkerSetUpdates {
|
|
|
|
markerUpdates: Array<DynmapMarkerUpdate>
|
|
|
|
areaUpdates: Array<DynmapAreaUpdate>
|
|
|
|
circleUpdates: Array<DynmapCircleUpdate>
|
|
|
|
lineUpdates: Array<DynmapLineUpdate>
|
2020-12-19 01:09:31 +00:00
|
|
|
removed?: boolean
|
|
|
|
payload?: {
|
|
|
|
showLabels: boolean;
|
|
|
|
hidden: boolean;
|
|
|
|
minZoom: number;
|
|
|
|
maxZoom: number;
|
|
|
|
priority: number;
|
|
|
|
label: string;
|
|
|
|
}
|
2020-12-11 15:28:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapUpdate {
|
|
|
|
id: string,
|
|
|
|
removed: boolean,
|
|
|
|
payload?: any,
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapMarkerUpdate extends DynmapUpdate {
|
|
|
|
payload?: DynmapMarker
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapAreaUpdate extends DynmapUpdate {
|
|
|
|
payload?: DynmapArea
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapCircleUpdate extends DynmapUpdate {
|
|
|
|
payload?: DynmapCircle
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapLineUpdate extends DynmapUpdate {
|
|
|
|
payload?: DynmapLine
|
2020-12-11 18:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface DynmapTileUpdate {
|
|
|
|
name: string
|
|
|
|
timestamp: number
|
2020-12-13 02:50:17 +00:00
|
|
|
}
|
|
|
|
|
2020-12-17 14:50:12 +00:00
|
|
|
interface DynmapChat {
|
|
|
|
type: 'chat' | 'playerjoin' | 'playerleave';
|
2021-01-07 22:37:53 +00:00
|
|
|
playerAccount?: string;
|
|
|
|
playerName?: string;
|
2020-12-17 14:50:12 +00:00
|
|
|
channel?: string;
|
|
|
|
message?: string;
|
2021-01-07 22:37:53 +00:00
|
|
|
source?: string;
|
2020-12-17 14:50:12 +00:00
|
|
|
timestamp: number;
|
|
|
|
}
|