@vuepress/plugin-pwa 2.0.0-rc.3 → 2.0.0-rc.31
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/client/components/PwaFoundPopup.d.ts +21 -0
- package/lib/client/components/PwaFoundPopup.js +56 -0
- package/lib/client/components/PwaInstall.d.ts +16 -0
- package/lib/client/components/PwaInstall.js +85 -0
- package/lib/client/components/PwaInstallModal.d.ts +33 -0
- package/lib/client/components/PwaInstallModal.js +169 -0
- package/lib/client/components/PwaReadyPopup.d.ts +21 -0
- package/lib/client/components/PwaReadyPopup.js +50 -0
- package/lib/client/components/icons.d.ts +9 -0
- package/lib/client/components/icons.js +25 -0
- package/lib/client/components/index.d.ts +3 -0
- package/lib/client/components/index.js +3 -0
- package/lib/client/composables/index.d.ts +3 -1
- package/lib/client/composables/index.js +3 -1
- package/lib/client/composables/setupPwa.d.ts +1 -0
- package/lib/client/composables/setupPwa.js +28 -0
- package/lib/client/composables/setupViewPoint.d.ts +1 -0
- package/lib/client/composables/setupViewPoint.js +18 -0
- package/lib/client/composables/usePwaEvent.js +2 -3
- package/lib/client/composables/useRegisterSW.d.ts +2 -0
- package/lib/client/composables/useRegisterSW.js +29 -0
- package/lib/client/index.d.ts +2 -0
- package/lib/client/index.js +2 -0
- package/lib/client/styles/modal.css +402 -0
- package/lib/client/styles/popup.css +66 -0
- package/lib/client/styles/vars.css +12 -0
- package/lib/client/utils/forceUpdate.d.ts +6 -0
- package/lib/client/utils/forceUpdate.js +16 -0
- package/lib/client/utils/index.d.ts +4 -0
- package/lib/client/utils/index.js +4 -0
- package/lib/client/utils/registerSW.d.ts +15 -0
- package/lib/client/utils/registerSW.js +57 -0
- package/lib/client/utils/skipWaiting.d.ts +6 -0
- package/lib/client/utils/skipWaiting.js +15 -0
- package/lib/client/utils/unregisterSW.d.ts +10 -0
- package/lib/client/utils/unregisterSW.js +24 -0
- package/lib/node/generateManifest.d.ts +3 -0
- package/lib/node/generateManifest.js +12 -0
- package/lib/node/generateServiceWorker.d.ts +2 -3
- package/lib/node/generateServiceWorker.js +50 -23
- package/lib/node/getManifest.d.ts +4 -0
- package/lib/node/getManifest.js +31 -0
- package/lib/node/helper.d.ts +4 -0
- package/lib/node/helper.js +38 -0
- package/lib/node/index.d.ts +3 -3
- package/lib/node/index.js +3 -3
- package/lib/node/injectLinksToHead.d.ts +3 -0
- package/lib/node/injectLinksToHead.js +62 -0
- package/lib/node/locales.d.ts +3 -0
- package/lib/node/locales.js +263 -0
- package/lib/node/logger.d.ts +3 -0
- package/lib/node/logger.js +3 -0
- package/lib/node/options.d.ts +183 -0
- package/lib/node/options.js +1 -0
- package/lib/node/prepareConfigFile.d.ts +3 -0
- package/lib/node/prepareConfigFile.js +48 -0
- package/lib/node/pwaPlugin.d.ts +3 -17
- package/lib/node/pwaPlugin.js +47 -14
- package/lib/shared/index.d.ts +2 -0
- package/lib/shared/index.js +2 -0
- package/lib/shared/locales.d.ts +70 -0
- package/lib/shared/locales.js +1 -0
- package/lib/shared/manifest.d.ts +129 -0
- package/lib/shared/manifest.js +2 -0
- package/package.json +19 -8
- package/lib/client/composables/useSkipWaiting.d.ts +0 -4
- package/lib/client/composables/useSkipWaiting.js +0 -13
- package/lib/client/config.d.ts +0 -3
- package/lib/client/config.js +0 -50
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { LocaleConfig } from 'vuepress/shared';
|
|
2
|
+
import type { GenerateSWOptions } from 'workbox-build';
|
|
3
|
+
import type { AppManifest, PwaPluginLocaleData } from '../shared/index.js';
|
|
4
|
+
interface ApplePwaOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Path of icon used on apple devices
|
|
7
|
+
*
|
|
8
|
+
* Recommend 152×152 size
|
|
9
|
+
*
|
|
10
|
+
* 苹果上使用的图标路径
|
|
11
|
+
*
|
|
12
|
+
* 推荐 152×152 大小
|
|
13
|
+
*/
|
|
14
|
+
icon?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Color of status bar
|
|
17
|
+
*
|
|
18
|
+
* 状态栏的颜色
|
|
19
|
+
*
|
|
20
|
+
* @default "black"
|
|
21
|
+
*/
|
|
22
|
+
statusBarColor?: 'black' | 'white';
|
|
23
|
+
/**
|
|
24
|
+
* Safari mask icon
|
|
25
|
+
*
|
|
26
|
+
* Safari 图标
|
|
27
|
+
*/
|
|
28
|
+
maskIcon?: string;
|
|
29
|
+
}
|
|
30
|
+
interface MicrosoftPwaOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Microsoft tile image
|
|
33
|
+
*
|
|
34
|
+
* 144×144 transparent recommended
|
|
35
|
+
*
|
|
36
|
+
* 微软磁贴图片
|
|
37
|
+
*
|
|
38
|
+
* 推荐 144×144,透明
|
|
39
|
+
*/
|
|
40
|
+
image?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Tile color
|
|
43
|
+
*
|
|
44
|
+
* 磁贴颜色
|
|
45
|
+
*/
|
|
46
|
+
color?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface PwaPluginOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Service Worker file path
|
|
51
|
+
*
|
|
52
|
+
* Service Worker 文件路径
|
|
53
|
+
*
|
|
54
|
+
* @default "service-worker.js"
|
|
55
|
+
*/
|
|
56
|
+
serviceWorkerFilename?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Whether display install button
|
|
59
|
+
*
|
|
60
|
+
* 是否显示安装按钮
|
|
61
|
+
*
|
|
62
|
+
* @default true
|
|
63
|
+
*/
|
|
64
|
+
showInstall?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Manifest file Config
|
|
67
|
+
*
|
|
68
|
+
* manifest 文件设置
|
|
69
|
+
*/
|
|
70
|
+
manifest?: AppManifest;
|
|
71
|
+
/**
|
|
72
|
+
* Path of favicon
|
|
73
|
+
*
|
|
74
|
+
* favicon 地址
|
|
75
|
+
*/
|
|
76
|
+
favicon?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Theme Color
|
|
79
|
+
*
|
|
80
|
+
* 主题色
|
|
81
|
+
*
|
|
82
|
+
* @default "#46bd87"
|
|
83
|
+
*/
|
|
84
|
+
themeColor?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Max size which allows to cache, with KB unit
|
|
87
|
+
*
|
|
88
|
+
* 允许缓存的最大大小,单位 KB
|
|
89
|
+
*
|
|
90
|
+
* @default 2048
|
|
91
|
+
*/
|
|
92
|
+
maxSize?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Whether cache html files besides home page and 404
|
|
95
|
+
*
|
|
96
|
+
* 是否缓存除主页与 404 之外的 HTML
|
|
97
|
+
*
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
cacheHTML?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Whether cache pictures
|
|
103
|
+
*
|
|
104
|
+
* 是否缓存站点图片
|
|
105
|
+
*
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
cacheImage?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Max size which allows to cache, with KB unit
|
|
111
|
+
*
|
|
112
|
+
* 图片允许缓存的最大大小,单位 KB
|
|
113
|
+
*
|
|
114
|
+
* @default 1024
|
|
115
|
+
*/
|
|
116
|
+
maxImageSize?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Settings for apple
|
|
119
|
+
*
|
|
120
|
+
* 苹果设置
|
|
121
|
+
*/
|
|
122
|
+
apple?: ApplePwaOptions | false;
|
|
123
|
+
/**
|
|
124
|
+
* Settings for Microsoft
|
|
125
|
+
*
|
|
126
|
+
* 微软设置
|
|
127
|
+
*/
|
|
128
|
+
msTile?: MicrosoftPwaOptions | false;
|
|
129
|
+
/**
|
|
130
|
+
* Update logic
|
|
131
|
+
*
|
|
132
|
+
* - `"disabled"`: Do nothing even when new service worker is available. After new service work succeeds installing and starts waiting, it will control page and provide new content in next visit.
|
|
133
|
+
* - `"available"`: Only display update popup when the new service worker is available
|
|
134
|
+
* - `"hint"`: Display a hint to let user choose to refresh immediately. This is helpful when you want users to see new docs immediately.
|
|
135
|
+
* - `"force"`: unregister current service worker immediately then refresh to get new content. **This may affect visiting experiences**!
|
|
136
|
+
*
|
|
137
|
+
* 更新逻辑
|
|
138
|
+
*
|
|
139
|
+
* - `"disabled"`: 即使有新的 service worker 也不做任何事情,新的 service work 开始等待后,会在用户下次访问时接管页面,让用户获得新内容。
|
|
140
|
+
* - `"available"`: 仅当新的 service worker 可用时才显示更新弹出窗口
|
|
141
|
+
* - `"hint"`: 显示更新内容可用提示,并允许用户立即刷新。当新的 SW 成功注册后,将转为更新内容就绪弹窗。当你希望用户立即查看新文档时,这很有帮助。
|
|
142
|
+
* - `"force"`: 立即注销当前 Service Worker 然后刷新以获取新内容。**这可能会影响访问体验**!
|
|
143
|
+
*
|
|
144
|
+
* @default "available"
|
|
145
|
+
*/
|
|
146
|
+
update?: 'available' | 'hint' | 'force' | 'disable';
|
|
147
|
+
/**
|
|
148
|
+
* A custom component to replace the default hint popup component.
|
|
149
|
+
*
|
|
150
|
+
* 用于替换默认提示弹出组件的自定义组件。
|
|
151
|
+
*
|
|
152
|
+
* @default "PwaFoundPopup"
|
|
153
|
+
*/
|
|
154
|
+
foundComponent?: string;
|
|
155
|
+
/**
|
|
156
|
+
* A custom component to replace the default update popup component.
|
|
157
|
+
*
|
|
158
|
+
* 用于替换默认更新弹出组件的自定义组件。
|
|
159
|
+
*
|
|
160
|
+
* @default "PwaReadyPopup"
|
|
161
|
+
*/
|
|
162
|
+
readyComponent?: string;
|
|
163
|
+
/**
|
|
164
|
+
* workbox-build’s [generateSW config](https://developers.google.com/web/tools/workbox/modules/workbox-build#full_generatesw_config)
|
|
165
|
+
*
|
|
166
|
+
*/
|
|
167
|
+
generateSWConfig?: Partial<GenerateSWOptions>;
|
|
168
|
+
/**
|
|
169
|
+
* Locales config
|
|
170
|
+
*
|
|
171
|
+
* 国际化配置
|
|
172
|
+
*/
|
|
173
|
+
locales?: LocaleConfig<PwaPluginLocaleData>;
|
|
174
|
+
/**
|
|
175
|
+
* Whether append base to all absolute links in options
|
|
176
|
+
*
|
|
177
|
+
* 是否为选项中所有绝对链接添加 base
|
|
178
|
+
*
|
|
179
|
+
* @default false
|
|
180
|
+
*/
|
|
181
|
+
appendBase?: boolean;
|
|
182
|
+
}
|
|
183
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getDirname, path } from 'vuepress/utils';
|
|
2
|
+
const __dirname = getDirname(import.meta.url);
|
|
3
|
+
export const prepareConfigFile = (app, options) => {
|
|
4
|
+
let configImport = '';
|
|
5
|
+
const rootComponents = [];
|
|
6
|
+
if (options.showInstall) {
|
|
7
|
+
configImport += `\
|
|
8
|
+
import { PwaInstall as _PwaInstall } from "${path.join(__dirname, '../client/components/PwaInstall.js')}";
|
|
9
|
+
`;
|
|
10
|
+
rootComponents.push('PwaInstall');
|
|
11
|
+
}
|
|
12
|
+
if (options.update === 'hint') {
|
|
13
|
+
configImport += `\
|
|
14
|
+
import { PwaFoundPopup as _PwaFoundPopup } from "${options.foundComponent ||
|
|
15
|
+
path.join(__dirname, '../client/components/PwaFoundPopup.js')}";
|
|
16
|
+
`;
|
|
17
|
+
rootComponents.push('PwaFoundPopup');
|
|
18
|
+
}
|
|
19
|
+
else if (options.update !== 'disable' && options.update !== 'force') {
|
|
20
|
+
configImport += `\
|
|
21
|
+
import { PwaReadyPopup as _PwaReadyPopup } from "${options.readyComponent ||
|
|
22
|
+
path.join(__dirname, '../client/components/PwaReadyPopup.js')}";
|
|
23
|
+
`;
|
|
24
|
+
rootComponents.push('PwaReadyPopup');
|
|
25
|
+
}
|
|
26
|
+
return app.writeTemp(`pwa/config.js`, `\
|
|
27
|
+
import { h } from "vue";
|
|
28
|
+
import { defineClientConfig } from "vuepress/client";
|
|
29
|
+
import { setupPwa } from "${path.join(__dirname, '../client/composables/setupPwa.js')}";
|
|
30
|
+
import { setupViewPoint } from "${path.join(__dirname, '../client/composables/setupViewPoint.js')}";
|
|
31
|
+
${configImport}
|
|
32
|
+
import "${path.join(__dirname, '../client/styles/vars.css')}";
|
|
33
|
+
|
|
34
|
+
const locales = __PWA_LOCALES__;
|
|
35
|
+
|
|
36
|
+
${rootComponents.map((item) => `const ${item} = () => h(_${item}, { locales })`).join('\n')}
|
|
37
|
+
|
|
38
|
+
export default defineClientConfig({
|
|
39
|
+
setup: () => {
|
|
40
|
+
setupPwa(__SW_PATH__, __SW_FORCE_UPDATE__);
|
|
41
|
+
setupViewPoint();
|
|
42
|
+
},
|
|
43
|
+
rootComponents: [
|
|
44
|
+
${rootComponents.map((item) => ` ${item},`).join('\n')}
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
`);
|
|
48
|
+
};
|
package/lib/node/pwaPlugin.d.ts
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
* Options for @vuepress/plugin-pwa
|
|
5
|
-
*/
|
|
6
|
-
export interface PwaPluginOptions extends GenerateSWConfig {
|
|
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: ({ serviceWorkerFilename, ...generateSWConfig }?: PwaPluginOptions) => Plugin;
|
|
1
|
+
import type { PluginFunction } from 'vuepress/core';
|
|
2
|
+
import type { PwaPluginOptions } from './options.js';
|
|
3
|
+
export declare const pwaPlugin: (options?: PwaPluginOptions) => PluginFunction;
|
package/lib/node/pwaPlugin.js
CHANGED
|
@@ -1,19 +1,52 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { addViteOptimizeDepsExclude, addViteSsrNoExternal, customizeDevServer, getLocaleConfig, } from '@vuepress/helper';
|
|
2
|
+
import { generateManifest } from './generateManifest.js';
|
|
2
3
|
import { generateServiceWorker } from './generateServiceWorker.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import { getManifest } from './getManifest.js';
|
|
5
|
+
import { appendBase } from './helper.js';
|
|
6
|
+
import { injectLinksToHead } from './injectLinksToHead.js';
|
|
7
|
+
import { pwaLocales } from './locales.js';
|
|
8
|
+
import { logger, PLUGIN_NAME } from './logger.js';
|
|
9
|
+
import { prepareConfigFile } from './prepareConfigFile.js';
|
|
10
|
+
export const pwaPlugin = (options = {}) => (app) => {
|
|
11
|
+
if (app.env.isDebug)
|
|
12
|
+
logger.info('Options:', options);
|
|
13
|
+
const { base, shouldPrefetch = true } = app.options;
|
|
14
|
+
if (options.appendBase)
|
|
15
|
+
appendBase(base, options);
|
|
16
|
+
if (shouldPrefetch === true)
|
|
17
|
+
logger.warn('The plugin will register service worker to handle assets, so we recommend you to set "shouldPrefetch: false" in VuePress config file.');
|
|
18
|
+
app.options.head = injectLinksToHead(options, base, app.options.head);
|
|
11
19
|
return {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
name: PLUGIN_NAME,
|
|
21
|
+
define: () => ({
|
|
22
|
+
__PWA_LOCALES__: getLocaleConfig({
|
|
23
|
+
app,
|
|
24
|
+
name: PLUGIN_NAME,
|
|
25
|
+
default: pwaLocales,
|
|
26
|
+
config: options.locales,
|
|
27
|
+
}),
|
|
28
|
+
__SW_FORCE_UPDATE__: options.update === 'force',
|
|
29
|
+
__SW_PATH__: options.serviceWorkerFilename || 'service-worker.js',
|
|
30
|
+
}),
|
|
31
|
+
extendsBundlerOptions: (bundlerOptions, app) => {
|
|
32
|
+
addViteOptimizeDepsExclude(bundlerOptions, app, [
|
|
33
|
+
'mitt',
|
|
34
|
+
'register-service-worker',
|
|
35
|
+
]);
|
|
36
|
+
addViteSsrNoExternal(bundlerOptions, app, '@vuepress/helper');
|
|
37
|
+
customizeDevServer(bundlerOptions, app, {
|
|
38
|
+
path: '/manifest.webmanifest',
|
|
39
|
+
response: async (_, response) => {
|
|
40
|
+
response.setHeader('Content-Type', 'application/manifest+json');
|
|
41
|
+
return JSON.stringify(await getManifest(app, options));
|
|
42
|
+
},
|
|
43
|
+
errMsg: 'Unexpected manifest generation error',
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
onGenerated: async (app) => {
|
|
47
|
+
await generateManifest(app, options);
|
|
48
|
+
await generateServiceWorker(app, options);
|
|
16
49
|
},
|
|
17
|
-
|
|
50
|
+
clientConfigFile: (app) => prepareConfigFile(app, options),
|
|
18
51
|
};
|
|
19
52
|
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ExactLocaleConfig } from '@vuepress/helper';
|
|
2
|
+
export interface PwaPluginLocaleData {
|
|
3
|
+
/**
|
|
4
|
+
* Install button text
|
|
5
|
+
*
|
|
6
|
+
* 安装按钮文字
|
|
7
|
+
*/
|
|
8
|
+
install: string;
|
|
9
|
+
/**
|
|
10
|
+
* iOS install hint text
|
|
11
|
+
*
|
|
12
|
+
* iOS 安装文字
|
|
13
|
+
*/
|
|
14
|
+
iOSInstall: string;
|
|
15
|
+
/**
|
|
16
|
+
* Cancel button text
|
|
17
|
+
*
|
|
18
|
+
* 取消按钮文字
|
|
19
|
+
*/
|
|
20
|
+
cancel: string;
|
|
21
|
+
/**
|
|
22
|
+
* Close button text
|
|
23
|
+
*
|
|
24
|
+
* 关闭按钮文字
|
|
25
|
+
*/
|
|
26
|
+
close: string;
|
|
27
|
+
/**
|
|
28
|
+
* Previous image text
|
|
29
|
+
*
|
|
30
|
+
* 上一张图片文字
|
|
31
|
+
*/
|
|
32
|
+
prevImage: string;
|
|
33
|
+
/**
|
|
34
|
+
* Next image text
|
|
35
|
+
*
|
|
36
|
+
* 下一张图片文字
|
|
37
|
+
*/
|
|
38
|
+
nextImage: string;
|
|
39
|
+
/**
|
|
40
|
+
* Install explain text
|
|
41
|
+
*
|
|
42
|
+
* 安装解释
|
|
43
|
+
*/
|
|
44
|
+
explain: string;
|
|
45
|
+
/**
|
|
46
|
+
* Description label text
|
|
47
|
+
*
|
|
48
|
+
* 描述标签文字
|
|
49
|
+
*/
|
|
50
|
+
desc: string;
|
|
51
|
+
/**
|
|
52
|
+
* Feature label text
|
|
53
|
+
*
|
|
54
|
+
* 特性标签文字
|
|
55
|
+
*/
|
|
56
|
+
feature: string;
|
|
57
|
+
/**
|
|
58
|
+
* Update hint text
|
|
59
|
+
*
|
|
60
|
+
* 提示有更新文字
|
|
61
|
+
*/
|
|
62
|
+
hint: string;
|
|
63
|
+
/**
|
|
64
|
+
* Update available text
|
|
65
|
+
*
|
|
66
|
+
* 更新可用文字
|
|
67
|
+
*/
|
|
68
|
+
update: string;
|
|
69
|
+
}
|
|
70
|
+
export type PwaPluginLocaleConfig = ExactLocaleConfig<PwaPluginLocaleData>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://www.w3.org/TR/mediaqueries-5/#display-mode
|
|
3
|
+
*/
|
|
4
|
+
export type DisplayMode = 'fullscreen' | 'standalone' | 'minimal-ui' | 'browser';
|
|
5
|
+
/**
|
|
6
|
+
* @see https://github.com/w3c/manifest/wiki/Categories
|
|
7
|
+
*/
|
|
8
|
+
export type ManifestCategory = 'books' | 'business' | 'education' | 'entertainment' | 'finance' | 'fitness' | 'food' | 'games' | 'government' | 'health' | 'kids' | 'lifestyle' | 'magazines' | 'medical' | 'music' | 'navigation' | 'news' | 'personalization' | 'photo' | 'politics' | 'productivity' | 'security' | 'shopping' | 'social' | 'sports' | 'travel' | 'utilities' | 'weather';
|
|
9
|
+
/**
|
|
10
|
+
* @see https://www.w3.org/TR/screen-orientation/#dom-orientationlocktype
|
|
11
|
+
*/
|
|
12
|
+
export type OrientationLockType = 'any' | 'natural' | 'landscape' | 'portrait' | 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary';
|
|
13
|
+
/**
|
|
14
|
+
* @see https://www.w3.org/TR/appmanifest/#manifest-image-resources
|
|
15
|
+
*/
|
|
16
|
+
export interface ManifestImageResource {
|
|
17
|
+
src: string;
|
|
18
|
+
sizes: string;
|
|
19
|
+
type?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ManifestIcon extends ManifestImageResource {
|
|
22
|
+
purpose?: 'any' | 'maskable' | 'monochrome';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @see https://www.w3.org/TR/appmanifest/#external-application-resource
|
|
26
|
+
*/
|
|
27
|
+
export interface ManifestExternalApplicationResource {
|
|
28
|
+
/**
|
|
29
|
+
* @see https://github.com/w3c/manifest/wiki/Platforms
|
|
30
|
+
*/
|
|
31
|
+
platform: 'chrome_web_store' | 'play' | 'chromeos_play' | 'itunes' | 'webapp' | 'windows' | 'f-droid' | 'amazon';
|
|
32
|
+
url: string;
|
|
33
|
+
id?: string;
|
|
34
|
+
min_version?: string;
|
|
35
|
+
fingerprints?: {
|
|
36
|
+
type: string;
|
|
37
|
+
value: string;
|
|
38
|
+
}[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @see https://www.w3.org/TR/appmanifest/#shortcut-items
|
|
42
|
+
*/
|
|
43
|
+
export interface ManifestShortCutItem {
|
|
44
|
+
name: string;
|
|
45
|
+
url: string;
|
|
46
|
+
short_name?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
icons?: ManifestIcon[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @see https://www.w3.org/TR/appmanifest/
|
|
52
|
+
*/
|
|
53
|
+
export interface AppManifest extends Record<string, unknown> {
|
|
54
|
+
/**
|
|
55
|
+
* @see https://www.w3.org/TR/appmanifest/#name-member
|
|
56
|
+
*
|
|
57
|
+
* The name of the web application as it is usually displayed to the user
|
|
58
|
+
*/
|
|
59
|
+
name?: string;
|
|
60
|
+
/**
|
|
61
|
+
* @see https://www.w3.org/TR/appmanifest/#short_name-member
|
|
62
|
+
*
|
|
63
|
+
* A short version of the name of the web application
|
|
64
|
+
*/
|
|
65
|
+
short_name?: string;
|
|
66
|
+
/**
|
|
67
|
+
* @see https://www.w3.org/TR/appmanifest/#dfn-background_color
|
|
68
|
+
*
|
|
69
|
+
* The expected background color of the web application
|
|
70
|
+
*/
|
|
71
|
+
background_color?: string;
|
|
72
|
+
/**
|
|
73
|
+
* @see https://www.w3.org/TR/appmanifest/#dir-member
|
|
74
|
+
*
|
|
75
|
+
* The base direction for the localizable members of the manifest.
|
|
76
|
+
*/
|
|
77
|
+
dir?: 'ltr' | 'rtl' | 'auto';
|
|
78
|
+
/**
|
|
79
|
+
* @see https://www.w3.org/TR/appmanifest/#lang-member
|
|
80
|
+
*
|
|
81
|
+
* specifies the primary language for the values of the manifest's localizable members
|
|
82
|
+
*/
|
|
83
|
+
lang?: string;
|
|
84
|
+
/**
|
|
85
|
+
* @see https://www.w3.org/TR/appmanifest/#dfn-display
|
|
86
|
+
*
|
|
87
|
+
* The developer's preferred display mode for the web application
|
|
88
|
+
*/
|
|
89
|
+
display?: DisplayMode;
|
|
90
|
+
icons?: ManifestIcon[];
|
|
91
|
+
/**
|
|
92
|
+
* @see https://www.w3.org/TR/appmanifest/#orientation-member
|
|
93
|
+
*
|
|
94
|
+
* Serves as the default screen orientation for all top-level browsing contexts of the web application
|
|
95
|
+
*/
|
|
96
|
+
orientation?: OrientationLockType;
|
|
97
|
+
/**
|
|
98
|
+
* @see https://www.w3.org/TR/appmanifest/#scope-member
|
|
99
|
+
*
|
|
100
|
+
* The navigation scope of this web application's application context.
|
|
101
|
+
*/
|
|
102
|
+
scope?: string;
|
|
103
|
+
/**
|
|
104
|
+
* @see https://www.w3.org/TR/appmanifest/#start_url-member
|
|
105
|
+
*
|
|
106
|
+
* Start URL
|
|
107
|
+
*/
|
|
108
|
+
start_url?: string;
|
|
109
|
+
/**
|
|
110
|
+
* @see https://www.w3.org/TR/appmanifest/#id-member
|
|
111
|
+
*
|
|
112
|
+
* Identity for the application
|
|
113
|
+
*/
|
|
114
|
+
id?: string;
|
|
115
|
+
/**
|
|
116
|
+
* @see https://www.w3.org/TR/appmanifest/#theme_color-member
|
|
117
|
+
*
|
|
118
|
+
* Default theme color for an application context
|
|
119
|
+
*/
|
|
120
|
+
theme_color?: string;
|
|
121
|
+
shortcuts?: ManifestShortCutItem[];
|
|
122
|
+
prefer_related_applications?: boolean;
|
|
123
|
+
related_applications?: ManifestExternalApplicationResource[];
|
|
124
|
+
description?: string;
|
|
125
|
+
categories?: ManifestCategory[];
|
|
126
|
+
screenshots?: ManifestImageResource[];
|
|
127
|
+
iarc_rating_id?: string;
|
|
128
|
+
features?: string[];
|
|
129
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/plugin-pwa",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.31",
|
|
4
4
|
"description": "VuePress plugin - progressive web application",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-plugin",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"plugin",
|
|
9
9
|
"pwa"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://ecosystem.vuejs.press/plugins/pwa.html",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/vuepress/ecosystem/issues"
|
|
14
14
|
},
|
|
@@ -18,11 +18,16 @@
|
|
|
18
18
|
"directory": "plugins/plugin-pwa"
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
|
-
"author":
|
|
21
|
+
"author": {
|
|
22
|
+
"name": "Mr.Hope",
|
|
23
|
+
"email": "mister-hope@outlook.com",
|
|
24
|
+
"url": "https://mister-hope.com"
|
|
25
|
+
},
|
|
22
26
|
"type": "module",
|
|
23
27
|
"exports": {
|
|
24
28
|
".": "./lib/node/index.js",
|
|
25
29
|
"./client": "./lib/client/index.js",
|
|
30
|
+
"./client/*": "./lib/client/*",
|
|
26
31
|
"./package.json": "./package.json"
|
|
27
32
|
},
|
|
28
33
|
"main": "./lib/node/index.js",
|
|
@@ -32,19 +37,25 @@
|
|
|
32
37
|
],
|
|
33
38
|
"scripts": {
|
|
34
39
|
"build": "tsc -b tsconfig.build.json",
|
|
35
|
-
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
|
|
40
|
+
"clean": "rimraf --glob ./lib ./*.tsbuildinfo",
|
|
41
|
+
"style": "sass src:lib --no-source-map"
|
|
36
42
|
},
|
|
37
43
|
"dependencies": {
|
|
44
|
+
"@vuepress/helper": "~2.0.0-rc.31",
|
|
45
|
+
"@vueuse/core": "^10.9.0",
|
|
38
46
|
"mitt": "^3.0.1",
|
|
39
47
|
"register-service-worker": "^1.7.2",
|
|
40
|
-
"vue": "^3.4.
|
|
41
|
-
"workbox-build": "^7.
|
|
48
|
+
"vue": "^3.4.27",
|
|
49
|
+
"workbox-build": "^7.1.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"sass": "^1.77.2"
|
|
42
53
|
},
|
|
43
54
|
"peerDependencies": {
|
|
44
|
-
"vuepress": "2.0.0-rc.
|
|
55
|
+
"vuepress": "2.0.0-rc.12"
|
|
45
56
|
},
|
|
46
57
|
"publishConfig": {
|
|
47
58
|
"access": "public"
|
|
48
59
|
},
|
|
49
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "c3d22eb10914f5a6bbb9cfb039498761ca94b524"
|
|
50
61
|
}
|
|
@@ -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/client/config.d.ts
DELETED