@vuepress/client 2.0.0-beta.33 → 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 +7 -2
- package/lib/provideGlobalComputed.d.ts +16 -2
- package/lib/provideGlobalComputed.js +11 -0
- package/lib/setupDevtools.d.ts +3 -0
- package/lib/setupDevtools.js +21 -0
- package/package.json +3 -2
- package/types.d.ts +2 -0
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
|
|
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,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) =>
|
|
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
|
};
|
|
@@ -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.
|
|
3
|
+
"version": "2.0.0-beta.34",
|
|
4
4
|
"description": "Client package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"copy": "cpx \"src/**/*.{d.ts,css}\" lib"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@vue/devtools-api": "^6.0.0-beta.21.1",
|
|
32
33
|
"@vuepress/shared": "2.0.0-beta.33",
|
|
33
34
|
"vue": "^3.2.26",
|
|
34
35
|
"vue-router": "^4.0.12"
|
|
@@ -40,5 +41,5 @@
|
|
|
40
41
|
"publishConfig": {
|
|
41
42
|
"access": "public"
|
|
42
43
|
},
|
|
43
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "aba907994697f4d0a691f2e3668dad4bea388f20"
|
|
44
45
|
}
|
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
|