@docusaurus/plugin-pwa 0.0.0-5066 → 0.0.0-5069

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
@@ -39,7 +39,7 @@ function getSWBabelLoader() {
39
39
  }
40
40
  function pluginPWA(context, options) {
41
41
  const { outDir, baseUrl, i18n: { currentLocale }, } = context;
42
- const { debug, offlineModeActivationStrategies, injectManifestConfig, reloadPopup, pwaHead, swCustom, swRegister, } = options;
42
+ const { debug, offlineModeActivationStrategies, injectManifestConfig, pwaHead, swCustom, swRegister, } = options;
43
43
  return {
44
44
  name: 'docusaurus-plugin-pwa',
45
45
  getThemePath() {
@@ -67,7 +67,6 @@ function pluginPWA(context, options) {
67
67
  PWA_DEBUG: debug,
68
68
  PWA_SERVICE_WORKER_URL: path_1.default.posix.resolve(`${config.output?.publicPath || '/'}`, 'sw.js'),
69
69
  PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES: offlineModeActivationStrategies,
70
- PWA_RELOAD_POPUP: reloadPopup,
71
70
  }),
72
71
  ],
73
72
  };
package/lib/options.js CHANGED
@@ -19,7 +19,6 @@ const DEFAULT_OPTIONS = {
19
19
  pwaHead: [],
20
20
  swCustom: undefined,
21
21
  swRegister: './registerSw.js',
22
- reloadPopup: '@theme/PwaReloadPopup',
23
22
  };
