Skip to content

Commit

Permalink
expose non-blocking, lichess styled dialog functions to extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
schlawg committed Dec 20, 2024
1 parent 33279a2 commit c5b9cfe
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ui/api/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type PubsubCallback, type PubsubEvent, pubsub } from 'common/pubsub';
import { alert, confirm, prompt, domDialog } from 'common/dialog';

// #TODO document these somewhere
const publicEvents = ['ply', 'analysis.change', 'chat.resize', 'analysis.closeAll'];
Expand All @@ -20,6 +21,12 @@ export interface Api {
chat: {
post: (text: string) => void;
};
dialog: {
alert: typeof alert;
confirm: typeof confirm;
prompt: typeof prompt;
domDialog: typeof domDialog;
};
overrides: {
[key: string]: (...args: any[]) => unknown;
};
Expand Down Expand Up @@ -71,6 +78,12 @@ export const api: Api = {
chat: {
post: (text: string) => pubsub.emit('socket.send', 'talk', text),
},
dialog: {
alert,
confirm,
prompt,
domDialog,
},
// some functions will be exposed here
// to be overriden by browser extensions
overrides: {},
Expand Down

0 comments on commit c5b9cfe

Please sign in to comment.