@vuepress/client 2.0.0-beta.28 → 2.0.0-beta.34

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/app.js CHANGED
@@ -9,6 +9,7 @@ import { createMemoryHistory, createRouter, createWebHistory, RouterView, START_
9
9
  import { pageData, resolvePageData, setupUpdateHead, siteData, } from './composables';
10
10
  import { provideGlobalComputed } from './provideGlobalComputed';
11
11
  import { registerGlobalComponents } from './registerGlobalComponents';
12
+ import { setupDevtools } from './setupDevtools';
12
13
  /**
13
14
  * - use `createApp` in dev mode
14
15
  * - use `createSSRApp` in build mode
@@ -60,9 +61,13 @@ export const createVueApp = async () => {
60
61
  ]);
61
62
  }
62
63
  });
63
- // global computed and global components
64
- provideGlobalComputed(app, router);
64
+ // global components and computed
65
65
  registerGlobalComponents(app);
66
+ const globalComputed = provideGlobalComputed(app, router);
67
+ // setup devtools in dev mode
68
+ if (__VUEPRESS_DEV__ || __VUE_PROD_DEVTOOLS__) {
69
+ setupDevtools(app, globalComputed);
70
+ }
66
71
  // invoke all clientAppEnhances
67
72
  for (const clientAppEnhance of clientAppEnhances) {
68
73
  await clientAppEnhance({ app, router, siteData });
@@ -1,4 +1,3 @@
1
1
  export * from './ClientOnly';
2
2
  export * from './Content';
3
- export * from './OutboundLink';
4
3
  export * from './Vuepress';
@@ -1,4 +1,3 @@
1
1
  export * from './ClientOnly';
2
2
  export * from './Content';
3
- export * from './OutboundLink';
4
3
  export * from './Vuepress';
@@ -1,14 +1,28 @@
1
1
  import type { App } from 'vue';
2
2
  import type { Router } from 'vue-router';
3
- import type { PageData, PageFrontmatter, PageHeadTitle, PageLang, RouteLocale, SiteData, SiteLocaleData } from './composables';
3
+ import type { PageData, PageDataRef, PageFrontmatter, PageFrontmatterRef, PageHead, PageHeadRef, PageHeadTitle, PageHeadTitleRef, PageLang, PageLangRef, RouteLocale, RouteLocaleRef, SiteData, SiteDataRef, SiteLocaleData, SiteLocaleDataRef } from './composables';
4
4
  import { withBase } from './utils';
5
+ /**
6
+ * Vuepress client global computed
7
+ */
8
+ export interface GlobalComputed {
9
+ pageData: PageDataRef;
10
+ pageFrontmatter: PageFrontmatterRef;
11
+ pageHead: PageHeadRef;
12
+ pageHeadTitle: PageHeadTitleRef;
13
+ pageLang: PageLangRef;
14
+ routeLocale: RouteLocaleRef;
15
+ siteData: SiteDataRef;
16
+ siteLocaleData: SiteLocaleDataRef;
17
+ }
5
18
  /**
6
19
  * Create and provide global computed
7
20
  */
8
- export declare const provideGlobalComputed: (app: App, router: Router) => void;
21
+ export declare const provideGlobalComputed: (app: App, router: Router) => GlobalComputed;
9
22
  declare module '@vue/runtime-core' {
10
23
  interface ComponentCustomProperties {
11
24
  $frontmatter: PageFrontmatter;
25
+ $head: PageHead;
12
26
  $headTitle: PageHeadTitle;
13
27
  $lang: PageLang;
14
28
  $page: PageData;
@@ -22,6 +22,7 @@ export const provideGlobalComputed = (app, router) => {
22
22
  // provide global helpers
23
23
  Object.defineProperties(app.config.globalProperties, {
24
24
  $frontmatter: { get: () => pageFrontmatter.value },
25
+ $head: { get: () => pageHead.value },
25
26
  $headTitle: { get: () => pageHeadTitle.value },
26
27
  $lang: { get: () => pageLang.value },
27
28
  $page: { get: () => pageData.value },
@@ -30,4 +31,14 @@ export const provideGlobalComputed = (app, router) => {
30
31
  $siteLocale: { get: () => siteLocaleData.value },
31
32
  $withBase: { get: () => withBase },
32
33
  });
34
+ return {
35
+ pageData,
36
+ pageFrontmatter,
37
+ pageHead,
38
+ pageHeadTitle,
39
+ pageLang,
40
+ routeLocale,
41
+ siteData,
42
+ siteLocaleData,
43
+ };
33
44
  };
@@ -1,4 +1,4 @@
1
- import { ClientOnly, Content, OutboundLink } from './components';
1
+ import { ClientOnly, Content } from './components';
2
2
  /**
3
3
  * Register global built-in components
4
4
  */
@@ -6,6 +6,5 @@ export const registerGlobalComponents = (app) => {
6
6
  /* eslint-disable vue/match-component-file-name */
7
7
  app.component('ClientOnly', ClientOnly);
8
8
  app.component('Content', Content);
9
- app.component('OutboundLink', OutboundLink);
10
9
  /* eslint-enable vue/match-component-file-name */
11
10
  };
@@ -0,0 +1,3 @@
1
+ import type { App } from 'vue';
2
+ import type { GlobalComputed } from './provideGlobalComputed';
3
+ export declare const setupDevtools: (app: App, globalComputed: GlobalComputed) => void;
@@ -0,0 +1,21 @@
1
+ import { setupDevtoolsPlugin } from '@vue/devtools-api';
2
+ export const setupDevtools = (app, globalComputed) => {
3
+ setupDevtoolsPlugin({
4
+ app,
5
+ id: 'org.vuejs.vuepress',
6
+ label: 'VuePress',
7
+ packageName: '@vuepress/client',
8
+ homepage: 'https://v2.vuepress.vuejs.org',
9
+ logo: 'https://v2.vuepress.vuejs.org/images/hero.png',
10
+ componentStateTypes: ['VuePress'],
11
+ }, (api) => {
12
+ api.on.inspectComponent((payload) => {
13
+ payload.instanceData.state.push(...Object.entries(globalComputed).map(([name, item]) => ({
14
+ type: 'VuePress',
15
+ key: name,
16
+ editable: false,
17
+ value: item.value,
18
+ })));
19
+ });
20
+ });
21
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/client",
3
- "version": "2.0.0-beta.28",
3
+ "version": "2.0.0-beta.34",
4
4
  "description": "Client package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -29,16 +29,17 @@
29
29
  "copy": "cpx \"src/**/*.{d.ts,css}\" lib"
30
30
  },
31
31
  "dependencies": {
32
- "@vuepress/shared": "2.0.0-beta.28",
33
- "vue": "^3.2.24",
32
+ "@vue/devtools-api": "^6.0.0-beta.21.1",
33
+ "@vuepress/shared": "2.0.0-beta.33",
34
+ "vue": "^3.2.26",
34
35
  "vue-router": "^4.0.12"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@types/webpack-env": "^1.16.3",
38
- "vite": "^2.7.1"
39
+ "vite": "^2.7.10"
39
40
  },
40
41
  "publishConfig": {
41
42
  "access": "public"
42
43
  },
43
- "gitHead": "71c34816a79263c7dcba3ff0c103e264abdbf0d2"
44
+ "gitHead": "aba907994697f4d0a691f2e3668dad4bea388f20"
44
45
  }
File without changes
package/types.d.ts CHANGED
@@ -2,3 +2,5 @@ declare const __VUEPRESS_VERSION__: string
2
2
  declare const __VUEPRESS_DEV__: boolean
3
3
  declare const __VUEPRESS_SSR__: boolean
4
4
  declare const __VUE_HMR_RUNTIME__: Record<string, any>
5
+ declare const __VUE_OPTIONS_API__: boolean
6
+ declare const __VUE_PROD_DEVTOOLS__: boolean
@@ -1,7 +0,0 @@
1
- .icon.outbound {
2
- position: relative;
3
- display: inline-block;
4
- color: #aaa;
5
- vertical-align: middle;
6
- top: -1px;
7
- }
@@ -1,3 +0,0 @@
1
- import type { FunctionalComponent } from 'vue';
2
- import './OutboundLink.css';
3
- export declare const OutboundLink: FunctionalComponent;
@@ -1,24 +0,0 @@
1
- import { h } from 'vue';
2
- import './OutboundLink.css';
3
- const svg = h('svg', {
4
- 'class': 'icon outbound',
5
- 'xmlns': 'http://www.w3.org/2000/svg',
6
- 'aria-hidden': 'true',
7
- 'focusable': 'false',
8
- 'x': '0px',
9
- 'y': '0px',
10
- 'viewBox': '0 0 100 100',
11
- 'width': '15',
12
- 'height': '15',
13
- }, [
14
- h('path', {
15
- fill: 'currentColor',
16
- d: 'M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z',
17
- }),
18
- h('polygon', {
19
- fill: 'currentColor',
20
- points: '45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9',
21
- }),
22
- ]);
23
- export const OutboundLink = (_, { slots }) => { var _a; return h('span', [svg, (_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)]); };
24
- OutboundLink.displayName = 'OutboundLink';