@vuepress/plugin-pwa 2.0.0-rc.47 → 2.0.0-rc.52
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/PwaReadyPopup-CKgFKMT_.js +2 -0
- package/lib/client/PwaReadyPopup-CKgFKMT_.js.map +1 -0
- package/lib/client/components/PwaFoundPopup.d.ts +10 -6
- package/lib/client/components/PwaFoundPopup.js +2 -58
- package/lib/client/components/PwaFoundPopup.js.map +1 -0
- package/lib/client/components/PwaInstall.d.ts +10 -6
- package/lib/client/components/PwaInstall.js +2 -87
- package/lib/client/components/PwaInstall.js.map +1 -0
- package/lib/client/components/PwaReadyPopup.d.ts +10 -6
- package/lib/client/components/PwaReadyPopup.js +2 -51
- package/lib/client/components/PwaReadyPopup.js.map +1 -0
- package/lib/client/composables/index.d.ts +22 -4
- package/lib/client/composables/index.js +2 -4
- package/lib/client/composables/index.js.map +1 -0
- package/lib/client/icons-DQk7h1-3.js +2 -0
- package/lib/client/icons-DQk7h1-3.js.map +1 -0
- package/lib/client/index-C0RlqHIH.js +2 -0
- package/lib/client/index-C0RlqHIH.js.map +1 -0
- package/lib/client/index.d.ts +51 -3
- package/lib/client/index.js +2 -3
- package/lib/client/index.js.map +1 -0
- package/lib/{shared/locales.d.ts → client/locales-C0hnw0bZ.d.ts} +6 -3
- package/lib/client/usePwaEvent-CUDY9qle.js +2 -0
- package/lib/client/usePwaEvent-CUDY9qle.js.map +1 -0
- package/lib/node/index.d.ts +391 -4
- package/lib/node/index.js +28 -4
- package/lib/node/index.js.map +1 -0
- package/package.json +6 -6
- package/lib/client/components/PwaInstallModal.d.ts +0 -33
- package/lib/client/components/PwaInstallModal.js +0 -179
- package/lib/client/components/icons.d.ts +0 -9
- package/lib/client/components/icons.js +0 -25
- package/lib/client/components/index.d.ts +0 -3
- package/lib/client/components/index.js +0 -3
- package/lib/client/composables/setupPwa.d.ts +0 -1
- package/lib/client/composables/setupPwa.js +0 -28
- package/lib/client/composables/setupViewPoint.d.ts +0 -1
- package/lib/client/composables/setupViewPoint.js +0 -18
- package/lib/client/composables/usePwaEvent.d.ts +0 -13
- package/lib/client/composables/usePwaEvent.js +0 -8
- package/lib/client/composables/useRegisterSW.d.ts +0 -2
- package/lib/client/composables/useRegisterSW.js +0 -29
- package/lib/client/utils/forceUpdate.d.ts +0 -6
- package/lib/client/utils/forceUpdate.js +0 -16
- package/lib/client/utils/index.d.ts +0 -4
- package/lib/client/utils/index.js +0 -4
- package/lib/client/utils/registerSW.d.ts +0 -15
- package/lib/client/utils/registerSW.js +0 -57
- package/lib/client/utils/skipWaiting.d.ts +0 -6
- package/lib/client/utils/skipWaiting.js +0 -15
- package/lib/client/utils/unregisterSW.d.ts +0 -10
- package/lib/client/utils/unregisterSW.js +0 -25
- package/lib/node/generateManifest.d.ts +0 -3
- package/lib/node/generateManifest.js +0 -12
- package/lib/node/generateServiceWorker.d.ts +0 -3
- package/lib/node/generateServiceWorker.js +0 -63
- package/lib/node/getManifest.d.ts +0 -4
- package/lib/node/getManifest.js +0 -34
- package/lib/node/helper.d.ts +0 -4
- package/lib/node/helper.js +0 -38
- package/lib/node/injectLinksToHead.d.ts +0 -3
- package/lib/node/injectLinksToHead.js +0 -62
- package/lib/node/locales.d.ts +0 -3
- package/lib/node/locales.js +0 -263
- package/lib/node/logger.d.ts +0 -3
- package/lib/node/logger.js +0 -3
- package/lib/node/options.d.ts +0 -183
- package/lib/node/options.js +0 -1
- package/lib/node/prepareConfigFile.d.ts +0 -3
- package/lib/node/prepareConfigFile.js +0 -48
- package/lib/node/pwaPlugin.d.ts +0 -3
- package/lib/node/pwaPlugin.js +0 -52
- package/lib/shared/index.d.ts +0 -2
- package/lib/shared/index.js +0 -2
- package/lib/shared/locales.js +0 -1
- package/lib/shared/manifest.d.ts +0 -129
- package/lib/shared/manifest.js +0 -1
|
@@ -1,48 +0,0 @@
|
|
|
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
DELETED
package/lib/node/pwaPlugin.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { addViteOptimizeDepsExclude, addViteSsrNoExternal, customizeDevServer, getLocaleConfig, } from '@vuepress/helper';
|
|
2
|
-
import { generateManifest } from './generateManifest.js';
|
|
3
|
-
import { generateServiceWorker } from './generateServiceWorker.js';
|
|
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 { PLUGIN_NAME, logger } 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);
|
|
19
|
-
return {
|
|
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) => {
|
|
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 () => {
|
|
47
|
-
await generateManifest(app, options);
|
|
48
|
-
await generateServiceWorker(app, options);
|
|
49
|
-
},
|
|
50
|
-
clientConfigFile: () => prepareConfigFile(app, options),
|
|
51
|
-
};
|
|
52
|
-
};
|
package/lib/shared/index.d.ts
DELETED
package/lib/shared/index.js
DELETED
package/lib/shared/locales.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/shared/manifest.d.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @see https://www.w3.org/TR/mediaqueries-5/#display-mode
|
|
3
|
-
*/
|
|
4
|
-
export type DisplayMode = 'browser' | 'fullscreen' | 'minimal-ui' | 'standalone';
|
|
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' | 'landscape-primary' | 'landscape-secondary' | 'landscape' | 'natural' | 'portrait-primary' | 'portrait-secondary' | 'portrait';
|
|
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: 'amazon' | 'chrome_web_store' | 'chromeos_play' | 'f-droid' | 'itunes' | 'play' | 'webapp' | 'windows';
|
|
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?: 'auto' | 'ltr' | 'rtl';
|
|
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/lib/shared/manifest.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|