SubscriptionManager.d.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * Copyright 2022 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 CommonDataTypes, type Session } from '../../../protocol/protocol.js';
  18. import type { BrowsingContextStorage } from '../context/browsingContextStorage.js';
  19. /**
  20. * Returns the cartesian product of the given arrays.
  21. *
  22. * Example:
  23. * cartesian([1, 2], ['a', 'b']); => [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
  24. */
  25. export declare function cartesianProduct(...a: any[][]): any[];
  26. /** Expands "AllEvents" events into atomic events. */
  27. export declare function unrollEvents(events: Session.SubscriptionRequestEvent[]): Session.SubscriptionRequestEvent[];
  28. export declare class SubscriptionManager {
  29. #private;
  30. constructor(browsingContextStorage: BrowsingContextStorage);
  31. getChannelsSubscribedToEvent(eventMethod: Session.SubscriptionRequestEvent, contextId: CommonDataTypes.BrowsingContext | null): (string | null)[];
  32. subscribe(event: Session.SubscriptionRequestEvent, contextId: CommonDataTypes.BrowsingContext | null, channel: string | null): void;
  33. /**
  34. * Unsubscribes atomically from all events in the given contexts and channel.
  35. */
  36. unsubscribeAll(events: Session.SubscriptionRequestEvent[], contextIds: (CommonDataTypes.BrowsingContext | null)[], channel: string | null): void;
  37. /**
  38. * Unsubscribes from the event in the given context and channel.
  39. * Syntactic sugar for "unsubscribeAll".
  40. */
  41. unsubscribe(eventName: Session.SubscriptionRequestEvent, contextId: CommonDataTypes.BrowsingContext | null, channel: string | null): void;
  42. }