bidiPreloadScript.d.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import type { CommonDataTypes, Script } from '../../../protocol/protocol.js';
  2. import { ChannelProxy } from '../script/channelProxy.js';
  3. import type { CdpTarget } from './cdpTarget.js';
  4. /**
  5. * BiDi IDs are generated by the server and are unique within the context.
  6. *
  7. * CDP preload script IDs are generated by the client and are unique
  8. * within the session.
  9. *
  10. * The mapping between BiDi and CDP preload script IDs is 1:many.
  11. * BiDi IDs are needed by the mapper to keep track of potential multiple CDP IDs
  12. * in the client.
  13. */
  14. export declare class BidiPreloadScript {
  15. #private;
  16. get id(): string;
  17. get contextId(): CommonDataTypes.BrowsingContext | null;
  18. get targetIds(): Set<string>;
  19. constructor(params: Script.AddPreloadScriptParameters);
  20. /** Channels of the preload script. */
  21. get channels(): ChannelProxy[];
  22. /**
  23. * Adds the script to the given CDP targets by calling the
  24. * `Page.addScriptToEvaluateOnNewDocument` command.
  25. */
  26. initInTargets(cdpTargets: Iterable<CdpTarget>): Promise<void>;
  27. /**
  28. * Adds the script to the given CDP target by calling the
  29. * `Page.addScriptToEvaluateOnNewDocument` command.
  30. */
  31. initInTarget(cdpTarget: CdpTarget): Promise<void>;
  32. /**
  33. * Schedules the script to be run right after
  34. * `Runtime.runIfWaitingForDebugger`, but does not wait for result.
  35. */
  36. scheduleEvaluateInTarget(cdpTarget: CdpTarget): void;
  37. /**
  38. * Removes this script from all CDP targets.
  39. */
  40. remove(): Promise<void>;
  41. /**
  42. * Removes the provided cdp target from the list of cdp preload scripts.
  43. */
  44. cdpTargetIsGone(cdpTargetId: string): void;
  45. }