LiveAtlas/src/dynmap.d.ts

234 lines
4.9 KiB
TypeScript
Raw Normal View History

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.
*/
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";
import {
Coordinate,
LiveAtlasPlayer,
LiveAtlasServerMessageConfig,
LiveAtlasWorldDefinition,
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;
grayHiddenPlayers: boolean;
expandUI: boolean;
2020-11-23 12:13:28 +00:00
}
interface DynmapComponentConfig {
2020-12-01 23:20:38 +00:00
markers: DynmapMarkersConfig;
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>;
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
}
interface DynmapPlayerMarkersConfig {
hideByDefault: boolean;
layerName: string;
layerPriority: number;
showBodies: boolean;
showSkinFaces: boolean;
showHealth: boolean;
smallFaces: boolean;
}
interface DynmapChatBoxConfig {
2020-12-17 14:50:12 +00:00
allowUrlName: boolean;
showPlayerFaces: boolean;
messageLifetime: number;
messageHistory: number;
}
interface DynmapChatSendingConfig {
loginRequired: boolean;
maxLength: number;
cooldown: number;
}
2020-11-23 12:13:28 +00:00
interface DynmapConfigurationResponse {
config: DynmapServerConfig,
messages: LiveAtlasServerMessageConfig,
worlds: Array<LiveAtlasWorldDefinition>,
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;
players: Set<LiveAtlasPlayer>;
updates: DynmapUpdates;
2020-11-23 12:13:28 +00:00
timestamp: number;
}
2020-12-01 23:20:38 +00:00
interface DynmapMarkerSet {
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;
}
interface DynmapUpdates {
markerSets: Map<string, DynmapMarkerSetUpdates>,
tiles: Array<DynmapTileUpdate>,
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;
}
}
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
}
interface DynmapTileUpdate {
name: string
timestamp: number
}
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;
}