24
23
  const optionsSchema = utils_validation_1.Joi.object({
25
24
  debug: utils_validation_1.Joi.bool().default(DEFAULT_OPTIONS.debug),
@@ -36,9 +35,10 @@ const optionsSchema = utils_validation_1.Joi.object({
36
35
  swRegister: utils_validation_1.Joi.alternatives()
37
36
  .try(utils_validation_1.Joi.string(), utils_validation_1.Joi.bool().valid(false))
38
37
  .default(DEFAULT_OPTIONS.swRegister),
39
- reloadPopup: utils_validation_1.Joi.alternatives()
40
- .try(utils_validation_1.Joi.string(), utils_validation_1.Joi.bool().valid(false))
41
- .default(DEFAULT_OPTIONS.reloadPopup),
38
+ // @ts-expect-error: forbidden
39
+ reloadPopup: utils_validation_1.Joi.any().forbidden().messages({
40
+ 'any.unknown': 'The reloadPopup option is removed in favor of swizzling. See https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-pwa#customizing-reload-popup for how to customize the reload popup using swizzling.',
41
+ }),
42
42
  });
43
43
  function validateOptions({ validate, options, }) {
44
44
  return validate(optionsSchema, options);
package/lib/registerSw.js CHANGED
@@ -8,7 +8,6 @@ import { createStorageSlot } from '@docusaurus/theme-common';
8
8
  // First: read the env variables (provided by Webpack)
9
9
  /* eslint-disable prefer-destructuring */
10
10
  const PWA_SERVICE_WORKER_URL = process.env.PWA_SERVICE_WORKER_URL;
11
- const PWA_RELOAD_POPUP = process.env.PWA_RELOAD_POPUP;
12
11
  const PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES = process.env
13
12
  .PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES;
14
13
  const PWA_DEBUG = process.env.PWA_DEBUG;
@@ -119,7 +118,7 @@ async function registerSW() {
119
118
  if (!offlineMode) {
120
119
  sendSkipWaiting();
121
120
  }
122
- else if (PWA_RELOAD_POPUP) {
121
+ else {
123
122
  const renderReloadPopup = (await import('./renderReloadPopup')).default;
124
123
  await renderReloadPopup({
125
124
  onReload() {
@@ -4,6 +4,5 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- export default function renderReloadPopup(props: {
8
- onReload: () => void;
9
- }): Promise<void>;
7
+ import type { Props } from '@theme/PwaReloadPopup';
8
+ export default function renderReloadPopup(props: Props): Promise<void>;
@@ -16,6 +16,6 @@ const createContainer = () => {
16
16
  };
17
17
  export default async function renderReloadPopup(props) {
18
18
  const container = getContainer() || createContainer();
19
- const { default: ReloadPopup } = await import(process.env.PWA_RELOAD_POPUP);
19
+ const ReloadPopup = (await import('@theme/PwaReloadPopup')).default;
20
20
  ReactDOM.render(<ReloadPopup {...props}/>, container);
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-pwa",
3
- "version": "0.0.0-5066",
3
+ "version": "0.0.0-5069",
4
4
  "description": "Docusaurus Plugin to add PWA support.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-pwa.d.ts",
@@ -20,16 +20,16 @@
20
20
  },
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@babel/core": "^7.18.0",
24
- "@babel/preset-env": "^7.18.0",
25
- "@docusaurus/core": "0.0.0-5066",
26
- "@docusaurus/theme-common": "0.0.0-5066",
27
- "@docusaurus/theme-translations": "0.0.0-5066",
28
- "@docusaurus/utils": "0.0.0-5066",
29
- "@docusaurus/utils-validation": "0.0.0-5066",
23
+ "@babel/core": "^7.18.2",
24
+ "@babel/preset-env": "^7.18.2",
25
+ "@docusaurus/core": "0.0.0-5069",
26
+ "@docusaurus/theme-common": "0.0.0-5069",
27
+ "@docusaurus/theme-translations": "0.0.0-5069",
28
+ "@docusaurus/utils": "0.0.0-5069",
29
+ "@docusaurus/utils-validation": "0.0.0-5069",
30
30
  "babel-loader": "^8.2.5",
31
31
  "clsx": "^1.1.1",
32
- "core-js": "^3.22.5",
32
+ "core-js": "^3.22.7",
33
33
  "terser-webpack-plugin": "^5.3.1",
34
34
  "tslib": "^2.4.0",
35
35
  "webpack": "^5.72.1",
@@ -39,7 +39,7 @@
39
39
  "workbox-window": "^6.5.3"
40
40
  },
41
41
  "devDependencies": {
42
- "@docusaurus/module-type-aliases": "0.0.0-5066",
42
+ "@docusaurus/module-type-aliases": "0.0.0-5069",
43
43
  "fs-extra": "^10.1.0"
44
44
  },
45
45
  "peerDependencies": {
@@ -49,5 +49,5 @@
49
49
  "engines": {
50
50
  "node": ">=16.14"
51
51
  },
52
- "gitHead": "441e77f61991faa76e06efbc4bd0be7332055945"
52
+ "gitHead": "36ac2dff36395edb2f26a90bd6456bf0d7926279"
53
53
  }
package/src/index.ts CHANGED
@@ -52,7 +52,6 @@ export default function pluginPWA(
52
52
  debug,
53
53
  offlineModeActivationStrategies,
54
54
  injectManifestConfig,
55
- reloadPopup,
56
55
  pwaHead,
57
56
  swCustom,
58
57
  swRegister,
@@ -94,7 +93,6 @@ export default function pluginPWA(
94
93
  ),
95
94
  PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES:
96
95
  offlineModeActivationStrategies,
97
- PWA_RELOAD_POPUP: reloadPopup,
98
96
  }),
99
97
  ],
100
98
  };
package/src/options.ts CHANGED
@@ -20,7 +20,6 @@ const DEFAULT_OPTIONS = {
20
20
  pwaHead: [],
21
21
  swCustom: undefined,
22
22
  swRegister: './registerSw.js',
23
- reloadPopup: '@theme/PwaReloadPopup',
24
23
  };
25
24
 
26
25
  const optionsSchema = Joi.object<PluginOptions>({
@@ -49,9 +48,11 @@ const optionsSchema = Joi.object<PluginOptions>({
49
48
  swRegister: Joi.alternatives()
50
49
  .try(Joi.string(), Joi.bool().valid(false))
51
50
  .default(DEFAULT_OPTIONS.swRegister),
52
- reloadPopup: Joi.alternatives()
53
- .try(Joi.string(), Joi.bool().valid(false))
54
- .default(DEFAULT_OPTIONS.reloadPopup),
51
+ // @ts-expect-error: forbidden
52
+ reloadPopup: Joi.any().forbidden().messages({
53
+ 'any.unknown':
54
+ 'The reloadPopup option is removed in favor of swizzling. See https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-pwa#customizing-reload-popup for how to customize the reload popup using swizzling.',
55
+ }),
55
56
  });
56
57
 
57
58
  export function validateOptions({
@@ -46,16 +46,6 @@ declare module '@docusaurus/plugin-pwa' {
46
46
  * @see https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-build#.injectManifest
47
47
  */
48
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
49
  /**
60
50
  * Array of objects containing `tagName` and key-value pairs for attributes
61
51
  * to inject into the `<head>` tag. Technically you can inject any head tag
package/src/registerSw.ts CHANGED
@@ -10,7 +10,6 @@ import {createStorageSlot} from '@docusaurus/theme-common';
10
10
  // First: read the env variables (provided by Webpack)
11
11
  /* eslint-disable prefer-destructuring */
12
12
  const PWA_SERVICE_WORKER_URL = process.env.PWA_SERVICE_WORKER_URL!;
13
- const PWA_RELOAD_POPUP = process.env.PWA_RELOAD_POPUP;
14
13
  const PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES = process.env
15
14
  .PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES as unknown as (keyof typeof OfflineModeActivationStrategiesImplementations)[];
16
15
  const PWA_DEBUG = process.env.PWA_DEBUG;
@@ -170,7 +169,7 @@ async function registerSW() {
170
169
  // Immediately load new service worker when files aren't cached
171
170
  if (!offlineMode) {
172
171
  sendSkipWaiting();
173
- } else if (PWA_RELOAD_POPUP) {
172
+ } else {
174
173
  const renderReloadPopup = (await import('./renderReloadPopup')).default;
175
174
  await renderReloadPopup({
176
175
  onReload() {
@@ -7,6 +7,7 @@
7
7
 
8
8
  import React from 'react';
9
9
  import ReactDOM from 'react-dom';
10
+ import type {Props} from '@theme/PwaReloadPopup';
10
11
 
11
12
  const POPUP_CONTAINER_ID = 'pwa-popup-container';
12
13
 
@@ -19,10 +20,8 @@ const createContainer = () => {
19
20
  return container;
20
21
  };
21
22
 
22
- export default async function renderReloadPopup(props: {
23
- onReload: () => void;
24
- }): Promise<void> {
23
+ export default async function renderReloadPopup(props: Props): Promise<void> {
25
24
  const container = getContainer() || createContainer();
26
- const {default: ReloadPopup} = await import(process.env.PWA_RELOAD_POPUP!);
25
+ const ReloadPopup = (await import('@theme/PwaReloadPopup')).default;
27
26
  ReactDOM.render(<ReloadPopup {...props} />, container);
28
27
  }