Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vite-pwa/vite-plugin-pwa
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 79a929e51cd3e6965033ae3a7b8ce322bb012a67
Choose a base ref
...
head repository: vite-pwa/vite-plugin-pwa
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2930a3cae51765de2925e52117bf00c03c3687d9
Choose a head ref

Commits on Sep 20, 2022

  1. Copy the full SHA
    4a9e8b9 View commit details
  2. docs: update

    antfu committed Sep 20, 2022
    Copy the full SHA
    9182779 View commit details
  3. release v0.13.0

    antfu committed Sep 20, 2022
    Copy the full SHA
    f8aba11 View commit details

Commits on Sep 22, 2022

  1. fix(api): return pwa info when required (#378)

    * fix(api): webmanifest should be generated always
    
    * chore: check also manifest is present
    
    * chore: update to logic to only return when required
    userquin authored Sep 22, 2022
    Copy the full SHA
    4927b19 View commit details
  2. chore: release v0.13.1

    userquin committed Sep 22, 2022
    Copy the full SHA
    cd7992b View commit details

Commits on Sep 26, 2022

  1. chore: improve types

    antfu committed Sep 26, 2022
    Copy the full SHA
    2be76b2 View commit details

Commits on Sep 30, 2022

  1. Copy the full SHA
    ce948b5 View commit details

Commits on Oct 9, 2022

  1. fix(dev): 404 workbox-*.js when base option exists (#389)

    * fix(dev): 404 workbox-*.js when base option exists
    
    * chore: test fro slash and remove semicolon
    
    Co-authored-by: hexuan <hexuan@idea.edu.cn>
    Co-authored-by: Joaquín Sánchez <userquin@gmail.com>
    3 people authored Oct 9, 2022
    Copy the full SHA
    3b6809e View commit details

Commits on Oct 16, 2022

  1. feat: support mode when injectManifest (#391)

    * feat: inject mode when injectManifest
    
    * chore: load replace plugin on demand
    
    Co-authored-by: userquin <userquin@gmail.com>
    yoyo930021 and userquin authored Oct 16, 2022
    Copy the full SHA
    2798fb6 View commit details

Commits on Nov 3, 2022

  1. chore: release v0.13.2

    userquin committed Nov 3, 2022
    Copy the full SHA
    c5dfccd View commit details

Commits on Nov 7, 2022

  1. Copy the full SHA
    a94fc2a View commit details
  2. chore: release v0.13.3

    userquin committed Nov 7, 2022
    Copy the full SHA
    50f5061 View commit details

Commits on Dec 12, 2022

  1. feat: Vite 4 support (#424)

    userquin authored Dec 12, 2022
    Copy the full SHA
    c19785f View commit details
  2. Copy the full SHA
    d8d2d36 View commit details
  3. Copy the full SHA
    ea1a58b View commit details
  4. feat: custom sw without injection point (#390)

    Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
    userquin and antfu authored Dec 12, 2022
    Copy the full SHA
    e500d1a View commit details
  5. release v0.14.0

    antfu committed Dec 12, 2022
    Copy the full SHA
    7d1ab01 View commit details

Commits on Dec 24, 2022

  1. Copy the full SHA
    fd9475d View commit details

Commits on Jan 3, 2023

  1. fix: prompt for update logic (#428)

    * fix: prompt for update logic
    
    * chore: cleanup console.log
    userquin authored Jan 3, 2023
    Copy the full SHA
    78f8672 View commit details
  2. chore: release v0.14.1

    userquin committed Jan 3, 2023
    Copy the full SHA
    d1b6616 View commit details

Commits on Jan 6, 2023

  1. Copy the full SHA
    3d6f489 View commit details

Commits on Feb 7, 2023

  1. feat: add share_target to manifest (#459)

    * feat: add share_target to manifest
    
    * chore: add share target files type
    userquin authored Feb 7, 2023
    Copy the full SHA
    d142c09 View commit details
  2. Copy the full SHA
    3baf046 View commit details
  3. Copy the full SHA
    62a34de View commit details
  4. chore: release v0.14.2

    userquin committed Feb 7, 2023
    Copy the full SHA
    cd14a85 View commit details

Commits on Feb 8, 2023

  1. feat: add configurable dev-dist folder and buildBase option (#461)

    * feat: add configurable `dev-dist` folder and `buildBase` option
    
    * chore: update `buildBase` type jsdoc
    
    * chore: .
    userquin authored Feb 8, 2023
    Copy the full SHA
    3676296 View commit details
  2. chore: release v0.14.3

    userquin committed Feb 8, 2023
    Copy the full SHA
    912e56e View commit details

Commits on Feb 10, 2023

  1. fix: use build base on virtual module (#464)

    * fix: use build base on virtual module
    
    * chore: include build base tests
    
    * chore: include build base tests for virtual
    userquin authored Feb 10, 2023
    Copy the full SHA
    64b5841 View commit details
  2. chore: release v0.14.4

    userquin committed Feb 10, 2023
    Copy the full SHA
    d4afb91 View commit details

Commits on Feb 20, 2023

  1. Copy the full SHA
    1e35b34 View commit details
  2. docs: typo on SvelteKit

    userquin authored Feb 20, 2023
    Copy the full SHA
    16a084e View commit details

Commits on Mar 19, 2023

  1. Copy the full SHA
    f797518 View commit details

Commits on Mar 22, 2023

  1. feat: virtual dts per framework (#486)

    * feat: virtual dts per framework
    
    * chore: add jsdocs to fw dts
    
    * chore: move options to types using dynamic import
    
    * chore: register options moved to types folder
    userquin authored Mar 22, 2023
    Copy the full SHA
    b45f1fa View commit details
  2. Copy the full SHA
    c73c7c0 View commit details
  3. chore: release v0.14.5

    userquin committed Mar 22, 2023
    Copy the full SHA
    03f7c54 View commit details

Commits on Mar 23, 2023

  1. Copy the full SHA
    32841bb View commit details
  2. chore: release v0.14.6

    userquin committed Mar 23, 2023
    Copy the full SHA
    b37206a View commit details

Commits on Mar 28, 2023

  1. Copy the full SHA
    1784576 View commit details
  2. chore: release v0.14.7

    userquin committed Mar 28, 2023
    Copy the full SHA
    a79ae1d View commit details

Commits on Apr 30, 2023

  1. Copy the full SHA
    ba74d16 View commit details

Commits on May 13, 2023

  1. fix: Make manifest.shortcuts.icons optional #509 (#510)

    Fixes #509
    
    Signed-off-by: Anton Melser <anton.melser@outlook.com>
    AntonOfTheWoods authored May 13, 2023
    Copy the full SHA
    c59de75 View commit details

Commits on May 19, 2023

  1. feat: ESM first (#493)

    * feat: ESM first
    
    * chore: remove CJS
    
    * chore: remove pwa plugin d.cts
    userquin authored May 19, 2023
    Copy the full SHA
    e8ee8c5 View commit details
  2. feat!: build custom service worker using vite (#506)

    * feat: build custom service worker using vite
    
    * fix: lock file
    
    * chore: change plugins type + add breaking changes version
    
    * chore: change plugins with user config (excluding define) and use merge config
    
    * chore: update `injectManifestViteOptions` jsdocs
    
    * chore: fix wording `injectManifestViteOptions` jsdocs
    
    * chore: change `CustomInjectManifestOptions` jsdocs
    
    * chore: include rollup options only
    userquin authored May 19, 2023
    Copy the full SHA
    7cacdd3 View commit details
  3. ci: add tests (#516)

    * ci: add tests
    
    * chore: add svelte tests
    
    * chore: add framework name to tests descriptions
    chore: use line reporter also on Playwright tests
    
    * chore: add preact tests
    
    * chore: remove Vitest globals (IntelliJ complains)
    
    * chore: add solid tests
    
    * chore: add solid global test script
    
    * chore: add TypeScript tests
    
    * fix: solijs claims build
    
    * fix: vanilla-ts-no-ip test
    
    * chore: allow vanilla-ts-no-ip test run with vite 3
    
    * chore: update vite react plugin
    
    * fix: netlify deploy
    
    * chore: exclude sveltekit example
    
    * chore: .
    
    * chore: include ts test with generateSW strategy
    
    * fix: add some workbox options to ts example
    
    * chore: update ts and remove cross-env
    userquin authored May 19, 2023
    Copy the full SHA
    2a5ed71 View commit details
  4. chore: update lock file

    userquin committed May 19, 2023
    Copy the full SHA
    006fb29 View commit details
  5. Copy the full SHA
    cd7737f View commit details
  6. chore: release v0.15.0

    userquin committed May 19, 2023
    Copy the full SHA
    ce87e2e View commit details

Commits on May 24, 2023

  1. Copy the full SHA
    bc80d19 View commit details
  2. chore: release v0.15.1

    userquin committed May 24, 2023
    Copy the full SHA
    29a37f3 View commit details

Commits on May 27, 2023

  1. chore: Update LICENSE

    userquin authored May 27, 2023
    Copy the full SHA
    47309db View commit details
Showing with 7,565 additions and 4,434 deletions.
  1. +1 −1 .eslintrc.json
  2. +3 −0 .gitignore
  3. +5 −0 .npmrc
  4. +8 −6 CONTRIBUTING.md
  5. +1 −1 LICENSE
  6. +10 −5 README.md
  7. +6 −189 client.d.ts
  8. +2 −3 docs/.vitepress/components.d.ts
  9. +10 −2 docs/.vitepress/config.ts
  10. +58 −0 docs/.vitepress/contributors.ts
  11. +0 −5 docs/.vitepress/theme/components/HeuristicWorkboxWindow.md
  12. +1 −28 docs/.vitepress/theme/components/HomePage.vue
  13. +1 −1 docs/deployment/index.md
  14. +0 −3 docs/examples/preact.md
  15. +0 −3 docs/examples/react.md
  16. +0 −3 docs/examples/solidjs.md
  17. +0 −3 docs/examples/svelte.md
  18. +0 −4 docs/examples/sveltekit.md
  19. +0 −3 docs/examples/vue.md
  20. +0 −2 docs/frameworks/preact.md
  21. +0 −2 docs/frameworks/react.md
  22. +0 −2 docs/frameworks/solidjs.md
  23. +0 −3 docs/frameworks/svelte.md
  24. +0 −4 docs/frameworks/vue.md
  25. +1 −5 docs/guide/development.md
  26. +20 −19 docs/guide/periodic-sw-updates.md
  27. +12 −12 docs/package.json
  28. +1 −1 docs/plugins/navbar.ts
  29. +6 −8 docs/scripts/build.ts
  30. +82 −0 docs/scripts/pwa.ts
  31. +7 −80 docs/vite.config.ts
  32. +43 −0 examples/preact-router/client-test/sw.spec.ts
  33. +52 −49 examples/preact-router/package.json
  34. +91 −0 examples/preact-router/playwright.config.ts
  35. +1 −0 examples/preact-router/src/ReloadPrompt.tsx
  36. +1 −0 examples/preact-router/src/vite-env.d.ts
  37. +38 −0 examples/preact-router/test/build.test.ts
  38. +1 −1 examples/preact-router/tsconfig.json
  39. +7 −0 examples/preact-router/vitest.config.mts
  40. +43 −0 examples/react-router/client-test/sw.spec.ts
  41. +54 −51 examples/react-router/package.json
  42. +91 −0 examples/react-router/playwright.config.ts
  43. +1 −0 examples/react-router/src/ReloadPrompt.tsx
  44. +2 −1 examples/react-router/src/vite-env.d.ts
  45. +38 −0 examples/react-router/test/build.test.ts
  46. +3 −2 examples/react-router/tsconfig.json
  47. +2 −2 examples/react-router/vite.config.ts
  48. +7 −0 examples/react-router/vitest.config.mts
  49. +43 −0 examples/solid-router/client-test/sw.spec.ts
  50. +52 −49 examples/solid-router/package.json
  51. +91 −0 examples/solid-router/playwright.config.ts
  52. +1 −1 examples/solid-router/src/ReloadPrompt.tsx
  53. +38 −0 examples/solid-router/test/build.test.ts
  54. +1 −1 examples/solid-router/tsconfig.json
  55. +7 −0 examples/solid-router/vitest.config.mts
  56. +43 −0 examples/svelte-routify/client-test/sw.spec.ts
  57. +53 −50 examples/svelte-routify/package.json
  58. +91 −0 examples/svelte-routify/playwright.config.ts
  59. +1 −0 examples/svelte-routify/src/lib/ReloadPrompt.svelte
  60. +2 −1 examples/svelte-routify/src/vite-env.d.ts
  61. +39 −0 examples/svelte-routify/test/build.test.ts
  62. +1 −3 examples/svelte-routify/tsconfig.json
  63. +2 −1 examples/svelte-routify/vite-env.d.ts
  64. +7 −0 examples/svelte-routify/vitest.config.mts
  65. +23 −23 examples/sveltekit-pwa/package.json
  66. +12 −10 examples/vanilla-ts-dev-options/package.json
  67. +1 −0 examples/vanilla-ts-dev-options/src/main.ts
  68. +2 −1 examples/vanilla-ts-dev-options/src/vite-env.ts
  69. +1 −1 examples/vanilla-ts-dev-options/tsconfig.json
  70. +1 −0 examples/vanilla-ts-dev-options/vite.config.ts
  71. +9 −0 examples/vanilla-ts-no-ip/README.md
  72. +98 −0 examples/vanilla-ts-no-ip/client-test/sw.spec.ts
  73. +22 −0 examples/vanilla-ts-no-ip/index.html
  74. +27 −0 examples/vanilla-ts-no-ip/package.json
  75. +91 −0 examples/vanilla-ts-no-ip/playwright.config.ts
  76. +130 −0 examples/vanilla-ts-no-ip/public/favicon.svg
  77. BIN examples/vanilla-ts-no-ip/public/pwa-192x192.png
  78. BIN examples/vanilla-ts-no-ip/public/pwa-512x512.png
  79. +66 −0 examples/vanilla-ts-no-ip/src/custom-sw.ts
  80. +33 −0 examples/vanilla-ts-no-ip/src/main.ts
  81. +5 −0 examples/vanilla-ts-no-ip/src/vite-env.ts
  82. +56 −0 examples/vanilla-ts-no-ip/test/build.test.ts
  83. +21 −0 examples/vanilla-ts-no-ip/tsconfig.json
  84. +61 −0 examples/vanilla-ts-no-ip/vite.config.ts
  85. +7 −0 examples/vanilla-ts-no-ip/vitest.config.mts
  86. +10 −11 examples/vue-basic-cdn/package.json
  87. +43 −0 examples/vue-router/client-test/sw.spec.ts
  88. +53 −50 examples/vue-router/package.json
  89. +91 −0 examples/vue-router/playwright.config.ts
  90. +1 −0 examples/vue-router/src/ReloadPrompt.vue
  91. +38 −0 examples/vue-router/test/build.test.ts
  92. +7 −0 examples/vue-router/vitest.config.mts
  93. +0 −2 index.d.ts
  94. +55 −55 info.d.ts
  95. +2 −3 netlify.toml
  96. +81 −38 package.json
  97. +4,916 −3,484 pnpm-lock.yaml
  98. +19 −0 preact.d.ts
  99. +19 −0 react.d.ts
  100. +2 −3 scripts/run-examples.ts
  101. +19 −0 solid.d.ts
  102. +17 −8 src/api.ts
  103. +3 −3 src/assets.ts
  104. +65 −49 src/client/build/register.ts
  105. +0 −1 src/constants.ts
  106. +6 −5 src/html.ts
  107. +1 −1 src/log.ts
  108. +43 −38 src/modules.ts
  109. +25 −8 src/options.ts
  110. +7 −3 src/plugins/build.ts
  111. +18 −11 src/plugins/dev.ts
  112. +23 −6 src/plugins/info.ts
  113. +4 −4 src/plugins/main.ts
  114. +73 −4 src/types.ts
  115. +2 −2 src/utils.ts
  116. +19 −0 svelte.d.ts
  117. +20 −0 types/index.d.ts
  118. +3 −0 types/package.json
  119. +13 −0 vanillajs.d.ts
  120. +19 −0 vue.d.ts
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@antfu",
"extends": ["@antfu"],
"overrides": [
{
"files": [
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -6,3 +6,6 @@ dev-dist
.idea/
# routify
.routify/
examples/*/test-results/
examples/*/playwright-report/
examples/*/playwright/.cache/
5 changes: 5 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ignore-workspace-root-check=true
shamefully-hoist=true
strict-peer-dependencies=false
auto-install-peers=true
shell-emulator=true
14 changes: 8 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@ To develop and test the `vite-plugin-pwa` package:

1. Fork the `vite-plugin-pwa` repository to your own GitHub account and then clone it to your local device.

2. Ensure using the latest Node.js (16.x)
2. Ensure using the latest Node.js (16.x), from version 0.16.0 `vite-plugin-pwa` requires Node.js 16.x.

3. `vite-plugin-pwa` uses pnpm v7. If you are working on multiple projects with different versions of pnpm, it's recommend to enable [Corepack](https://github.com/nodejs/corepack) by running `corepack enable`.
3. `vite-plugin-pwa` uses pnpm v8. If you are working on multiple projects with different versions of pnpm, it's recommend to enable [Corepack](https://github.com/nodejs/corepack) by running `corepack enable`.

4. Check out a branch where you can work and commit your changes:
```shell
@@ -38,10 +38,12 @@ The `vite-plugin-pwa` repo includes a set of examples where you can test the cha
> If your changes are specific to some behavior, just use the corresponding option on the `cli`.
## Testing website docs changes
## Running tests

Before running tests, you'll need to install [Playwright](https://playwright.dev/) Chromium browser: `pnpm playwright install chromium`.

`vite-plugin-pwa` uses `Vitepress` for the website docs, if your changes are about the documentation, you can find the website on the `docs` folder.
Run `pnpm run test` in root folder or inside each examples folder after build `vite-plugin-pwa`.

Once you made the changes to the documentation, you can test them running `pnpm run docs` from the root folder.
## Testing website docs changes

To check the website build, just run `pnpm run docs:serve` from the root folder.
`vite-plugin-pwa` docs website has been moved to [docs repository](https://github.com/vite-pwa/docs).
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Anthony Fu<https://github.com/antfu>
Copyright (c) 2020-PRESENT Anthony Fu <https://github.com/antfu>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align='center'>
<img src='https://vite-plugin-pwa.netlify.app/banner_light.svg' alt="vite-plugin-pwa - Zero-config PWA for Vite"><br>
<img src='https://vite-pwa-org.netlify.app/banner_light.svg' alt="vite-plugin-pwa - Zero-config PWA for Vite"><br>
Zero-config PWA Framework-agnostic Plugin for Vite
</p>

@@ -10,7 +10,7 @@ Zero-config PWA Framework-agnostic Plugin for Vite
<a href="https://www.npmjs.com/package/vite-plugin-pwa" target="__blank">
<img alt="NPM Downloads" src="https://img.shields.io/npm/dm/vite-plugin-pwa?color=476582&label=">
</a>
<a href="https://vite-plugin-pwa.netlify.app/" target="__blank">
<a href="https://vite-pwa-org.netlify.app/" target="__blank">
<img src="https://img.shields.io/static/v1?label=&message=docs%20%26%20guides&color=2e859c" alt="Docs & Guides">
</a>
<br>
@@ -30,7 +30,7 @@ Zero-config PWA Framework-agnostic Plugin for Vite

## 🚀 Features

- 📖 [**Documentation & guides**](https://vite-plugin-pwa.netlify.app/)
- 📖 [**Documentation & guides**](https://vite-pwa-org.netlify.app/)
- 👌 **Zero-Config**: sensible built-in default configs for common use cases
- 🔩 **Extensible**: expose the full ability to customize the behavior of the plugin
- 🦾 **Type Strong**: written in [TypeScript](https://www.typescriptlang.org/)
@@ -40,9 +40,14 @@ Zero-config PWA Framework-agnostic Plugin for Vite
- ⚙️ **Stale-while-revalidate**: automatic reload when new content is available
-**Static assets handling**: configure static assets for offline support
- 🐞 **Development Support**: debug your custom service worker logic as you develop your application
- 🛠️ **Versatile**: integration with meta frameworks: [îles](https://github.com/ElMassimo/iles), [SvelteKit](https://github.com/sveltejs/kit), [VitePress](https://github.com/vuejs/vitepress), [Astro](https://github.com/withastro/astro), and [Nuxt 3](https://github.com/nuxt/nuxt)

## 📦 Install

> From v0.13, `vite-plugin-pwa` requires **Vite 3.1 or above**.
> From v0.16 `vite-plugin-pwa` requires **Node 16 or above**: `workbox v7` requires **Node 16 or above**.
```bash
npm i vite-plugin-pwa -D

@@ -68,7 +73,7 @@ export default {
}
```

Read the [📖 documentation](https://vite-plugin-pwa.netlify.app/guide/) for a complete guide on how to configure and use
Read the [📖 documentation](https://vite-pwa-org.netlify.app/guide/) for a complete guide on how to configure and use
this plugin.

Check out the client type declarations [client.d.ts](./client.d.ts) for built-in frameworks support.
@@ -83,4 +88,4 @@ Check out the type declaration [src/types.ts](./src/types.ts) and the following

## 📄 License

MIT License © 2020-PRESENT [Anthony Fu](https://github.com/antfu)
[MIT](./LICENSE) License &copy; 2020-PRESENT [Anthony Fu](https://github.com/antfu)
195 changes: 6 additions & 189 deletions client.d.ts
Original file line number Diff line number Diff line change
@@ -1,189 +1,6 @@
declare module 'virtual:pwa-register' {
export interface RegisterSWOptions {
immediate?: boolean
onNeedRefresh?: () => void
onOfflineReady?: () => void
/**
* Called only if `onRegisteredSW` is not provided.
*
* @deprecated Use `onRegisteredSW` instead.
* @param registration The service worker registration if available.
*/
onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
/**
* Called once the service worker is registered (requires version `0.12.8+`).
*
* @param swScriptUrl The service worker script url.
* @param registration The service worker registration if available.
*/
onRegisteredSW?: (swScriptUrl: string, registration: ServiceWorkerRegistration | undefined) => void
onRegisterError?: (error: any) => void
}

export function registerSW(options?: RegisterSWOptions): (reloadPage?: boolean) => Promise<void>
}

declare module 'virtual:pwa-register/vue' {
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore ignore when vue is not installed
import type { Ref } from 'vue'

export interface RegisterSWOptions {
immediate?: boolean
onNeedRefresh?: () => void
onOfflineReady?: () => void
/**
* Called only if `onRegisteredSW` is not provided.
*
* @deprecated Use `onRegisteredSW` instead.
* @param registration The service worker registration if available.
*/
onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
/**
* Called once the service worker is registered (requires version `0.12.8+`).
*
* @param swScriptUrl The service worker script url.
* @param registration The service worker registration if available.
*/
onRegisteredSW?: (swScriptUrl: string, registration: ServiceWorkerRegistration | undefined) => void
onRegisterError?: (error: any) => void
}

export function useRegisterSW(options?: RegisterSWOptions): {
needRefresh: Ref<boolean>
offlineReady: Ref<boolean>
updateServiceWorker: (reloadPage?: boolean) => Promise<void>
}
}

declare module 'virtual:pwa-register/svelte' {
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore ignore when svelte is not installed
import type { Writable } from 'svelte/store'

export interface RegisterSWOptions {
immediate?: boolean
onNeedRefresh?: () => void
onOfflineReady?: () => void
/**
* Called only if `onRegisteredSW` is not provided.
*
* @deprecated Use `onRegisteredSW` instead.
* @param registration The service worker registration if available.
*/
onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
/**
* Called once the service worker is registered (requires version `0.12.8+`).
*
* @param swScriptUrl The service worker script url.
* @param registration The service worker registration if available.
*/
onRegisteredSW?: (swScriptUrl: string, registration: ServiceWorkerRegistration | undefined) => void
onRegisterError?: (error: any) => void
}

export function useRegisterSW(options?: RegisterSWOptions): {
needRefresh: Writable<boolean>
offlineReady: Writable<boolean>
updateServiceWorker: (reloadPage?: boolean) => Promise<void>
}
}

declare module 'virtual:pwa-register/react' {
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore ignore when react is not installed
import type { Dispatch, SetStateAction } from 'react'

export interface RegisterSWOptions {
immediate?: boolean
onNeedRefresh?: () => void
onOfflineReady?: () => void
/**
* Called only if `onRegisteredSW` is not provided.
*
* @deprecated Use `onRegisteredSW` instead.
* @param registration The service worker registration if available.
*/
onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
/**
* Called once the service worker is registered (requires version `0.12.8+`).
*
* @param swScriptUrl The service worker script url.
* @param registration The service worker registration if available.
*/
onRegisteredSW?: (swScriptUrl: string, registration: ServiceWorkerRegistration | undefined) => void
onRegisterError?: (error: any) => void
}

export function useRegisterSW(options?: RegisterSWOptions): {
needRefresh: [boolean, Dispatch<SetStateAction<boolean>>]
offlineReady: [boolean, Dispatch<SetStateAction<boolean>>]
updateServiceWorker: (reloadPage?: boolean) => Promise<void>
}
}

declare module 'virtual:pwa-register/solid' {
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore ignore when solid-js is not installed
import type { Accessor, Setter } from 'solid-js'

export interface RegisterSWOptions {
immediate?: boolean
onNeedRefresh?: () => void
onOfflineReady?: () => void
/**
* Called only if `onRegisteredSW` is not provided.
*
* @deprecated Use `onRegisteredSW` instead.
* @param registration The service worker registration if available.
*/
onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
/**
* Called once the service worker is registered (requires version `0.12.8+`).
*
* @param swScriptUrl The service worker script url.
* @param registration The service worker registration if available.
*/
onRegisteredSW?: (swScriptUrl: string, registration: ServiceWorkerRegistration | undefined) => void
onRegisterError?: (error: any) => void
}

export function useRegisterSW(options?: RegisterSWOptions): {
needRefresh: [Accessor<boolean>, Setter<boolean>]
offlineReady: [Accessor<boolean>, Setter<boolean>]
updateServiceWorker: (reloadPage?: boolean) => Promise<void>
}
}

declare module 'virtual:pwa-register/preact' {
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore ignore when preact/hooks is not installed
import type { StateUpdater } from 'preact/hooks'

export interface RegisterSWOptions {
immediate?: boolean
onNeedRefresh?: () => void
onOfflineReady?: () => void
/**
* Called only if `onRegisteredSW` is not provided.
*
* @deprecated Use `onRegisteredSW` instead.
* @param registration The service worker registration if available.
*/
onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
/**
* Called once the service worker is registered (requires version `0.12.8+`).
*
* @param swScriptUrl The service worker script url.
* @param registration The service worker registration if available.
*/
onRegisteredSW?: (swScriptUrl: string, registration: ServiceWorkerRegistration | undefined) => void
onRegisterError?: (error: any) => void
}

export function useRegisterSW(options?: RegisterSWOptions): {
needRefresh: [boolean, StateUpdater<boolean>]
offlineReady: [boolean, StateUpdater<boolean>]
updateServiceWorker: (reloadPage?: boolean) => Promise<void>
}
}
import './vue'
import './preact'
import './react'
import './svelte'
import './solid'
import './vanillajs'
5 changes: 2 additions & 3 deletions docs/.vitepress/components.d.ts
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'

export {}

declare module '@vue/runtime-core' {
export interface GlobalComponents {
CleanupOutdatedCaches: typeof import('./theme/components/CleanupOutdatedCaches.md')['default']
@@ -11,7 +13,6 @@ declare module '@vue/runtime-core' {
ExamplesInjectManifest: typeof import('./theme/components/ExamplesInjectManifest.md')['default']
GenerateSWCleanupOutdatedCaches: typeof import('./theme/components/GenerateSWCleanupOutdatedCaches.md')['default']
GenerateSWSourceMap: typeof import('./theme/components/GenerateSWSourceMap.md')['default']
HeuristicWorkboxWindow: typeof import('./theme/components/HeuristicWorkboxWindow.md')['default']
HomePage: typeof import('./theme/components/HomePage.vue')['default']
InjectManifestCleanupOutdatedCaches: typeof import('./theme/components/InjectManifestCleanupOutdatedCaches.md')['default']
InjectManifestSourceMap: typeof import('./theme/components/InjectManifestSourceMap.md')['default']
@@ -24,5 +25,3 @@ declare module '@vue/runtime-core' {
TypeScriptError2307: typeof import('./theme/components/TypeScriptError2307.md')['default']
}
}

export {}
12 changes: 10 additions & 2 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { defineConfig } from 'vitepress'
import { version } from '../../package.json'
import { pwa } from '../scripts/pwa'
import { buildEnd } from '../scripts/build'

const Guide = [
{
@@ -224,8 +226,8 @@ function prepareSidebar(idx: number) {
})
}

const ogUrl = 'https://vite-plugin-pwa.netlify.app/'
const ogImage = 'https://vite-plugin-pwa.netlify.app/og-image.png'
const ogUrl = 'https://vite-pwa-org.netlify.app/'
const ogImage = 'https://vite-pwa-org.netlify.app/og-image.png'

export default defineConfig({
lang: 'en-US',
@@ -328,4 +330,10 @@ export default defineConfig({
'/workbox/': prepareSidebar(4),
},
},
vite: {
plugins: [
pwa(),
],
},
buildEnd,
})
Loading