WorkboxEvent.d.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { WorkboxEventTarget } from './WorkboxEventTarget.js';
  2. import '../_version.js';
  3. /**
  4. * A minimal `Event` subclass shim.
  5. * This doesn't *actually* subclass `Event` because not all browsers support
  6. * constructable `EventTarget`, and using a real `Event` will error.
  7. * @private
  8. */
  9. export declare class WorkboxEvent<K extends keyof WorkboxEventMap> {
  10. type: K;
  11. target?: WorkboxEventTarget;
  12. sw?: ServiceWorker;
  13. originalEvent?: Event;
  14. isExternal?: boolean;
  15. constructor(type: K, props: Omit<WorkboxEventMap[K], 'target' | 'type'>);
  16. }
  17. export interface WorkboxMessageEvent extends WorkboxEvent<'message'> {
  18. data: any;
  19. originalEvent: Event;
  20. ports: readonly MessagePort[];
  21. }
  22. export interface WorkboxLifecycleEvent extends WorkboxEvent<keyof WorkboxLifecycleEventMap> {
  23. isUpdate?: boolean;
  24. }
  25. export interface WorkboxLifecycleWaitingEvent extends WorkboxLifecycleEvent {
  26. wasWaitingBeforeRegister?: boolean;
  27. }
  28. export interface WorkboxLifecycleEventMap {
  29. installing: WorkboxLifecycleEvent;
  30. installed: WorkboxLifecycleEvent;
  31. waiting: WorkboxLifecycleWaitingEvent;
  32. activating: WorkboxLifecycleEvent;
  33. activated: WorkboxLifecycleEvent;
  34. controlling: WorkboxLifecycleEvent;
  35. redundant: WorkboxLifecycleEvent;
  36. }
  37. export interface WorkboxEventMap extends WorkboxLifecycleEventMap {
  38. message: WorkboxMessageEvent;
  39. }