vitepress 1.0.0-alpha.13 → 1.0.0-alpha.15

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.
Files changed (51) hide show
  1. package/dist/client/app/components/ClientOnly.js +10 -10
  2. package/dist/client/app/components/Content.js +17 -11
  3. package/dist/client/app/composables/copyCode.js +68 -64
  4. package/dist/client/app/composables/head.js +51 -51
  5. package/dist/client/app/composables/preFetch.js +94 -94
  6. package/dist/client/app/data.js +44 -44
  7. package/dist/client/app/devtools.js +28 -28
  8. package/dist/client/app/index.js +97 -97
  9. package/dist/client/app/router.js +207 -200
  10. package/dist/client/app/ssr.js +8 -9
  11. package/dist/client/app/theme.js +1 -1
  12. package/dist/client/app/utils.js +47 -47
  13. package/dist/client/index.d.ts +42 -110
  14. package/dist/client/index.js +9 -9
  15. package/dist/client/shared.js +109 -109
  16. package/dist/client/theme-default/Layout.vue +5 -2
  17. package/dist/client/theme-default/components/VPDoc.vue +5 -2
  18. package/dist/client/theme-default/components/VPDocAside.vue +2 -2
  19. package/dist/client/theme-default/components/VPDocAsideOutline.vue +19 -47
  20. package/dist/client/theme-default/components/VPDocAsideOutlineItem.vue +51 -0
  21. package/dist/client/theme-default/components/VPNavBar.vue +1 -1
  22. package/dist/client/theme-default/components/VPNavBarExtra.vue +4 -1
  23. package/dist/client/theme-default/components/VPNavScreen.vue +1 -1
  24. package/dist/client/theme-default/components/VPSidebarLink.vue +16 -14
  25. package/dist/client/theme-default/components/VPSwitchAppearance.vue +8 -0
  26. package/dist/client/theme-default/composables/aside.js +17 -17
  27. package/dist/client/theme-default/composables/edit-link.js +11 -11
  28. package/dist/client/theme-default/composables/flyout.js +40 -40
  29. package/dist/client/theme-default/composables/nav.js +53 -53
  30. package/dist/client/theme-default/composables/outline.js +141 -96
  31. package/dist/client/theme-default/composables/prev-next.js +22 -22
  32. package/dist/client/theme-default/composables/sidebar.js +63 -63
  33. package/dist/client/theme-default/composables/sponsor-grid.js +94 -94
  34. package/dist/client/theme-default/index.js +23 -23
  35. package/dist/client/theme-default/styles/base.css +3 -2
  36. package/dist/client/theme-default/styles/lib-override/nprogress.css +12 -0
  37. package/dist/client/theme-default/styles/vars.css +6 -4
  38. package/dist/client/theme-default/support/sidebar.js +37 -37
  39. package/dist/client/theme-default/support/socialIcons.js +11 -11
  40. package/dist/client/theme-default/support/utils.js +63 -63
  41. package/dist/node/cli.js +3 -3
  42. package/dist/node/index.d.ts +1717 -323
  43. package/dist/node/index.js +2 -2
  44. package/dist/node/{serve-1b26f7f9.js → serve-38d4ddb1.js} +1832 -11801
  45. package/dist/node-cjs/cli.cjs +3 -3
  46. package/dist/node-cjs/index.cjs +2 -2
  47. package/dist/node-cjs/{serve-d52b9e69.cjs → serve-b7f045a1.cjs} +1822 -11791
  48. package/package.json +27 -24
  49. package/types/default-theme.d.ts +7 -0
  50. package/types/index.d.ts +2 -34
  51. package/types/shared.d.ts +31 -2
