diff --git a/gluon.d.ts b/gluon.d.ts index 24b3313..c59da16 100644 --- a/gluon.d.ts +++ b/gluon.d.ts @@ -1,3 +1,64 @@ +type WindowApi = { + /** + * Evaluate a string or function in the web context. + * @returns Return value of expression given. + */ + eval: ( + /** String or function to evaluate. */ + expression: string|Function + ) => Promise +}; + +type IPCApi = { + /** + * Send an IPC event to the web context. + * @returns Replied event data (null by default). + */ + send( + /** Type of event to send. */ + type: string, + + /** Data of event to send. */ + data: any + ): Promise, + + /** + * Subscribe to IPC events of a specific type with a callback. + */ + on( + /** Type of event to handle. */ + type: string, + + /** + * Ran whenever an IPC event of type specified is recieved. Should return optionally with what to reply with. + * @returns Optionally with what to reply with, otherwise null by default. + */ + callback: (data: any) => any + ): void +}; + +type CDPApi = { + /** + * Send a CDP command to the browser. + * {@link https://chromedevtools.github.io/devtools-protocol/ Chrome DevTools Protocol Documentation} + * @returns Result of command from browser. + */ + send( + /** Method of CDP command. */ + method: string, + + /** Parameters of CDP command. */ + params: Object? + ): Promise +}; + +type Window = { + window: WindowApi, + ipc: IPCApi, + cdp: CDPApi +}; + + /** A browser that Gluon supports. */ type Browser = 'chrome'|'chrome_canary'|'chromium'|'edge'|'firefox'|'firefox_nightly'; @@ -19,4 +80,4 @@ export function open( /** Additional options for opening. */ options: OpenOptions -); \ No newline at end of file +): Promise; \ No newline at end of file diff --git a/roadmap.md b/roadmap.md index 4ca4c85..b9baef3 100644 --- a/roadmap.md +++ b/roadmap.md @@ -5,6 +5,7 @@ ## December 2022 - January 2023 - [X] Total internal rewrite +- [X] Type definitions - [ ] "Hibernation" feasibility study - [ ] Automated PR/commit CI testing - [ ] System Tray API