2021-07-25 14:12:40 +00:00
|
|
|
/*
|
2022-02-21 21:50:31 +00:00
|
|
|
* Copyright 2022 James Lyne
|
2021-07-25 14:12:40 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2021-05-27 13:30:56 +00:00
|
|
|
import {State} from "@/store";
|
2021-07-24 01:27:25 +00:00
|
|
|
import {DynmapUrlConfig} from "@/dynmap";
|
2021-07-23 19:32:15 +00:00
|
|
|
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
|
2022-01-16 21:18:48 +00:00
|
|
|
import {
|
|
|
|
Coords,
|
|
|
|
DoneCallback, FitBoundsOptions,
|
2022-02-21 20:27:09 +00:00
|
|
|
InternalTiles, LatLng,
|
2022-01-16 21:18:48 +00:00
|
|
|
PathOptions,
|
|
|
|
PointTuple,
|
|
|
|
PolylineOptions
|
|
|
|
} from "leaflet";
|
2021-07-25 13:53:45 +00:00
|
|
|
import {CoordinatesControlOptions} from "@/leaflet/control/CoordinatesControl";
|
|
|
|
import {ClockControlOptions} from "@/leaflet/control/ClockControl";
|
|
|
|
import {LogoControlOptions} from "@/leaflet/control/LogoControl";
|
2022-01-12 15:21:01 +00:00
|
|
|
import {globalMessages, serverMessages} from "../messages";
|
2022-01-15 15:45:59 +00:00
|
|
|
import {LiveAtlasMarkerType} from "@/util/markers";
|
2022-02-23 00:42:53 +00:00
|
|
|
import {LiveAtlasTileLayer, LiveAtlasTileLayerOptions} from "@/leaflet/tileLayer/LiveAtlasTileLayer";
|
2021-05-15 19:25:03 +00:00
|
|
|
|
|
|
|
declare module "*.png" {
|
|
|
|
const value: any;
|
|
|
|
export = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
declare module '*.vue' {
|
2021-07-19 15:40:30 +00:00
|
|
|
import type {DefineComponent} from 'vue'
|
|
|
|
const component: DefineComponent<{}, {}, any>
|
2021-05-15 19:25:03 +00:00
|
|
|
export default component
|
2020-12-20 16:01:15 +00:00
|
|
|
}
|
|
|
|
|
2021-07-20 20:12:08 +00:00
|
|
|
declare global {
|
|
|
|
// noinspection JSUnusedGlobalSymbols
|
|
|
|
interface Window {
|
|
|
|
liveAtlasConfig: LiveAtlasGlobalConfig,
|
|
|
|
}
|
2021-09-10 14:32:48 +00:00
|
|
|
|
|
|
|
declare const process : {
|
|
|
|
env: {
|
2022-01-12 00:31:54 +00:00
|
|
|
VITE_APP_VERSION: string
|
2021-09-10 14:32:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ProcessEnv {
|
|
|
|
[key: string]: string | undefined
|
2021-07-20 20:12:08 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 15:40:30 +00:00
|
|
|
interface Coordinate {
|
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
z: number;
|
|
|
|
}
|
|
|
|
|
2022-01-14 19:52:23 +00:00
|
|
|
interface Coordinate2D {
|
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
}
|
|
|
|
|
2021-07-19 15:40:30 +00:00
|
|
|
interface LiveAtlasLocation {
|
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
z: number;
|
|
|
|
world?: string;
|
|
|
|
}
|
|
|
|
|
2022-01-16 21:18:48 +00:00
|
|
|
interface LiveAtlasBounds {
|
|
|
|
min: Coordinate;
|
|
|
|
max: Coordinate;
|
|
|
|
world?: string;
|
|
|
|
}
|
|
|
|
|
2022-01-16 22:15:12 +00:00
|
|
|
interface LiveAtlasMapViewTarget {
|
|
|
|
location: LiveAtlasLocation | LiveAtlasBounds;
|
|
|
|
map?: string;
|
|
|
|
zoom?: number;
|
|
|
|
options?: FitBoundsOptions;
|
|
|
|
}
|
|
|
|
|
2021-07-20 20:12:08 +00:00
|
|
|
interface LiveAtlasGlobalConfig {
|
|
|
|
servers: Map<string, LiveAtlasServerDefinition>;
|
|
|
|
messages: LiveAtlasGlobalMessageConfig;
|
|
|
|
ui: LiveAtlasUIConfig;
|
2021-12-09 18:26:57 +00:00
|
|
|
version?: number;
|
2021-07-20 20:12:08 +00:00
|
|
|
}
|
|
|
|
|
2021-05-18 15:48:56 +00:00
|
|
|
interface LiveAtlasServerDefinition {
|
2021-07-25 01:02:42 +00:00
|
|
|
id: string;
|
|
|
|
label?: string;
|
2021-07-29 17:06:19 +00:00
|
|
|
dynmap?: DynmapUrlConfig;
|
|
|
|
pl3xmap?: string;
|
2022-01-12 01:06:18 +00:00
|
|
|
squaremap?: string;
|
2022-02-21 21:50:31 +00:00
|
|
|
overviewer?: string;
|
2021-05-20 15:13:25 +00:00
|
|
|
}
|
|
|
|
|
2021-07-20 20:12:08 +00:00
|
|
|
// Messages defined directly in LiveAtlas and used for all servers
|
2022-01-12 15:21:01 +00:00
|
|
|
type LiveAtlasGlobalMessageConfig = {
|
|
|
|
[K in typeof globalMessages[number]]: string;
|
2021-05-25 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
2021-07-20 20:12:08 +00:00
|
|
|
// Messages defined by dynmap configuration responses and can vary per server
|
2022-01-12 15:21:01 +00:00
|
|
|
type LiveAtlasServerMessageConfig = {
|
|
|
|
[K in typeof serverMessages[number]]: string;
|
2021-07-20 20:12:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type LiveAtlasMessageConfig = LiveAtlasGlobalMessageConfig & LiveAtlasServerMessageConfig;
|
|
|
|
|
|
|
|
interface LiveAtlasUIConfig {
|
|
|
|
playersAboveMarkers: boolean;
|
2021-07-21 15:19:18 +00:00
|
|
|
playersSearch: boolean;
|
2021-12-07 21:53:09 +00:00
|
|
|
compactPlayerMarkers: boolean;
|
2022-02-20 19:34:52 +00:00
|
|
|
disableContextMenu: boolean;
|
2022-04-01 12:27:17 +00:00
|
|
|
disableMarkerUI: boolean;
|
2021-07-20 20:12:08 +00:00
|
|
|
}
|
|
|
|
|
2022-01-14 13:16:04 +00:00
|
|
|
export type LiveAtlasUIElement = 'layers' | 'chat' | LiveAtlasSidebarSection;
|
2021-08-30 21:27:41 +00:00
|
|
|
export type LiveAtlasUIModal = 'login' | 'settings';
|
2022-01-17 15:15:00 +00:00
|
|
|
export type LiveAtlasSidebarSection = 'servers' | 'players' | 'maps' | 'markers';
|
2021-07-21 16:27:24 +00:00
|
|
|
export type LiveAtlasDimension = 'overworld' | 'nether' | 'end';
|
2021-06-23 16:40:56 +00:00
|
|
|
|
2022-01-10 19:36:06 +00:00
|
|
|
export type LiveAtlasSidebarSectionState = {
|
|
|
|
collapsed?: boolean;
|
|
|
|
}
|
|
|
|
|
2021-07-24 01:27:25 +00:00
|
|
|
interface LiveAtlasPlayer {
|
|
|
|
name: string;
|
|
|
|
displayName: string;
|
|
|
|
uuid?: string;
|
|
|
|
armor: number;
|
|
|
|
health: number;
|
|
|
|
sort: number;
|
|
|
|
hidden: boolean;
|
|
|
|
location: LiveAtlasLocation;
|
2021-12-09 01:13:23 +00:00
|
|
|
yaw?: number;
|
2021-07-24 01:27:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface LiveAtlasSortedPlayers extends Array<LiveAtlasPlayer> {
|
2021-06-23 16:40:56 +00:00
|
|
|
dirty?: boolean;
|
|
|
|
}
|
2021-07-19 15:40:30 +00:00
|
|
|
|
2021-07-23 19:32:15 +00:00
|
|
|
interface LiveAtlasWorldDefinition {
|
2021-07-19 15:40:30 +00:00
|
|
|
name: string;
|
2021-07-24 19:12:18 +00:00
|
|
|
displayName: string;
|
2021-07-21 16:27:24 +00:00
|
|
|
dimension: LiveAtlasDimension;
|
2022-02-27 20:27:34 +00:00
|
|
|
seaLevel: number;
|
2022-02-04 21:58:07 +00:00
|
|
|
maps: Set<LiveAtlasMapDefinition>;
|
2021-07-19 15:40:30 +00:00
|
|
|
}
|
|
|
|
|
2022-02-21 20:27:09 +00:00
|
|
|
interface LiveAtlasProjection {
|
|
|
|
locationToLatLng(location: Coordinate): LatLng;
|
|
|
|
latLngToLocation(latLng: LatLng, y: number): Coordinate;
|
|
|
|
}
|
|
|
|
|
2021-07-19 15:40:30 +00:00
|
|
|
interface LiveAtlasWorldState {
|
|
|
|
raining: boolean;
|
|
|
|
thundering: boolean;
|
|
|
|
timeOfDay: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface LiveAtlasParsedUrl {
|
|
|
|
world?: string;
|
|
|
|
map?: string;
|
|
|
|
location?: Coordinate;
|
|
|
|
zoom?: number;
|
|
|
|
legacy: boolean;
|
|
|
|
}
|
2021-07-24 00:15:52 +00:00
|
|
|
|
|
|
|
interface LiveAtlasMapProvider {
|
|
|
|
loadServerConfiguration(): Promise<void>;
|
2021-07-25 00:57:59 +00:00
|
|
|
populateWorld(world: LiveAtlasWorldDefinition): Promise<void>;
|
2022-02-23 00:42:53 +00:00
|
|
|
populateMap(map: LiveAtlasMapDefinition): Promise<void>;
|
2021-07-24 00:15:52 +00:00
|
|
|
startUpdates(): void;
|
|
|
|
stopUpdates(): void;
|
2022-01-21 20:20:01 +00:00
|
|
|
createTileLayer(options: LiveAtlasTileLayerOptions): LiveAtlasTileLayer;
|
2021-07-24 00:15:52 +00:00
|
|
|
sendChatMessage(message: string): void;
|
2021-08-30 21:27:41 +00:00
|
|
|
login(formData: FormData): void;
|
|
|
|
logout(): void;
|
|
|
|
register(formData: FormData): void;
|
2021-07-24 00:15:52 +00:00
|
|
|
}
|
2021-07-24 03:06:19 +00:00
|
|
|
|
2022-02-25 18:05:36 +00:00
|
|
|
interface LiveAtlasOverlay {
|
2021-07-24 03:06:19 +00:00
|
|
|
id: string,
|
|
|
|
label: string;
|
|
|
|
hidden: boolean;
|
|
|
|
priority: number;
|
|
|
|
minZoom?: number;
|
|
|
|
maxZoom?: number;
|
2022-02-25 18:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface LiveAtlasMarkerSet extends LiveAtlasOverlay {
|
2021-07-24 03:06:19 +00:00
|
|
|
showLabels?: boolean;
|
2022-01-11 16:08:30 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 18:05:36 +00:00
|
|
|
interface LiveAtlasTileLayerOverlay extends LiveAtlasOverlay {
|
|
|
|
tileLayerOptions: LiveAtlasTileLayerOptions;
|
|
|
|
}
|
|
|
|
|
2022-01-13 16:07:27 +00:00
|
|
|
interface LiveAtlasMarker {
|
2022-01-15 15:45:59 +00:00
|
|
|
id: string;
|
|
|
|
type: LiveAtlasMarkerType;
|
2022-01-13 16:07:27 +00:00
|
|
|
tooltip: string;
|
2022-01-14 13:54:27 +00:00
|
|
|
tooltipHTML?: string;
|
2022-01-13 16:07:27 +00:00
|
|
|
popup?: string;
|
2022-01-14 13:54:27 +00:00
|
|
|
isPopupHTML?: boolean;
|
2022-01-14 18:35:59 +00:00
|
|
|
location: Coordinate;
|
|
|
|
minZoom?: number;
|
|
|
|
maxZoom?: number;
|
2022-01-13 16:07:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface LiveAtlasPointMarker extends LiveAtlasMarker {
|
2022-01-15 15:45:59 +00:00
|
|
|
type: LiveAtlasMarkerType.POINT;
|
2022-02-24 18:39:00 +00:00
|
|
|
iconUrl: string;
|
2022-02-24 21:08:27 +00:00
|
|
|
iconSize?: PointTuple;
|
2022-02-24 22:53:26 +00:00
|
|
|
iconAnchor?: PointTuple;
|
2021-07-24 03:06:19 +00:00
|
|
|
}
|
|
|
|
|
2022-01-13 16:07:27 +00:00
|
|
|
interface LiveAtlasPathMarker extends LiveAtlasMarker {
|
2021-07-28 00:56:41 +00:00
|
|
|
style: PathOptions;
|
2022-01-16 21:18:48 +00:00
|
|
|
bounds: LiveAtlasBounds;
|
2021-07-24 03:06:19 +00:00
|
|
|
}
|
|
|
|
|
2022-01-13 14:06:18 +00:00
|
|
|
interface LiveAtlasLineMarker extends LiveAtlasPathMarker {
|
2022-01-15 15:45:59 +00:00
|
|
|
type: LiveAtlasMarkerType.LINE;
|
2021-07-28 00:56:41 +00:00
|
|
|
points: Coordinate[];
|
|
|
|
style: PolylineOptions;
|
|
|
|
}
|
|
|
|
|
2022-01-15 15:45:59 +00:00
|
|
|
interface LiveAtlasAreaMarker extends LiveAtlasLineMarker {
|
|
|
|
type: LiveAtlasMarkerType.AREA;
|
|
|
|
outline: boolean;
|
2022-01-16 21:18:48 +00:00
|
|
|
points: Coordinate[] | Coordinate[][];
|
2022-01-15 15:45:59 +00:00
|
|
|
}
|
|
|
|
|
2022-01-13 14:06:18 +00:00
|
|
|
interface LiveAtlasCircleMarker extends LiveAtlasPathMarker {
|
2022-01-15 15:45:59 +00:00
|
|
|
type: LiveAtlasMarkerType.CIRCLE;
|
2021-07-24 03:06:19 +00:00
|
|
|
radius: PointTuple;
|
|
|
|
}
|
2021-07-25 00:57:59 +00:00
|
|
|
|
2022-02-26 14:41:23 +00:00
|
|
|
interface PlayerImageQueueEntry {
|
2021-07-25 00:57:59 +00:00
|
|
|
cacheKey: string;
|
|
|
|
name: string;
|
|
|
|
uuid?: string;
|
2021-09-29 13:33:52 +00:00
|
|
|
size: LiveAtlasPlayerImageSize;
|
2021-07-25 00:57:59 +00:00
|
|
|
image: HTMLImageElement;
|
|
|
|
}
|
2021-07-25 13:53:45 +00:00
|
|
|
|
|
|
|
interface LiveAtlasServerConfig {
|
|
|
|
defaultMap?: string;
|
|
|
|
defaultWorld?: string;
|
|
|
|
defaultZoom: number;
|
|
|
|
followMap?: string;
|
2021-07-28 22:52:51 +00:00
|
|
|
followZoom?: number;
|
2021-07-25 13:53:45 +00:00
|
|
|
title: string;
|
|
|
|
expandUI: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface LiveAtlasComponentConfig {
|
|
|
|
markers: {
|
|
|
|
showLabels: boolean;
|
|
|
|
};
|
2022-02-05 15:11:09 +00:00
|
|
|
players: {
|
|
|
|
markers?: LiveAtlasPlayerMarkerConfig;
|
2021-09-29 20:16:31 +00:00
|
|
|
showImages: boolean;
|
2022-02-05 15:11:09 +00:00
|
|
|
grayHiddenPlayers: boolean;
|
2022-02-26 14:41:23 +00:00
|
|
|
imageUrl: (entry: PlayerImageQueueEntry) => string;
|
2022-02-05 15:11:09 +00:00
|
|
|
};
|
2021-07-25 13:53:45 +00:00
|
|
|
coordinatesControl?: CoordinatesControlOptions;
|
|
|
|
clockControl?: ClockControlOptions;
|
|
|
|
linkControl: boolean;
|
|
|
|
layerControl: boolean;
|
|
|
|
logoControls: Array<LogoControlOptions>;
|
|
|
|
chatBox?: LiveAtlasChatBoxConfig;
|
|
|
|
chatSending?: LiveAtlasChatSendingConfig;
|
|
|
|
chatBalloons: boolean;
|
|
|
|
login: boolean;
|
|
|
|
}
|
|
|
|
|
2021-07-28 21:16:26 +00:00
|
|
|
interface LiveAtlasPartialComponentConfig {
|
|
|
|
markers?: {
|
|
|
|
showLabels: boolean;
|
|
|
|
};
|
2022-02-05 15:11:09 +00:00
|
|
|
players?: {
|
|
|
|
markers?: LiveAtlasPlayerMarkerConfig;
|
|
|
|
showImages?: boolean;
|
|
|
|
grayHiddenPlayers?: boolean;
|
2022-02-26 14:41:23 +00:00
|
|
|
imageUrl?: (entry: PlayerImageQueueEntry) => string;
|
2022-02-05 15:11:09 +00:00
|
|
|
};
|
2021-07-28 21:16:26 +00:00
|
|
|
coordinatesControl?: CoordinatesControlOptions;
|
|
|
|
clockControl?: ClockControlOptions;
|
|
|
|
linkControl?: boolean;
|
|
|
|
layerControl?: boolean;
|
|
|
|
logoControls?: Array<LogoControlOptions>;
|
|
|
|
chatBox?: LiveAtlasChatBoxConfig;
|
|
|
|
chatSending?: LiveAtlasChatSendingConfig;
|
|
|
|
chatBalloons?: boolean;
|
|
|
|
login?: boolean;
|
|
|
|
}
|
|
|
|
|
2021-07-25 13:53:45 +00:00
|
|
|
interface LiveAtlasPlayerMarkerConfig {
|
|
|
|
hideByDefault: boolean;
|
|
|
|
layerName: string;
|
|
|
|
layerPriority: number;
|
2021-09-29 00:30:35 +00:00
|
|
|
imageSize: LiveAtlasPlayerImageSize;
|
2021-07-25 13:53:45 +00:00
|
|
|
showHealth: boolean;
|
2021-09-28 17:54:51 +00:00
|
|
|
showArmor: boolean;
|
2021-12-09 01:13:23 +00:00
|
|
|
showYaw: boolean;
|
2021-07-25 13:53:45 +00:00
|
|
|
}
|
|
|
|
|
2021-09-29 00:30:35 +00:00
|
|
|
export type LiveAtlasPlayerImageSize = 'none' | 'small' | 'large' | 'body';
|
|
|
|
|
2021-07-25 13:53:45 +00:00
|
|
|
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;
|
|
|
|
}
|
2021-08-13 23:08:01 +00:00
|
|
|
|
2021-08-31 15:35:30 +00:00
|
|
|
export interface LiveAtlasInternalTiles extends InternalTiles {
|
|
|
|
[key: string]: LiveAtlasTile;
|
|
|
|
}
|
|
|
|
|
2021-08-13 23:08:01 +00:00
|
|
|
export interface LiveAtlasTile {
|
|
|
|
active?: boolean;
|
|
|
|
coords: Coords;
|
|
|
|
current: boolean;
|
|
|
|
el: LiveAtlasTileElement;
|
|
|
|
loaded?: Date;
|
|
|
|
retain?: boolean;
|
|
|
|
complete: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface LiveAtlasTileElement extends HTMLImageElement {
|
|
|
|
tileName?: string;
|
|
|
|
url: string;
|
|
|
|
callback: DoneCallback;
|
|
|
|
abortController: AbortController;
|
|
|
|
}
|