@docusaurus/plugin-pwa 2.0.0-beta.15 → 2.0.0-beta.16

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.d.ts CHANGED
@@ -6,5 +6,5 @@
6
6
  */
7
7
  import type { LoadContext, Plugin } from '@docusaurus/types';
8
8
  import type { PluginOptions } from '@docusaurus/plugin-pwa';
9
- export default function (context: LoadContext, options: PluginOptions): Plugin<void>;
9
+ export default function pluginPWA(context: LoadContext, options: PluginOptions): Plugin<void>;
10
10
  export { validateOptions } from './options';
package/lib/index.js CHANGED
@@ -34,21 +34,19 @@ function getSWBabelLoader() {
34
34
  },
35
35
  ],
36
36
  ],
37
- plugins: [
38
- require.resolve('@babel/plugin-proposal-object-rest-spread'),
39
- require.resolve('@babel/plugin-proposal-optional-chaining'),
40
- require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'),
41
- ],
42
37
  },
43
38
  };
44
39
  }
45
- function default_1(context, options) {
40
+ function pluginPWA(context, options) {
46
41
  const { outDir, baseUrl, i18n: { currentLocale }, } = context;
47
42
  const { debug, offlineModeActivationStrategies, injectManifestConfig, reloadPopup, pwaHead, swCustom, swRegister, } = options;
48
43
  return {
49
44
  name: 'docusaurus-plugin-pwa',
50
45
  getThemePath() {
51
- return path_1.default.resolve(__dirname, './theme');
46
+ return path_1.default.resolve(__dirname, '../lib/theme');
47
+ },
48
+ getTypeScriptThemePath() {
49
+ return path_1.default.resolve(__dirname, '../src/theme');
52
50
  },
53
51
  getClientModules() {
54
52
  return isProd ? [swRegister] : [];
@@ -137,7 +135,7 @@ function default_1(context, options) {
137
135
  rules: [
138
136
  {
139
137
  test: swSourceFileTest,
140
- exclude: /(node_modules)/,
138
+ exclude: /node_modules/,
141
139
  use: getSWBabelLoader(),
142
140
  },
143
141
  ],
@@ -163,6 +161,6 @@ function default_1(context, options) {
163
161
  },
164
162
  };
165
163
  }
166
- exports.default = default_1;
164
+ exports.default = pluginPWA;
167
165
  var options_1 = require("./options");
168
166
  Object.defineProperty(exports, "validateOptions", { enumerable: true, get: function () { return options_1.validateOptions; } });
package/lib/registerSw.js CHANGED
@@ -219,8 +219,8 @@ async function registerSW() {
219
219
  }
220
220
  }
221
221
 
222
- // TODO these events still works in chrome but have been removed from the spec in 2019!
223
- // See https://github.com/w3c/manifest/pull/836
222
+ // TODO these events still works in chrome but have been removed from the spec
223
+ // in 2019! See https://github.com/w3c/manifest/pull/836
224
224
  function addLegacyAppInstalledEventsListeners() {
225
225
  if (typeof window !== 'undefined') {
226
226
  if (debug) {
@@ -248,7 +248,8 @@ function addLegacyAppInstalledEventsListeners() {
248
248
  await clearRegistrations();
249
249
  });
250
250
 
251
- // TODO this event still works in chrome but has been removed from the spec in 2019!!!
251
+ // TODO this event still works in chrome but has been removed from the spec
252
+ // in 2019!!!
252
253
  window.addEventListener('beforeinstallprompt', async (event) => {
253
254
  if (debug) {
254
255
  console.log(
@@ -256,7 +257,8 @@ function addLegacyAppInstalledEventsListeners() {
256
257
  event,
257
258
  );
258
259
  }
259
- // TODO instead of default browser install UI, show custom docusaurus prompt?
260
+ // TODO instead of default browser install UI, show custom docusaurus
261
+ // prompt?
260
262
  // event.preventDefault();
261
263
  if (debug) {
262
264
  console.log(
@@ -273,7 +275,7 @@ function addLegacyAppInstalledEventsListeners() {
273
275
  }
274
276
  // After uninstalling the app, if the user doesn't clear all data, then
275
277
  // the previous service worker will continue serving cached files. We
276
- // need to clear registrations and reload, otherwise the popup will show.
278
+ // need to clear registrations and reload, otherwise the popup shows.
277
279
  await clearRegistrations();
278
280
  }
279
281
  });
package/lib/sw.js CHANGED
@@ -18,10 +18,10 @@ function parseSwParams() {
18
18
  return params;
19
19
  }
20
20
 
21
- // doc advise against dynamic imports in SW
21
+ // doc advises against dynamic imports in SW
22
22
  // https://developers.google.com/web/tools/workbox/guides/using-bundlers#code_splitting_and_dynamic_imports
23
23
  // https://twitter.com/sebastienlorber/status/1280155204575518720
24
- // but I think it's working fine as it's inlined by webpack, need to double check?
24
+ // but looks it's working fine as it's inlined by webpack, need to double check
25
25
  async function runSWCustomCode(params) {
26
26
  if (process.env.PWA_SW_CUSTOM) {
27
27
  const customSW = await import(process.env.PWA_SW_CUSTOM);
@@ -70,6 +70,7 @@ function getPossibleURLs(url) {
70
70
  (async () => {
71
71
  const params = parseSwParams();
72
72
 
73
+ // eslint-disable-next-line no-underscore-dangle
73
74
  const precacheManifest = self.__WB_MANIFEST;
74
75
  const controller = new PrecacheController({
75
76
  fallbackToNetwork: true, // safer to turn this true?
@@ -5,6 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  /// <reference types="react" />
8
- import type { PwaReloadPopupProps } from '@theme/PwaReloadPopup';
9
- declare function PwaReloadPopup({ onReload }: PwaReloadPopupProps): JSX.Element | false;
10
- export default PwaReloadPopup;
8
+ import type { Props } from '@theme/PwaReloadPopup';
9
+ export default function PwaReloadPopup({ onReload }: Props): JSX.Element | false;
@@ -8,7 +8,7 @@ import React, { useState } from 'react';
8
8
  import clsx from 'clsx';
9
9
  import Translate, { translate } from '@docusaurus/Translate';
10
10
  import styles from './styles.module.css';
11
- function PwaReloadPopup({ onReload }) {
11
+ export default function PwaReloadPopup({ onReload }) {
12
12
  const [isVisible, setIsVisible] = useState(true);
13
13
  return (isVisible && (<div className={clsx('alert', 'alert--secondary', styles.popup)}>
14
14
  <p>
@@ -36,4 +36,3 @@ function PwaReloadPopup({ onReload }) {
36
36
  </div>
37
37
  </div>));
38
38
  }
39
- export default PwaReloadPopup;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-pwa",
3
- "version": "2.0.0-beta.15",
3
+ "version": "2.0.0-beta.16",
4
4
  "description": "Docusaurus Plugin to add PWA support.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-pwa.d.ts",
@@ -20,33 +20,31 @@
20
20
  },
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
24
- "@babel/plugin-proposal-optional-chaining": "^7.16.0",
25
- "@babel/preset-env": "^7.16.4",
26
- "@docusaurus/core": "2.0.0-beta.15",
27
- "@docusaurus/theme-common": "2.0.0-beta.15",
28
- "@docusaurus/theme-translations": "2.0.0-beta.15",
29
- "@docusaurus/utils": "2.0.0-beta.15",
30
- "@docusaurus/utils-validation": "2.0.0-beta.15",
31
- "babel-loader": "^8.2.2",
23
+ "@babel/core": "^7.17.5",
24
+ "@babel/preset-env": "^7.16.11",
25
+ "@docusaurus/core": "2.0.0-beta.16",
26
+ "@docusaurus/theme-common": "2.0.0-beta.16",
27
+ "@docusaurus/theme-translations": "2.0.0-beta.16",
28
+ "@docusaurus/utils": "2.0.0-beta.16",
29
+ "@docusaurus/utils-validation": "2.0.0-beta.16",
30
+ "babel-loader": "^8.2.3",
32
31
  "clsx": "^1.1.1",
33
- "core-js": "^3.18.0",
34
- "terser-webpack-plugin": "^5.2.4",
32
+ "core-js": "^3.21.0",
33
+ "terser-webpack-plugin": "^5.3.1",
35
34
  "tslib": "^2.3.1",
36
- "webpack": "^5.61.0",
37
- "webpack-merge": "^5.7.3",
38
- "workbox-build": "^6.1.1",
39
- "workbox-precaching": "^6.1.1",
40
- "workbox-window": "^6.1.1"
35
+ "webpack": "^5.69.1",
36
+ "webpack-merge": "^5.8.0",
37
+ "workbox-build": "^6.5.0",
38
+ "workbox-precaching": "^6.5.0",
39
+ "workbox-window": "^6.5.0"
41
40
  },
42
41
  "devDependencies": {
43
- "@docusaurus/module-type-aliases": "2.0.0-beta.15",
44
- "fs-extra": "^10.0.0"
42
+ "@docusaurus/module-type-aliases": "2.0.0-beta.16",
43
+ "fs-extra": "^10.0.1"
45
44
  },
46
45
  "peerDependencies": {
47
- "@babel/core": "^7.0.0",
48
46
  "react": "^16.8.4 || ^17.0.0",
49
47
  "react-dom": "^16.8.4 || ^17.0.0"
50
48
  },
51
- "gitHead": "6cfad16436c07d8d11e5c2e1486dc59afd483e33"
49
+ "gitHead": "eb43c4d4f95a4fb97dc9bb9dc615413e0dc2e1e7"
52
50
  }
package/src/index.ts CHANGED
@@ -37,16 +37,11 @@ function getSWBabelLoader() {
37
37
  },
38
38
  ],
39
39
  ],
40
- plugins: [
41
- require.resolve('@babel/plugin-proposal-object-rest-spread'),
42
- require.resolve('@babel/plugin-proposal-optional-chaining'),
43
- require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'),
44
- ],
45
40
  },
46
41
  };
47
42
  }
48
43
 
49
- export default function (
44
+ export default function pluginPWA(
50
45
  context: LoadContext,
51
46
  options: PluginOptions,
52
47
  ): Plugin<void> {
@@ -69,7 +64,10 @@ export default function (
69
64
  name: 'docusaurus-plugin-pwa',
70
65
 
71
66
  getThemePath() {
72
- return path.resolve(__dirname, './theme');
67
+ return path.resolve(__dirname, '../lib/theme');
68
+ },
69
+ getTypeScriptThemePath() {
70
+ return path.resolve(__dirname, '../src/theme');
73
71
  },
74
72
 
75
73
  getClientModules() {
@@ -174,7 +172,7 @@ export default function (
174
172
  rules: [
175
173
  {
176
174
  test: swSourceFileTest,
177
- exclude: /(node_modules)/,
175
+ exclude: /node_modules/,
178
176
  use: getSWBabelLoader(),
179
177
  },
180
178
  ],
@@ -25,10 +25,8 @@ declare module '@docusaurus/plugin-pwa' {
25
25
  }
26
26
 
27
27
  declare module '@theme/PwaReloadPopup' {
28
- export type PwaReloadPopupProps = {
28
+ export interface Props {
29
29
  readonly onReload: () => void;
30
- };
31
-
32
- const PwaReloadPopup: (props: PwaReloadPopupProps) => JSX.Element;
33
- export default PwaReloadPopup;
30
+ }
31
+ export default function PwaReloadPopup(props: Props): JSX.Element;
34
32
  }
package/src/registerSw.js CHANGED
@@ -219,8 +219,8 @@ async function registerSW() {
219
219
  }
220
220
  }
221
221
 
222
- // TODO these events still works in chrome but have been removed from the spec in 2019!
223
- // See https://github.com/w3c/manifest/pull/836
222
+ // TODO these events still works in chrome but have been removed from the spec
223
+ // in 2019! See https://github.com/w3c/manifest/pull/836
224
224
  function addLegacyAppInstalledEventsListeners() {
225
225
  if (typeof window !== 'undefined') {
226
226
  if (debug) {
@@ -248,7 +248,8 @@ function addLegacyAppInstalledEventsListeners() {
248
248
  await clearRegistrations();
249
249
  });
250
250
 
251
- // TODO this event still works in chrome but has been removed from the spec in 2019!!!
251
+ // TODO this event still works in chrome but has been removed from the spec
252
+ // in 2019!!!
252
253
  window.addEventListener('beforeinstallprompt', async (event) => {
253
254
  if (debug) {
254
255
  console.log(
@@ -256,7 +257,8 @@ function addLegacyAppInstalledEventsListeners() {
256
257
  event,
257
258
  );
258
259
  }
259
- // TODO instead of default browser install UI, show custom docusaurus prompt?
260
+ // TODO instead of default browser install UI, show custom docusaurus
261
+ // prompt?
260
262
  // event.preventDefault();
261
263
  if (debug) {
262
264
  console.log(
@@ -273,7 +275,7 @@ function addLegacyAppInstalledEventsListeners() {
273
275
  }
274
276
  // After uninstalling the app, if the user doesn't clear all data, then
275
277
  // the previous service worker will continue serving cached files. We
276
- // need to clear registrations and reload, otherwise the popup will show.
278
+ // need to clear registrations and reload, otherwise the popup shows.
277
279
  await clearRegistrations();
278
280
  }
279
281
  });
package/src/sw.js CHANGED
@@ -18,10 +18,10 @@ function parseSwParams() {
18
18
  return params;
19
19
  }
20
20
 
21
- // doc advise against dynamic imports in SW
21
+ // doc advises against dynamic imports in SW
22
22
  // https://developers.google.com/web/tools/workbox/guides/using-bundlers#code_splitting_and_dynamic_imports
23
23
  // https://twitter.com/sebastienlorber/status/1280155204575518720
24
- // but I think it's working fine as it's inlined by webpack, need to double check?
24
+ // but looks it's working fine as it's inlined by webpack, need to double check
25
25
  async function runSWCustomCode(params) {
26
26
  if (process.env.PWA_SW_CUSTOM) {
27
27
  const customSW = await import(process.env.PWA_SW_CUSTOM);
@@ -70,6 +70,7 @@ function getPossibleURLs(url) {
70
70
  (async () => {
71
71
  const params = parseSwParams();
72
72
 
73
+ // eslint-disable-next-line no-underscore-dangle
73
74
  const precacheManifest = self.__WB_MANIFEST;
74
75
  const controller = new PrecacheController({
75
76
  fallbackToNetwork: true, // safer to turn this true?
@@ -9,11 +9,11 @@ import React, {useState} from 'react';
9
9
  import clsx from 'clsx';
10
10
  import Translate, {translate} from '@docusaurus/Translate';
11
11
 
12
- import type {PwaReloadPopupProps} from '@theme/PwaReloadPopup';
12
+ import type {Props} from '@theme/PwaReloadPopup';
13
13
 
14
14
  import styles from './styles.module.css';
15
15
 
16
- function PwaReloadPopup({onReload}: PwaReloadPopupProps): JSX.Element | false {
16
+ export default function PwaReloadPopup({onReload}: Props): JSX.Element | false {
17
17
  const [isVisible, setIsVisible] = useState(true);
18
18
 
19
19
  return (
@@ -58,5 +58,3 @@ function PwaReloadPopup({onReload}: PwaReloadPopupProps): JSX.Element | false {
58
58
  )
59
59
  );
60
60
  }
61
-
62
- export default PwaReloadPopup;