Skip to content

Commit

Permalink
chore: fix types again (#2860)
Browse files Browse the repository at this point in the history
Note (to self) to build the CDDL you need to build the HTML first...

In BiDi there are no domains, they are called modules reflect that in
the comment.
The `session.end` is not an Unknown command its not implemented make the
difference.
  • Loading branch information
Lightning00Blade authored Dec 2, 2024
1 parent 4f39070 commit 921f637
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
44 changes: 29 additions & 15 deletions src/bidiMapper/CommandProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,7 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
command: ChromiumBidi.Command,
): Promise<ChromiumBidi.ResultData> {
switch (command.method) {
case 'session.end':
// TODO: Implement.
break;

// Bluetooth domain
// Bluetooth module
// keep-sorted start block=yes
case 'bluetooth.handleRequestDevicePrompt':
return await this.#bluetoothProcessor.handleRequestDevicePrompt(
Expand All @@ -167,7 +163,7 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
);
// keep-sorted end

// Browser domain
// Browser module
// keep-sorted start block=yes
case 'browser.close':
return this.#browserProcessor.close();
Expand All @@ -187,7 +183,7 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
);
// keep-sorted end

// Browsing Context domain
// Browsing Context module
// keep-sorted start block=yes
case 'browsingContext.activate':
return await this.#browsingContextProcessor.activate(
Expand Down Expand Up @@ -239,7 +235,7 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
);
// keep-sorted end

// CDP domain
// CDP module
// keep-sorted start block=yes
case 'cdp.getSession':
return this.#cdpProcessor.getSession(
Expand All @@ -255,7 +251,7 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
);
// keep-sorted end

// Input domain
// Input module
// keep-sorted start block=yes
case 'input.performActions':
return await this.#inputProcessor.performActions(
Expand All @@ -271,7 +267,7 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
);
// keep-sorted end

// Network domain
// Network module
// keep-sorted start block=yes
case 'network.addIntercept':
return await this.#networkProcessor.addIntercept(
Expand Down Expand Up @@ -307,15 +303,15 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
);
// keep-sorted end

// Permissions domain
// Permissions module
// keep-sorted start block=yes
case 'permissions.setPermission':
return await this.#permissionsProcessor.setPermissions(
this.#parser.parseSetPermissionsParams(command.params),
);
// keep-sorted end

// Script domain
// Script module
// keep-sorted start block=yes
case 'script.addPreloadScript':
return await this.#scriptProcessor.addPreloadScript(
Expand Down Expand Up @@ -349,8 +345,12 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
);
// keep-sorted end

// Session domain
// Session module
// keep-sorted start block=yes
case 'session.end':
throw new UnknownErrorException(
`Method ${command.method} is not implemented.`,
);
case 'session.new':
return await this.#sessionProcessor.new(command.params);
case 'session.status':
Expand All @@ -367,7 +367,7 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
);
// keep-sorted end

// Storage domain
// Storage module
// keep-sorted start block=yes
case 'storage.deleteCookies':
return await this.#storageProcessor.deleteCookies(
Expand All @@ -382,12 +382,26 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
this.#parser.parseSetCookieParams(command.params),
);
// keep-sorted end

// WebExtension module
// keep-sorted start block=yes
case 'webExtension.install':
throw new UnknownErrorException(
`Method ${command.method} is not implemented.`,
);
case 'webExtension.uninstall':
throw new UnknownErrorException(
`Method ${command.method} is not implemented.`,
);
// keep-sorted end
}

// Intentionally kept outside the switch statement to ensure that
// ESLint @typescript-eslint/switch-exhaustiveness-check triggers if a new
// command is added.
throw new UnknownCommandException(`Unknown command '${command.method}'.`);
throw new UnknownCommandException(
`Unknown command '${(command as {method?: string})?.method}'.`,
);
}

// Workaround for as zod.union always take the first schema
Expand Down
2 changes: 1 addition & 1 deletion src/protocol-parser/generated/webdriver-bidi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2912,7 +2912,7 @@ export namespace Input {
);
}
export const WebExtensionsCommandSchema = z.lazy(() =>
WebExtension.InstallSchema.and(WebExtension.UninstallSchema),
z.union([WebExtension.InstallSchema, WebExtension.UninstallSchema]),
);
export const WebExtensionsResultSchema = z.lazy(
() => WebExtension.InstallResultSchema,
Expand Down
5 changes: 3 additions & 2 deletions src/protocol/generated/webdriver-bidi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2287,8 +2287,9 @@ export namespace Input {
files: [...string[]];
};
}
export type WebExtensionsCommand = WebExtension.Install &
WebExtension.Uninstall;
export type WebExtensionsCommand =
| WebExtension.Install
| WebExtension.Uninstall;
export type WebExtensionsResult = WebExtension.InstallResult;
export namespace WebExtension {
export type Extension = string;
Expand Down

0 comments on commit 921f637

Please sign in to comment.