thelounge/client/js/types.d.ts

101 lines
2.5 KiB
TypeScript
Raw Normal View History

2022-05-23 09:44:01 +02:00
import {defineComponent} from "vue";
2022-05-15 00:18:06 +02:00
import Chan from "../../src/models/chan";
import Network from "../../src/models/network";
2022-05-23 09:44:01 +02:00
import User from "../../src/models/user";
import Message from "../../src/models/msg";
import {Mention} from "../../src/client";
import {ClientConfiguration} from "../../src/server";
import {LinkPreview} from "../../src/plugins/irc-events/link";
2022-05-05 00:41:57 +02:00
interface LoungeWindow extends Window {
g_TheLoungeRemoveLoading?: () => void;
2022-05-23 09:44:01 +02:00
navigator: Window["navigator"] & {
setAppBadge?: (highlightCount: number) => void;
clearAppBadge?: () => void;
};
}
2022-05-03 08:50:59 +02:00
2022-05-23 09:44:01 +02:00
type ClientUser = User & {
//
};
type ClientMessage = Omit<Message, "users"> & {
2022-05-23 11:27:10 +02:00
time: number;
users: string[];
2022-05-23 11:27:10 +02:00
};
type ClientChan = Omit<Chan, "users" | "messages"> & {
2022-05-03 08:50:59 +02:00
moreHistoryAvailable: boolean;
2022-05-15 00:18:06 +02:00
editTopic: boolean;
2022-05-23 09:44:01 +02:00
users: ClientUser[];
2022-05-23 11:27:10 +02:00
messages: ClientMessage[];
2022-05-22 02:27:51 +02:00
// these are added in store/initChannel
pendingMessage: string;
inputHistoryPosition: number;
inputHistory: string[];
historyLoading: boolean;
scrolledToBottom: boolean;
usersOutdated: boolean;
};
type InitClientChan = ClientChan & {
// total messages is deleted after its use when init event is sent/handled
totalMessages?: number;
2022-05-15 00:18:06 +02:00
};
2022-05-23 09:44:01 +02:00
// We omit channels so we can use ClientChan[] instead of Chan[]
type ClientNetwork = Omit<Network, "channels"> & {
2022-05-15 00:18:06 +02:00
isJoinChannelShown: boolean;
2022-05-22 02:27:51 +02:00
isCollapsed: boolean;
2022-05-23 09:44:01 +02:00
channels: ClientChan[];
2022-05-03 08:50:59 +02:00
};
2022-05-23 09:44:01 +02:00
type NetChan = {
channel: ClientChan;
network: ClientNetwork;
};
type ClientConfiguration = ClientConfiguration;
type ClientMention = Mention & {
localetime: string;
channel: NetChan | null;
};
2022-05-23 11:27:10 +02:00
type ClientLinkPreview = LinkPreview & {
sourceLoaded?: boolean;
};
2022-05-23 09:44:01 +02:00
declare module "vue-router" {
import Vue from "./vue";
interface Router {
app: Vue.VueApp;
}
}
interface BeforeInstallPromptEvent extends Event {
/**
* Returns an array of DOMString items containing the platforms on which the event was dispatched.
* This is provided for user agents that want to present a choice of versions to the user such as,
* for example, "web" or "play" which would allow the user to chose between a web version or
* an Android version.
*/
readonly platforms: Array<string>;
/**
* Returns a Promise that resolves to a DOMString containing either "accepted" or "dismissed".
*/
readonly userChoice: Promise<{
outcome: "accepted" | "dismissed";
platform: string;
}>;
/**
* Allows a developer to show the install prompt at a time of their own choosing.
* This method returns a Promise.
*/
prompt(): Promise<void>;
}