@vuepress/plugin-pwa 2.0.0-beta.5 → 2.0.0-beta.50-pre
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/package.json +21 -20
- package/CHANGELOG.md +0 -155
- package/lib/clientAppSetup.d.ts +0 -2
- package/lib/clientAppSetup.js +0 -48
- package/lib/composables/index.d.ts +0 -2
- package/lib/composables/index.js +0 -2
- package/lib/composables/usePwaEvent.d.ts +0 -22
- package/lib/composables/usePwaEvent.js +0 -9
- package/lib/composables/useSkipWaiting.d.ts +0 -4
- package/lib/composables/useSkipWaiting.js +0 -13
- package/lib/index.d.ts +0 -18
- package/lib/index.js +0 -50
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/plugin-pwa",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.50-pre",
|
|
4
4
|
"description": "VuePress plugin - progressive web application",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-plugin",
|
|
@@ -18,30 +18,31 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"author": "meteorlxy",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./lib/node/index.js",
|
|
24
|
+
"./client": "./lib/client/index.js",
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"main": "./lib/node/index.js",
|
|
28
|
+
"types": "./lib/node/index.d.ts",
|
|
23
29
|
"files": [
|
|
24
|
-
"lib"
|
|
25
|
-
"styles"
|
|
30
|
+
"./lib"
|
|
26
31
|
],
|
|
27
|
-
"scripts": {
|
|
28
|
-
"build": "tsc -b tsconfig.build.json",
|
|
29
|
-
"clean": "rimraf lib *.tsbuildinfo"
|
|
30
|
-
},
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"@vuepress/client": "2.0.0-beta.
|
|
33
|
-
"@vuepress/core": "2.0.0-beta.
|
|
34
|
-
"@vuepress/utils": "2.0.0-beta.
|
|
35
|
-
"mitt": "^
|
|
33
|
+
"@vuepress/client": "2.0.0-beta.50-pre",
|
|
34
|
+
"@vuepress/core": "2.0.0-beta.50-pre",
|
|
35
|
+
"@vuepress/utils": "2.0.0-beta.50-pre",
|
|
36
|
+
"mitt": "^3.0.0",
|
|
36
37
|
"register-service-worker": "^1.7.2",
|
|
37
|
-
"vue": "^3.
|
|
38
|
-
"workbox-build": "^6.
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@types/workbox-build": "^5.0.0"
|
|
38
|
+
"vue": "^3.2.37",
|
|
39
|
+
"workbox-build": "^6.5.4"
|
|
42
40
|
},
|
|
43
41
|
"publishConfig": {
|
|
44
42
|
"access": "public"
|
|
45
43
|
},
|
|
46
|
-
"
|
|
47
|
-
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc -b tsconfig.build.json",
|
|
46
|
+
"clean": "rimraf lib *.tsbuildinfo"
|
|
47
|
+
}
|
|
48
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# [2.0.0-beta.5](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.4...v2.0.0-beta.5) (2021-03-26)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# [2.0.0-beta.4](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.3...v2.0.0-beta.4) (2021-03-20)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# [2.0.0-beta.1](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.0...v2.0.0-beta.1) (2021-03-13)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# [2.0.0-beta.0](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.26...v2.0.0-beta.0) (2021-03-13)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# [2.0.0-alpha.25](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.24...v2.0.0-alpha.25) (2021-02-20)
|
|
39
|
-
|
|
40
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
# [2.0.0-alpha.24](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.23...v2.0.0-alpha.24) (2021-02-13)
|
|
47
|
-
|
|
48
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
# [2.0.0-alpha.23](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.22...v2.0.0-alpha.23) (2021-02-10)
|
|
55
|
-
|
|
56
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# [2.0.0-alpha.22](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.21...v2.0.0-alpha.22) (2021-02-10)
|
|
63
|
-
|
|
64
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
# [2.0.0-alpha.20](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.19...v2.0.0-alpha.20) (2021-02-04)
|
|
71
|
-
|
|
72
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
# [2.0.0-alpha.19](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.18...v2.0.0-alpha.19) (2021-01-24)
|
|
79
|
-
|
|
80
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
# [2.0.0-alpha.18](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.17...v2.0.0-alpha.18) (2021-01-17)
|
|
87
|
-
|
|
88
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
# [2.0.0-alpha.17](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.16...v2.0.0-alpha.17) (2021-01-13)
|
|
95
|
-
|
|
96
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
# [2.0.0-alpha.16](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.15...v2.0.0-alpha.16) (2021-01-11)
|
|
103
|
-
|
|
104
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
# [2.0.0-alpha.15](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.14...v2.0.0-alpha.15) (2021-01-04)
|
|
111
|
-
|
|
112
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
# [2.0.0-alpha.14](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.13...v2.0.0-alpha.14) (2021-01-03)
|
|
119
|
-
|
|
120
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
# [2.0.0-alpha.13](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.12...v2.0.0-alpha.13) (2020-12-23)
|
|
127
|
-
|
|
128
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
# [2.0.0-alpha.12](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.11...v2.0.0-alpha.12) (2020-12-19)
|
|
135
|
-
|
|
136
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
# [2.0.0-alpha.9](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.8...v2.0.0-alpha.9) (2020-12-16)
|
|
143
|
-
|
|
144
|
-
**Note:** Version bump only for package @vuepress/plugin-pwa
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
# [2.0.0-alpha.8](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.7...v2.0.0-alpha.8) (2020-12-11)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
### Features
|
|
154
|
-
|
|
155
|
-
* **plugin-pwa:** migrate pwa plugin ([aa54fd6](https://github.com/vuepress/vuepress-next/commit/aa54fd65aa77b32b97de0a38359f1ad07f96f566))
|
package/lib/clientAppSetup.d.ts
DELETED
package/lib/clientAppSetup.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import mitt from 'mitt';
|
|
2
|
-
import { onMounted, provide } from 'vue';
|
|
3
|
-
import { defineClientAppSetup, withBase } from '@vuepress/client';
|
|
4
|
-
import { pwaEventSymbol } from './composables';
|
|
5
|
-
const swFilename = __PWA_SW_FILENAME__;
|
|
6
|
-
export default defineClientAppSetup(() => {
|
|
7
|
-
if (__DEV__ || __SSR__ || !swFilename)
|
|
8
|
-
return;
|
|
9
|
-
const log = (...args) => console.log('[@vuepress/plugin-pwa]', ...args);
|
|
10
|
-
// create event emitter and provide it
|
|
11
|
-
const event = mitt();
|
|
12
|
-
provide(pwaEventSymbol, event);
|
|
13
|
-
onMounted(async () => {
|
|
14
|
-
// lazy load register-service-worker
|
|
15
|
-
const { register } = await import('register-service-worker');
|
|
16
|
-
// Register service worker
|
|
17
|
-
register(withBase(swFilename), {
|
|
18
|
-
ready(registration) {
|
|
19
|
-
log('Service worker is active.');
|
|
20
|
-
event.emit('ready', registration);
|
|
21
|
-
},
|
|
22
|
-
registered(registration) {
|
|
23
|
-
log('Service worker has been registered.');
|
|
24
|
-
event.emit('registered', registration);
|
|
25
|
-
},
|
|
26
|
-
cached(registration) {
|
|
27
|
-
log('Content has been cached for offline use.');
|
|
28
|
-
event.emit('cached', registration);
|
|
29
|
-
},
|
|
30
|
-
updatefound(registration) {
|
|
31
|
-
log('New content is downloading.');
|
|
32
|
-
event.emit('updatefound', registration);
|
|
33
|
-
},
|
|
34
|
-
updated(registration) {
|
|
35
|
-
log('New content is available, please refresh.');
|
|
36
|
-
event.emit('updated', registration);
|
|
37
|
-
},
|
|
38
|
-
offline() {
|
|
39
|
-
log('No internet connection found. App is running in offline mode.');
|
|
40
|
-
event.emit('offline');
|
|
41
|
-
},
|
|
42
|
-
error(err) {
|
|
43
|
-
log('Error during service worker registration:', err);
|
|
44
|
-
event.emit('error', err);
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
});
|
package/lib/composables/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Emitter, Handler, WildcardHandler } from 'mitt';
|
|
2
|
-
import type { InjectionKey } from 'vue';
|
|
3
|
-
export interface PwaEvent extends Emitter {
|
|
4
|
-
on(type: 'ready', handler: Handler<ServiceWorkerRegistration>): void;
|
|
5
|
-
on(type: 'registered', handler: Handler<ServiceWorkerRegistration>): void;
|
|
6
|
-
on(type: 'cached', handler: Handler<ServiceWorkerRegistration>): void;
|
|
7
|
-
on(type: 'updatefound', handler: Handler<ServiceWorkerRegistration>): void;
|
|
8
|
-
on(type: 'updated', handler: Handler<ServiceWorkerRegistration>): void;
|
|
9
|
-
on(type: 'offline', handler: Handler<void>): void;
|
|
10
|
-
on(type: 'error', handler: Handler<Error>): void;
|
|
11
|
-
on(type: '*', handler: WildcardHandler): void;
|
|
12
|
-
emit(type: 'ready', event: ServiceWorkerRegistration): void;
|
|
13
|
-
emit(type: 'registered', event: ServiceWorkerRegistration): void;
|
|
14
|
-
emit(type: 'cached', event: ServiceWorkerRegistration): void;
|
|
15
|
-
emit(type: 'updatefound', event: ServiceWorkerRegistration): void;
|
|
16
|
-
emit(type: 'updated', event: ServiceWorkerRegistration): void;
|
|
17
|
-
emit(type: 'offline'): void;
|
|
18
|
-
emit(type: 'error', event: Error): void;
|
|
19
|
-
emit(type: '*', event?: any): void;
|
|
20
|
-
}
|
|
21
|
-
export declare const pwaEventSymbol: InjectionKey<PwaEvent>;
|
|
22
|
-
export declare const usePwaEvent: () => PwaEvent;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
export const pwaEventSymbol = Symbol('pwaEvent');
|
|
3
|
-
export const usePwaEvent = () => {
|
|
4
|
-
const pawEvent = inject(pwaEventSymbol);
|
|
5
|
-
if (!pawEvent) {
|
|
6
|
-
throw new Error('usePwaEvent() is called without provider.');
|
|
7
|
-
}
|
|
8
|
-
return pawEvent;
|
|
9
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Call `skipWaiting()` inside current waiting worker
|
|
3
|
-
*/
|
|
4
|
-
export const useSkipWaiting = (registration) => {
|
|
5
|
-
// get the waiting worker
|
|
6
|
-
const worker = registration.waiting;
|
|
7
|
-
// if there is no waiting worker, return directly
|
|
8
|
-
if (!worker)
|
|
9
|
-
return;
|
|
10
|
-
// post SKIP_WAITING message to the waiting worker
|
|
11
|
-
const channel = new MessageChannel();
|
|
12
|
-
worker.postMessage({ type: 'SKIP_WAITING' }, [channel.port2]);
|
|
13
|
-
};
|
package/lib/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from '@vuepress/core';
|
|
2
|
-
import type { GenerateSWConfig } from 'workbox-build';
|
|
3
|
-
/**
|
|
4
|
-
* Options for @vuepress/plugin-pwa
|
|
5
|
-
*/
|
|
6
|
-
export interface PwaPluginOptions extends Omit<GenerateSWConfig, 'swDest' | 'globDirectory'> {
|
|
7
|
-
/**
|
|
8
|
-
* Filename of the generated service worker file
|
|
9
|
-
*
|
|
10
|
-
* If you put it into a sub directory, the `scope` of service worker
|
|
11
|
-
* might be affected
|
|
12
|
-
*
|
|
13
|
-
* @default 'service-worker.js'
|
|
14
|
-
*/
|
|
15
|
-
serviceWorkerFilename?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare const pwaPlugin: Plugin<PwaPluginOptions>;
|
|
18
|
-
export default pwaPlugin;
|
package/lib/index.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pwaPlugin = void 0;
|
|
4
|
-
const utils_1 = require("@vuepress/utils");
|
|
5
|
-
const assetsExtensions = [
|
|
6
|
-
// basic
|
|
7
|
-
'html',
|
|
8
|
-
'js',
|
|
9
|
-
'css',
|
|
10
|
-
// images
|
|
11
|
-
'png',
|
|
12
|
-
'jpg',
|
|
13
|
-
'jpeg',
|
|
14
|
-
'gif',
|
|
15
|
-
'svg',
|
|
16
|
-
// fonts
|
|
17
|
-
'woff',
|
|
18
|
-
'woff2',
|
|
19
|
-
'eot',
|
|
20
|
-
'tff',
|
|
21
|
-
'otf',
|
|
22
|
-
];
|
|
23
|
-
const pwaPlugin = ({ serviceWorkerFilename = 'service-worker.js', ...generateSWConfig }) => ({
|
|
24
|
-
name: '@vuepress/plugin-pwa',
|
|
25
|
-
clientAppSetupFiles: utils_1.path.resolve(__dirname, './clientAppSetup.js'),
|
|
26
|
-
define: {
|
|
27
|
-
__PWA_SW_FILENAME__: serviceWorkerFilename,
|
|
28
|
-
},
|
|
29
|
-
async onGenerated(app) {
|
|
30
|
-
await utils_1.withSpinner('Generating service worker')(async () => {
|
|
31
|
-
// lazy-load workbox-build
|
|
32
|
-
const generateSW = require('workbox-build/build/generate-sw');
|
|
33
|
-
const globDirectory = app.dir.dest();
|
|
34
|
-
const swDest = app.dir.dest(serviceWorkerFilename);
|
|
35
|
-
const { warnings } = await generateSW({
|
|
36
|
-
dontCacheBustURLsMatching: new RegExp(`\\.[0-9a-f]{8}\\.(${assetsExtensions.join('|')})$`),
|
|
37
|
-
globPatterns: [`**/*.{${assetsExtensions.join(',')}}`],
|
|
38
|
-
mode: app.env.isDebug ? 'development' : 'production',
|
|
39
|
-
sourcemap: app.env.isDebug,
|
|
40
|
-
...generateSWConfig,
|
|
41
|
-
// should not be override by user config
|
|
42
|
-
globDirectory,
|
|
43
|
-
swDest,
|
|
44
|
-
});
|
|
45
|
-
warnings.forEach((warning) => utils_1.logger.warn('[@vuepress/plugin-pwa]', warning));
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
exports.pwaPlugin = pwaPlugin;
|
|
50
|
-
exports.default = exports.pwaPlugin;
|