@vuepress/plugin-pwa 2.0.0-rc.102 → 2.0.0-rc.103
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PwaReadyPopup-BPfm3Qt3.js","sources":["../../src/client/utils/skipWaiting.ts","../../src/client/components/PwaReadyPopup.ts"],"sourcesContent":["/**\n * Call `skipWaiting()` inside current waiting worker\n *\n * 在当前等待中的 Service Worker 中调用 `skipWaiting()`\n */\nexport const skipWaiting = (registration: ServiceWorkerRegistration): void => {\n // Get the waiting worker\n const worker = registration.waiting\n\n // If there is no waiting worker, return directly\n if (!worker) return\n\n // Post SKIP_WAITING message to the waiting worker\n const channel = new MessageChannel()\n\n worker.postMessage({ type: 'SKIP_WAITING' }, [channel.port2])\n}\n","import type {
|
|
1
|
+
{"version":3,"file":"PwaReadyPopup-BPfm3Qt3.js","sources":["../../src/client/utils/skipWaiting.ts","../../src/client/components/PwaReadyPopup.ts"],"sourcesContent":["/**\n * Call `skipWaiting()` inside current waiting worker\n *\n * 在当前等待中的 Service Worker 中调用 `skipWaiting()`\n */\nexport const skipWaiting = (registration: ServiceWorkerRegistration): void => {\n // Get the waiting worker\n const worker = registration.waiting\n\n // If there is no waiting worker, return directly\n if (!worker) return\n\n // Post SKIP_WAITING message to the waiting worker\n const channel = new MessageChannel()\n\n worker.postMessage({ type: 'SKIP_WAITING' }, [channel.port2])\n}\n","import type { Slot } from '@vuepress/helper/client'\nimport { useLocale } from '@vuepress/helper/client'\nimport type { PropType, SlotsType, VNode } from 'vue'\nimport {\n Transition,\n computed,\n defineComponent,\n h,\n onMounted,\n shallowRef,\n} from 'vue'\nimport { usePwaEvent } from '../composables/index.js'\nimport type { PwaPluginLocaleConfig } from '../types.js'\nimport { skipWaiting } from '../utils/index.js'\nimport { UpdateIcon } from './icons.js'\n\nimport '@vuepress/helper/transition/fade-in-scale-up.css'\nimport '../styles/popup.css'\n\nexport const PwaReadyPopup = defineComponent({\n name: 'PwaReadyPopup',\n\n props: {\n /** locale data */\n locales: {\n type: Object as PropType<PwaPluginLocaleConfig>,\n required: true,\n },\n },\n\n slots: Object as SlotsType<{\n default?: Slot<{ isReady: boolean; reload: () => void }>\n }>,\n\n setup(props, { slots }) {\n const locale = useLocale(props.locales)\n const registration = shallowRef<ServiceWorkerRegistration>()\n\n const isReady = computed(() => Boolean(registration.value))\n\n const reload = (): void => {\n if (registration.value) {\n skipWaiting(registration.value)\n registration.value = undefined\n }\n }\n\n onMounted(() => {\n const event = usePwaEvent()\n\n event.on('updated', (reg) => {\n registration.value = reg\n })\n })\n\n return (): VNode =>\n h(\n Transition,\n { name: 'fade-in-scale-up' },\n () =>\n slots.default?.({\n isReady: isReady.value,\n reload,\n }) ??\n (isReady.value\n ? h(\n 'button',\n {\n type: 'button',\n class: 'sw-update-popup',\n tabindex: 0,\n onClick: () => {\n reload()\n },\n },\n [\n locale.value.update,\n h('span', { class: 'icon-wrapper' }, h(UpdateIcon)),\n ],\n )\n : null),\n )\n },\n})\n"],"names":["skipWaiting","registration","worker","channel","PwaReadyPopup","defineComponent","props","slots","locale","useLocale","shallowRef","isReady","computed","reload","onMounted","usePwaEvent","reg","h","Transition","UpdateIcon"],"mappings":"wUAKa,MAAAA,EAAeC,GAAkD,CAE5E,MAAMC,EAASD,EAAa,QAG5B,GAAI,CAACC,EAAQ,OAGb,MAAMC,EAAU,IAAI,eAEpBD,EAAO,YAAY,CAAE,KAAM,cAAe,EAAG,CAACC,EAAQ,KAAK,CAAC,CAC9D,ECGaC,EAAgBC,EAAgB,CAC3C,KAAM,gBAEN,MAAO,CAEL,QAAS,CACP,KAAM,OACN,SAAU,EACZ,CACF,EAEA,MAAO,OAIP,MAAMC,EAAO,CAAE,MAAAC,CAAM,EAAG,CACtB,MAAMC,EAASC,EAAUH,EAAM,OAAO,EAChCL,EAAeS,EAEfC,EAAAA,EAAUC,EAAS,IAAM,EAAQX,EAAa,KAAM,EAEpDY,EAAS,IAAY,CACrBZ,EAAa,QACfD,EAAYC,EAAa,KAAK,EAC9BA,EAAa,MAAQ,OAEzB,EAEA,OAAAa,EAAU,IAAM,CACAC,IAER,GAAG,UAAYC,GAAQ,CAC3Bf,EAAa,MAAQe,CACvB,CAAC,CACH,CAAC,EAEM,IACLC,EACEC,EACA,CAAE,KAAM,kBAAmB,EAC3B,IACEX,EAAM,UAAU,CACd,QAASI,EAAQ,MACjB,OAAAE,CACF,CAAC,IACAF,EAAQ,MACLM,EACE,SACA,CACE,KAAM,SACN,MAAO,kBACP,SAAU,EACV,QAAS,IAAM,CACbJ,EACF,CAAA,CACF,EACA,CACEL,EAAO,MAAM,OACbS,EAAE,OAAQ,CAAE,MAAO,cAAe,EAAGA,EAAEE,CAAU,CAAC,CACpD,CACF,EACA,KACR,CACJ,CACF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { PropType, VNode, SlotsType } from 'vue';
|
|
3
|
-
import {
|
|
3
|
+
import { Slot } from '@vuepress/helper/client';
|
|
4
4
|
import { P as PwaPluginLocaleConfig } from '../types-B0Ty8tPv.js';
|
|
5
5
|
|
|
6
6
|
declare const PwaFoundPopup: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
@@ -16,10 +16,10 @@ declare const PwaFoundPopup: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
16
16
|
required: true;
|
|
17
17
|
};
|
|
18
18
|
}>> & Readonly<{}>, {}, SlotsType<{
|
|
19
|
-
default?:
|
|
19
|
+
default?: Slot<{
|
|
20
20
|
found: boolean;
|
|
21
21
|
refresh: () => void;
|
|
22
|
-
}
|
|
22
|
+
}>;
|
|
23
23
|
}>, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
24
24
|
|
|
25
25
|
export { PwaFoundPopup };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PwaFoundPopup.js","sources":["../../../src/client/components/PwaFoundPopup.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"PwaFoundPopup.js","sources":["../../../src/client/components/PwaFoundPopup.ts"],"sourcesContent":["import type { Slot } from '@vuepress/helper/client'\nimport { useLocale } from '@vuepress/helper/client'\nimport type { PropType, SlotsType, VNode } from 'vue'\nimport { Transition, defineComponent, h, onMounted, ref } from 'vue'\nimport { usePwaEvent } from '../composables/index.js'\nimport type { PwaPluginLocaleConfig } from '../types.js'\nimport { UpdateIcon } from './icons.js'\n\nimport '@vuepress/helper/transition/fade-in-scale-up.css'\nimport '../styles/popup.css'\n\nexport const PwaFoundPopup = defineComponent({\n name: 'PwaFoundPopup',\n\n props: {\n /** locale data */\n locales: {\n type: Object as PropType<PwaPluginLocaleConfig>,\n required: true,\n },\n },\n\n slots: Object as SlotsType<{\n default?: Slot<{ found: boolean; refresh: () => void }>\n }>,\n\n setup(props, { slots }) {\n const locale = useLocale(props.locales)\n const found = ref(false)\n\n const refresh = (): void => {\n if (found.value) {\n // force refresh\n // @ts-expect-error: A non-standard API\n window.location.reload(true)\n found.value = false\n }\n }\n\n onMounted(() => {\n const event = usePwaEvent()\n\n event.on('updatefound', () => {\n void navigator.serviceWorker.getRegistration().then((registration) => {\n // Check whether a valid service worker is active\n if (registration?.active) found.value = true\n })\n })\n\n event.on('updated', () => {\n found.value = false\n })\n })\n\n return (): VNode =>\n h(\n Transition,\n { name: 'fade-in-scale-up' },\n () =>\n slots.default?.({\n found: found.value,\n refresh,\n }) ??\n (found.value\n ? h(\n 'button',\n {\n type: 'button',\n class: 'sw-hint-popup',\n tabindex: 0,\n onClick: () => {\n refresh()\n },\n },\n [\n locale.value.hint,\n h('span', { class: 'icon-wrapper' }, h(UpdateIcon)),\n ],\n )\n : null),\n )\n },\n})\n"],"names":["PwaFoundPopup","defineComponent","props","slots","locale","useLocale","found","ref","refresh","onMounted","event","usePwaEvent","registration","h","Transition","UpdateIcon"],"mappings":"sTAWO,MAAMA,EAAgBC,EAAgB,CAC3C,KAAM,gBAEN,MAAO,CAEL,QAAS,CACP,KAAM,OACN,SAAU,EACZ,CACF,EAEA,MAAO,OAIP,MAAMC,EAAO,CAAE,MAAAC,CAAM,EAAG,CACtB,MAAMC,EAASC,EAAUH,EAAM,OAAO,EAChCI,EAAQC,EAAI,EAAK,EAEjBC,EAAU,IAAY,CACtBF,EAAM,QAGR,OAAO,SAAS,OAAO,EAAI,EAC3BA,EAAM,MAAQ,GAElB,EAEA,OAAAG,EAAU,IAAM,CACd,MAAMC,EAAQC,EAAAA,EAEdD,EAAM,GAAG,cAAe,IAAM,CACvB,UAAU,cAAc,kBAAkB,KAAME,GAAiB,CAEhEA,GAAc,SAAQN,EAAM,MAAQ,GAC1C,CAAC,CACH,CAAC,EAEDI,EAAM,GAAG,UAAW,IAAM,CACxBJ,EAAM,MAAQ,EAChB,CAAC,CACH,CAAC,EAEM,IACLO,EACEC,EACA,CAAE,KAAM,kBAAmB,EAC3B,IACEX,EAAM,UAAU,CACd,MAAOG,EAAM,MACb,QAAAE,CACF,CAAC,IACAF,EAAM,MACHO,EACE,SACA,CACE,KAAM,SACN,MAAO,gBACP,SAAU,EACV,QAAS,IAAM,CACbL,GACF,CACF,EACA,CACEJ,EAAO,MAAM,KACbS,EAAE,OAAQ,CAAE,MAAO,cAAe,EAAGA,EAAEE,CAAU,CAAC,CACpD,CACF,EACA,KACR,CACJ,CACF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { PropType, VNode, SlotsType } from 'vue';
|
|
3
|
-
import {
|
|
3
|
+
import { Slot } from '@vuepress/helper/client';
|
|
4
4
|
import { P as PwaPluginLocaleConfig } from '../types-B0Ty8tPv.js';
|
|
5
5
|
|
|
6
6
|
declare const PwaReadyPopup: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
@@ -16,10 +16,10 @@ declare const PwaReadyPopup: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
16
16
|
required: true;
|
|
17
17
|
};
|
|
18
18
|
}>> & Readonly<{}>, {}, SlotsType<{
|
|
19
|
-
default?:
|
|
19
|
+
default?: Slot<{
|
|
20
20
|
isReady: boolean;
|
|
21
21
|
reload: () => void;
|
|
22
|
-
}
|
|
22
|
+
}>;
|
|
23
23
|
}>, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
24
24
|
|
|
25
25
|
export { PwaReadyPopup };
|
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.103",
|
|
4
4
|
"description": "VuePress plugin - progressive web application",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-plugin",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"lib"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@vuepress/helper": "2.0.0-rc.
|
|
39
|
+
"@vuepress/helper": "2.0.0-rc.103",
|
|
40
40
|
"@vueuse/core": "^13.1.0",
|
|
41
41
|
"mitt": "^3.0.1",
|
|
42
42
|
"register-service-worker": "^1.7.2",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"rollup": "^4.40.2"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"vuepress": "2.0.0-rc.
|
|
50
|
+
"vuepress": "2.0.0-rc.23"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "b730bbcfea25d3b41390e137f086884149e2399e"
|
|
56
56
|
}
|