@vuepress/plugin-pwa 2.0.0-rc.18 → 2.0.0-rc.20

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,3 +1,4 @@
1
1
  export * from './setupPwa.js';
2
+ export * from './setupViewPoint.js';
2
3
  export * from './usePwaEvent.js';
3
4
  export * from './useRegisterSW.js';
@@ -1,3 +1,4 @@
1
1
  export * from './setupPwa.js';
2
+ export * from './setupViewPoint.js';
2
3
  export * from './usePwaEvent.js';
3
4
  export * from './useRegisterSW.js';
@@ -0,0 +1 @@
1
+ export declare const setupViewPoint: () => void;
@@ -0,0 +1,18 @@
1
+ import { onMounted } from 'vue';
2
+ export const setupViewPoint = () => {
3
+ onMounted(() => {
4
+ const isStandAlone = window.matchMedia('(display-mode: standalone)').matches;
5
+ if (isStandAlone) {
6
+ const head = document.head.querySelector('meta[name="viewport"]');
7
+ if (head) {
8
+ head.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover');
9
+ return;
10
+ }
11
+ const viewportMeta = document.createElement('meta');
12
+ viewportMeta.name = 'viewport';
13
+ viewportMeta.content =
14
+ 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover';
15
+ document.head.appendChild(viewportMeta);
16
+ }
17
+ });
18
+ };
@@ -58,7 +58,5 @@ export const injectLinksToHead = (options, base = '/', head = []) => {
58
58
  setMeta('msapplication-TileImage', fallBackIcon);
59
59
  setMeta('msapplication-TileColor', options.themeColor || '#46bd87');
60
60
  }
61
- // Enhance pwa experience
62
- setMeta('viewport', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover');
63
61
  return head;
64
62
  };
@@ -27,6 +27,7 @@ import { PwaReadyPopup as _PwaReadyPopup } from "${options.readyComponent ||
27
27
  import { h } from "vue";
28
28
  import { defineClientConfig } from "vuepress/client";
29
29
  import { setupPwa } from "${path.join(__dirname, '../client/composables/setupPwa.js')}";
30
+ import { setupViewPoint } from "${path.join(__dirname, '../client/composables/setupViewPoint.js')}";
30
31
  ${configImport}
31
32
  import "${path.join(__dirname, '../client/styles/vars.css')}";
32
33
 
@@ -37,6 +38,7 @@ ${rootComponents.map((item) => `const ${item} = () => h(_${item}, { locales })`)
37
38
  export default defineClientConfig({
38
39
  setup: () => {
39
40
  setupPwa(__SW_PATH__, __SW_FORCE_UPDATE__);
41
+ setupViewPoint();
40
42
  },
41
43
  rootComponents: [
42
44
  ${rootComponents.map((item) => ` ${item},`).join('\n')}
@@ -33,10 +33,7 @@ export const pwaPlugin = (options = {}) => (app) => {
33
33
  'mitt',
34
34
  'register-service-worker',
35
35
  ]);
36
- addViteSsrNoExternal(bundlerOptions, app, [
37
- '@vuepress/helper',
38
- 'vuepress-shared',
39
- ]);
36
+ addViteSsrNoExternal(bundlerOptions, app, '@vuepress/helper');
40
37
  customizeDevServer(bundlerOptions, app, {
41
38
  path: '/manifest.webmanifest',
42
39
  response: async (_, response) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/plugin-pwa",
3
- "version": "2.0.0-rc.18",
3
+ "version": "2.0.0-rc.20",
4
4
  "description": "VuePress plugin - progressive web application",
5
5
  "keywords": [
6
6
  "vuepress-plugin",
@@ -41,7 +41,7 @@
41
41
  "style": "sass src:lib --no-source-map"
42
42
  },
43
43
  "dependencies": {
44
- "@vuepress/helper": "~2.0.0-rc.18",
44
+ "@vuepress/helper": "~2.0.0-rc.19",
45
45
  "@vueuse/core": "^10.9.0",
46
46
  "mitt": "^3.0.1",
47
47
  "register-service-worker": "^1.7.2",
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "8bad47f0dbefd1037574255bf95a719bb680f60e"
57
+ "gitHead": "7042b2665c01b45c39a511efe059aed11b77c6f3"
58
58
  }