@vuepress/plugin-pwa 2.0.0-rc.16 → 2.0.0-rc.18
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 → PwaFoundPopup.d.ts} +4 -4
- package/lib/client/components/{PWAFoundPopup.js → PwaFoundPopup.js} +4 -4
- package/lib/client/components/{PWAInstall.d.ts → PwaInstall.d.ts} +4 -4
- package/lib/client/components/{PWAInstall.js → PwaInstall.js} +4 -4
- package/lib/client/components/{PWAInstallModal.d.ts → PwaInstallModal.d.ts} +4 -4
- package/lib/client/components/{PWAInstallModal.js → PwaInstallModal.js} +2 -2
- package/lib/client/components/{PWAReadyPopup.d.ts → PwaReadyPopup.d.ts} +4 -4
- package/lib/client/components/{PWAReadyPopup.js → PwaReadyPopup.js} +4 -4
- package/lib/client/components/index.d.ts +3 -3
- package/lib/client/components/index.js +3 -3
- package/lib/client/composables/index.d.ts +2 -2
- package/lib/client/composables/index.js +2 -2
- package/lib/client/composables/setupPwa.d.ts +1 -0
- package/lib/client/composables/{setupPWA.js → setupPwa.js} +2 -2
- package/lib/client/composables/{usePWAEvent.d.ts → usePwaEvent.d.ts} +3 -3
- package/lib/client/composables/usePwaEvent.js +8 -0
- package/lib/client/composables/useRegisterSW.d.ts +2 -2
- package/lib/node/generateManifest.d.ts +2 -2
- package/lib/node/generateServiceWorker.d.ts +2 -2
- package/lib/node/getManifest.d.ts +2 -2
- package/lib/node/helper.d.ts +2 -2
- package/lib/node/injectLinksToHead.d.ts +2 -2
- package/lib/node/locales.d.ts +2 -2
- package/lib/node/options.d.ts +9 -10
- package/lib/node/prepareConfigFile.d.ts +2 -2
- package/lib/node/prepareConfigFile.js +11 -11
- package/lib/node/pwaPlugin.d.ts +2 -2
- package/lib/node/pwaPlugin.js +3 -3
- package/lib/shared/locales.d.ts +2 -2
- package/package.json +5 -5
- package/lib/client/composables/setupPWA.d.ts +0 -1
- package/lib/client/composables/usePWAEvent.js +0 -8
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { PropType, SlotsType, VNode } from 'vue';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PwaPluginLocaleConfig } from '../../shared/index.js';
|
|
3
3
|
import '../styles/popup.css';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const PwaFoundPopup: import("vue").DefineComponent<{
|
|
5
5
|
/** locale data */
|
|
6
6
|
locales: {
|
|
7
|
-
type: PropType<
|
|
7
|
+
type: PropType<PwaPluginLocaleConfig>;
|
|
8
8
|
required: true;
|
|
9
9
|
};
|
|
10
10
|
}, () => VNode, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
11
11
|
/** locale data */
|
|
12
12
|
locales: {
|
|
13
|
-
type: PropType<
|
|
13
|
+
type: PropType<PwaPluginLocaleConfig>;
|
|
14
14
|
required: true;
|
|
15
15
|
};
|
|
16
16
|
}>>, {}, SlotsType<{
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useLocaleConfig } from '@vuepress/helper/client';
|
|
2
2
|
import { defineComponent, h, onMounted, ref, Transition } from 'vue';
|
|
3
|
-
import {
|
|
3
|
+
import { usePwaEvent } from '../composables/index.js';
|
|
4
4
|
import { UpdateIcon } from './icons.js';
|
|
5
5
|
import '../styles/popup.css';
|
|
6
|
-
export const
|
|
7
|
-
name: '
|
|
6
|
+
export const PwaFoundPopup = defineComponent({
|
|
7
|
+
name: 'PwaFoundPopup',
|
|
8
8
|
props: {
|
|
9
9
|
/** locale data */
|
|
10
10
|
locales: {
|
|
@@ -25,7 +25,7 @@ export const PWAFoundPopup = defineComponent({
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
onMounted(() => {
|
|
28
|
-
const event =
|
|
28
|
+
const event = usePwaEvent();
|
|
29
29
|
event.on('updatefound', () => {
|
|
30
30
|
navigator.serviceWorker.getRegistration().then((registration) => {
|
|
31
31
|
// Check whether a valid service worker is active
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { PropType, VNode } from 'vue';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PwaPluginLocaleConfig } from '../../shared/index.js';
|
|
3
3
|
import '../styles/modal.css';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const PwaInstall: import("vue").DefineComponent<{
|
|
5
5
|
/** locale data */
|
|
6
6
|
locales: {
|
|
7
|
-
type: PropType<
|
|
7
|
+
type: PropType<PwaPluginLocaleConfig>;
|
|
8
8
|
required: true;
|
|
9
9
|
};
|
|
10
10
|
}, () => VNode, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
11
11
|
/** locale data */
|
|
12
12
|
locales: {
|
|
13
|
-
type: PropType<
|
|
13
|
+
type: PropType<PwaPluginLocaleConfig>;
|
|
14
14
|
required: true;
|
|
15
15
|
};
|
|
16
16
|
}>>, {}, {}>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useLocaleConfig } from '@vuepress/helper/client';
|
|
2
2
|
import { useToggle } from '@vueuse/core';
|
|
3
3
|
import { computed, defineComponent, h, onMounted, ref } from 'vue';
|
|
4
|
-
import {
|
|
4
|
+
import { PwaInstallModal } from './PwaInstallModal.js';
|
|
5
5
|
import '../styles/modal.css';
|
|
6
|
-
export const
|
|
7
|
-
name: '
|
|
6
|
+
export const PwaInstall = defineComponent({
|
|
7
|
+
name: 'PwaInstall',
|
|
8
8
|
props: {
|
|
9
9
|
/** locale data */
|
|
10
10
|
locales: {
|
|
@@ -68,7 +68,7 @@ export const PWAInstall = defineComponent({
|
|
|
68
68
|
},
|
|
69
69
|
}, locale.value.install)
|
|
70
70
|
: null,
|
|
71
|
-
h(
|
|
71
|
+
h(PwaInstallModal, {
|
|
72
72
|
style: {
|
|
73
73
|
display: isOpen.value ? 'block' : 'none',
|
|
74
74
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { PropType, VNode } from 'vue';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const
|
|
2
|
+
import type { PwaPluginLocaleConfig } from '../../shared/index.js';
|
|
3
|
+
export declare const PwaInstallModal: import("vue").DefineComponent<{
|
|
4
4
|
/** locale data */
|
|
5
5
|
locales: {
|
|
6
|
-
type: PropType<
|
|
6
|
+
type: PropType<PwaPluginLocaleConfig>;
|
|
7
7
|
required: true;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
@@ -15,7 +15,7 @@ export declare const PWAInstallModal: import("vue").DefineComponent<{
|
|
|
15
15
|
}, () => VNode, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("close" | "canInstall" | "hint")[], "close" | "canInstall" | "hint", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
16
16
|
/** locale data */
|
|
17
17
|
locales: {
|
|
18
|
-
type: PropType<
|
|
18
|
+
type: PropType<PwaPluginLocaleConfig>;
|
|
19
19
|
required: true;
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
@@ -3,8 +3,8 @@ import { useEventListener } from '@vueuse/core';
|
|
|
3
3
|
import { defineComponent, h, onMounted, shallowRef } from 'vue';
|
|
4
4
|
import { withBase } from 'vuepress/client';
|
|
5
5
|
import { ArrowLeftIcon, ArrowRightIcon, CloseIcon } from './icons.js';
|
|
6
|
-
export const
|
|
7
|
-
name: '
|
|
6
|
+
export const PwaInstallModal = defineComponent({
|
|
7
|
+
name: 'PwaInstallModal',
|
|
8
8
|
props: {
|
|
9
9
|
/** locale data */
|
|
10
10
|
locales: {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { PropType, SlotsType, VNode } from 'vue';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PwaPluginLocaleConfig } from '../../shared/index.js';
|
|
3
3
|
import '../styles/popup.css';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const PwaReadyPopup: import("vue").DefineComponent<{
|
|
5
5
|
/** locale data */
|
|
6
6
|
locales: {
|
|
7
|
-
type: PropType<
|
|
7
|
+
type: PropType<PwaPluginLocaleConfig>;
|
|
8
8
|
required: true;
|
|
9
9
|
};
|
|
10
10
|
}, () => VNode, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
11
11
|
/** locale data */
|
|
12
12
|
locales: {
|
|
13
|
-
type: PropType<
|
|
13
|
+
type: PropType<PwaPluginLocaleConfig>;
|
|
14
14
|
required: true;
|
|
15
15
|
};
|
|
16
16
|
}>>, {}, SlotsType<{
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useLocaleConfig } from '@vuepress/helper/client';
|
|
2
2
|
import { computed, defineComponent, h, onMounted, shallowRef, Transition, } from 'vue';
|
|
3
|
-
import {
|
|
3
|
+
import { usePwaEvent } from '../composables/index.js';
|
|
4
4
|
import { skipWaiting } from '../utils/index.js';
|
|
5
5
|
import { UpdateIcon } from './icons.js';
|
|
6
6
|
import '../styles/popup.css';
|
|
7
|
-
export const
|
|
8
|
-
name: '
|
|
7
|
+
export const PwaReadyPopup = defineComponent({
|
|
8
|
+
name: 'PwaReadyPopup',
|
|
9
9
|
props: {
|
|
10
10
|
/** locale data */
|
|
11
11
|
locales: {
|
|
@@ -25,7 +25,7 @@ export const PWAReadyPopup = defineComponent({
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
onMounted(() => {
|
|
28
|
-
const event =
|
|
28
|
+
const event = usePwaEvent();
|
|
29
29
|
event.on('updated', (reg) => {
|
|
30
30
|
if (reg)
|
|
31
31
|
registration.value = reg;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './PwaInstall.js';
|
|
2
|
+
export * from './PwaFoundPopup.js';
|
|
3
|
+
export * from './PwaReadyPopup.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './PwaInstall.js';
|
|
2
|
+
export * from './PwaFoundPopup.js';
|
|
3
|
+
export * from './PwaReadyPopup.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './setupPwa.js';
|
|
2
|
+
export * from './usePwaEvent.js';
|
|
3
3
|
export * from './useRegisterSW.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './setupPwa.js';
|
|
2
|
+
export * from './usePwaEvent.js';
|
|
3
3
|
export * from './useRegisterSW.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const setupPwa: (serviceWorkerPath: string, shouldForceUpdate?: boolean) => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import mitt from 'mitt';
|
|
2
2
|
import { onMounted, provide } from 'vue';
|
|
3
3
|
import { forceUpdate } from '../utils/index.js';
|
|
4
|
-
import { pwaEventSymbol } from './
|
|
4
|
+
import { pwaEventSymbol } from './usePwaEvent.js';
|
|
5
5
|
import { useRegisterSW } from './useRegisterSW.js';
|
|
6
|
-
export const
|
|
6
|
+
export const setupPwa = (serviceWorkerPath, shouldForceUpdate = false) => {
|
|
7
7
|
if (__VUEPRESS_SSR__)
|
|
8
8
|
return;
|
|
9
9
|
// Create event emitter and provide it
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Emitter } from 'mitt';
|
|
2
2
|
import type { InjectionKey } from 'vue';
|
|
3
|
-
export type
|
|
3
|
+
export type PwaEvent = Emitter<{
|
|
4
4
|
ready: ServiceWorkerRegistration;
|
|
5
5
|
registered: ServiceWorkerRegistration;
|
|
6
6
|
cached: ServiceWorkerRegistration;
|
|
@@ -9,5 +9,5 @@ export type PWAEvent = Emitter<{
|
|
|
9
9
|
offline: void;
|
|
10
10
|
error: Error;
|
|
11
11
|
}>;
|
|
12
|
-
export declare const pwaEventSymbol: InjectionKey<
|
|
13
|
-
export declare const
|
|
12
|
+
export declare const pwaEventSymbol: InjectionKey<PwaEvent>;
|
|
13
|
+
export declare const usePwaEvent: () => PwaEvent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { inject } from 'vue';
|
|
2
|
+
export const pwaEventSymbol = Symbol(__VUEPRESS_DEV__ ? 'PwaEvent' : '');
|
|
3
|
+
export const usePwaEvent = () => {
|
|
4
|
+
const pwaEvent = inject(pwaEventSymbol);
|
|
5
|
+
if (!pwaEvent)
|
|
6
|
+
throw new Error('usePwaEvent() is called without provider.');
|
|
7
|
+
return pwaEvent;
|
|
8
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const useRegisterSW: (serviceWorkerPath: string, event:
|
|
1
|
+
import type { PwaEvent } from './usePwaEvent.js';
|
|
2
|
+
export declare const useRegisterSW: (serviceWorkerPath: string, event: PwaEvent) => Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { App } from 'vuepress/core';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const generateManifest: (app: App, options:
|
|
2
|
+
import type { PwaPluginOptions } from './options.js';
|
|
3
|
+
export declare const generateManifest: (app: App, options: PwaPluginOptions) => Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { App } from 'vuepress/core';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const generateServiceWorker: (app: App, options:
|
|
2
|
+
import type { PwaPluginOptions } from './options.js';
|
|
3
|
+
export declare const generateServiceWorker: (app: App, options: PwaPluginOptions) => Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { App } from 'vuepress/core';
|
|
2
2
|
import type { AppManifest } from '../shared/index.js';
|
|
3
|
-
import type {
|
|
4
|
-
export declare const getManifest: (app: App, options:
|
|
3
|
+
import type { PwaPluginOptions } from './options.js';
|
|
4
|
+
export declare const getManifest: (app: App, options: PwaPluginOptions) => Promise<AppManifest>;
|
package/lib/node/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AppManifest } from '../shared/index.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PwaPluginOptions } from './options.js';
|
|
3
3
|
export declare const appendBaseToManifest: (base: string, manifest: AppManifest) => AppManifest;
|
|
4
|
-
export declare const appendBase: (base: string, options:
|
|
4
|
+
export declare const appendBase: (base: string, options: PwaPluginOptions) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HeadConfig } from 'vuepress/core';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const injectLinksToHead: (options:
|
|
2
|
+
import type { PwaPluginOptions } from './options.js';
|
|
3
|
+
export declare const injectLinksToHead: (options: PwaPluginOptions, base?: string, head?: HeadConfig[]) => HeadConfig[];
|
package/lib/node/locales.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PwaPluginLocaleConfig } from '../shared/index.js';
|
|
2
2
|
/** Multi language config for pwa popup */
|
|
3
|
-
export declare const pwaLocales:
|
|
3
|
+
export declare const pwaLocales: PwaPluginLocaleConfig;
|
package/lib/node/options.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LocaleConfig } from 'vuepress/shared';
|
|
2
2
|
import type { GenerateSWOptions } from 'workbox-build';
|
|
3
|
-
import type { AppManifest,
|
|
4
|
-
interface
|
|
3
|
+
import type { AppManifest, PwaPluginLocaleData } from '../shared/index.js';
|
|
4
|
+
interface ApplePwaOptions {
|
|
5
5
|
/**
|
|
6
6
|
* Path of icon used on apple devices
|
|
7
7
|
*
|
|
@@ -27,7 +27,7 @@ interface ApplePWAOptions {
|
|
|
27
27
|
*/
|
|
28
28
|
maskIcon?: string;
|
|
29
29
|
}
|
|
30
|
-
interface
|
|
30
|
+
interface MicrosoftPwaOptions {
|
|
31
31
|
/**
|
|
32
32
|
* Microsoft tile image
|
|
33
33
|
*
|
|
@@ -45,8 +45,7 @@ interface MicrosoftPWAOptions {
|
|
|
45
45
|
*/
|
|
46
46
|
color?: string;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
export interface PWAPluginOptions {
|
|
48
|
+
export interface PwaPluginOptions {
|
|
50
49
|
/**
|
|
51
50
|
* Service Worker file path
|
|
52
51
|
*
|
|
@@ -120,13 +119,13 @@ export interface PWAPluginOptions {
|
|
|
120
119
|
*
|
|
121
120
|
* 苹果设置
|
|
122
121
|
*/
|
|
123
|
-
apple?:
|
|
122
|
+
apple?: ApplePwaOptions | false;
|
|
124
123
|
/**
|
|
125
124
|
* Settings for Microsoft
|
|
126
125
|
*
|
|
127
126
|
* 微软设置
|
|
128
127
|
*/
|
|
129
|
-
msTile?:
|
|
128
|
+
msTile?: MicrosoftPwaOptions | false;
|
|
130
129
|
/**
|
|
131
130
|
* Update logic
|
|
132
131
|
*
|
|
@@ -150,7 +149,7 @@ export interface PWAPluginOptions {
|
|
|
150
149
|
*
|
|
151
150
|
* 用于替换默认提示弹出组件的自定义组件。
|
|
152
151
|
*
|
|
153
|
-
* @default "
|
|
152
|
+
* @default "PwaFoundPopup"
|
|
154
153
|
*/
|
|
155
154
|
foundComponent?: string;
|
|
156
155
|
/**
|
|
@@ -158,7 +157,7 @@ export interface PWAPluginOptions {
|
|
|
158
157
|
*
|
|
159
158
|
* 用于替换默认更新弹出组件的自定义组件。
|
|
160
159
|
*
|
|
161
|
-
* @default "
|
|
160
|
+
* @default "PwaReadyPopup"
|
|
162
161
|
*/
|
|
163
162
|
readyComponent?: string;
|
|
164
163
|
/**
|
|
@@ -171,7 +170,7 @@ export interface PWAPluginOptions {
|
|
|
171
170
|
*
|
|
172
171
|
* 国际化配置
|
|
173
172
|
*/
|
|
174
|
-
locales?: LocaleConfig<
|
|
173
|
+
locales?: LocaleConfig<PwaPluginLocaleData>;
|
|
175
174
|
/**
|
|
176
175
|
* Whether append base to all absolute links in options
|
|
177
176
|
*
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { App } from 'vuepress/core';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const prepareConfigFile: (app: App, options:
|
|
2
|
+
import type { PwaPluginOptions } from './options.js';
|
|
3
|
+
export declare const prepareConfigFile: (app: App, options: PwaPluginOptions) => Promise<string>;
|
|
@@ -5,38 +5,38 @@ export const prepareConfigFile = (app, options) => {
|
|
|
5
5
|
const rootComponents = [];
|
|
6
6
|
if (options.showInstall) {
|
|
7
7
|
configImport += `\
|
|
8
|
-
import {
|
|
8
|
+
import { PwaInstall as _PwaInstall } from "${path.join(__dirname, '../client/components/PwaInstall.js')}";
|
|
9
9
|
`;
|
|
10
|
-
rootComponents.push('
|
|
10
|
+
rootComponents.push('PwaInstall');
|
|
11
11
|
}
|
|
12
12
|
if (options.update === 'hint') {
|
|
13
13
|
configImport += `\
|
|
14
|
-
import {
|
|
15
|
-
path.join(__dirname, '../client/components/
|
|
14
|
+
import { PwaFoundPopup as _PwaFoundPopup } from "${options.foundComponent ||
|
|
15
|
+
path.join(__dirname, '../client/components/PwaFoundPopup.js')}";
|
|
16
16
|
`;
|
|
17
|
-
rootComponents.push('
|
|
17
|
+
rootComponents.push('PwaFoundPopup');
|
|
18
18
|
}
|
|
19
19
|
else if (options.update !== 'disable' && options.update !== 'force') {
|
|
20
20
|
configImport += `\
|
|
21
|
-
import {
|
|
22
|
-
path.join(__dirname, '../client/components/
|
|
21
|
+
import { PwaReadyPopup as _PwaReadyPopup } from "${options.readyComponent ||
|
|
22
|
+
path.join(__dirname, '../client/components/PwaReadyPopup.js')}";
|
|
23
23
|
`;
|
|
24
|
-
rootComponents.push('
|
|
24
|
+
rootComponents.push('PwaReadyPopup');
|
|
25
25
|
}
|
|
26
26
|
return app.writeTemp(`pwa/config.js`, `\
|
|
27
27
|
import { h } from "vue";
|
|
28
28
|
import { defineClientConfig } from "vuepress/client";
|
|
29
|
-
import {
|
|
29
|
+
import { setupPwa } from "${path.join(__dirname, '../client/composables/setupPwa.js')}";
|
|
30
30
|
${configImport}
|
|
31
31
|
import "${path.join(__dirname, '../client/styles/vars.css')}";
|
|
32
32
|
|
|
33
|
-
const locales =
|
|
33
|
+
const locales = __PWA_LOCALES__;
|
|
34
34
|
|
|
35
35
|
${rootComponents.map((item) => `const ${item} = () => h(_${item}, { locales })`).join('\n')}
|
|
36
36
|
|
|
37
37
|
export default defineClientConfig({
|
|
38
38
|
setup: () => {
|
|
39
|
-
|
|
39
|
+
setupPwa(__SW_PATH__, __SW_FORCE_UPDATE__);
|
|
40
40
|
},
|
|
41
41
|
rootComponents: [
|
|
42
42
|
${rootComponents.map((item) => ` ${item},`).join('\n')}
|
package/lib/node/pwaPlugin.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { PluginFunction } from 'vuepress/core';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const pwaPlugin: (options?:
|
|
2
|
+
import type { PwaPluginOptions } from './options.js';
|
|
3
|
+
export declare const pwaPlugin: (options?: PwaPluginOptions) => PluginFunction;
|
package/lib/node/pwaPlugin.js
CHANGED
|
@@ -19,14 +19,14 @@ export const pwaPlugin = (options = {}) => (app) => {
|
|
|
19
19
|
return {
|
|
20
20
|
name: PLUGIN_NAME,
|
|
21
21
|
define: () => ({
|
|
22
|
-
|
|
22
|
+
__PWA_LOCALES__: getLocaleConfig({
|
|
23
23
|
app,
|
|
24
24
|
name: PLUGIN_NAME,
|
|
25
25
|
default: pwaLocales,
|
|
26
26
|
config: options.locales,
|
|
27
27
|
}),
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
__SW_FORCE_UPDATE__: options.update === 'force',
|
|
29
|
+
__SW_PATH__: options.serviceWorkerFilename || 'service-worker.js',
|
|
30
30
|
}),
|
|
31
31
|
extendsBundlerOptions: (bundlerOptions, app) => {
|
|
32
32
|
addViteOptimizeDepsExclude(bundlerOptions, app, [
|
package/lib/shared/locales.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExactLocaleConfig } from '@vuepress/helper';
|
|
2
|
-
export interface
|
|
2
|
+
export interface PwaPluginLocaleData {
|
|
3
3
|
/**
|
|
4
4
|
* Install button text
|
|
5
5
|
*
|
|
@@ -67,4 +67,4 @@ export interface PWAPluginLocaleData {
|
|
|
67
67
|
*/
|
|
68
68
|
update: string;
|
|
69
69
|
}
|
|
70
|
-
export type
|
|
70
|
+
export type PwaPluginLocaleConfig = ExactLocaleConfig<PwaPluginLocaleData>;
|
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.18",
|
|
4
4
|
"description": "VuePress plugin - progressive web application",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-plugin",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"style": "sass src:lib --no-source-map"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@vuepress/helper": "~2.0.0-rc.
|
|
45
|
-
"@vueuse/core": "^10.
|
|
44
|
+
"@vuepress/helper": "~2.0.0-rc.18",
|
|
45
|
+
"@vueuse/core": "^10.9.0",
|
|
46
46
|
"mitt": "^3.0.1",
|
|
47
47
|
"register-service-worker": "^1.7.2",
|
|
48
|
-
"vue": "^3.4.
|
|
48
|
+
"vue": "^3.4.21",
|
|
49
49
|
"workbox-build": "^7.0.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "8bad47f0dbefd1037574255bf95a719bb680f60e"
|
|
58
58
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const setupPWA: (serviceWorkerPath: string, shouldForceUpdate?: boolean) => void;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
export const pwaEventSymbol = Symbol(__VUEPRESS_DEV__ ? 'PWAEvent' : '');
|
|
3
|
-
export const usePWAEvent = () => {
|
|
4
|
-
const pwaEvent = inject(pwaEventSymbol);
|
|
5
|
-
if (!pwaEvent)
|
|
6
|
-
throw new Error('usePWAEvent() is called without provider.');
|
|
7
|
-
return pwaEvent;
|
|
8
|
-
};
|