53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
// Local copy of the @source/presence-sdk type contract used by presences in this repo.
|
|
// Keep in sync with src/presence-sdk/index.ts in the extension.
|
|
|
|
export declare const ActivityType: {
|
|
readonly PLAYING: 0;
|
|
readonly LISTENING: 2;
|
|
readonly WATCHING: 3;
|
|
};
|
|
export type ActivityTypeValue = (typeof ActivityType)[keyof typeof ActivityType];
|
|
|
|
export interface PresenceActivityInput {
|
|
type: ActivityTypeValue;
|
|
name: string;
|
|
details?: string | null;
|
|
state?: string | null;
|
|
url?: string | null;
|
|
largeImage?: string | null;
|
|
largeText?: string | null;
|
|
smallImage?: string | null;
|
|
smallText?: string | null;
|
|
startedAt?: number | null;
|
|
endsAt?: number | null;
|
|
}
|
|
|
|
export interface PresenceStorage {
|
|
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
set(key: string, value: unknown): Promise<void>;
|
|
delete(key: string): Promise<void>;
|
|
clear(): Promise<void>;
|
|
}
|
|
|
|
export interface PresenceContext {
|
|
readonly url: string;
|
|
readonly tabActive: boolean;
|
|
readonly storage: PresenceStorage;
|
|
setActivity(activity: PresenceActivityInput | null): void;
|
|
clear(): void;
|
|
log(...args: unknown[]): void;
|
|
warn(...args: unknown[]): void;
|
|
error(...args: unknown[]): void;
|
|
}
|
|
|
|
export interface PresenceDefinition {
|
|
match: string[];
|
|
tickInterval?: number;
|
|
onLoad?: (ctx: PresenceContext) => void | Promise<void>;
|
|
tick?: (ctx: PresenceContext) => void | Promise<void>;
|
|
onUnload?: (ctx: PresenceContext) => void | Promise<void>;
|
|
}
|
|
|
|
export declare function definePresence(def: PresenceDefinition): PresenceDefinition;
|
|
export type { PresenceDefinition as Presence };
|