@docusaurus/plugin-pwa 0.0.0-5044 → 0.0.0-5049

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
@@ -74,7 +74,7 @@ function pluginPWA(context, options) {
74
74
  },
75
75
  injectHtmlTags() {
76
76
  const headTags = [];
77
- if (isProd && pwaHead) {
77
+ if (isProd) {
78
78
  pwaHead.forEach(({ tagName, ...attributes }) => {
79
79
  ['href', 'content'].forEach((attribute) => {
80
80
  const attributeValue = attributes[attribute];
@@ -124,7 +124,7 @@ function pluginPWA(context, options) {
124
124
  plugins: [
125
125
  new webpack_1.default.EnvironmentPlugin({
126
126
  // Fallback value required with Webpack 5
127
- PWA_SW_CUSTOM: swCustom || '',
127
+ PWA_SW_CUSTOM: swCustom ?? '',
128
128
  }),
129
129
  new LogPlugin_1.default({
130
130
  name: 'Service Worker',
package/lib/options.js CHANGED
@@ -21,7 +21,7 @@ const DEFAULT_OPTIONS = {
21
21
  swRegister: './registerSw.js',
22
22
  reloadPopup: '@theme/PwaReloadPopup',
23
23
  };
24
- const Schema = utils_validation_1.Joi.object({
24
+ const optionsSchema = utils_validation_1.Joi.object({
25
25
  debug: utils_validation_1.Joi.bool().default(DEFAULT_OPTIONS.debug),
26
26
  offlineModeActivationStrategies: utils_validation_1.Joi.array()
27
27
  .items(utils_validation_1.Joi.string()
@@ -41,6 +41,6 @@ const Schema = utils_validation_1.Joi.object({
41
41
  .default(DEFAULT_OPTIONS.reloadPopup),
42
42
  });
43
43
  function validateOptions({ validate, options, }) {
44
- return validate(Schema, options);
44
+ return validate(optionsSchema, options);
45
45
  }
46
46
  exports.validateOptions = validateOptions;
@@ -9,7 +9,7 @@ declare global {
9
9
  getInstalledRelatedApps: () => Promise<{
10
10
  platform: string;
11
11
  }[]>;
12
- connection: {
12
+ connection?: {
13
13
  effectiveType: string;
14
14
  saveData: boolean;
15
15
  };
package/lib/registerSw.js CHANGED
@@ -22,7 +22,7 @@ async function clearRegistrations() {
22
22
  console.log(`[Docusaurus-PWA][registerSw]: will unregister all service worker registrations`, registrations);
23
23
  }
24
24
  await Promise.all(registrations.map(async (registration) => {
25
- const result = await registration?.unregister();
25
+ const result = await registration.unregister();
26
26
  if (debug) {
27
27
  console.log(`[Docusaurus-PWA][registerSw]: unregister() service worker registration`, registrations, result);
28
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-pwa",
3
- "version": "0.0.0-5044",
3
+ "version": "0.0.0-5049",
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.18.0",
24
24
  "@babel/preset-env": "^7.18.0",
25
- "@docusaurus/core": "0.0.0-5044",
26
- "@docusaurus/theme-common": "0.0.0-5044",
27
- "@docusaurus/theme-translations": "0.0.0-5044",
28
- "@docusaurus/utils": "0.0.0-5044",
29
- "@docusaurus/utils-validation": "0.0.0-5044",
25
+ "@docusaurus/core": "0.0.0-5049",
26
+ "@docusaurus/theme-common": "0.0.0-5049",
27
+ "@docusaurus/theme-translations": "0.0.0-5049",
28
+ "@docusaurus/utils": "0.0.0-5049",
29
+ "@docusaurus/utils-validation": "0.0.0-5049",
30
30
  "babel-loader": "^8.2.5",
31
31
  "clsx": "^1.1.1",
32
32
  "core-js": "^3.22.5",
@@ -39,12 +39,12 @@
39
39
  "workbox-window": "^6.5.3"
40
40
  },
41
41
  "devDependencies": {
42
- "@docusaurus/module-type-aliases": "0.0.0-5044",
42
+ "@docusaurus/module-type-aliases": "0.0.0-5049",
43
43
  "fs-extra": "^10.1.0"
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": "9ffd6ca265dc2af7ed5b96daf5ebf32708e899cf"
49
+ "gitHead": "527b2a01c46b67483327a1a6873fccf81bc19e2c"
50
50
  }
package/src/index.ts CHANGED
@@ -89,7 +89,7 @@ export default function pluginPWA(
89
89
  new webpack.EnvironmentPlugin({
90
90
  PWA_DEBUG: debug,
91
91
  PWA_SERVICE_WORKER_URL: path.posix.resolve(
92
- `${config.output?.publicPath || '/'}`,
92
+ `${(config.output?.publicPath as string) || '/'}`,
93
93
  'sw.js',
94
94
  ),
95
95
  PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES:
@@ -102,7 +102,7 @@ export default function pluginPWA(
102
102
 
103
103
  injectHtmlTags() {
104
104
  const headTags: HtmlTags = [];
105
- if (isProd && pwaHead) {
105
+ if (isProd) {
106
106
  pwaHead.forEach(({tagName, ...attributes}) => {
107
107
  (['href', 'content'] as const).forEach((attribute) => {
108
108
  const attributeValue = attributes[attribute];
@@ -160,7 +160,7 @@ export default function pluginPWA(
160
160
  plugins: [
161
161
  new webpack.EnvironmentPlugin({
162
162
  // Fallback value required with Webpack 5
163
- PWA_SW_CUSTOM: swCustom || '',
163
+ PWA_SW_CUSTOM: swCustom ?? '',
164
164
  }),
165
165
  new LogPlugin({
166
166
  name: 'Service Worker',
@@ -189,7 +189,7 @@ export default function pluginPWA(
189
189
  '**/*.{png,jpg,jpeg,gif,svg,ico}',
190
190
  '**/*.{woff,woff2,eot,ttf,otf}',
191
191
  // @ts-expect-error: internal API?
192
- ...(injectManifest.globPatterns ?? []),
192
+ ...((injectManifest.globPatterns as string[] | undefined) ?? []),
193
193
  ],
194
194
  // Those attributes are not overrideable
195
195
  swDest,
package/src/options.ts CHANGED
@@ -23,7 +23,7 @@ const DEFAULT_OPTIONS = {
23
23
  reloadPopup: '@theme/PwaReloadPopup',
24
24
  };
25
25
 
26
- const Schema = Joi.object({
26
+ const optionsSchema = Joi.object<PluginOptions>({
27
27
  debug: Joi.bool().default(DEFAULT_OPTIONS.debug),
28
28
  offlineModeActivationStrategies: Joi.array()
29
29
  .items(
@@ -58,5 +58,5 @@ export function validateOptions({
58
58
  validate,
59
59
  options,
60
60
  }: OptionValidationContext<PluginOptions, PluginOptions>): PluginOptions {
61
- return validate(Schema, options);
61
+ return validate(optionsSchema, options);
62
62
  }
package/src/registerSw.ts CHANGED
@@ -9,7 +9,7 @@ import {createStorageSlot} from '@docusaurus/theme-common';
9
9
 
10
10
  // First: read the env variables (provided by Webpack)
11
11
  /* eslint-disable prefer-destructuring */
12
- const PWA_SERVICE_WORKER_URL = process.env.PWA_SERVICE_WORKER_URL;
12
+ const PWA_SERVICE_WORKER_URL = process.env.PWA_SERVICE_WORKER_URL!;
13
13
  const PWA_RELOAD_POPUP = process.env.PWA_RELOAD_POPUP;
14
14
  const PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES = process.env
15
15
  .PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES as unknown as (keyof typeof OfflineModeActivationStrategiesImplementations)[];
@@ -34,7 +34,7 @@ async function clearRegistrations() {
34
34
  }
35
35
  await Promise.all(
36
36
  registrations.map(async (registration) => {
37
- const result = await registration?.unregister();
37
+ const result = await registration.unregister();
38
38
  if (debug) {
39
39
  console.log(
40
40
  `[Docusaurus-PWA][registerSw]: unregister() service worker registration`,
@@ -69,7 +69,7 @@ async function isAppInstalledEventFired() {
69
69
  declare global {
70
70
  interface Navigator {
71
71
  getInstalledRelatedApps: () => Promise<{platform: string}[]>;
72
- connection: {effectiveType: string; saveData: boolean};
72
+ connection?: {effectiveType: string; saveData: boolean};
73
73
  }
74
74
  }
75
75