CommandProcessor.d.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Copyright 2021 Google LLC.
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import { type BrowsingContext, type Cdp, type Input, Message, type Script, type Session } from '../protocol/protocol.js';
  18. import { type LoggerFn } from '../utils/log.js';
  19. import { EventEmitter } from '../utils/EventEmitter.js';
  20. import type { ICdpConnection } from '../cdp/cdpConnection.js';
  21. import type { BrowsingContextStorage } from './domains/context/browsingContextStorage.js';
  22. import type { IEventManager } from './domains/events/EventManager.js';
  23. import { OutgoingBidiMessage } from './OutgoingBidiMessage.js';
  24. import type { RealmStorage } from './domains/script/realmStorage.js';
  25. type CommandProcessorEvents = {
  26. response: Promise<OutgoingBidiMessage>;
  27. };
  28. export interface BidiParser {
  29. parseAddPreloadScriptParams(params: object): Script.AddPreloadScriptParameters;
  30. parseRemovePreloadScriptParams(params: object): Script.RemovePreloadScriptParameters;
  31. parseGetRealmsParams(params: object): Script.GetRealmsParameters;
  32. parseCallFunctionParams(params: object): Script.CallFunctionParameters;
  33. parseEvaluateParams(params: object): Script.EvaluateParameters;
  34. parseDisownParams(params: object): Script.DisownParameters;
  35. parseSendCommandParams(params: object): Cdp.SendCommandParams;
  36. parseGetSessionParams(params: object): Cdp.GetSessionParams;
  37. parseSubscribeParams(params: object): Session.SubscriptionRequest;
  38. parseNavigateParams(params: object): BrowsingContext.NavigateParameters;
  39. parseReloadParams(params: object): BrowsingContext.ReloadParameters;
  40. parseGetTreeParams(params: object): BrowsingContext.GetTreeParameters;
  41. parseCreateParams(params: object): BrowsingContext.CreateParameters;
  42. parseCloseParams(params: object): BrowsingContext.CloseParameters;
  43. parseCaptureScreenshotParams(params: object): BrowsingContext.CaptureScreenshotParameters;
  44. parsePrintParams(params: object): BrowsingContext.PrintParameters;
  45. parseSetViewportParams(params: object): BrowsingContext.SetViewportParameters;
  46. parsePerformActionsParams(params: object): Input.PerformActionsParameters;
  47. parseReleaseActionsParams(params: object): Input.ReleaseActionsParameters;
  48. }
  49. export declare class CommandProcessor extends EventEmitter<CommandProcessorEvents> {
  50. #private;
  51. constructor(cdpConnection: ICdpConnection, eventManager: IEventManager, selfTargetId: string, parser: BidiParser | undefined, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, logger?: LoggerFn);
  52. processCommand(command: Message.RawCommandRequest): Promise<void>;
  53. }
  54. export {};