WorkboxEvent.d.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. constructor(type: K, props: Omit<WorkboxEventMap[K], 'target' | 'type'>);
  15. }
  16. export interface WorkboxMessageEvent extends WorkboxEvent<'message'> {
  17. originalEvent: Event;
  18. data: any;
  19. }
  20. export interface WorkboxLifecycleEvent extends WorkboxEvent<keyof WorkboxLifecycleEventMap> {
  21. isUpdate?: boolean;
  22. }
  23. export interface WorkboxLifecycleWaitingEvent extends WorkboxLifecycleEvent {
  24. wasWaitingBeforeRegister?: boolean;
  25. }
  26. export interface WorkboxLifecycleEventMap {
  27. 'installing': WorkboxLifecycleEvent;
  28. 'installed': WorkboxLifecycleEvent;
  29. 'waiting': WorkboxLifecycleWaitingEvent;
  30. 'activating': WorkboxLifecycleEvent;
  31. 'activated': WorkboxLifecycleEvent;
  32. 'controlling': WorkboxLifecycleEvent;
  33. 'externalinstalling': WorkboxLifecycleEvent;
  34. 'externalinstalled': WorkboxLifecycleEvent;
  35. 'externalwaiting': WorkboxLifecycleWaitingEvent;
  36. 'externalactivating': WorkboxLifecycleEvent;
  37. 'externalactivated': WorkboxLifecycleEvent;
  38. 'redundant': WorkboxLifecycleEvent;
  39. }
  40. export interface WorkboxEventMap extends WorkboxLifecycleEventMap {
  41. 'message': WorkboxMessageEvent;
  42. }