@@ -1,10 +1,10 @@
1
- import { defineComponent, ref, onMounted } from 'vue';
2
- export const ClientOnly = defineComponent({
3
- setup(_, { slots }) {
4
- const show = ref(false);
5
- onMounted(() => {
6
- show.value = true;
7
- });
8
- return () => (show.value && slots.default ? slots.default() : null);
9
- }
10
- });
1
+ import { defineComponent, ref, onMounted } from 'vue';
2
+ export const ClientOnly = defineComponent({
3
+ setup(_, { slots }) {
4
+ const show = ref(false);
5
+ onMounted(() => {
6
+ show.value = true;
7
+ });
8
+ return () => (show.value && slots.default ? slots.default() : null);
9
+ }
10
+ });
@@ -1,11 +1,17 @@
1
- import { defineComponent, h } from 'vue';
2
- import { useRoute } from '../router.js';
3
- export const Content = defineComponent({
4
- name: 'VitePressContent',
5
- setup() {
6
- const route = useRoute();
7
- return () => h('div', { style: { position: 'relative' } }, [
8
- route.component ? h(route.component) : null
9
- ]);
10
- }
11
- });
1
+ import { defineComponent, h, onUpdated } from 'vue';
2
+ import { useRoute } from '../router.js';
3
+ export const Content = defineComponent({
4
+ name: 'VitePressContent',
5
+ props: {
6
+ onContentUpdated: Function
7
+ },
8
+ setup(props) {
9
+ const route = useRoute();
10
+ onUpdated(() => {
11
+ props.onContentUpdated?.();
12
+ });
13
+ return () => h('div', { style: { position: 'relative' } }, [
14
+ route.component ? h(route.component) : null
15
+ ]);
16
+ }
17
+ });
@@ -1,64 +1,68 @@
1
- import { inBrowser } from '../utils.js';
2
- export function useCopyCode() {
3
- if (inBrowser) {
4
- window.addEventListener('click', (e) => {
5
- const el = e.target;
6
- if (el.matches('div[class*="language-"] > button.copy')) {
7
- const parent = el.parentElement;
8
- const sibling = el.nextElementSibling
9
- ?.nextElementSibling;
10
- if (!parent || !sibling) {
11
- return;
12
- }
13
- const isShell = /language-(shellscript|shell|bash|sh|zsh)/.test(parent.classList.toString());
14
- let { innerText: text = '' } = sibling;
15
- if (isShell) {
16
- text = text.replace(/^ *(\$|>) /gm, '');
17
- }
18
- copyToClipboard(text).then(() => {
19
- el.classList.add('copied');
20
- setTimeout(() => {
21
- el.classList.remove('copied');
22
- el.blur();
23
- }, 2000);
24
- });
25
- }
26
- });
27
- }
28
- }
29
- async function copyToClipboard(text) {
30
- try {
31
- return navigator.clipboard.writeText(text);
32
- }
33
- catch {
34
- const element = document.createElement('textarea');
35
- const previouslyFocusedElement = document.activeElement;
36
- element.value = text;
37
- // Prevent keyboard from showing on mobile
38
- element.setAttribute('readonly', '');
39
- element.style.contain = 'strict';
40
- element.style.position = 'absolute';
41
- element.style.left = '-9999px';
42
- element.style.fontSize = '12pt'; // Prevent zooming on iOS
43
- const selection = document.getSelection();
44
- const originalRange = selection
45
- ? selection.rangeCount > 0 && selection.getRangeAt(0)
46
- : null;
47
- document.body.appendChild(element);
48
- element.select();
49
- // Explicit selection workaround for iOS
50
- element.selectionStart = 0;
51
- element.selectionEnd = text.length;
52
- document.execCommand('copy');
53
- document.body.removeChild(element);
54
- if (originalRange) {
55
- selection.removeAllRanges(); // originalRange can't be truthy when selection is falsy
56
- selection.addRange(originalRange);
57
- }
58
- // Get the focus back on the previously focused element, if any
59
- if (previouslyFocusedElement) {
60
- ;
61
- previouslyFocusedElement.focus();
62
- }
63
- }
64
- }
1
+ import { inBrowser } from '../utils.js';
2
+ export function useCopyCode() {
3
+ if (inBrowser) {
4
+ const timeoutIdMap = new Map();
5
+ window.addEventListener('click', (e) => {
6
+ const el = e.target;
7
+ if (el.matches('div[class*="language-"] > button.copy')) {
8
+ const parent = el.parentElement;
9
+ const sibling = el.nextElementSibling
10
+ ?.nextElementSibling;
11
+ if (!parent || !sibling) {
12
+ return;
13
+ }
14
+ const isShell = /language-(shellscript|shell|bash|sh|zsh)/.test(parent.classList.toString());
15
+ let { innerText: text = '' } = sibling;
16
+ if (isShell) {
17
+ text = text.replace(/^ *(\$|>) /gm, '');
18
+ }
19
+ copyToClipboard(text).then(() => {
20
+ el.classList.add('copied');
21
+ clearTimeout(timeoutIdMap.get(el));
22
+ const timeoutId = setTimeout(() => {
23
+ el.classList.remove('copied');
24
+ el.blur();
25
+ timeoutIdMap.delete(el);
26
+ }, 2000);
27
+ timeoutIdMap.set(el, timeoutId);
28
+ });
29
+ }
30
+ });
31
+ }
32
+ }
33
+ async function copyToClipboard(text) {
34
+ try {
35
+ return navigator.clipboard.writeText(text);
36
+ }
37
+ catch {
38
+ const element = document.createElement('textarea');
39
+ const previouslyFocusedElement = document.activeElement;
40
+ element.value = text;
41
+ // Prevent keyboard from showing on mobile
42
+ element.setAttribute('readonly', '');
43
+ element.style.contain = 'strict';
44
+ element.style.position = 'absolute';
45
+ element.style.left = '-9999px';
46
+ element.style.fontSize = '12pt'; // Prevent zooming on iOS
47
+ const selection = document.getSelection();
48
+ const originalRange = selection
49
+ ? selection.rangeCount > 0 && selection.getRangeAt(0)
50
+ : null;
51
+ document.body.appendChild(element);
52
+ element.select();
53
+ // Explicit selection workaround for iOS
54
+ element.selectionStart = 0;
55
+ element.selectionEnd = text.length;
56
+ document.execCommand('copy');
57
+ document.body.removeChild(element);
58
+ if (originalRange) {
59
+ selection.removeAllRanges(); // originalRange can't be truthy when selection is falsy
60
+ selection.addRange(originalRange);
61
+ }
62
+ // Get the focus back on the previously focused element, if any
63
+ if (previouslyFocusedElement) {
64
+ ;
65
+ previouslyFocusedElement.focus();
66
+ }
67
+ }
68
+ }
@@ -1,51 +1,51 @@
1
- import { watchEffect } from 'vue';
2
- import { createTitle, mergeHead } from '../../shared.js';
3
- export function useUpdateHead(route, siteDataByRouteRef) {
4
- let managedHeadTags = [];
5
- let isFirstUpdate = true;
6
- const updateHeadTags = (newTags) => {
7
- if (import.meta.env.PROD && isFirstUpdate) {
8
- // in production, the initial meta tags are already pre-rendered so we
9
- // skip the first update.
10
- isFirstUpdate = false;
11
- return;
12
- }
13
- managedHeadTags.forEach((el) => document.head.removeChild(el));
14
- managedHeadTags = [];
15
- newTags.forEach((headConfig) => {
16
- const el = createHeadElement(headConfig);
17
- document.head.appendChild(el);
18
- managedHeadTags.push(el);
19
- });
20
- };
21
- watchEffect(() => {
22
- const pageData = route.data;
23
- const siteData = siteDataByRouteRef.value;
24
- const pageDescription = pageData && pageData.description;
25
- const frontmatterHead = (pageData && pageData.frontmatter.head) || [];
26
- // update title and description
27
- document.title = createTitle(siteData, pageData);
28
- document
29
- .querySelector(`meta[name=description]`)
30
- .setAttribute('content', pageDescription || siteData.description);
31
- updateHeadTags(mergeHead(siteData.head, filterOutHeadDescription(frontmatterHead)));
32
- });
33
- }
34
- function createHeadElement([tag, attrs, innerHTML]) {
35
- const el = document.createElement(tag);
36
- for (const key in attrs) {
37
- el.setAttribute(key, attrs[key]);
38
- }
39
- if (innerHTML) {
40
- el.innerHTML = innerHTML;
41
- }
42
- return el;
43
- }
44
- function isMetaDescription(headConfig) {
45
- return (headConfig[0] === 'meta' &&
46
- headConfig[1] &&
47
- headConfig[1].name === 'description');
48
- }
49
- function filterOutHeadDescription(head) {
50
- return head.filter((h) => !isMetaDescription(h));
51
- }
1
+ import { watchEffect } from 'vue';
2
+ import { createTitle, mergeHead } from '../../shared.js';
3
+ export function useUpdateHead(route, siteDataByRouteRef) {
4
+ let managedHeadTags = [];
5
+ let isFirstUpdate = true;
6
+ const updateHeadTags = (newTags) => {
7
+ if (import.meta.env.PROD && isFirstUpdate) {
8
+ // in production, the initial meta tags are already pre-rendered so we
9
+ // skip the first update.
10
+ isFirstUpdate = false;
11
+ return;
12
+ }
13
+ managedHeadTags.forEach((el) => document.head.removeChild(el));
14
+ managedHeadTags = [];
15
+ newTags.forEach((headConfig) => {
16
+ const el = createHeadElement(headConfig);
17
+ document.head.appendChild(el);
18
+ managedHeadTags.push(el);
19
+ });
20
+ };
21
+ watchEffect(() => {
22
+ const pageData = route.data;
23
+ const siteData = siteDataByRouteRef.value;
24
+ const pageDescription = pageData && pageData.description;
25
+ const frontmatterHead = (pageData && pageData.frontmatter.head) || [];
26
+ // update title and description
27
+ document.title = createTitle(siteData, pageData);
28
+ document
29
+ .querySelector(`meta[name=description]`)
30
+ .setAttribute('content', pageDescription || siteData.description);
31
+ updateHeadTags(mergeHead(siteData.head, filterOutHeadDescription(frontmatterHead)));
32
+ });
33
+ }
34
+ function createHeadElement([tag, attrs, innerHTML]) {
35
+ const el = document.createElement(tag);
36
+ for (const key in attrs) {
37
+ el.setAttribute(key, attrs[key]);
38
+ }
39
+ if (innerHTML) {
40
+ el.innerHTML = innerHTML;
41
+ }
42
+ return el;
43
+ }
44
+ function isMetaDescription(headConfig) {
45
+ return (headConfig[0] === 'meta' &&
46
+ headConfig[1] &&
47
+ headConfig[1].name === 'description');
48
+ }
49
+ function filterOutHeadDescription(head) {
50
+ return head.filter((h) => !isMetaDescription(h));
51
+ }
@@ -1,94 +1,94 @@
1
- // Customized pre-fetch for page chunks based on
2
- // https://github.com/GoogleChromeLabs/quicklink
3
- import { useRoute } from '../router.js';
4
- import { onMounted, onUnmounted, watch } from 'vue';
5
- import { inBrowser, pathToFile } from '../utils.js';
6
- const hasFetched = new Set();
7
- const createLink = () => document.createElement('link');
8
- const viaDOM = (url) => {
9
- const link = createLink();
10
- link.rel = `prefetch`;
11
- link.href = url;
12
- document.head.appendChild(link);
13
- };
14
- const viaXHR = (url) => {
15
- const req = new XMLHttpRequest();
16
- req.open('GET', url, (req.withCredentials = true));
17
- req.send();
18
- };
19
- let link;
20
- const doFetch = inBrowser &&
21
- (link = createLink()) &&
22
- link.relList &&
23
- link.relList.supports &&
24
- link.relList.supports('prefetch')
25
- ? viaDOM
26
- : viaXHR;
27
- export function usePrefetch() {
28
- if (!inBrowser) {
29
- return;
30
- }
31
- if (!window.IntersectionObserver) {
32
- return;
33
- }
34
- let conn;
35
- if ((conn = navigator.connection) &&
36
- (conn.saveData || /2g/.test(conn.effectiveType))) {
37
- // Don't prefetch if using 2G or if Save-Data is enabled.
38
- return;
39
- }
40
- const rIC = window.requestIdleCallback || setTimeout;
41
- let observer = null;
42
- const observeLinks = () => {
43
- if (observer) {
44
- observer.disconnect();
45
- }
46
- observer = new IntersectionObserver((entries) => {
47
- entries.forEach((entry) => {
48
- if (entry.isIntersecting) {
49
- const link = entry.target;
50
- observer.unobserve(link);
51
- const { pathname } = link;
52
- if (!hasFetched.has(pathname)) {
53
- hasFetched.add(pathname);
54
- const pageChunkPath = pathToFile(pathname);
55
- doFetch(pageChunkPath);
56
- }
57
- }
58
- });
59
- });
60
- rIC(() => {
61
- document.querySelectorAll('#app a').forEach((link) => {
62
- const { target, hostname, pathname } = link;
63
- const extMatch = pathname.match(/\.\w+$/);
64
- if (extMatch && extMatch[0] !== '.html') {
65
- return;
66
- }
67
- if (
68
- // only prefetch same tab navigation, since a new tab will load
69
- // the lean js chunk instead.
70
- target !== `_blank` &&
71
- // only prefetch inbound links
72
- hostname === location.hostname) {
73
- if (pathname !== location.pathname) {
74
- observer.observe(link);
75
- }
76
- else {
77
- // No need to prefetch chunk for the current page, but also mark
78
- // it as already fetched. This is because the initial page uses its
79
- // lean chunk, and if we don't mark it, navigation to another page
80
- // with a link back to the first page will fetch its full chunk
81
- // which isn't needed.
82
- hasFetched.add(pathname);
83
- }
84
- }
85
- });
86
- });
87
- };
88
- onMounted(observeLinks);
89
- const route = useRoute();
90
- watch(() => route.path, observeLinks);
91
- onUnmounted(() => {
92
- observer && observer.disconnect();
93
- });
94
- }
1
+ // Customized pre-fetch for page chunks based on
2
+ // https://github.com/GoogleChromeLabs/quicklink
3
+ import { useRoute } from '../router.js';
4
+ import { onMounted, onUnmounted, watch } from 'vue';
5
+ import { inBrowser, pathToFile } from '../utils.js';
6
+ const hasFetched = new Set();
7
+ const createLink = () => document.createElement('link');
8
+ const viaDOM = (url) => {
9
+ const link = createLink();
10
+ link.rel = `prefetch`;
11
+ link.href = url;
12
+ document.head.appendChild(link);
13
+ };
14
+ const viaXHR = (url) => {
15
+ const req = new XMLHttpRequest();
16
+ req.open('GET', url, (req.withCredentials = true));
17
+ req.send();
18
+ };
19
+ let link;
20
+ const doFetch = inBrowser &&
21
+ (link = createLink()) &&
22
+ link.relList &&
23
+ link.relList.supports &&
24
+ link.relList.supports('prefetch')
25
+ ? viaDOM
26
+ : viaXHR;
27
+ export function usePrefetch() {
28
+ if (!inBrowser) {
29
+ return;
30
+ }
31
+ if (!window.IntersectionObserver) {
32
+ return;
33
+ }
34
+ let conn;
35
+ if ((conn = navigator.connection) &&
36
+ (conn.saveData || /2g/.test(conn.effectiveType))) {
37
+ // Don't prefetch if using 2G or if Save-Data is enabled.
38
+ return;
39
+ }
40
+ const rIC = window.requestIdleCallback || setTimeout;
41
+ let observer = null;
42
+ const observeLinks = () => {
43
+ if (observer) {
44
+ observer.disconnect();
45
+ }
46
+ observer = new IntersectionObserver((entries) => {
47
+ entries.forEach((entry) => {
48
+ if (entry.isIntersecting) {
49
+ const link = entry.target;
50
+ observer.unobserve(link);
51
+ const { pathname } = link;
52
+ if (!hasFetched.has(pathname)) {
53
+ hasFetched.add(pathname);
54
+ const pageChunkPath = pathToFile(pathname);
55
+ doFetch(pageChunkPath);
56
+ }
57
+ }
58
+ });
59
+ });
60
+ rIC(() => {
61
+ document.querySelectorAll('#app a').forEach((link) => {
62
+ const { target, hostname, pathname } = link;
63
+ const extMatch = pathname.match(/\.\w+$/);
64
+ if (extMatch && extMatch[0] !== '.html') {
65
+ return;
66
+ }
67
+ if (
68
+ // only prefetch same tab navigation, since a new tab will load
69
+ // the lean js chunk instead.
70
+ target !== `_blank` &&
71
+ // only prefetch inbound links
72
+ hostname === location.hostname) {
73
+ if (pathname !== location.pathname) {
74
+ observer.observe(link);
75
+ }
76
+ else {
77
+ // No need to prefetch chunk for the current page, but also mark
78
+ // it as already fetched. This is because the initial page uses its
79
+ // lean chunk, and if we don't mark it, navigation to another page
80
+ // with a link back to the first page will fetch its full chunk
81
+ // which isn't needed.
82
+ hasFetched.add(pathname);
83
+ }
84
+ }
85
+ });
86
+ });
87
+ };
88
+ onMounted(observeLinks);
89
+ const route = useRoute();
90
+ watch(() => route.path, observeLinks);
91
+ onUnmounted(() => {
92
+ observer && observer.disconnect();
93
+ });
94
+ }
@@ -1,44 +1,44 @@
1
- import { shallowRef, readonly, computed, inject } from 'vue';
2
- import siteData from '@siteData';
3
- import { resolveSiteDataByRoute, createTitle } from '../shared.js';
4
- import { withBase } from './utils.js';
5
- export const dataSymbol = Symbol();
6
- // site data is a singleton
7
- export const siteDataRef = shallowRef((import.meta.env.PROD ? siteData : readonly(siteData)));
8
- // hmr
9
- if (import.meta.hot) {
10
- import.meta.hot.accept('/@siteData', (m) => {
11
- if (m) {
12
- siteDataRef.value = m.default;
13
- }
14
- });
15
- }
16
- // per-app data
17
- export function initData(route) {
18
- const site = computed(() => resolveSiteDataByRoute(siteDataRef.value, route.path));
19
- return {
20
- site,
21
- theme: computed(() => site.value.themeConfig),
22
- page: computed(() => route.data),
23
- frontmatter: computed(() => route.data.frontmatter),
24
- lang: computed(() => site.value.lang),
25
- localePath: computed(() => {
26
- const { langs, lang } = site.value;
27
- const path = Object.keys(langs).find((langPath) => langs[langPath].lang === lang);
28
- return withBase(path || '/');
29
- }),
30
- title: computed(() => {
31
- return createTitle(site.value, route.data);
32
- }),
33
- description: computed(() => {
34
- return route.data.description || site.value.description;
35
- })
36
- };
37
- }
38
- export function useData() {
39
- const data = inject(dataSymbol);
40
- if (!data) {
41
- throw new Error('vitepress data not properly injected in app');
42
- }
43
- return data;
44
- }
1
+ import { shallowRef, readonly, computed, inject } from 'vue';
2
+ import siteData from '@siteData';
3
+ import { resolveSiteDataByRoute, createTitle } from '../shared.js';
4
+ import { withBase } from './utils.js';
5
+ export const dataSymbol = Symbol();
6
+ // site data is a singleton
7
+ export const siteDataRef = shallowRef((import.meta.env.PROD ? siteData : readonly(siteData)));
8
+ // hmr
9
+ if (import.meta.hot) {
10
+ import.meta.hot.accept('/@siteData', (m) => {
11
+ if (m) {
12
+ siteDataRef.value = m.default;
13
+ }
14
+ });
15
+ }
16
+ // per-app data
17
+ export function initData(route) {
18
+ const site = computed(() => resolveSiteDataByRoute(siteDataRef.value, route.path));
19
+ return {
20
+ site,
21
+ theme: computed(() => site.value.themeConfig),
22
+ page: computed(() => route.data),
23
+ frontmatter: computed(() => route.data.frontmatter),
24
+ lang: computed(() => site.value.lang),
25
+ localePath: computed(() => {
26
+ const { langs, lang } = site.value;
27
+ const path = Object.keys(langs).find((langPath) => langs[langPath].lang === lang);
28
+ return withBase(path || '/');
29
+ }),
30
+ title: computed(() => {
31
+ return createTitle(site.value, route.data);
32
+ }),
33
+ description: computed(() => {
34
+ return route.data.description || site.value.description;
35
+ })
36
+ };
37
+ }
38
+ export function useData() {
39
+ const data = inject(dataSymbol);
40
+ if (!data) {
41
+ throw new Error('vitepress data not properly injected in app');
42
+ }
43
+ return data;
44
+ }
@@ -1,28 +1,28 @@
1
- import { setupDevtoolsPlugin } from '@vue/devtools-api';
2
- const COMPONENT_STATE_TYPE = 'VitePress';
3
- export const setupDevtools = (app, router, data) => {
4
- setupDevtoolsPlugin({
5
- // fix recursive reference
6
- app: app,
7
- id: 'org.vuejs.vitepress',
8
- label: 'VitePress',
9
- packageName: 'vitepress',
10
- homepage: 'https://vitepress.vuejs.org',
11
- componentStateTypes: [COMPONENT_STATE_TYPE]
12
- }, (api) => {
13
- api.on.inspectComponent((payload) => {
14
- payload.instanceData.state.push({
15
- type: COMPONENT_STATE_TYPE,
16
- key: 'route',
17
- value: router.route,
18
- editable: false
19
- });
20
- payload.instanceData.state.push({
21
- type: COMPONENT_STATE_TYPE,
22
- key: 'data',
23
- value: data,
24
- editable: false
25
- });
26
- });
27
- });
28
- };
1
+ import { setupDevtoolsPlugin } from '@vue/devtools-api';
2
+ const COMPONENT_STATE_TYPE = 'VitePress';
3
+ export const setupDevtools = (app, router, data) => {
4
+ setupDevtoolsPlugin({
5
+ // fix recursive reference
6
+ app: app,
7
+ id: 'org.vuejs.vitepress',
8
+ label: 'VitePress',
9
+ packageName: 'vitepress',
10
+ homepage: 'https://vitepress.vuejs.org',
11
+ componentStateTypes: [COMPONENT_STATE_TYPE]
12
+ }, (api) => {
13
+ api.on.inspectComponent((payload) => {
14
+ payload.instanceData.state.push({
15
+ type: COMPONENT_STATE_TYPE,
16
+ key: 'route',
17
+ value: router.route,
18
+ editable: false
19
+ });
20
+ payload.instanceData.state.push({
21
+ type: COMPONENT_STATE_TYPE,
22
+ key: 'data',
23
+ value: data,
24
+ editable: false
25
+ });
26
+ });
27
+ });
28
+ };