Skip to content

Commit

Permalink
update types
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore committed Mar 13, 2024
1 parent f28394a commit 29f2958
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions types/core/engine/command/bidi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,26 @@ export class Bidi {
/**
* Add a fanction that will get the events that you subscribes.
* @async
* @example await commands.bidi.onMessage(function(event) {
* const myEvent = JSON.parse(Buffer.from(event.toString()));
* console.log(myEvent);
* });
* @param {Function} f - The callback function to handle incoming messages. The function will get an event passed on to it. Remember to subscribe to the event.
* @throws {Error} Throws an error if the method is called in a browser other than Firefox.
*/
onMessage(f: Function): Promise<void>;
/**
* Retrieves the raw client for Bidi.
* @async
* @example const bidi = await commands.bidi.getRawClient();
* @example const bidi = commands.bidi.getRawClient();
* @returns {Promise<Object>} A promise that resolves to the Bidi client.
* @throws {Error} Throws an error if the browser is not supported.
*/
getRawClient(): Promise<any>;
/**
* Subscribe to a event.
* @async
* @example // Subscribe to requests before they are sent
* await commands.bidi.subscribe('network.beforeRequestSent');
* @param {string} messageType The type of message to subscribe to.
* @returns {Promise<Object>} A promise that resolves you have subscribed.
* @throws {Error} Throws an error if the method is called in a browser other than Firefox.
Expand All @@ -41,6 +46,8 @@ export class Bidi {
/**
* Unsubscribe to an event.
* @async
* @example // Unsubscribe to requests before they are sent
* await commands.bidi.unsubscribe('network.beforeRequestSent');
* @param {string} messageType The type of message to unsubscribe to.
* @returns {Promise<Object>} A promise that resolves you have unsubscribed.
* @throws {Error} Throws an error if the method is called in a browser other than Firefox.
Expand All @@ -50,7 +57,14 @@ export class Bidi {
* Sends a command using Bidi.
*
* @async
* @example await commands.bidi.send({});
* @example
* const params = {
* method: 'script.addPreloadScript',
* params: {
* functionDeclaration: "function() {alert('hello')}"
* }
* };
* await commands.bidi.send(params);
* @param {Object} parameters - The paramaters for the command.
* @throws {Error} Throws an error if the browser is not supported or if the command fails.
* @returns {Promise<Object>} A promise that resolves when the command has been sent.
Expand Down
2 changes: 1 addition & 1 deletion types/core/engine/command/bidi.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 29f2958

Please sign in to comment.