Skip to content

Commit

Permalink
docs: use Module for BiDi as spec (#2861)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning00Blade authored Dec 3, 2024
1 parent 521ebb5 commit f21bfd8
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,9 @@ If your command has parameters, update the [`BidiCommandParameterParser`](https:

Write the core logic for your command in the appropriate domain processor. Again, [example](https://github.com/GoogleChromeLabs/chromium-bidi/blob/0f971303281aba1910786035facc5eb54a833232/src/bidiMapper/modules/permissions/PermissionsProcessor.ts#L32) is your friend.

#### Call the domain processor's method
#### Call the module processor's method

Call your new domain processor method from `CommandProcessor.#processCommand`, passing in the parsed parameters. [Example](https://github.com/GoogleChromeLabs/chromium-bidi/blob/0f971303281aba1910786035facc5eb54a833232/src/bidiMapper/CommandProcessor.ts#L313).
Call your new module processor method from `CommandProcessor.#processCommand`, passing in the parsed parameters. [Example](https://github.com/GoogleChromeLabs/chromium-bidi/blob/0f971303281aba1910786035facc5eb54a833232/src/bidiMapper/CommandProcessor.ts#L313).

#### Add e2e tests

Expand Down
20 changes: 10 additions & 10 deletions src/bidiMapper/BidiNoOpParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import type {
import type {BidiCommandParameterParser} from './BidiParser.js';

export class BidiNoOpParser implements BidiCommandParameterParser {
// Bluetooth domain
// Bluetooth module
// keep-sorted start block=yes
parseHandleRequestDevicePromptParams(
params: unknown,
Expand All @@ -55,7 +55,7 @@ export class BidiNoOpParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Browser domain
// Browser module
// keep-sorted start block=yes
parseRemoveUserContextParams(
params: unknown,
Expand All @@ -64,7 +64,7 @@ export class BidiNoOpParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Browsing Context domain
// Browsing Context module
// keep-sorted start block=yes
parseActivateParams(params: unknown): BrowsingContext.ActivateParameters {
return params as BrowsingContext.ActivateParameters;
Expand Down Expand Up @@ -114,7 +114,7 @@ export class BidiNoOpParser implements BidiCommandParameterParser {
}
// keep-sorted end

// CDP domain
// CDP module
// keep-sorted start block=yes
parseGetSessionParams(params: unknown): Cdp.GetSessionParameters {
return params as Cdp.GetSessionParameters;
Expand All @@ -127,7 +127,7 @@ export class BidiNoOpParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Script domain
// Script module
// keep-sorted start block=yes
parseAddPreloadScriptParams(
params: unknown,
Expand All @@ -153,7 +153,7 @@ export class BidiNoOpParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Input domain
// Input module
// keep-sorted start block=yes
parsePerformActionsParams(params: unknown): Input.PerformActionsParameters {
return params as Input.PerformActionsParameters;
Expand All @@ -166,7 +166,7 @@ export class BidiNoOpParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Network domain
// Network module
// keep-sorted start block=yes
parseAddInterceptParams(params: unknown): Network.AddInterceptParameters {
return params as Network.AddInterceptParameters;
Expand Down Expand Up @@ -204,7 +204,7 @@ export class BidiNoOpParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Permissions domain
// Permissions module
// keep-sorted start block=yes
parseSetPermissionsParams(
params: unknown,
Expand All @@ -213,14 +213,14 @@ export class BidiNoOpParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Session domain
// Session module
// keep-sorted start block=yes
parseSubscribeParams(params: unknown): Session.SubscriptionRequest {
return params as Session.SubscriptionRequest;
}
// keep-sorted end

// Storage domain
// Storage module
// keep-sorted start block=yes
parseDeleteCookiesParams(params: unknown): Storage.DeleteCookiesParameters {
return params as Storage.DeleteCookiesParameters;
Expand Down
20 changes: 10 additions & 10 deletions src/bidiMapper/BidiParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import type {
} from '../protocol/protocol.js';

export interface BidiCommandParameterParser {
// Bluetooth domain
// Bluetooth module
// keep-sorted start block=yes
parseHandleRequestDevicePromptParams(
params: unknown,
Expand All @@ -45,14 +45,14 @@ export interface BidiCommandParameterParser {
): Bluetooth.SimulatePreconnectedPeripheralParameters;
// keep-sorted end

// Browser domain
// Browser module
// keep-sorted start block=yes
parseRemoveUserContextParams(
params: unknown,
): Browser.RemoveUserContextParameters;
// keep-sorted end

// Browsing Context domain
// Browsing Context module
// keep-sorted start block=yes
parseActivateParams(params: unknown): BrowsingContext.ActivateParameters;
parseCaptureScreenshotParams(
Expand All @@ -78,28 +78,28 @@ export interface BidiCommandParameterParser {
): BrowsingContext.TraverseHistoryParameters;
// keep-sorted end

// CDP domain
// CDP module
// keep-sorted start block=yes
parseGetSessionParams(params: unknown): Cdp.GetSessionParameters;
parseResolveRealmParams(params: unknown): Cdp.ResolveRealmParameters;
parseSendCommandParams(params: unknown): Cdp.SendCommandParameters;
// keep-sorted end

// Input domain
// Input module
// keep-sorted start block=yes
parsePerformActionsParams(params: unknown): Input.PerformActionsParameters;
parseReleaseActionsParams(params: unknown): Input.ReleaseActionsParameters;
parseSetFilesParams(params: unknown): Input.SetFilesParameters;
// keep-sorted end

// PermissionsDomain domain
// Permissions module
// keep-sorted start block=yes
parseSetPermissionsParams(
params: unknown,
): Permissions.SetPermissionParameters;
// keep-sorted end block=yes

// Network domain
// Network module
// keep-sorted start block=yes
parseAddInterceptParams(params: unknown): Network.AddInterceptParameters;
parseContinueRequestParams(
Expand All @@ -121,7 +121,7 @@ export interface BidiCommandParameterParser {
parseSetCacheBehavior(params: unknown): Network.SetCacheBehaviorParameters;
// keep-sorted end block=yes

// Script domain
// Script module
// keep-sorted start block=yes
parseAddPreloadScriptParams(
params: unknown,
Expand All @@ -135,12 +135,12 @@ export interface BidiCommandParameterParser {
): Script.RemovePreloadScriptParameters;
// keep-sorted end

// Session domain
// Session module
// keep-sorted start block=yes
parseSubscribeParams(params: unknown): Session.SubscriptionRequest;
// keep-sorted end

// Storage domain
// Storage module
// keep-sorted start block=yes
parseDeleteCookiesParams(params: unknown): Storage.DeleteCookiesParameters;
parseGetCookiesParams(params: unknown): Storage.GetCookiesParameters;
Expand Down
2 changes: 1 addition & 1 deletion src/bidiMapper/modules/network/NetworkProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type {NetworkRequest} from './NetworkRequest.js';
import type {NetworkStorage} from './NetworkStorage.js';
import {isSpecialScheme, type ParsedUrlPattern} from './NetworkUtils.js';

/** Dispatches Network domain commands. */
/** Dispatches Network module commands. */
export class NetworkProcessor {
readonly #browsingContextStorage: BrowsingContextStorage;
readonly #networkStorage: NetworkStorage;
Expand Down
2 changes: 1 addition & 1 deletion src/bidiMapper/modules/network/NetworkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

/**
* @fileoverview Utility functions for the Network domain.
* @fileoverview Utility functions for the Network module.
*/
import type {Protocol} from 'devtools-protocol';

Expand Down
4 changes: 2 additions & 2 deletions src/bidiMapper/modules/session/EventManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export class EventManager extends EventEmitter<EventManagerEventsMap> {
}

// List of the subscription items that were actually added. Each contains a specific
// event and context. No domain event (like "network") or global context subscription
// event and context. No module event (like "network") or global context subscription
// (like null) are included.
const addedSubscriptionItems: SubscriptionItem[] = [];

Expand Down Expand Up @@ -225,7 +225,7 @@ export class EventManager extends EventEmitter<EventManagerEventsMap> {
}

// Iterate over all new subscription items and call hooks if any. There can be
// duplicates, e.g. when subscribing to the whole domain and some specific event in
// duplicates, e.g. when subscribing to the whole module and some specific event in
// the same time ("network", "network.responseCompleted"). `distinctValues` guarantees
// that hooks are called only once per pair event + context.
distinctValues(addedSubscriptionItems).forEach(({contextId, event}) => {
Expand Down
4 changes: 2 additions & 2 deletions src/bidiMapper/modules/session/SubscriptionManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ describe('SubscriptionManager', () => {
).to.deep.equal([]);
});

it('should unsubscribe the domain', () => {
it('should unsubscribe the module', () => {
subscriptionManager.subscribe(ALL_EVENTS, SOME_CONTEXT, SOME_CHANNEL);
subscriptionManager.unsubscribe(ALL_EVENTS, SOME_CONTEXT, SOME_CHANNEL);
expect(
Expand All @@ -319,7 +319,7 @@ describe('SubscriptionManager', () => {
).to.deep.equal([]);
});

it('should not unsubscribe the domain if not subscribed', () => {
it('should not unsubscribe the module if not subscribed', () => {
subscriptionManager.subscribe(ALL_EVENTS, SOME_CONTEXT, SOME_CHANNEL);
subscriptionManager.unsubscribe(ALL_EVENTS, SOME_CONTEXT, SOME_CHANNEL);
expect(
Expand Down
2 changes: 1 addition & 1 deletion src/bidiMapper/modules/storage/StorageProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
} from '../network/NetworkUtils.js';

/**
* Responsible for handling the `storage` domain.
* Responsible for handling the `storage` module.
*/
export class StorageProcessor {
readonly #browserCdpClient: CdpClient;
Expand Down
20 changes: 10 additions & 10 deletions src/bidiTab/BidiParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import type {
import * as Parser from '../protocol-parser/protocol-parser.js';

export class BidiParser implements BidiCommandParameterParser {
// Bluetooth domain
// Bluetooth module
// keep-sorted start block=yes
parseHandleRequestDevicePromptParams(
params: unknown,
Expand All @@ -54,7 +54,7 @@ export class BidiParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Browser domain
// Browser module
// keep-sorted start block=yes
parseRemoveUserContextParams(
params: unknown,
Expand All @@ -63,7 +63,7 @@ export class BidiParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Browsing Context domain
// Browsing Context module
// keep-sorted start block=yes
parseActivateParams(params: unknown): BrowsingContext.ActivateParameters {
return Parser.BrowsingContext.parseActivateParams(params);
Expand Down Expand Up @@ -113,7 +113,7 @@ export class BidiParser implements BidiCommandParameterParser {
}
// keep-sorted end

// CDP domain
// CDP module
// keep-sorted start block=yes
parseGetSessionParams(params: unknown): Cdp.GetSessionParameters {
return Parser.Cdp.parseGetSessionRequest(params);
Expand All @@ -126,7 +126,7 @@ export class BidiParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Input domain
// Input module
// keep-sorted start block=yes
parsePerformActionsParams(params: unknown): Input.PerformActionsParameters {
return Parser.Input.parsePerformActionsParams(params);
Expand All @@ -139,7 +139,7 @@ export class BidiParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Network domain
// Network module
// keep-sorted start block=yes
parseAddInterceptParams(params: unknown): Network.AddInterceptParameters {
return Parser.Network.parseAddInterceptParameters(params);
Expand Down Expand Up @@ -177,7 +177,7 @@ export class BidiParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Permissions domain
// Permissions module
// keep-sorted start block=yes
parseSetPermissionsParams(
params: unknown,
Expand All @@ -186,7 +186,7 @@ export class BidiParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Script domain
// Script module
// keep-sorted start block=yes
parseAddPreloadScriptParams(
params: unknown,
Expand All @@ -212,14 +212,14 @@ export class BidiParser implements BidiCommandParameterParser {
}
// keep-sorted end

// Session domain
// Session module
// keep-sorted start block=yes
parseSubscribeParams(params: unknown): Session.SubscriptionRequest {
return Parser.Session.parseSubscribeParams(params);
}
// keep-sorted end

// Storage domain
// Storage module
// keep-sorted start block=yes
parseDeleteCookiesParams(params: unknown): Storage.DeleteCookiesParameters {
return Parser.Storage.parseDeleteCookiesParams(params);
Expand Down

0 comments on commit f21bfd8

Please sign in to comment.