info.d.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. declare module 'virtual:pwa-info' {
  2. export interface PwaInfo {
  3. pwaInDevEnvironment: boolean
  4. /**
  5. * The webmanifest will be always here.
  6. */
  7. webManifest: {
  8. href: string
  9. useCredentials: boolean
  10. /**
  11. * The link tag with or without `crossorigin`:
  12. * - `<link rel="manifest" href="<webManifestUrl>" />`.
  13. * - `<link rel="manifest" href="<webManifestUrl>" crossorigin=use-credentials" />`.
  14. */
  15. linkTag: string
  16. }
  17. /**
  18. * The service worker data will be exposed only if required, that's, will **NOT** be exposed if:
  19. * - not using `pwaPluginOptions.injectRegister` with `script` or `inline` values
  20. * - if using `pwaPluginOptions.injectRegister` with `auto` (default) and importing any of the virtual modules
  21. */
  22. registerSW?: {
  23. /**
  24. * When this flag is `true` the service worker must be registered via inline script otherwise registered via script with src attribute `registerSW.js` .
  25. */
  26. inline: boolean
  27. /**
  28. * The path for the inline script: will contain the service worker url.
  29. */
  30. inlinePath: string
  31. /**
  32. * The path for the src script for `registerSW.js`.
  33. */
  34. registerPath: string
  35. /**
  36. * The scope for the service worker: only required for `inline: true`.
  37. */
  38. scope: string
  39. /**
  40. * The type for the service worker: only required for `inline: true`.
  41. */
  42. type: 'classic' | 'module'
  43. /**
  44. * The script tag if `shouldRegisterSW` returns `true`.
  45. */
  46. scriptTag?: string
  47. }
  48. }
  49. /**
  50. * Return the PWA information if available.
  51. *
  52. * This property will be `undefined` if:
  53. * - SSR build
  54. * - PWA is disabled: `pwaPluginOptions.disable = true`
  55. * - running `Dev Server` and `pwaPluginOptions.devOptions.enabled = false` (default).
  56. *
  57. * @returns The PWA information.
  58. */
  59. export const pwaInfo: PwaInfo | undefined
  60. }