@docusaurus/plugin-pwa 0.0.0-4727 → 0.0.0-4731

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -49,7 +49,7 @@ function pluginPWA(context, options) {
49
49
  return '../src/theme';
50
50
  },
51
51
  getClientModules() {
52
- return isProd ? [swRegister] : [];
52
+ return isProd && swRegister ? [swRegister] : [];
53
53
  },
54
54
  getDefaultCodeTranslationMessages() {
55
55
  return (0, theme_translations_1.readDefaultCodeTranslationMessages)({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-pwa",
3
- "version": "0.0.0-4727",
3
+ "version": "0.0.0-4731",
4
4
  "description": "Docusaurus Plugin to add PWA support.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-pwa.d.ts",
@@ -22,11 +22,11 @@
22
22
  "dependencies": {
23
23
  "@babel/core": "^7.17.7",
24
24
  "@babel/preset-env": "^7.16.11",
25
- "@docusaurus/core": "0.0.0-4727",
26
- "@docusaurus/theme-common": "0.0.0-4727",
27
- "@docusaurus/theme-translations": "0.0.0-4727",
28
- "@docusaurus/utils": "0.0.0-4727",
29
- "@docusaurus/utils-validation": "0.0.0-4727",
25
+ "@docusaurus/core": "0.0.0-4731",
26
+ "@docusaurus/theme-common": "0.0.0-4731",
27
+ "@docusaurus/theme-translations": "0.0.0-4731",
28
+ "@docusaurus/utils": "0.0.0-4731",
29
+ "@docusaurus/utils-validation": "0.0.0-4731",
30
30
  "babel-loader": "^8.2.3",
31
31
  "clsx": "^1.1.1",
32
32
  "core-js": "^3.21.1",
@@ -39,12 +39,12 @@
39
39
  "workbox-window": "^6.5.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@docusaurus/module-type-aliases": "0.0.0-4727",
42
+ "@docusaurus/module-type-aliases": "0.0.0-4731",
43
43
  "fs-extra": "^10.0.1"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "react": "^16.8.4 || ^17.0.0",
47
47
  "react-dom": "^16.8.4 || ^17.0.0"
48
48
  },
49
- "gitHead": "967bfff81002933a1c68980300233e0320398e04"
49
+ "gitHead": "f3787c5cd81d0d934005814e3038d897f5ba58aa"
50
50
  }
package/src/index.ts CHANGED
@@ -71,7 +71,7 @@ export default function pluginPWA(
71
71
  },
72
72
 
73
73
  getClientModules() {
74
- return isProd ? [swRegister] : [];
74
+ return isProd && swRegister ? [swRegister] : [];
75
75
  },
76
76
 
77
77
  getDefaultCodeTranslationMessages() {
@@ -6,26 +6,90 @@
6
6
  */
7
7
 
8
8
  declare module '@docusaurus/plugin-pwa' {
9
- export type pwaHead = {
10
- tagName: string;
11
- href?: string;
12
- content?: string;
13
- [attributeName: string]: string | boolean;
14
- };
9
+ import type {InjectManifestOptions} from 'workbox-build';
15
10
 
16
11
  export type PluginOptions = {
12
+ /**
13
+ * Turn debug mode on:
14
+ *
15
+ * - Workbox logs
16
+ * - Additional Docusaurus logs
17
+ * - Unoptimized SW file output
18
+ * - Source maps
19
+ */
17
20
  debug?: boolean;
18
- offlineModeActivationStrategies;
19
- injectManifestConfig;
20
- reloadPopup;
21
- pwaHead: pwaHead[];
22
- swCustom;
23
- swRegister;
21
+ /**
22
+ * Strategies used to turn the offline mode on:
23
+ *
24
+ * - `appInstalled`: activates for users having installed the site as an app
25
+ * (not 100% reliable)
26
+ * - `standalone`: activates for users running the app as standalone (often
27
+ * the case once a PWA is installed)
28
+ * - `queryString`: activates if queryString contains `offlineMode=true`
29
+ * (convenient for PWA debugging)
30
+ * - `mobile`: activates for mobile users (width <= 940px)
31
+ * - `saveData`: activates for users with `navigator.connection.saveData ===
32
+ * true`
33
+ * - `always`: activates for all users
34
+ */
35
+ offlineModeActivationStrategies: (
36
+ | 'appInstalled'
37
+ | 'queryString'
38
+ | 'standalone'
39
+ | 'mobile'
40
+ | 'saveData'
41
+ | 'always'
42
+ )[];
43
+ /**
44
+ * Workbox options to pass to `workbox.injectManifest()`. This gives you
45
+ * control over which assets will be precached, and be available offline.
46
+ * @see https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-build#.injectManifest
47
+ */
48
+ injectManifestConfig: InjectManifestOptions;
49
+ /**
50
+ * Module path to reload popup component. This popup is rendered when a new
51
+ * service worker is waiting to be installed, and we suggest a reload to
52
+ * the user.
53
+ *
54
+ * Passing `false` will disable the popup, but this is not recommended:
55
+ * users won't have a way to get up-to-date content.
56
+ * @see {@link @theme/PwaReloadPopup}
57
+ */
58
+ reloadPopup: string | false;
59
+ /**
60
+ * Array of objects containing `tagName` and key-value pairs for attributes
61
+ * to inject into the `<head>` tag. Technically you can inject any head tag
62
+ * through this, but it's ideally used for tags to make your site PWA-
63
+ * compliant.
64
+ */
65
+ pwaHead: {
66
+ tagName: string;
67
+ href?: string;
68
+ content?: string;
69
+ [attributeName: string]: string | boolean;
70
+ }[];
71
+ /**
72
+ * Useful for additional Workbox rules. You can do whatever a service worker
73
+ * can do here, and use the full power of workbox libraries. The code is
74
+ * transpiled, so you can use modern ES6+ syntax here.
75
+ */
76
+ swCustom?: string;
77
+ /**
78
+ * Adds an entry before the Docusaurus app so that registration can happen
79
+ * before the app runs. The default `registerSW.js` file is enough for
80
+ * simple registration. Passing `false` will disable registration entirely.
81
+ */
82
+ swRegister: string | false;
24
83
  };
25
84
  }
26
85
 
27
86
  declare module '@theme/PwaReloadPopup' {
28
87
  export interface Props {
88
+ /**
89
+ * The popup should call this callback when the `reload` button is clicked.
90
+ * This will tell the service worker to install the waiting service worker
91
+ * and reload the page.
92
+ */
29
93
  readonly onReload: () => void;
30
94
  }
31
95
  export default function PwaReloadPopup(props: Props): JSX.Element;