@docusaurus/plugin-pwa 0.0.0-4518 → 0.0.0-4524
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 +1 -1
- package/lib/index.js +2 -2
- package/lib/registerSw.js +7 -5
- package/lib/sw.js +3 -2
- package/package.json +8 -8
- package/src/index.ts +1 -1
- package/src/registerSw.js +7 -5
- package/src/sw.js +3 -2
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
|
@@ -42,7 +42,7 @@ function getSWBabelLoader() {
|
|
|
42
42
|
},
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function pluginPWA(context, options) {
|
|
46
46
|
const { outDir, baseUrl, i18n: { currentLocale }, } = context;
|
|
47
47
|
const { debug, offlineModeActivationStrategies, injectManifestConfig, reloadPopup, pwaHead, swCustom, swRegister, } = options;
|
|
48
48
|
return {
|
|
@@ -163,6 +163,6 @@ function default_1(context, options) {
|
|
|
163
163
|
},
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
-
exports.default =
|
|
166
|
+
exports.default = pluginPWA;
|
|
167
167
|
var options_1 = require("./options");
|
|
168
168
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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?
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-pwa",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4524",
|
|
4
4
|
"description": "Docusaurus Plugin to add PWA support.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-pwa.d.ts",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
24
24
|
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
25
25
|
"@babel/preset-env": "^7.16.4",
|
|
26
|
-
"@docusaurus/core": "0.0.0-
|
|
27
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
28
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
29
|
-
"@docusaurus/utils": "0.0.0-
|
|
30
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
26
|
+
"@docusaurus/core": "0.0.0-4524",
|
|
27
|
+
"@docusaurus/theme-common": "0.0.0-4524",
|
|
28
|
+
"@docusaurus/theme-translations": "0.0.0-4524",
|
|
29
|
+
"@docusaurus/utils": "0.0.0-4524",
|
|
30
|
+
"@docusaurus/utils-validation": "0.0.0-4524",
|
|
31
31
|
"babel-loader": "^8.2.2",
|
|
32
32
|
"clsx": "^1.1.1",
|
|
33
33
|
"core-js": "^3.18.0",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"workbox-window": "^6.1.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
43
|
+
"@docusaurus/module-type-aliases": "0.0.0-4524",
|
|
44
44
|
"fs-extra": "^10.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"react": "^16.8.4 || ^17.0.0",
|
|
49
49
|
"react-dom": "^16.8.4 || ^17.0.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "41a6bff3a67446f7d2a2972cbe4d05fec7378a15"
|
|
52
52
|
}
|
package/src/index.ts
CHANGED
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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?
|