@docusaurus/plugin-pwa 2.4.1 → 3.0.0-alpha.0
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 +2 -2
- package/lib/registerSw.js +9 -2
- package/package.json +23 -22
- package/src/index.ts +2 -2
- package/src/registerSw.ts +8 -2
package/lib/index.js
CHANGED
|
@@ -10,11 +10,11 @@ exports.validateOptions = void 0;
|
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
12
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
13
|
+
const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
|
|
13
14
|
const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
|
|
14
15
|
const workbox_build_1 = require("workbox-build");
|
|
15
16
|
const utils_1 = require("@docusaurus/utils");
|
|
16
17
|
const utils_2 = require("@docusaurus/core/lib/webpack/utils");
|
|
17
|
-
const LogPlugin_1 = tslib_1.__importDefault(require("@docusaurus/core/lib/webpack/plugins/LogPlugin"));
|
|
18
18
|
const theme_translations_1 = require("@docusaurus/theme-translations");
|
|
19
19
|
const isProd = process.env.NODE_ENV === 'production';
|
|
20
20
|
function getSWBabelLoader() {
|
|
@@ -125,7 +125,7 @@ function pluginPWA(context, options) {
|
|
|
125
125
|
// Fallback value required with Webpack 5
|
|
126
126
|
PWA_SW_CUSTOM: swCustom ?? '',
|
|
127
127
|
}),
|
|
128
|
-
new
|
|
128
|
+
new webpackbar_1.default({
|
|
129
129
|
name: 'Service Worker',
|
|
130
130
|
color: 'red',
|
|
131
131
|
}),
|
package/lib/registerSw.js
CHANGED
|
@@ -50,8 +50,15 @@ async function getIsAppInstalledRelatedApps() {
|
|
|
50
50
|
if (!('getInstalledRelatedApps' in window.navigator)) {
|
|
51
51
|
return false;
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
try {
|
|
54
|
+
const relatedApps = await navigator.getInstalledRelatedApps();
|
|
55
|
+
return relatedApps.some((app) => app.platform === 'webapp');
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
// Error might be thrown when Docusaurus is embedded in an iframe:
|
|
59
|
+
// registerSW failed DOMException: Failed to execute 'getInstalledRelatedApps' on 'Navigator': getInstalledRelatedApps() is only supported in top-level browsing contexts.
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
55
62
|
}
|
|
56
63
|
function isStandaloneDisplayMode() {
|
|
57
64
|
return window.matchMedia('(display-mode: standalone)').matches;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-pwa",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
4
4
|
"description": "Docusaurus Plugin to add PWA support.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-pwa.d.ts",
|
|
@@ -20,35 +20,36 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@babel/core": "^7.
|
|
24
|
-
"@babel/preset-env": "^7.
|
|
25
|
-
"@docusaurus/core": "
|
|
26
|
-
"@docusaurus/theme-common": "
|
|
27
|
-
"@docusaurus/theme-translations": "
|
|
28
|
-
"@docusaurus/types": "
|
|
29
|
-
"@docusaurus/utils": "
|
|
30
|
-
"@docusaurus/utils-validation": "
|
|
31
|
-
"babel-loader": "^
|
|
23
|
+
"@babel/core": "^7.20.12",
|
|
24
|
+
"@babel/preset-env": "^7.20.2",
|
|
25
|
+
"@docusaurus/core": "3.0.0-alpha.0",
|
|
26
|
+
"@docusaurus/theme-common": "3.0.0-alpha.0",
|
|
27
|
+
"@docusaurus/theme-translations": "3.0.0-alpha.0",
|
|
28
|
+
"@docusaurus/types": "3.0.0-alpha.0",
|
|
29
|
+
"@docusaurus/utils": "3.0.0-alpha.0",
|
|
30
|
+
"@docusaurus/utils-validation": "3.0.0-alpha.0",
|
|
31
|
+
"babel-loader": "^9.1.2",
|
|
32
32
|
"clsx": "^1.2.1",
|
|
33
|
-
"core-js": "^3.
|
|
34
|
-
"terser-webpack-plugin": "^5.3.
|
|
35
|
-
"tslib": "^2.
|
|
36
|
-
"webpack": "^5.
|
|
33
|
+
"core-js": "^3.29.0",
|
|
34
|
+
"terser-webpack-plugin": "^5.3.7",
|
|
35
|
+
"tslib": "^2.5.0",
|
|
36
|
+
"webpack": "^5.76.0",
|
|
37
37
|
"webpack-merge": "^5.8.0",
|
|
38
|
-
"
|
|
39
|
-
"workbox-
|
|
40
|
-
"workbox-
|
|
38
|
+
"webpackbar": "^5.0.2",
|
|
39
|
+
"workbox-build": "^6.5.4",
|
|
40
|
+
"workbox-precaching": "^6.5.4",
|
|
41
|
+
"workbox-window": "^6.5.4"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@docusaurus/module-type-aliases": "
|
|
44
|
-
"fs-extra": "^
|
|
44
|
+
"@docusaurus/module-type-aliases": "3.0.0-alpha.0",
|
|
45
|
+
"fs-extra": "^11.1.0"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"react": "^
|
|
48
|
-
"react-dom": "^
|
|
48
|
+
"react": "^18.0.0",
|
|
49
|
+
"react-dom": "^18.0.0"
|
|
49
50
|
},
|
|
50
51
|
"engines": {
|
|
51
52
|
"node": ">=16.14"
|
|
52
53
|
},
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "7327f7ff880ed97ad7855744e59c9c55d467a950"
|
|
54
55
|
}
|
package/src/index.ts
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import webpack, {type Configuration} from 'webpack';
|
|
10
|
+
import WebpackBar from 'webpackbar';
|
|
10
11
|
import Terser from 'terser-webpack-plugin';
|
|
11
12
|
import {injectManifest} from 'workbox-build';
|
|
12
13
|
import {normalizeUrl} from '@docusaurus/utils';
|
|
13
14
|
import {compile} from '@docusaurus/core/lib/webpack/utils';
|
|
14
|
-
import LogPlugin from '@docusaurus/core/lib/webpack/plugins/LogPlugin';
|
|
15
15
|
import {readDefaultCodeTranslationMessages} from '@docusaurus/theme-translations';
|
|
16
16
|
import type {HtmlTags, LoadContext, Plugin} from '@docusaurus/types';
|
|
17
17
|
import type {PluginOptions} from '@docusaurus/plugin-pwa';
|
|
@@ -160,7 +160,7 @@ export default function pluginPWA(
|
|
|
160
160
|
// Fallback value required with Webpack 5
|
|
161
161
|
PWA_SW_CUSTOM: swCustom ?? '',
|
|
162
162
|
}),
|
|
163
|
-
new
|
|
163
|
+
new WebpackBar({
|
|
164
164
|
name: 'Service Worker',
|
|
165
165
|
color: 'red',
|
|
166
166
|
}),
|
package/src/registerSw.ts
CHANGED
|
@@ -72,8 +72,14 @@ async function getIsAppInstalledRelatedApps() {
|
|
|
72
72
|
if (!('getInstalledRelatedApps' in window.navigator)) {
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
try {
|
|
76
|
+
const relatedApps = await navigator.getInstalledRelatedApps();
|
|
77
|
+
return relatedApps.some((app) => app.platform === 'webapp');
|
|
78
|
+
} catch (e) {
|
|
79
|
+
// Error might be thrown when Docusaurus is embedded in an iframe:
|
|
80
|
+
// registerSW failed DOMException: Failed to execute 'getInstalledRelatedApps' on 'Navigator': getInstalledRelatedApps() is only supported in top-level browsing contexts.
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
77
83
|
}
|
|
78
84
|
function isStandaloneDisplayMode() {
|
|
79
85
|
return window.matchMedia('(display-mode: standalone)').matches;
|