@vuepress/plugin-pwa 2.0.0-rc.123 → 2.0.0-rc.125
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/dist/PwaFoundPopup-DWmIsyXx.d.ts +24 -0
- package/dist/PwaInstall-Ee3il2nW.js +2 -0
- package/dist/PwaInstall-Ee3il2nW.js.map +1 -0
- package/dist/PwaInstall-w3x5rHx6.d.ts +18 -0
- package/dist/PwaReadyPopup-6AypjW2B.js +2 -0
- package/dist/PwaReadyPopup-6AypjW2B.js.map +1 -0
- package/dist/PwaReadyPopup-CDLxW7kc.d.ts +24 -0
- package/dist/client/components/PwaFoundPopup.d.ts +2 -0
- package/dist/client/components/PwaFoundPopup.js +2 -0
- package/dist/client/components/PwaFoundPopup.js.map +1 -0
- package/dist/client/components/PwaInstall.d.ts +2 -0
- package/dist/client/components/PwaInstall.js +1 -0
- package/dist/client/components/PwaReadyPopup.d.ts +2 -0
- package/dist/client/components/PwaReadyPopup.js +1 -0
- package/{lib → dist}/client/composables/index.d.ts +19 -15
- package/dist/client/composables/index.js +1 -0
- package/{lib → dist}/client/index.d.ts +16 -14
- package/dist/client/index.js +2 -0
- package/dist/client/index.js.map +1 -0
- package/dist/composables-Bdxx2hts.js +2 -0
- package/dist/composables-Bdxx2hts.js.map +1 -0
- package/{lib/client/icons-DQk7h1-3.js → dist/icons-RRw4DIWa.js} +2 -2
- package/dist/icons-RRw4DIWa.js.map +1 -0
- package/dist/locales-Bj0jQ5BO.d.ts +72 -0
- package/dist/node/index.d.ts +332 -0
- package/dist/node/index.js +30 -0
- package/dist/node/index.js.map +1 -0
- package/dist/types-D2911FOa.d.ts +8 -0
- package/package.json +17 -13
- package/lib/client/PwaReadyPopup-Crl_YRc0.js +0 -2
- package/lib/client/PwaReadyPopup-Crl_YRc0.js.map +0 -1
- package/lib/client/components/PwaFoundPopup.d.ts +0 -25
- package/lib/client/components/PwaFoundPopup.js +0 -2
- package/lib/client/components/PwaFoundPopup.js.map +0 -1
- package/lib/client/components/PwaInstall.d.ts +0 -20
- package/lib/client/components/PwaInstall.js +0 -2
- package/lib/client/components/PwaInstall.js.map +0 -1
- package/lib/client/components/PwaReadyPopup.d.ts +0 -25
- package/lib/client/components/PwaReadyPopup.js +0 -2
- package/lib/client/components/PwaReadyPopup.js.map +0 -1
- package/lib/client/composables/index.js +0 -2
- package/lib/client/composables/index.js.map +0 -1
- package/lib/client/icons-DQk7h1-3.js.map +0 -1
- package/lib/client/index-BvxQeVsR.js +0 -2
- package/lib/client/index-BvxQeVsR.js.map +0 -1
- package/lib/client/index.js +0 -2
- package/lib/client/index.js.map +0 -1
- package/lib/client/types-B0Ty8tPv.d.ts +0 -74
- package/lib/client/usePwaEvent-CUDY9qle.js +0 -2
- package/lib/client/usePwaEvent-CUDY9qle.js.map +0 -1
- package/lib/node/index.d.ts +0 -396
- package/lib/node/index.js +0 -30
- package/lib/node/index.js.map +0 -1
- /package/{lib → dist}/client/styles/modal.css +0 -0
- /package/{lib → dist}/client/styles/modal.css.map +0 -0
- /package/{lib → dist}/client/styles/popup.css +0 -0
- /package/{lib → dist}/client/styles/popup.css.map +0 -0
- /package/{lib → dist}/client/styles/vars.css +0 -0
- /package/{lib → dist}/client/styles/vars.css.map +0 -0
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { PropType, VNode } from 'vue';
|
|
3
|
-
import { P as PwaPluginLocaleConfig } from '../types-B0Ty8tPv.js';
|
|
4
|
-
import '@vuepress/helper/client';
|
|
5
|
-
|
|
6
|
-
declare const PwaInstall: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
7
|
-
/** locale data */
|
|
8
|
-
locales: {
|
|
9
|
-
type: PropType<PwaPluginLocaleConfig>;
|
|
10
|
-
required: true;
|
|
11
|
-
};
|
|
12
|
-
}>, () => VNode, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
13
|
-
/** locale data */
|
|
14
|
-
locales: {
|
|
15
|
-
type: PropType<PwaPluginLocaleConfig>;
|
|
16
|
-
required: true;
|
|
17
|
-
};
|
|
18
|
-
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
19
|
-
|
|
20
|
-
export { PwaInstall };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{useLocale as d}from"@vuepress/helper/client";import{useEventListener as m,useToggle as C}from"@vueuse/core";import{defineComponent as h,shallowRef as f,onMounted as g,h as e,ref as u,computed as b}from"vue";import{withBase as k}from"vuepress/client";import{C as P,A as S,a as A}from"../icons-DQk7h1-3.js";import"../styles/modal.css";const O=()=>{const l=document.querySelector(".screenshot");l&&l.scrollBy({left:-l.clientWidth,top:0,behavior:"smooth"})},x=()=>{const l=document.querySelector(".screenshot");l&&l.scrollBy({left:l.clientWidth,top:0,behavior:"smooth"})},E=h({name:"PwaInstallModal",props:{locales:{type:Object,required:!0},useHint:Boolean},emits:["canInstall","hint","close"],setup(l,{emit:s}){const o=d(l.locales),a=f({}),c=f(),r=async()=>{const t=localStorage.getItem("manifest");if(t)a.value=JSON.parse(t);else try{const i=await(await fetch(k("manifest.webmanifest"))).json();a.value=i,localStorage.setItem("manifest",JSON.stringify(i))}catch{console.error("[PWA]: Error getting manifest, check that you have a valid web manifest or network connection")}},v=async()=>{c.value&&(c.value.prompt(),document.dispatchEvent(new CustomEvent("show")),(await c.value.userChoice).outcome==="accepted"?(console.info("PWA has been installed"),s("close",!1),s("canInstall",!1)):(console.info("You choose to not install PWA"),s("close",!1),s("canInstall",!1)))},p=()=>{console.info("You accepted the install hint"),s("hint")};return g(()=>{window.hasOwnProperty("BeforeInstallPromptEvent")&&(m(window,"beforeinstallprompt",t=>{c.value=t,s("canInstall",!0),t.preventDefault()}),m("keyup",t=>{t.key==="Escape"&&s("close",!1)},{passive:!0}),r())}),()=>e("div",{id:"install-modal-wrapper"},[e("div",{class:"background",onClick:()=>{s("close",!1)}}),e("div",{class:"install-modal"},[e("div",{class:"header"},[e("button",{type:"button",class:"close-button","aria-label":o.value.close,onClick:()=>{s("close",!1)}},e(P)),e("div",{class:"logo"},[a.value.icons?e("img",{src:a.value.icons[0]?.src,alt:"App Logo"}):null,e("div",{class:"title"},[e("h1",a.value.short_name||a.value.name),e("p",{class:"desc"},o.value.explain)])])]),e("div",{class:"content"},[e("div",{class:"highlight"},[a.value.features?e("div",{class:"feature-wrapper"},[e("h3",o.value.feature),e("ul",a.value.features.map(t=>e("li",t)))]):null,a.value.screenshots?e("div",{class:"screenshot-wrapper"},[e("button",{type:"button","aria-label":o.value.prevImage,onClick:O},e(S)),e("section",{class:"screenshot"},[a.value.screenshots.map(t=>e("div",e("img",{src:t.src,alt:"App Screenshot"})))]),e("button",{type:"button","aria-label":o.value.nextImage,onClick:x},e(A))]):null]),e("div",{class:"description"},[e("h3",o.value.desc),e("p",a.value.description)])]),l.useHint?e("div",{class:"ios-text",onClick:p},[e("p",o.value.iOSInstall),e("button",{type:"button",class:"success"},"Got it!")]):e("div",{class:"button-wrapper"},[e("button",{type:"button",class:"install-button",onClick:v},[o.value.install,e("span",a.value.short_name)]),e("button",{type:"button",class:"cancel-button",onClick:()=>{s("close",!1)}},o.value.cancel)])])])}}),B=h({name:"PwaInstall",props:{locales:{type:Object,required:!0}},setup(l){const s=d(l.locales),[o,a]=C(),c=u(!1),r=u(!1),v=u(!1),p=u(!1),t=u(!1),i=b(()=>v.value&&p.value&&!t.value),w=b(()=>r.value&&c.value||i.value),y=()=>navigator.standalone?navigator.standalone:matchMedia("(display-mode: standalone)").matches,I=()=>{a(!1),t.value=!0,localStorage.setItem("iOS-pwa-hint","hinted")};return g(()=>{if(y()){const{userAgent:n}=navigator;v.value=n.includes("iPhone")||n.includes("iPad")||!!(n.includes("Macintosh")&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2),p.value=navigator.userAgent.includes("Safari")&&!n.includes("Chrome"),t.value=!!localStorage.getItem("iOS-pwa-hint")}"getInstalledRelatedApps"in navigator&&navigator.getInstalledRelatedApps().then(n=>{r.value=n.length>0})}),()=>e("div",{id:"pwa-install"},[w.value?e("button",{type:"button",class:"modal-button",onClick:()=>{a(!0)}},s.value.install):null,e(E,{style:{display:o.value?"block":"none"},locales:l.locales,useHint:i.value,onCanInstall:n=>{c.value=n},onHint:()=>{I()},onClose:()=>a(!1)})])}});export{B as PwaInstall};
|
|
2
|
-
//# sourceMappingURL=PwaInstall.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PwaInstall.js","sources":["../../../src/client/components/PwaInstallModal.ts","../../../src/client/components/PwaInstall.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { useLocale } from '@vuepress/helper/client'\nimport { useEventListener } from '@vueuse/core'\nimport type { PropType, VNode } from 'vue'\nimport { defineComponent, h, onMounted, shallowRef } from 'vue'\nimport { withBase } from 'vuepress/client'\nimport type { AppManifest } from '../../shared/index.js'\nimport type { PwaPluginLocaleConfig } from '../types.js'\nimport { ArrowLeftIcon, ArrowRightIcon, CloseIcon } from './icons.js'\n\ninterface InstallPromptEvent extends Event {\n readonly platforms: string\n prompt: () => void\n readonly userChoice: Promise<{ outcome: 'accepted' | 'dismissed' }>\n}\n\nconst scrollToLeft = (): void => {\n const screenshotsDiv = document.querySelector('.screenshot')\n\n if (screenshotsDiv)\n screenshotsDiv.scrollBy({\n left: -screenshotsDiv.clientWidth,\n top: 0,\n behavior: 'smooth',\n })\n}\n\nconst scrollToRight = (): void => {\n const screenshotsDiv = document.querySelector('.screenshot')\n\n if (screenshotsDiv)\n screenshotsDiv.scrollBy({\n left: screenshotsDiv.clientWidth,\n top: 0,\n behavior: 'smooth',\n })\n}\n\nexport const PwaInstallModal = defineComponent({\n name: 'PwaInstallModal',\n\n props: {\n /** locale data */\n locales: {\n type: Object as PropType<PwaPluginLocaleConfig>,\n required: true,\n },\n\n /**\n * Whether use hint message instead of showing a button\n *\n * 是否使用提示\n */\n useHint: Boolean,\n },\n\n emits: ['canInstall', 'hint', 'close'],\n\n setup(props, { emit }) {\n const locale = useLocale(props.locales)\n\n const manifest = shallowRef<AppManifest>({})\n const deferredPrompt = shallowRef<InstallPromptEvent>()\n\n const getManifest = async (): Promise<void> => {\n const manifestContent = localStorage.getItem('manifest')\n\n if (manifestContent)\n manifest.value = JSON.parse(manifestContent) as AppManifest\n else\n try {\n const response = await fetch(withBase('manifest.webmanifest'))\n const data = (await response.json()) as AppManifest\n\n manifest.value = data\n localStorage.setItem('manifest', JSON.stringify(data))\n } catch {\n console.error(\n '[PWA]: Error getting manifest, check that you have a valid web manifest or network connection',\n )\n }\n }\n\n const install = async (): Promise<void> => {\n if (deferredPrompt.value) {\n deferredPrompt.value.prompt()\n\n document.dispatchEvent(new CustomEvent('show'))\n\n const choiceResult = await deferredPrompt.value.userChoice\n\n if (choiceResult.outcome === 'accepted') {\n console.info('PWA has been installed')\n\n emit('close', false)\n emit('canInstall', false)\n } else {\n console.info('You choose to not install PWA')\n\n emit('close', false)\n emit('canInstall', false)\n }\n }\n }\n\n const hint = (): void => {\n console.info('You accepted the install hint')\n emit('hint')\n }\n\n onMounted(() => {\n // eslint-disable-next-line no-prototype-builtins\n if (window.hasOwnProperty('BeforeInstallPromptEvent')) {\n useEventListener(window, 'beforeinstallprompt', (event) => {\n deferredPrompt.value = event as InstallPromptEvent\n\n emit('canInstall', true)\n event.preventDefault()\n })\n\n useEventListener(\n 'keyup',\n (event): void => {\n if (event.key === 'Escape') emit('close', false)\n },\n { passive: true },\n )\n\n void getManifest()\n }\n })\n\n return (): VNode =>\n h('div', { id: 'install-modal-wrapper' }, [\n h('div', {\n class: 'background',\n onClick: () => {\n emit('close', false)\n },\n }),\n\n h('div', { class: 'install-modal' }, [\n h('div', { class: 'header' }, [\n // close button\n h(\n 'button',\n {\n 'type': 'button',\n 'class': 'close-button',\n 'aria-label': locale.value.close,\n 'onClick': () => {\n emit('close', false)\n },\n },\n h(CloseIcon),\n ),\n\n h('div', { class: 'logo' }, [\n manifest.value.icons\n ? h('img', {\n src: manifest.value.icons[0]?.src,\n alt: 'App Logo',\n })\n : null,\n h('div', { class: 'title' }, [\n h('h1', manifest.value.short_name || manifest.value.name),\n h('p', { class: 'desc' }, locale.value.explain),\n ]),\n ]),\n ]),\n\n h('div', { class: 'content' }, [\n h('div', { class: 'highlight' }, [\n manifest.value.features\n ? h('div', { class: 'feature-wrapper' }, [\n h('h3', locale.value.feature),\n h(\n 'ul',\n manifest.value.features.map((feature) =>\n h('li', feature),\n ),\n ),\n ])\n : null,\n\n manifest.value.screenshots\n ? h('div', { class: 'screenshot-wrapper' }, [\n h(\n 'button',\n {\n 'type': 'button',\n 'aria-label': locale.value.prevImage,\n 'onClick': scrollToLeft,\n },\n h(ArrowLeftIcon),\n ),\n h('section', { class: 'screenshot' }, [\n manifest.value.screenshots.map((screenshot) =>\n h(\n 'div',\n h('img', {\n src: screenshot.src,\n alt: 'App Screenshot',\n }),\n ),\n ),\n ]),\n h(\n 'button',\n {\n 'type': 'button',\n 'aria-label': locale.value.nextImage,\n 'onClick': scrollToRight,\n },\n h(ArrowRightIcon),\n ),\n ])\n : null,\n ]),\n\n h('div', { class: 'description' }, [\n h('h3', locale.value.desc),\n h('p', manifest.value.description),\n ]),\n ]),\n\n props.useHint\n ? h('div', { class: 'ios-text', onClick: hint }, [\n h('p', locale.value.iOSInstall),\n h('button', { type: 'button', class: 'success' }, 'Got it!'),\n ])\n : h('div', { class: 'button-wrapper' }, [\n h(\n 'button',\n { type: 'button', class: 'install-button', onClick: install },\n [locale.value.install, h('span', manifest.value.short_name)],\n ),\n h(\n 'button',\n {\n type: 'button',\n class: 'cancel-button',\n onClick: () => {\n emit('close', false)\n },\n },\n locale.value.cancel,\n ),\n ]),\n ]),\n ])\n },\n})\n","import { useLocale } from '@vuepress/helper/client'\nimport { useToggle } from '@vueuse/core'\nimport type { PropType, VNode } from 'vue'\nimport { computed, defineComponent, h, onMounted, ref } from 'vue'\nimport type { ManifestExternalApplicationResource } from '../../shared/index.js'\nimport type { PwaPluginLocaleConfig } from '../types.js'\nimport { PwaInstallModal } from './PwaInstallModal.js'\n\nimport '../styles/modal.css'\n\ninterface ModernNavigator extends Navigator {\n // Nonstandard Api\n getInstalledRelatedApps: () => Promise<ManifestExternalApplicationResource[]>\n}\n\ninterface SafariNavigator extends Navigator {\n // Available on Apple’s iOS Safari only.\n standalone: boolean\n}\n\nexport const PwaInstall = defineComponent({\n name: 'PwaInstall',\n\n props: {\n /** locale data */\n locales: {\n type: Object as PropType<PwaPluginLocaleConfig>,\n required: true,\n },\n },\n\n setup(props) {\n const locale = useLocale(props.locales)\n const [isOpen, toggleIsOpen] = useToggle()\n\n const canInstall = ref(false)\n const hasRelatedApps = ref(false)\n const isIOS = ref(false)\n const isSafari = ref(false)\n const hinted = ref(false)\n\n const useHint = computed(\n () => isIOS.value && isSafari.value && !hinted.value,\n )\n\n const showInstall = computed(\n () => (hasRelatedApps.value && canInstall.value) || useHint.value,\n )\n\n const getInstallStatus = (): boolean => {\n if ((navigator as SafariNavigator).standalone)\n return (navigator as SafariNavigator).standalone\n\n return matchMedia('(display-mode: standalone)').matches\n }\n\n const hint = (): void => {\n toggleIsOpen(false)\n hinted.value = true\n // do not notify again\n localStorage.setItem('iOS-pwa-hint', 'hinted')\n }\n\n onMounted(() => {\n if (getInstallStatus()) {\n const { userAgent } = navigator\n\n // handle iOS specifically\n isIOS.value =\n // regular iPhone\n userAgent.includes('iPhone') ||\n // regular iPad\n userAgent.includes('iPad') ||\n // iPad pro\n Boolean(\n userAgent.includes('Macintosh') &&\n navigator.maxTouchPoints &&\n navigator.maxTouchPoints > 2,\n )\n\n isSafari.value =\n navigator.userAgent.includes('Safari') &&\n !userAgent.includes('Chrome')\n\n hinted.value = Boolean(localStorage.getItem('iOS-pwa-hint'))\n }\n\n if ('getInstalledRelatedApps' in (navigator as ModernNavigator))\n void (navigator as ModernNavigator)\n .getInstalledRelatedApps()\n .then((result) => {\n hasRelatedApps.value = result.length > 0\n })\n })\n\n return (): VNode =>\n h('div', { id: 'pwa-install' }, [\n showInstall.value\n ? h(\n 'button',\n {\n type: 'button',\n class: 'modal-button',\n onClick: () => {\n toggleIsOpen(true)\n },\n },\n locale.value.install,\n )\n : null,\n h(PwaInstallModal, {\n style: {\n display: isOpen.value ? 'block' : 'none',\n },\n locales: props.locales,\n useHint: useHint.value,\n onCanInstall: (value: boolean) => {\n canInstall.value = value\n },\n onHint: () => {\n hint()\n },\n onClose: () => toggleIsOpen(false),\n }),\n ])\n },\n})\n"],"names":["scrollToLeft","screenshotsDiv","scrollToRight","PwaInstallModal","defineComponent","props","emit","locale","useLocale","manifest","shallowRef","deferredPrompt","getManifest","manifestContent","data","withBase","install","hint","onMounted","useEventListener","event","h","CloseIcon","feature","ArrowLeftIcon","screenshot","ArrowRightIcon","PwaInstall","isOpen","toggleIsOpen","useToggle","canInstall","ref","hasRelatedApps","isIOS","isSafari","hinted","useHint","computed","showInstall","getInstallStatus","userAgent","result","value"],"mappings":"oVAgBA,MAAMA,EAAe,IAAY,CAC/B,MAAMC,EAAiB,SAAS,cAAc,aAAa,EAEvDA,GACFA,EAAe,SAAS,CACtB,KAAM,CAACA,EAAe,YACtB,IAAK,EACL,SAAU,QACZ,CAAC,CACL,EAEMC,EAAgB,IAAY,CAChC,MAAMD,EAAiB,SAAS,cAAc,aAAa,EAEvDA,GACFA,EAAe,SAAS,CACtB,KAAMA,EAAe,YACrB,IAAK,EACL,SAAU,QACZ,CAAC,CACL,EAEaE,EAAkBC,EAAgB,CAC7C,KAAM,kBAEN,MAAO,CAEL,QAAS,CACP,KAAM,OACN,SAAU,EACZ,EAOA,QAAS,OACX,EAEA,MAAO,CAAC,aAAc,OAAQ,OAAO,EAErC,MAAMC,EAAO,CAAE,KAAAC,CAAK,EAAG,CACrB,MAAMC,EAASC,EAAUH,EAAM,OAAO,EAEhCI,EAAWC,EAAwB,CAAA,CAAE,EACrCC,EAAiBD,EAA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,EAAK,EAClBO,EAAO,MAAQ,GAEf,aAAa,QAAQ,eAAgB,QAAQ,CAC/C,EAEA,OAAAlB,EAAU,IAAM,CACd,GAAIsB,EAAAA,EAAoB,CACtB,KAAM,CAAE,UAAAC,CAAU,EAAI,UAGtBP,EAAM,MAEJO,EAAU,SAAS,QAAQ,GAE3BA,EAAU,SAAS,MAAM,GAEzB,CAAA,EACEA,EAAU,SAAS,WAAW,GAC9B,UAAU,gBACV,UAAU,eAAiB,GAG/BN,EAAS,MACP,UAAU,UAAU,SAAS,QAAQ,GACrC,CAACM,EAAU,SAAS,QAAQ,EAE9BL,EAAO,MAAQ,CAAA,CAAQ,aAAa,QAAQ,cAAc,CAC5D,CAEI,4BAA8B,WAC1B,UACH,0BACA,KAAMM,GAAW,CAChBT,EAAe,MAAQS,EAAO,OAAS,CACzC,CAAC,CACP,CAAC,EAEM,IACLrB,EAAE,MAAO,CAAE,GAAI,aAAc,EAAG,CAC9BkB,EAAY,MACRlB,EACE,SACA,CACE,KAAM,SACN,MAAO,eACP,QAAS,IAAM,CACbQ,EAAa,EAAI,CACnB,CACF,EACAtB,EAAO,MAAM,OACf,EACA,KACJc,EAAElB,EAAiB,CACjB,MAAO,CACL,QAASyB,EAAO,MAAQ,QAAU,MACpC,EACA,QAASvB,EAAM,QACf,QAASgC,EAAQ,MACjB,aAAeM,GAAmB,CAChCZ,EAAW,MAAQY,CACrB,EACA,OAAQ,IAAM,CACZ1B,EAAAA,CACF,EACA,QAAS,IAAMY,EAAa,EAAK,CACnC,CAAC,CACH,CAAC,CACL,CACF,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { PropType, VNode, SlotsType } from 'vue';
|
|
3
|
-
import { Slot } from '@vuepress/helper/client';
|
|
4
|
-
import { P as PwaPluginLocaleConfig } from '../types-B0Ty8tPv.js';
|
|
5
|
-
|
|
6
|
-
declare const PwaReadyPopup: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
7
|
-
/** locale data */
|
|
8
|
-
locales: {
|
|
9
|
-
type: PropType<PwaPluginLocaleConfig>;
|
|
10
|
-
required: true;
|
|
11
|
-
};
|
|
12
|
-
}>, () => VNode, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
13
|
-
/** locale data */
|
|
14
|
-
locales: {
|
|
15
|
-
type: PropType<PwaPluginLocaleConfig>;
|
|
16
|
-
required: true;
|
|
17
|
-
};
|
|
18
|
-
}>> & Readonly<{}>, {}, SlotsType<{
|
|
19
|
-
default?: Slot<{
|
|
20
|
-
isReady: boolean;
|
|
21
|
-
reload: () => void;
|
|
22
|
-
}>;
|
|
23
|
-
}>, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
24
|
-
|
|
25
|
-
export { PwaReadyPopup };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"@vuepress/helper/client";import"vue";import"../icons-DQk7h1-3.js";import"@vuepress/helper/transition/fade-in-scale-up.css";import"../styles/popup.css";import{P as e}from"../PwaReadyPopup-Crl_YRc0.js";import"../usePwaEvent-CUDY9qle.js";export{e as PwaReadyPopup};
|
|
2
|
-
//# sourceMappingURL=PwaReadyPopup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PwaReadyPopup.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{s as p,a as r,u as i}from"../index-BvxQeVsR.js";import{p as u,u as w}from"../usePwaEvent-CUDY9qle.js";import"mitt";import"vue";import"vuepress/client";export{u as pwaEventSymbol,p as setupPwa,r as setupViewPoint,w as usePwaEvent,i as useRegisterSW};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"icons-DQk7h1-3.js","sources":["../../src/client/components/icons.ts"],"sourcesContent":["// oxlint-disable id-length\nimport type { FunctionalComponent, VNode } from 'vue'\nimport { h } from 'vue'\n\ninterface SVGWrapperProps {\n name?: string\n color?: string\n}\n\nconst SVGWrapper: FunctionalComponent<\n SVGWrapperProps,\n Record<never, never>,\n { default: () => VNode | VNode[] }\n> = ({ name = '', color = 'currentColor' }, { slots }) =>\n h(\n 'svg',\n {\n 'xmlns': 'http://www.w3.org/2000/svg',\n 'class': ['icon', `${name}-icon`],\n 'viewBox': '0 0 1024 1024',\n 'fill': color,\n 'aria-label': `${name} icon`,\n },\n slots.default(),\n )\n\nSVGWrapper.displayName = 'SVGWrapper'\n\nexport const ArrowLeftIcon: FunctionalComponent = () =>\n h(SVGWrapper, { name: 'arrow-left' }, () =>\n h('path', {\n d: 'M802.8 448h-428l166-158.8c23.8-25 23.8-65.4 0-90.4s-62.4-25-86.4 0L178 466.8c-12 11.6-18 27.4-18 44.8v0.8c0 17.4 6 33.2 18 44.8l276.2 268c24 25 62.6 25 86.4 0 23.8-25 23.8-65.4 0-90.4l-166-158.8h428c33.8 0 61.2-28.6 61.2-64 0.2-36-27.2-64-61-64z',\n }),\n )\n\nArrowLeftIcon.displayName = 'ArrowLeftIcon'\n\nexport const ArrowRightIcon: FunctionalComponent = () =>\n h(SVGWrapper, { name: 'arrow-right' }, () =>\n h('path', {\n d: 'M569.8 825.2l276.2-268c12-11.6 18-27.4 18-44.8v-0.8c0-17.4-6-33.2-18-44.8l-276.2-268c-24-25-62.6-25-86.4 0-23.8 25-23.8 65.4 0 90.4l166 158.8h-428c-34 0-61.4 28.6-61.4 64 0 36 27.4 64 61.2 64h428l-166 158.8c-23.8 25-23.8 65.4 0 90.4 24 25 62.6 25 86.6 0z',\n }),\n )\n\nArrowRightIcon.displayName = 'ArrowRightIcon'\n\nexport const CloseIcon: FunctionalComponent = () =>\n h(SVGWrapper, { name: 'close' }, () =>\n h('path', {\n d: 'M589.654 511.965 1007.212 84.22a49.777 49.777 0 0 0-.73-70.02 49.046 49.046 0 0 0-69.687.665L519.967 441.946 85.882 14.2a49.08 49.08 0 0 0-69.687.664 49.777 49.777 0 0 0 .664 70.019l433.454 427.082L16.859 939.048a49.777 49.777 0 0 0-.664 70.019 49.013 49.013 0 0 0 69.687.663l434.085-427.746 416.828 427.083A49.013 49.013 0 0 0 972.037 1024a48.416 48.416 0 0 0 34.512-14.27 49.777 49.777 0 0 0 .73-70.019z',\n }),\n )\n\nCloseIcon.displayName = 'CloseIcon'\n\nexport const UpdateIcon: FunctionalComponent = () =>\n h(SVGWrapper, { name: 'update' }, () =>\n h('path', {\n d: 'M949.949 146.25v255.826c0 21.981-13.989 35.97-35.97 35.97H658.154c-13.988 0-25.983-7.992-33.973-21.981-5.997-13.989-4-27.977 7.991-39.97l79.942-77.946c-55.954-51.973-121.918-77.955-199.863-77.955-37.975 0-75.95 8.002-113.924 21.99-37.975 15.985-67.948 37.976-91.934 63.957-25.982 23.987-47.973 53.96-63.957 91.934-29.983 73.955-29.983 153.895 0 227.85 15.984 37.976 37.975 67.947 63.957 91.934 23.986 25.982 53.959 47.973 91.934 63.956 37.974 13.989 75.95 21.991 113.924 21.991 45.967 0 87.942-9.998 127.913-29.982 41.976-17.99 75.951-45.967 101.931-83.943 7.993-4 11.994-5.995 13.989-5.995 5.997 0 9.998 1.994 13.988 5.995l77.958 77.946c3.989 4 5.986 7.993 5.986 11.994 0 1.994-1.996 5.995-3.99 11.994-43.973 51.962-93.941 91.934-151.9 117.914-53.958 25.983-115.92 39.972-185.874 39.972-61.961 0-119.921-11.984-169.89-33.973-57.96-25.985-105.923-57.963-139.896-93.943-35.98-33.972-67.958-81.936-93.94-139.897-45.967-101.93-45.967-237.846 0-339.777 25.982-57.96 57.96-105.923 93.94-139.896 33.973-35.98 81.936-67.958 139.896-93.94 49.968-21.99 107.928-33.974 169.89-33.974 55.963 0 109.923 9.988 161.885 29.973 53.97 21.99 101.933 51.963 139.908 89.938l73.954-73.944c9.987-9.998 23.987-13.988 39.971-8.002 13.988 8.002 21.98 19.995 21.98 33.984z',\n }),\n )\n\nUpdateIcon.displayName = 'UpdateIcon'\n"],"names":["SVGWrapper","name","color","slots","h","ArrowLeftIcon","ArrowRightIcon","CloseIcon","UpdateIcon"],"mappings":"wBASA,MAAMA,EAIF,CAAC,CAAE,KAAAC,EAAO,GAAI,MAAAC,EAAQ,cAAe,EAAG,CAAE,MAAAC,CAAM,IAClDC,EACE,MACA,CACE,MAAS,6BACT,MAAS,CAAC,OAAQ,GAAGH,CAAI,OAAO,EAChC,QAAW,gBACX,KAAQC,EACR,aAAc,GAAGD,CAAI,OACvB,EACAE,EAAM,QAAA,CACR,EAEFH,EAAW,YAAc,aAElB,MAAMK,EAAqC,IAChDD,EAAEJ,EAAY,CAAE,KAAM,YAAa,EAAG,IACpCI,EAAE,OAAQ,CACR,EAAG,uPACL,CAAC,CACH,EAEFC,EAAc,YAAc,gBAErB,MAAMC,EAAsC,IACjDF,EAAEJ,EAAY,CAAE,KAAM,aAAc,EAAG,IACrCI,EAAE,OAAQ,CACR,EAAG,gQACL,CAAC,CACH,EAEFE,EAAe,YAAc,iBAEtB,MAAMC,EAAiC,IAC5CH,EAAEJ,EAAY,CAAE,KAAM,OAAQ,EAAG,IAC/BI,EAAE,OAAQ,CACR,EAAG,uZACL,CAAC,CACH,EAEFG,EAAU,YAAc,YAEjB,MAAMC,EAAkC,IAC7CJ,EAAEJ,EAAY,CAAE,KAAM,QAAS,EAAG,IAChCI,EAAE,OAAQ,CACR,EAAG,+tCACL,CAAC,CACH,EAEFI,EAAW,YAAc"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import s from"mitt";import{provide as l,onMounted as i}from"vue";import{p as m}from"./usePwaEvent-CUDY9qle.js";import{withBase as u}from"vuepress/client";const n=()=>{navigator.serviceWorker.getRegistration().then(r=>{r?.active&&r.addEventListener("updatefound",()=>{window.location.reload(!0)})})},c=async(r,t={},e=!0)=>{const{register:a}=await import("register-service-worker");a(r,{ready(o){e&&console.info("[Service Worker]: active"),t.ready?.(o)},registered(o){e&&console.log("[Service Worker]: registered"),t.registered?.(o)},cached(o){e&&console.log("[Service Worker]: cached"),t.cached?.(o)},updatefound(o){e&&console.log("[Service Worker]: update found"),t.updatefound?.(o)},updated(o){e&&console.log("[Service Worker]: updated"),t.updated?.(o)},offline(){e&&console.log("[Service Worker]: offline"),t.offline?.()},error(o){e&&console.error("[Service Worker]:",o),t.error?.(o)}})},d=async(r,t)=>c(u(r),{ready(e){t.emit("ready",e)},registered(e){t.emit("registered",e)},cached(e){t.emit("cached",e)},updatefound(e){t.emit("updatefound",e)},updated(e){const a="service-worker-version",o=Number(localStorage.getItem(a)||0);localStorage.setItem(a,(o+1).toString()),localStorage.removeItem("manifest"),t.emit("updated",e)},offline(){t.emit("offline")},error(e){t.emit("error",e)}}),f=(r,t=!1)=>{if(__VUEPRESS_SSR__)return;const e=s();l(m,e),i(async()=>{if(__VUEPRESS_DEV__||!("serviceWorker"in navigator))return;let a=!1;navigator.serviceWorker.controller&&navigator.serviceWorker.addEventListener("controllerchange",()=>{a||(a=!0,window.location.reload())}),t&&n(),await d(r,e)})},v=()=>{i(()=>{if(window.matchMedia("(display-mode: standalone)").matches){const r=document.head.querySelector('meta[name="viewport"]');if(r){r.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover");return}const t=document.createElement("meta");t.name="viewport",t.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover",document.head.append(t)}})};export{v as a,n as f,c as r,f as s,d as u};
|
|
2
|
-
//# sourceMappingURL=index-BvxQeVsR.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-BvxQeVsR.js","sources":["../../src/client/utils/forceUpdate.ts","../../src/client/utils/registerSW.ts","../../src/client/composables/useRegisterSW.ts","../../src/client/composables/setupPwa.ts","../../src/client/composables/setupViewPoint.ts"],"sourcesContent":["/**\n * Force update page content\n *\n * 强制更新页面内容\n */\nexport const forceUpdate = (): void => {\n void navigator.serviceWorker.getRegistration().then((registration) => {\n // Check whether a valid service worker is active\n if (registration?.active)\n registration.addEventListener('updatefound', () => {\n // force refresh\n // @ts-expect-error: A non-standard API\n window.location.reload(true)\n })\n })\n}\n","/* eslint-disable no-console */\nimport type { Hooks } from 'register-service-worker'\n\n/**\n * Register serviceWorker under `serviceWorkerPath`\n *\n * 在 `serviceWorkerPath` 下注册 Service Worker\n *\n * @param serviceWorkerPath - Service Worker path / Service Worker 路径\n * @param hooks - Service worker hooks / Service Worker 钩子\n * @param showStatus - Whether to show status in console / 是否在控制台显示状态\n */\nexport const registerSW = async (\n serviceWorkerPath: string,\n hooks: Hooks = {},\n showStatus = true,\n): Promise<void> => {\n const { register } = await import(\n /* webpackChunkName: \"register-service-worker\" */ 'register-service-worker'\n )\n\n // Register service worker\n register(serviceWorkerPath, {\n ready(registration) {\n if (showStatus) console.info('[Service Worker]: active')\n hooks.ready?.(registration)\n },\n\n registered(registration) {\n if (showStatus) console.log('[Service Worker]: registered')\n hooks.registered?.(registration)\n },\n\n cached(registration) {\n if (showStatus) console.log('[Service Worker]: cached')\n hooks.cached?.(registration)\n },\n\n updatefound(registration) {\n if (showStatus) console.log('[Service Worker]: update found')\n hooks.updatefound?.(registration)\n },\n\n updated(registration) {\n if (showStatus) console.log('[Service Worker]: updated')\n hooks.updated?.(registration)\n },\n\n offline() {\n if (showStatus) console.log('[Service Worker]: offline')\n hooks.offline?.()\n },\n\n error(err) {\n if (showStatus) console.error('[Service Worker]:', err)\n hooks.error?.(err)\n },\n })\n}\n","import { withBase } from 'vuepress/client'\nimport { registerSW } from '../utils/index.js'\nimport type { PwaEvent } from './usePwaEvent.js'\n\n/**\n * Register service worker with event emitter\n *\n * 使用事件发射器注册 Service Worker\n *\n * @param serviceWorkerPath - Service Worker path / Service Worker 路径\n * @param event - PWA event emitter / PWA 事件发射器\n */\nexport const useRegisterSW = async (\n serviceWorkerPath: string,\n event: PwaEvent,\n): Promise<void> =>\n registerSW(withBase(serviceWorkerPath), {\n ready(registration) {\n event.emit('ready', registration)\n },\n\n registered(registration) {\n event.emit('registered', registration)\n },\n\n cached(registration) {\n event.emit('cached', registration)\n },\n\n updatefound(registration) {\n event.emit('updatefound', registration)\n },\n\n updated(registration) {\n const key = 'service-worker-version'\n const version = Number(localStorage.getItem(key) || 0)\n\n localStorage.setItem(key, (version + 1).toString())\n localStorage.removeItem('manifest')\n\n event.emit('updated', registration)\n },\n\n offline() {\n event.emit('offline')\n },\n\n error(err) {\n event.emit('error', err)\n },\n })\n","import mitt from 'mitt'\nimport { onMounted, provide } from 'vue'\nimport { forceUpdate } from '../utils/index.js'\nimport { pwaEventSymbol } from './usePwaEvent.js'\nimport { useRegisterSW } from './useRegisterSW.js'\nimport type { PwaEvent } from './index.js'\n\n/**\n * Setup PWA functionality\n *\n * 设置 PWA 功能\n *\n * @param serviceWorkerPath - Service Worker path / Service Worker 路径\n * @param shouldForceUpdate - Whether to force update / 是否强制更新\n */\nexport const setupPwa = (\n serviceWorkerPath: string,\n shouldForceUpdate = false,\n): void => {\n if (__VUEPRESS_SSR__) return\n\n // Create event emitter and provide it\n const event: PwaEvent = mitt()\n\n provide(pwaEventSymbol, event)\n\n onMounted(async () => {\n if (__VUEPRESS_DEV__ || !('serviceWorker' in navigator)) return\n\n let refreshing = false\n\n // Only listen controllerchange event when a serviceWorker is active\n if (navigator.serviceWorker.controller)\n navigator.serviceWorker.addEventListener('controllerchange', () => {\n if (refreshing) return\n\n refreshing = true\n window.location.reload()\n })\n\n if (shouldForceUpdate) forceUpdate()\n\n await useRegisterSW(serviceWorkerPath, event)\n })\n}\n","import { onMounted } from 'vue'\n\n/**\n * Setup viewport for PWA standalone mode\n *\n * 为 PWA 独立模式设置视口\n */\nexport const setupViewPoint = (): void => {\n onMounted(() => {\n const isStandAlone = window.matchMedia('(display-mode: standalone)').matches\n\n if (isStandAlone) {\n const head = document.head.querySelector('meta[name=\"viewport\"]')\n\n if (head) {\n head.setAttribute(\n 'content',\n 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover',\n )\n return\n }\n\n const viewportMeta = document.createElement('meta')\n\n viewportMeta.name = 'viewport'\n viewportMeta.content =\n 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover'\n\n document.head.append(viewportMeta)\n }\n })\n}\n"],"names":["forceUpdate","registration","registerSW","serviceWorkerPath","hooks","showStatus","register","err","useRegisterSW","event","withBase","key","version","setupPwa","shouldForceUpdate","mitt","provide","pwaEventSymbol","onMounted","refreshing","setupViewPoint","head","viewportMeta"],"mappings":"0JAKO,MAAMA,EAAc,IAAY,CAChC,UAAU,cAAc,kBAAkB,KAAMC,GAAiB,CAEhEA,GAAc,QAChBA,EAAa,iBAAiB,cAAe,IAAM,CAGjD,OAAO,SAAS,OAAO,EAAI,CAC7B,CAAC,CACL,CAAC,CACH,ECHaC,EAAa,MACxBC,EACAC,EAAe,CAAA,EACfC,EAAa,KACK,CAClB,KAAM,CAAE,SAAAC,CAAS,EAAI,KAAM,QACyB,yBACpD,EAGAA,EAASH,EAAmB,CAC1B,MAAMF,EAAc,CACdI,GAAY,QAAQ,KAAK,0BAA0B,EACvDD,EAAM,QAAQH,CAAY,CAC5B,EAEA,WAAWA,EAAc,CACnBI,GAAY,QAAQ,IAAI,8BAA8B,EAC1DD,EAAM,aAAaH,CAAY,CACjC,EAEA,OAAOA,EAAc,CACfI,GAAY,QAAQ,IAAI,0BAA0B,EACtDD,EAAM,SAASH,CAAY,CAC7B,EAEA,YAAYA,EAAc,CACpBI,GAAY,QAAQ,IAAI,gCAAgC,EAC5DD,EAAM,cAAcH,CAAY,CAClC,EAEA,QAAQA,EAAc,CAChBI,GAAY,QAAQ,IAAI,2BAA2B,EACvDD,EAAM,UAAUH,CAAY,CAC9B,EAEA,SAAU,CACJI,GAAY,QAAQ,IA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G,EAAO,SAAS,KAAK,cAAc,uBAAuB,EAEhE,GAAIA,EAAM,CACRA,EAAK,aACH,UACA,gGACF,EACA,MACF,CAEA,MAAMC,EAAe,SAAS,cAAc,MAAM,EAElDA,EAAa,KAAO,WACpBA,EAAa,QACX,iGAEF,SAAS,KAAK,OAAOA,CAAY,CACnC,CACF,CAAC,CACH"}
|
package/lib/client/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{PwaFoundPopup as P}from"./components/PwaFoundPopup.js";import{PwaInstall as l}from"./components/PwaInstall.js";import{P as v,s as x}from"./PwaReadyPopup-Crl_YRc0.js";import{f as k,r as y,s as S,a as R,u as h}from"./index-BvxQeVsR.js";import{p as E,u as U}from"./usePwaEvent-CUDY9qle.js";import"@vuepress/helper/client";import"vue";import"./icons-DQk7h1-3.js";import"@vuepress/helper/transition/fade-in-scale-up.css";import"./styles/popup.css";import"@vueuse/core";import"vuepress/client";import"./styles/modal.css";import"mitt";const t=async()=>{try{const r=await navigator.serviceWorker.getRegistration();if(r){const e=await r.unregister();return e&&console.log("[PWA] Current service worker unregistered"),e}}catch(r){console.error("[PWA] Unregister current service worker failed with error:",r)}return!1};export{P as PwaFoundPopup,l as PwaInstall,v as PwaReadyPopup,k as forceUpdate,E as pwaEventSymbol,y as registerSW,S as setupPwa,R as setupViewPoint,x as skipWaiting,t as unregisterSW,U as usePwaEvent,h as useRegisterSW};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/lib/client/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/client/utils/unregisterSW.ts"],"sourcesContent":["/* eslint-disable no-console */\n/**\n * Call `unregister()` inside current active worker\n *\n * 在当前激活的 Service Worker 中调用 `unregister()`\n *\n * @returns `true` if unregister success, `false` if unregister failed / `true` 表示注销成功,`false` 表示注销失败\n */\nexport const unregisterSW = async (): Promise<boolean> => {\n try {\n const registration = await navigator.serviceWorker.getRegistration()\n if (registration) {\n const found = await registration.unregister()\n if (found) console.log('[PWA] Current service worker unregistered')\n return found\n }\n } catch (err: unknown) {\n console.error(\n '[PWA] Unregister current service worker failed with error:',\n err,\n )\n }\n return false\n}\n"],"names":["unregisterSW","registration","found","err"],"mappings":"uhBAQO,MAAMA,EAAe,SAA8B,CACxD,GAAI,CACF,MAAMC,EAAe,MAAM,UAAU,cAAc,kBACnD,GAAIA,EAAc,CAChB,MAAMC,EAAQ,MAAMD,EAAa,aACjC,OAAIC,GAAO,QAAQ,IAAI,2CAA2C,EAC3DA,CACT,CACF,OAASC,EAAc,CACrB,QAAQ,MACN,6DACAA,CACF,CACF,CACA,MAAO,EACT"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { ExactLocaleConfig } from '@vuepress/helper/client';
|
|
2
|
-
|
|
3
|
-
interface PwaPluginLocaleData {
|
|
4
|
-
/**
|
|
5
|
-
* Install button text
|
|
6
|
-
*
|
|
7
|
-
* 安装按钮文字
|
|
8
|
-
*/
|
|
9
|
-
install: string;
|
|
10
|
-
/**
|
|
11
|
-
* iOS install hint text
|
|
12
|
-
*
|
|
13
|
-
* iOS 安装文字
|
|
14
|
-
*/
|
|
15
|
-
iOSInstall: string;
|
|
16
|
-
/**
|
|
17
|
-
* Cancel button text
|
|
18
|
-
*
|
|
19
|
-
* 取消按钮文字
|
|
20
|
-
*/
|
|
21
|
-
cancel: string;
|
|
22
|
-
/**
|
|
23
|
-
* Close button text
|
|
24
|
-
*
|
|
25
|
-
* 关闭按钮文字
|
|
26
|
-
*/
|
|
27
|
-
close: string;
|
|
28
|
-
/**
|
|
29
|
-
* Previous image text
|
|
30
|
-
*
|
|
31
|
-
* 上一张图片文字
|
|
32
|
-
*/
|
|
33
|
-
prevImage: string;
|
|
34
|
-
/**
|
|
35
|
-
* Next image text
|
|
36
|
-
*
|
|
37
|
-
* 下一张图片文字
|
|
38
|
-
*/
|
|
39
|
-
nextImage: string;
|
|
40
|
-
/**
|
|
41
|
-
* Install explain text
|
|
42
|
-
*
|
|
43
|
-
* 安装解释
|
|
44
|
-
*/
|
|
45
|
-
explain: string;
|
|
46
|
-
/**
|
|
47
|
-
* Description label text
|
|
48
|
-
*
|
|
49
|
-
* 描述标签文字
|
|
50
|
-
*/
|
|
51
|
-
desc: string;
|
|
52
|
-
/**
|
|
53
|
-
* Feature label text
|
|
54
|
-
*
|
|
55
|
-
* 特性标签文字
|
|
56
|
-
*/
|
|
57
|
-
feature: string;
|
|
58
|
-
/**
|
|
59
|
-
* Update hint text
|
|
60
|
-
*
|
|
61
|
-
* 提示有更新文字
|
|
62
|
-
*/
|
|
63
|
-
hint: string;
|
|
64
|
-
/**
|
|
65
|
-
* Update available text
|
|
66
|
-
*
|
|
67
|
-
* 更新可用文字
|
|
68
|
-
*/
|
|
69
|
-
update: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
type PwaPluginLocaleConfig = ExactLocaleConfig<PwaPluginLocaleData>;
|
|
73
|
-
|
|
74
|
-
export type { PwaPluginLocaleConfig as P };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePwaEvent-CUDY9qle.js","sources":["../../src/client/composables/usePwaEvent.ts"],"sourcesContent":["import type { Emitter } from 'mitt'\nimport type { InjectionKey } from 'vue'\nimport { inject } from 'vue'\n\ndeclare const __VUEPRESS_DEV__: boolean\n\nexport type PwaEvent = Emitter<{\n ready: ServiceWorkerRegistration\n registered: ServiceWorkerRegistration\n cached: ServiceWorkerRegistration\n updatefound: ServiceWorkerRegistration\n updated: ServiceWorkerRegistration\n offline: void\n error: Error\n}>\n\nexport const pwaEventSymbol: InjectionKey<PwaEvent> = Symbol(\n __VUEPRESS_DEV__ ? 'PwaEvent' : '',\n)\n\n/**\n * Use PWA event emitter\n *\n * 使用 PWA 事件发射器\n *\n * @returns PWA event emitter / PWA 事件发射器\n */\nexport const usePwaEvent = (): PwaEvent => {\n const pwaEvent = inject(pwaEventSymbol)\n\n if (!pwaEvent) throw new Error('usePwaEvent() is called without provider.')\n\n return pwaEvent\n}\n"],"names":["pwaEventSymbol","usePwaEvent","pwaEvent","inject"],"mappings":"6BAgBO,MAAMA,EAAyC,OACpD,iBAAmB,WAAa,EAClC,EASaC,EAAc,IAAgB,CACzC,MAAMC,EAAWC,EAAOH,CAAc,EAEtC,GAAI,CAACE,EAAU,MAAM,IAAI,MAAM,2CAA2C,EAE1E,OAAOA,CACT"}
|
package/lib/node/index.d.ts
DELETED
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
import { DefaultLocaleInfo } from '@vuepress/helper';
|
|
2
|
-
import { LocaleConfig } from 'vuepress/shared';
|
|
3
|
-
import { GenerateSWOptions } from 'workbox-build';
|
|
4
|
-
import { PluginFunction } from 'vuepress/core';
|
|
5
|
-
|
|
6
|
-
interface PwaPluginLocaleData {
|
|
7
|
-
/**
|
|
8
|
-
* Install button text
|
|
9
|
-
*
|
|
10
|
-
* 安装按钮文字
|
|
11
|
-
*/
|
|
12
|
-
install: string;
|
|
13
|
-
/**
|
|
14
|
-
* iOS install hint text
|
|
15
|
-
*
|
|
16
|
-
* iOS 安装文字
|
|
17
|
-
*/
|
|
18
|
-
iOSInstall: string;
|
|
19
|
-
/**
|
|
20
|
-
* Cancel button text
|
|
21
|
-
*
|
|
22
|
-
* 取消按钮文字
|
|
23
|
-
*/
|
|
24
|
-
cancel: string;
|
|
25
|
-
/**
|
|
26
|
-
* Close button text
|
|
27
|
-
*
|
|
28
|
-
* 关闭按钮文字
|
|
29
|
-
*/
|
|
30
|
-
close: string;
|
|
31
|
-
/**
|
|
32
|
-
* Previous image text
|
|
33
|
-
*
|
|
34
|
-
* 上一张图片文字
|
|
35
|
-
*/
|
|
36
|
-
prevImage: string;
|
|
37
|
-
/**
|
|
38
|
-
* Next image text
|
|
39
|
-
*
|
|
40
|
-
* 下一张图片文字
|
|
41
|
-
*/
|
|
42
|
-
nextImage: string;
|
|
43
|
-
/**
|
|
44
|
-
* Install explain text
|
|
45
|
-
*
|
|
46
|
-
* 安装解释
|
|
47
|
-
*/
|
|
48
|
-
explain: string;
|
|
49
|
-
/**
|
|
50
|
-
* Description label text
|
|
51
|
-
*
|
|
52
|
-
* 描述标签文字
|
|
53
|
-
*/
|
|
54
|
-
desc: string;
|
|
55
|
-
/**
|
|
56
|
-
* Feature label text
|
|
57
|
-
*
|
|
58
|
-
* 特性标签文字
|
|
59
|
-
*/
|
|
60
|
-
feature: string;
|
|
61
|
-
/**
|
|
62
|
-
* Update hint text
|
|
63
|
-
*
|
|
64
|
-
* 提示有更新文字
|
|
65
|
-
*/
|
|
66
|
-
hint: string;
|
|
67
|
-
/**
|
|
68
|
-
* Update available text
|
|
69
|
-
*
|
|
70
|
-
* 更新可用文字
|
|
71
|
-
*/
|
|
72
|
-
update: string;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @see https://www.w3.org/TR/mediaqueries-5/#display-mode
|
|
77
|
-
*/
|
|
78
|
-
type DisplayMode = 'browser' | 'fullscreen' | 'minimal-ui' | 'standalone';
|
|
79
|
-
/**
|
|
80
|
-
* @see https://github.com/w3c/manifest/wiki/Categories
|
|
81
|
-
*/
|
|
82
|
-
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';
|
|
83
|
-
/**
|
|
84
|
-
* @see https://www.w3.org/TR/screen-orientation/#dom-orientationlocktype
|
|
85
|
-
*/
|
|
86
|
-
type OrientationLockType = 'any' | 'landscape-primary' | 'landscape-secondary' | 'landscape' | 'natural' | 'portrait-primary' | 'portrait-secondary' | 'portrait';
|
|
87
|
-
/**
|
|
88
|
-
* @see https://www.w3.org/TR/appmanifest/#manifest-image-resources
|
|
89
|
-
*/
|
|
90
|
-
interface ManifestImageResource {
|
|
91
|
-
src: string;
|
|
92
|
-
sizes: string;
|
|
93
|
-
type?: string;
|
|
94
|
-
}
|
|
95
|
-
interface ManifestIcon extends ManifestImageResource {
|
|
96
|
-
purpose?: 'any' | 'maskable' | 'monochrome';
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* @see https://www.w3.org/TR/appmanifest/#external-application-resource
|
|
100
|
-
*/
|
|
101
|
-
interface ManifestExternalApplicationResource {
|
|
102
|
-
/**
|
|
103
|
-
* @see https://github.com/w3c/manifest/wiki/Platforms
|
|
104
|
-
*/
|
|
105
|
-
platform: 'amazon' | 'chrome_web_store' | 'chromeos_play' | 'f-droid' | 'itunes' | 'play' | 'webapp' | 'windows';
|
|
106
|
-
url: string;
|
|
107
|
-
id?: string;
|
|
108
|
-
min_version?: string;
|
|
109
|
-
fingerprints?: {
|
|
110
|
-
type: string;
|
|
111
|
-
value: string;
|
|
112
|
-
}[];
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* @see https://www.w3.org/TR/appmanifest/#shortcut-items
|
|
116
|
-
*/
|
|
117
|
-
interface ManifestShortCutItem {
|
|
118
|
-
name: string;
|
|
119
|
-
url: string;
|
|
120
|
-
short_name?: string;
|
|
121
|
-
description?: string;
|
|
122
|
-
icons?: ManifestIcon[];
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* @see https://www.w3.org/TR/appmanifest/
|
|
126
|
-
*/
|
|
127
|
-
interface AppManifest extends Record<string, unknown> {
|
|
128
|
-
/**
|
|
129
|
-
* @see https://www.w3.org/TR/appmanifest/#name-member
|
|
130
|
-
*
|
|
131
|
-
* The name of the web application as it is usually displayed to the user
|
|
132
|
-
*/
|
|
133
|
-
name?: string;
|
|
134
|
-
/**
|
|
135
|
-
* @see https://www.w3.org/TR/appmanifest/#short_name-member
|
|
136
|
-
*
|
|
137
|
-
* A short version of the name of the web application
|
|
138
|
-
*/
|
|
139
|
-
short_name?: string;
|
|
140
|
-
/**
|
|
141
|
-
* @see https://www.w3.org/TR/appmanifest/#dfn-background_color
|
|
142
|
-
*
|
|
143
|
-
* The expected background color of the web application
|
|
144
|
-
*/
|
|
145
|
-
background_color?: string;
|
|
146
|
-
/**
|
|
147
|
-
* @see https://www.w3.org/TR/appmanifest/#dir-member
|
|
148
|
-
*
|
|
149
|
-
* The base direction for the localizable members of the manifest.
|
|
150
|
-
*/
|
|
151
|
-
dir?: 'auto' | 'ltr' | 'rtl';
|
|
152
|
-
/**
|
|
153
|
-
* @see https://www.w3.org/TR/appmanifest/#lang-member
|
|
154
|
-
*
|
|
155
|
-
* specifies the primary language for the values of the manifest's localizable members
|
|
156
|
-
*/
|
|
157
|
-
lang?: string;
|
|
158
|
-
/**
|
|
159
|
-
* @see https://www.w3.org/TR/appmanifest/#dfn-display
|
|
160
|
-
*
|
|
161
|
-
* The developer's preferred display mode for the web application
|
|
162
|
-
*/
|
|
163
|
-
display?: DisplayMode;
|
|
164
|
-
icons?: ManifestIcon[];
|
|
165
|
-
/**
|
|
166
|
-
* @see https://www.w3.org/TR/appmanifest/#orientation-member
|
|
167
|
-
*
|
|
168
|
-
* Serves as the default screen orientation for all top-level browsing contexts of the web application
|
|
169
|
-
*/
|
|
170
|
-
orientation?: OrientationLockType;
|
|
171
|
-
/**
|
|
172
|
-
* @see https://www.w3.org/TR/appmanifest/#scope-member
|
|
173
|
-
*
|
|
174
|
-
* The navigation scope of this web application's application context.
|
|
175
|
-
*/
|
|
176
|
-
scope?: string;
|
|
177
|
-
/**
|
|
178
|
-
* @see https://www.w3.org/TR/appmanifest/#start_url-member
|
|
179
|
-
*
|
|
180
|
-
* Start URL
|
|
181
|
-
*/
|
|
182
|
-
start_url?: string;
|
|
183
|
-
/**
|
|
184
|
-
* @see https://www.w3.org/TR/appmanifest/#id-member
|
|
185
|
-
*
|
|
186
|
-
* Identity for the application
|
|
187
|
-
*/
|
|
188
|
-
id?: string;
|
|
189
|
-
/**
|
|
190
|
-
* @see https://www.w3.org/TR/appmanifest/#theme_color-member
|
|
191
|
-
*
|
|
192
|
-
* Default theme color for an application context
|
|
193
|
-
*/
|
|
194
|
-
theme_color?: string;
|
|
195
|
-
shortcuts?: ManifestShortCutItem[];
|
|
196
|
-
prefer_related_applications?: boolean;
|
|
197
|
-
related_applications?: ManifestExternalApplicationResource[];
|
|
198
|
-
description?: string;
|
|
199
|
-
categories?: ManifestCategory[];
|
|
200
|
-
screenshots?: ManifestImageResource[];
|
|
201
|
-
iarc_rating_id?: string;
|
|
202
|
-
features?: string[];
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Default locale info for `@vuepress/plugin-pwa`
|
|
207
|
-
*/
|
|
208
|
-
declare const pwaLocaleInfo: DefaultLocaleInfo<PwaPluginLocaleData>;
|
|
209
|
-
|
|
210
|
-
interface ApplePwaOptions {
|
|
211
|
-
/**
|
|
212
|
-
* Path of icon used on apple devices
|
|
213
|
-
*
|
|
214
|
-
* Recommend 152×152 size
|
|
215
|
-
*
|
|
216
|
-
* 苹果上使用的图标路径
|
|
217
|
-
*
|
|
218
|
-
* 推荐 152×152 大小
|
|
219
|
-
*/
|
|
220
|
-
icon?: string;
|
|
221
|
-
/**
|
|
222
|
-
* Safari mask icon
|
|
223
|
-
*
|
|
224
|
-
* Safari 图标
|
|
225
|
-
*/
|
|
226
|
-
maskIcon?: string;
|
|
227
|
-
/**
|
|
228
|
-
* @deprecated Related tag is unstandardized so you should avoid declaring it.
|
|
229
|
-
*
|
|
230
|
-
* Color of status bar
|
|
231
|
-
*
|
|
232
|
-
* 状态栏的颜色
|
|
233
|
-
*
|
|
234
|
-
* @default "default"
|
|
235
|
-
*/
|
|
236
|
-
statusBarColor?: 'black-translucent' | 'black' | 'default';
|
|
237
|
-
}
|
|
238
|
-
interface PwaPluginOptions {
|
|
239
|
-
/**
|
|
240
|
-
* Service Worker file path
|
|
241
|
-
*
|
|
242
|
-
* Service Worker 文件路径
|
|
243
|
-
*
|
|
244
|
-
* @default "service-worker.js"
|
|
245
|
-
*/
|
|
246
|
-
serviceWorkerFilename?: string;
|
|
247
|
-
/**
|
|
248
|
-
* Whether display install button
|
|
249
|
-
*
|
|
250
|
-
* 是否显示安装按钮
|
|
251
|
-
*
|
|
252
|
-
* @default true
|
|
253
|
-
*/
|
|
254
|
-
showInstall?: boolean;
|
|
255
|
-
/**
|
|
256
|
-
* Manifest file Config
|
|
257
|
-
*
|
|
258
|
-
* manifest 文件设置
|
|
259
|
-
*/
|
|
260
|
-
manifest?: AppManifest;
|
|
261
|
-
/**
|
|
262
|
-
* Path of favicon
|
|
263
|
-
*
|
|
264
|
-
* favicon 地址
|
|
265
|
-
*/
|
|
266
|
-
favicon?: string;
|
|
267
|
-
/**
|
|
268
|
-
* Theme Color
|
|
269
|
-
*
|
|
270
|
-
* 主题色
|
|
271
|
-
*
|
|
272
|
-
* @default "#46bd87"
|
|
273
|
-
*/
|
|
274
|
-
themeColor?: string;
|
|
275
|
-
/**
|
|
276
|
-
* Max size which allows to cache, with KB unit
|
|
277
|
-
*
|
|
278
|
-
* 允许缓存的最大大小,单位 KB
|
|
279
|
-
*
|
|
280
|
-
* @default 2048
|
|
281
|
-
*/
|
|
282
|
-
maxSize?: number;
|
|
283
|
-
/**
|
|
284
|
-
* Whether cache html files besides home page and 404
|
|
285
|
-
*
|
|
286
|
-
* 是否缓存除主页与 404 之外的 HTML
|
|
287
|
-
*
|
|
288
|
-
* @default false
|
|
289
|
-
*/
|
|
290
|
-
cacheHTML?: boolean;
|
|
291
|
-
/**
|
|
292
|
-
* Whether cache pictures
|
|
293
|
-
*
|
|
294
|
-
* 是否缓存站点图片
|
|
295
|
-
*
|
|
296
|
-
* @default false
|
|
297
|
-
*/
|
|
298
|
-
cacheImage?: boolean;
|
|
299
|
-
/**
|
|
300
|
-
* Max size which allows to cache, with KB unit
|
|
301
|
-
*
|
|
302
|
-
* 图片允许缓存的最大大小,单位 KB
|
|
303
|
-
*
|
|
304
|
-
* @default 1024
|
|
305
|
-
*/
|
|
306
|
-
maxImageSize?: number;
|
|
307
|
-
/**
|
|
308
|
-
* Settings for apple
|
|
309
|
-
*
|
|
310
|
-
* 苹果设置
|
|
311
|
-
*/
|
|
312
|
-
apple?: ApplePwaOptions | false;
|
|
313
|
-
/**
|
|
314
|
-
* Update logic
|
|
315
|
-
*
|
|
316
|
-
* - `"disable"`: 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.
|
|
317
|
-
* - `"available"`: Only display update popup when the new service worker is available
|
|
318
|
-
* - `"hint"`: Display a hint to let user choose to refresh immediately. This is helpful when you want users to see new docs immediately.
|
|
319
|
-
* - `"force"`: unregister current service worker immediately then refresh to get new content. **This may affect visiting experiences**!
|
|
320
|
-
*
|
|
321
|
-
* 更新逻辑
|
|
322
|
-
*
|
|
323
|
-
* - `"disable"`: 即使有新的 service worker 也不做任何事情,新的 service work 开始等待后,会在用户下次访问时接管页面,让用户获得新内容。
|
|
324
|
-
* - `"available"`: 仅当新的 service worker 可用时才显示更新弹出窗口
|
|
325
|
-
* - `"hint"`: 显示更新内容可用提示,并允许用户立即刷新。当新的 SW 成功注册后,将转为更新内容就绪弹窗。当你希望用户立即查看新文档时,这很有帮助。
|
|
326
|
-
* - `"force"`: 立即注销当前 Service Worker 然后刷新以获取新内容。**这可能会影响访问体验**!
|
|
327
|
-
*
|
|
328
|
-
* @default "available"
|
|
329
|
-
*/
|
|
330
|
-
update?: 'available' | 'disable' | 'force' | 'hint';
|
|
331
|
-
/**
|
|
332
|
-
* A custom component to replace the default hint popup component.
|
|
333
|
-
*
|
|
334
|
-
* 用于替换默认提示弹出组件的自定义组件。
|
|
335
|
-
*
|
|
336
|
-
* @default "PwaFoundPopup"
|
|
337
|
-
*/
|
|
338
|
-
foundComponent?: string;
|
|
339
|
-
/**
|
|
340
|
-
* A custom component to replace the default update popup component.
|
|
341
|
-
*
|
|
342
|
-
* 用于替换默认更新弹出组件的自定义组件。
|
|
343
|
-
*
|
|
344
|
-
* @default "PwaReadyPopup"
|
|
345
|
-
*/
|
|
346
|
-
readyComponent?: string;
|
|
347
|
-
/**
|
|
348
|
-
* workbox-build’s [generateSW config](https://developers.google.com/web/tools/workbox/modules/workbox-build#full_generatesw_config)
|
|
349
|
-
*
|
|
350
|
-
*/
|
|
351
|
-
generateSWConfig?: Partial<GenerateSWOptions>;
|
|
352
|
-
/**
|
|
353
|
-
* Locales config
|
|
354
|
-
*
|
|
355
|
-
* 国际化配置
|
|
356
|
-
*/
|
|
357
|
-
locales?: LocaleConfig<PwaPluginLocaleData>;
|
|
358
|
-
/**
|
|
359
|
-
* Whether append base to all absolute links in options
|
|
360
|
-
*
|
|
361
|
-
* 是否为选项中所有绝对链接添加 base
|
|
362
|
-
*
|
|
363
|
-
* @default false
|
|
364
|
-
*/
|
|
365
|
-
appendBase?: boolean;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* PWA plugin
|
|
370
|
-
*
|
|
371
|
-
* PWA 插件
|
|
372
|
-
*
|
|
373
|
-
* @param options - Plugin options / 插件选项
|
|
374
|
-
* @returns VuePress plugin / VuePress 插件
|
|
375
|
-
*
|
|
376
|
-
* @example
|
|
377
|
-
* ```ts
|
|
378
|
-
* import { pwaPlugin } from '@vuepress/plugin-pwa'
|
|
379
|
-
*
|
|
380
|
-
* export default {
|
|
381
|
-
* plugins: [
|
|
382
|
-
* pwaPlugin({
|
|
383
|
-
* showInstall: true,
|
|
384
|
-
* manifest: {
|
|
385
|
-
* name: 'My PWA App'
|
|
386
|
-
* },
|
|
387
|
-
* update: 'hint'
|
|
388
|
-
* })
|
|
389
|
-
* ]
|
|
390
|
-
* }
|
|
391
|
-
* ```
|
|
392
|
-
*/
|
|
393
|
-
declare const pwaPlugin: (options?: PwaPluginOptions) => PluginFunction;
|
|
394
|
-
|
|
395
|
-
export { pwaLocaleInfo, pwaPlugin };
|
|
396
|
-
export type { AppManifest, DisplayMode, ManifestCategory, ManifestExternalApplicationResource, ManifestIcon, ManifestImageResource, ManifestShortCutItem, OrientationLockType, PwaPluginLocaleData, PwaPluginOptions };
|