vitepress 2.0.0-alpha.20 → 2.0.0-alpha.21

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 (121) hide show
  1. package/README.md +27 -7
  2. package/THIRD-PARTY-NOTICES.md +2 -2
  3. package/dist/client/app/components/ClientOnly.d.ts +2 -3
  4. package/dist/client/app/components/Content.d.ts +2 -3
  5. package/dist/client/app/composables/codeGroups.d.ts +2 -3
  6. package/dist/client/app/composables/copyCode.d.ts +2 -3
  7. package/dist/client/app/composables/copyCode.js +1 -1
  8. package/dist/client/app/composables/head.d.ts +2 -3
  9. package/dist/client/app/composables/icon.d.ts +2 -3
  10. package/dist/client/app/composables/preFetch.d.ts +2 -3
  11. package/dist/client/app/composables/preFetch.js +29 -28
  12. package/dist/client/app/data.d.ts +5 -5
  13. package/dist/client/app/devtools.d.ts +2 -3
  14. package/dist/client/app/index.d.ts +2 -3
  15. package/dist/client/app/index.js +4 -6
  16. package/dist/client/app/router.d.ts +13 -8
  17. package/dist/client/app/router.js +16 -7
  18. package/dist/client/app/ssr.d.ts +2 -3
  19. package/dist/client/app/theme.d.ts +3 -4
  20. package/dist/client/app/utils.d.ts +9 -9
  21. package/dist/client/app/utils.js +10 -5
  22. package/dist/client/shared.d.ts +48 -27
  23. package/dist/client/shared.js +35 -2
  24. package/dist/client/theme-default/NotFound.vue +6 -4
  25. package/dist/client/theme-default/components/VPBackdrop.vue +1 -6
  26. package/dist/client/theme-default/components/VPBadge.vue +4 -3
  27. package/dist/client/theme-default/components/VPButton.d.vue.ts +4 -4
  28. package/dist/client/theme-default/components/VPButton.vue +5 -3
  29. package/dist/client/theme-default/components/VPContent.vue +3 -3
  30. package/dist/client/theme-default/components/VPDoc.vue +4 -3
  31. package/dist/client/theme-default/components/VPDocAsideOutline.vue +3 -3
  32. package/dist/client/theme-default/components/VPDocFooter.vue +5 -5
  33. package/dist/client/theme-default/components/VPDocFooterLastUpdated.vue +2 -2
  34. package/dist/client/theme-default/components/VPDocOutlineItem.vue +3 -4
  35. package/dist/client/theme-default/components/VPFeature.vue +6 -6
  36. package/dist/client/theme-default/components/VPFlyout.vue +5 -5
  37. package/dist/client/theme-default/components/VPFooter.vue +6 -10
  38. package/dist/client/theme-default/components/VPHero.d.vue.ts +3 -3
  39. package/dist/client/theme-default/components/VPHero.vue +6 -10
  40. package/dist/client/theme-default/components/VPHomeContent.vue +1 -2
  41. package/dist/client/theme-default/components/VPHomeHero.d.vue.ts +7 -7
  42. package/dist/client/theme-default/components/VPImage.vue +2 -2
  43. package/dist/client/theme-default/components/VPLink.d.vue.ts +2 -2
  44. package/dist/client/theme-default/components/VPLink.vue +6 -0
  45. package/dist/client/theme-default/components/VPLocalNav.vue +4 -5
  46. package/dist/client/theme-default/components/VPLocalNavOutlineDropdown.vue +4 -7
  47. package/dist/client/theme-default/components/VPLocalSearchBox.vue +7 -26
  48. package/dist/client/theme-default/components/VPMenuGroup.vue +4 -3
  49. package/dist/client/theme-default/components/VPMenuLink.vue +3 -3
  50. package/dist/client/theme-default/components/VPNav.vue +1 -2
  51. package/dist/client/theme-default/components/VPNavAppearance.vue +2 -1
  52. package/dist/client/theme-default/components/VPNavBar.vue +15 -20
  53. package/dist/client/theme-default/components/VPNavBarExtra.vue +1 -1
  54. package/dist/client/theme-default/components/VPNavBarHamburger.vue +8 -6
  55. package/dist/client/theme-default/components/VPNavBarSearch.vue +2 -2
  56. package/dist/client/theme-default/components/VPNavBarSearchButton.vue +2 -0
  57. package/dist/client/theme-default/components/VPNavBarTitle.vue +2 -2
  58. package/dist/client/theme-default/components/VPNavMenu.vue +1 -1
  59. package/dist/client/theme-default/components/VPNavMenuGroup.vue +3 -3
  60. package/dist/client/theme-default/components/VPNavMenuLink.vue +1 -1
  61. package/dist/client/theme-default/components/VPNavScreen.vue +1 -6
  62. package/dist/client/theme-default/components/VPNavTranslations.vue +7 -5
  63. package/dist/client/theme-default/components/VPSidebar.vue +5 -6
  64. package/dist/client/theme-default/components/VPSidebarItem.vue +7 -8
  65. package/dist/client/theme-default/components/VPSkipLink.vue +2 -2
  66. package/dist/client/theme-default/components/VPSponsors.d.vue.ts +1 -1
  67. package/dist/client/theme-default/components/VPSwitch.vue +5 -6
  68. package/dist/client/theme-default/components/VPSwitchAppearance.vue +1 -2
  69. package/dist/client/theme-default/components/VPTeamMembersItem.vue +5 -5
  70. package/dist/client/theme-default/components/VPTeamPageSection.vue +3 -4
  71. package/dist/client/theme-default/components/VPTeamPageTitle.vue +2 -2
  72. package/dist/client/theme-default/composables/data.d.ts +2 -3
  73. package/dist/client/theme-default/composables/edit-link.d.ts +2 -3
  74. package/dist/client/theme-default/composables/flyout.d.ts +3 -4
  75. package/dist/client/theme-default/composables/langs.d.ts +4 -5
  76. package/dist/client/theme-default/composables/layout.d.ts +5 -6
  77. package/dist/client/theme-default/composables/nav-overflow.d.ts +9 -10
  78. package/dist/client/theme-default/composables/nav.d.ts +7 -8
  79. package/dist/client/theme-default/composables/outline.d.ts +5 -6
  80. package/dist/client/theme-default/composables/prev-next.d.ts +2 -3
  81. package/dist/client/theme-default/composables/scroll-lock.d.ts +2 -11
  82. package/dist/client/theme-default/composables/scroll-lock.js +5 -12
  83. package/dist/client/theme-default/composables/sidebar.d.ts +4 -5
  84. package/dist/client/theme-default/composables/sponsor-grid.d.ts +5 -6
  85. package/dist/client/theme-default/fonts/inter-italic-cyrillic-ext.woff2 +0 -0
  86. package/dist/client/theme-default/fonts/inter-italic-cyrillic.woff2 +0 -0
  87. package/dist/client/theme-default/fonts/inter-italic-greek-ext.woff2 +0 -0
  88. package/dist/client/theme-default/fonts/inter-italic-greek.woff2 +0 -0
  89. package/dist/client/theme-default/fonts/inter-italic-latin-ext.woff2 +0 -0
  90. package/dist/client/theme-default/fonts/inter-italic-latin.woff2 +0 -0
  91. package/dist/client/theme-default/fonts/inter-italic-symbols.woff2 +0 -0
  92. package/dist/client/theme-default/fonts/inter-italic-vietnamese.woff2 +0 -0
  93. package/dist/client/theme-default/fonts/inter-roman-cyrillic-ext.woff2 +0 -0
  94. package/dist/client/theme-default/fonts/inter-roman-cyrillic.woff2 +0 -0
  95. package/dist/client/theme-default/fonts/inter-roman-greek-ext.woff2 +0 -0
  96. package/dist/client/theme-default/fonts/inter-roman-greek.woff2 +0 -0
  97. package/dist/client/theme-default/fonts/inter-roman-latin-ext.woff2 +0 -0
  98. package/dist/client/theme-default/fonts/inter-roman-latin.woff2 +0 -0
  99. package/dist/client/theme-default/fonts/inter-roman-symbols.woff2 +0 -0
  100. package/dist/client/theme-default/fonts/inter-roman-vietnamese.woff2 +0 -0
  101. package/dist/client/theme-default/styles/components/vp-code-group.css +5 -8
  102. package/dist/client/theme-default/styles/components/vp-doc.css +49 -45
  103. package/dist/client/theme-default/styles/docsearch.css +3 -2
  104. package/dist/client/theme-default/styles/fonts.css +22 -9
  105. package/dist/client/theme-default/styles/icons.css +22 -8
  106. package/dist/client/theme-default/styles/vars.css +15 -0
  107. package/dist/client/theme-default/support/docsearch.d.ts +14 -15
  108. package/dist/client/theme-default/support/local-search.d.ts +9 -0
  109. package/dist/client/theme-default/support/local-search.js +31 -0
  110. package/dist/client/theme-default/support/lru.d.ts +2 -3
  111. package/dist/client/theme-default/support/reactivity.d.ts +2 -3
  112. package/dist/client/theme-default/support/sidebar.d.ts +6 -7
  113. package/dist/client/theme-default/support/translation.d.ts +2 -3
  114. package/dist/client/theme-default/support/utils.d.ts +6 -7
  115. package/dist/node/{chunk-BYTgXTwz.js → chunk-BjrVv9r8.js} +17133 -17242
  116. package/dist/node/cli.js +3 -6
  117. package/dist/node/index.d.ts +64 -50
  118. package/dist/node/index.js +1 -2
  119. package/dist/web-types.json +1 -1
  120. package/package.json +56 -57
  121. package/types/shared.d.ts +3 -3
package/README.md CHANGED
@@ -31,10 +31,30 @@ Copyright (c) 2019-present, Yuxi (Evan) You
31
31
 
32
32
  This project would not be possible without the support of these amazing companies and tools.
33
33
 
34
- | | | |
35
- | --------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
36
- | <a href="https://voidzero.dev" target="_blank"><img alt="VoidZero's logo" src="https://github.com/voidzero-dev.png" width="80" /></a> | **[VoidZero](https://voidzero.dev)** | The company behind Vite, Vitest, Rolldown, and Oxc. VoidZero has been a long-time sponsor of VitePress. VitePress itself is built on top of this ecosystem of high-performance JavaScript tooling. |
37
- | <a href="https://stackblitz.com" target="_blank"><img alt="StackBlitz's logo" src="https://github.com/stackblitz.png" width="80" /></a> | **[StackBlitz](https://stackblitz.com)** | Creators of WebContainers and a browser-based development platform. Their technology powers the VitePress playground and provides instant preview releases for our pull requests and commits. |
38
- | <a href="https://algolia.com" target="_blank"><img alt="Algolia's logo" src="https://github.com/algolia.png" width="80" /></a> | **[Algolia](https://algolia.com)** | An AI-powered search platform that provides fast, scalable search. Algolia powers DocSearch for VitePress. Their team has been a long-time partner in building and maintaining our search integration. |
39
- | <a href="https://browserstack.com" target="_blank"><img alt="BrowserStack's logo" src="https://github.com/browserstack.png" width="80" /></a> | **[BrowserStack](https://browserstack.com)** | A cloud-based testing platform for websites and mobile apps. BrowserStack provides the cross-browser and real-device infrastructure used to ensure VitePress works consistently across all browsers. |
40
- | <a href="https://netlify.com" target="_blank"><img alt="Netlify's logo" src="https://github.com/netlify.png" width="80" /></a> | **[Netlify](https://netlify.com)** | A platform for building, deploying, and hosting modern web projects. Netlify powers our website deployments with their generous open source plan and provides deploy previews for the pull requests. |
34
+ <table>
35
+ <tr>
36
+ <td width="120" align="center"><a href="https://voidzero.dev" target="_blank"><img alt="VoidZero's logo" src="https://github.com/voidzero-dev.png" width="80" /></a></td>
37
+ <td><strong><a href="https://voidzero.dev">VoidZero</a></strong></td>
38
+ <td>The company behind Vite, Vitest, Rolldown, and Oxc. VoidZero has been a long-time sponsor of VitePress. VitePress itself is built on top of this ecosystem of high-performance JavaScript tooling.</td>
39
+ </tr>
40
+ <tr>
41
+ <td width="120" align="center"><a href="https://stackblitz.com" target="_blank"><img alt="StackBlitz's logo" src="https://github.com/stackblitz.png" width="80" /></a></td>
42
+ <td><strong><a href="https://stackblitz.com">StackBlitz</a></strong></td>
43
+ <td>Creators of WebContainers and a browser-based development platform. Their technology powers the VitePress playground and provides instant preview releases for our pull requests and commits.</td>
44
+ </tr>
45
+ <tr>
46
+ <td width="120" align="center"><a href="https://algolia.com" target="_blank"><img alt="Algolia's logo" src="https://github.com/algolia.png" width="80" /></a></td>
47
+ <td><strong><a href="https://algolia.com">Algolia</a></strong></td>
48
+ <td>An AI-powered search platform that provides fast, scalable search. Algolia powers DocSearch for VitePress. Their team has been a long-time partner in building and maintaining our search integration.</td>
49
+ </tr>
50
+ <tr>
51
+ <td width="120" align="center"><a href="https://browserstack.com" target="_blank"><img alt="BrowserStack's logo" src="https://github.com/browserstack.png" width="80" /></a></td>
52
+ <td><strong><a href="https://browserstack.com">BrowserStack</a></strong></td>
53
+ <td>A cloud-based testing platform for websites and mobile apps. BrowserStack provides the cross-browser and real-device infrastructure used to ensure VitePress works consistently across all browsers.</td>
54
+ </tr>
55
+ <tr>
56
+ <td width="120" align="center"><a href="https://netlify.com" target="_blank"><img alt="Netlify's logo" src="https://github.com/netlify.png" width="80" /></a></td>
57
+ <td><strong><a href="https://netlify.com">Netlify</a></strong></td>
58
+ <td>A platform for building, deploying, and hosting modern web projects. Netlify powers our website deployments with their generous open source plan and provides deploy previews for the pull requests.</td>
59
+ </tr>
60
+ </table>
@@ -6,7 +6,7 @@ VitePress is published under the MIT license (see LICENSE). The published vitepr
6
6
 
7
7
  License: MIT
8
8
  By: Anthony Fu <anthonyfu117@hotmail.com>
9
- Repository: https://github.com/antfu/install-pkg
9
+ Repository: https://github.com/antfu-collective/install-pkg
10
10
 
11
11
  > MIT License
12
12
  >
@@ -691,7 +691,7 @@ Repository: https://github.com/jonschlinkert/gray-matter
691
691
 
692
692
  License: MIT
693
693
  By: netroy <aditya@netroy.in> (http://netroy.in/)
694
- Repository: https://github.com/image-size/image-size
694
+ Repository: https://codeberg.org/image-size/image-size
695
695
 
696
696
  > The MIT License (MIT)
697
697
  >
@@ -1,6 +1,5 @@
1
1
  //#region src/client/app/components/ClientOnly.d.ts
2
- declare const ClientOnly: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
2
+ export declare const ClientOnly: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
3
3
  [key: string]: any;
4
4
  }>[] | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
5
- //#endregion
6
- export { ClientOnly };
5
+ //#endregion
@@ -1,5 +1,5 @@
1
1
  //#region src/client/app/components/Content.d.ts
2
- declare const Content: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ export declare const Content: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
3
  as: {
4
4
  type: (ObjectConstructor | StringConstructor)[];
5
5
  default: string;
@@ -14,5 +14,4 @@ declare const Content: import("vue").DefineComponent<import("vue").ExtractPropTy
14
14
  }>> & Readonly<{}>, {
15
15
  as: string | Record<string, any>;
16
16
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
17
- //#endregion
18
- export { Content };
17
+ //#endregion
@@ -1,4 +1,3 @@
1
1
  //#region src/client/app/composables/codeGroups.d.ts
2
- declare function useCodeGroups(): void;
3
- //#endregion
4
- export { useCodeGroups };
2
+ export declare function useCodeGroups(): void;
3
+ //#endregion
@@ -1,4 +1,3 @@
1
1
  //#region src/client/app/composables/copyCode.d.ts
2
- declare function useCopyCode(): void;
3
- //#endregion
4
- export { useCopyCode };
2
+ export declare function useCopyCode(): void;
3
+ //#endregion
@@ -41,7 +41,7 @@ async function copyToClipboard(text) {
41
41
  element.setAttribute("readonly", "");
42
42
  element.style.contain = "strict";
43
43
  element.style.position = "absolute";
44
- element.style.left = "-9999px";
44
+ element.style.insetInlineStart = "-9999px";
45
45
  element.style.fontSize = "12pt";
46
46
  const selection = document.getSelection();
47
47
  const originalRange = selection ? selection.rangeCount > 0 && selection.getRangeAt(0) : null;
@@ -1,6 +1,5 @@
1
1
  import { Route, SiteData } from "../../shared.js";
2
2
  import { Ref } from "vue";
3
3
  //#region src/client/app/composables/head.d.ts
4
- declare function useUpdateHead(route: Route, siteDataByRouteRef: Ref<SiteData>): void;
5
- //#endregion
6
- export { useUpdateHead };
4
+ export declare function useUpdateHead(route: Route, siteDataByRouteRef: Ref<SiteData>): void;
5
+ //#endregion
@@ -6,8 +6,7 @@ import { ComputedRef, MaybeRefOrGetter } from "vue";
6
6
  * the build emits its CSS rule; in dev the SVG is served on demand and
7
7
  * applied to `el` inline.
8
8
  */
9
- declare function useIcon(icon: MaybeRefOrGetter<string | {
9
+ export declare function useIcon(icon: MaybeRefOrGetter<string | {
10
10
  svg: string;
11
11
  } | undefined>, el?: MaybeRefOrGetter<HTMLElement | null>): ComputedRef<string | undefined>;
12
- //#endregion
13
- export { useIcon };
12
+ //#endregion
@@ -1,4 +1,3 @@
1
1
  //#region src/client/app/composables/preFetch.d.ts
2
- declare function usePrefetch(): void;
3
- //#endregion
4
- export { usePrefetch };
2
+ export declare function usePrefetch(): void;
3
+ //#endregion
@@ -1,65 +1,66 @@
1
1
  import { EXTERNAL_URL_RE, inBrowser } from "../../shared.js";
2
2
  import { pathToFile } from "../utils.js";
3
- import { useRoute } from "../router.js";
4
- import { onMounted, onUnmounted, watch } from "vue";
3
+ import { getRoutableLinkUrl, useRoute } from "../router.js";
4
+ import { computed, onMounted, onUnmounted, watch } from "vue";
5
+ import { useNetwork } from "@vueuse/core";
5
6
  //#region src/client/app/composables/preFetch.ts
6
7
  const hasFetched = /* @__PURE__ */ new Set();
7
8
  const createLink = () => document.createElement("link");
8
- const viaDOM = (url) => {
9
+ const viaDOM = (url, onError) => {
9
10
  const link = createLink();
10
11
  link.rel = `prefetch`;
11
12
  if (EXTERNAL_URL_RE.test(url)) link.crossOrigin = "";
12
13
  link.href = url;
14
+ link.onerror = () => {
15
+ link.remove();
16
+ onError();
17
+ };
13
18
  document.head.appendChild(link);
14
19
  };
15
- const viaXHR = (url) => {
20
+ const viaXHR = (url, onError) => {
16
21
  const req = new XMLHttpRequest();
17
22
  req.open("GET", url, true);
18
23
  req.withCredentials = !EXTERNAL_URL_RE.test(url);
24
+ req.onerror = onError;
19
25
  req.send();
20
26
  };
21
- let link;
22
- const doFetch = inBrowser && (link = createLink()) && link.relList && link.relList.supports && link.relList.supports("prefetch") ? viaDOM : viaXHR;
23
27
  function usePrefetch() {
24
28
  if (!inBrowser) return;
25
- if (!window.IntersectionObserver) return;
26
- let conn;
27
- if ((conn = navigator.connection) && (conn.saveData || /2g/.test(conn.effectiveType))) return;
29
+ const { isOnline, saveData, effectiveType } = useNetwork();
30
+ const isWeak = computed(() => !isOnline.value || saveData.value || !!effectiveType.value?.includes("2g"));
31
+ const prefetch = createLink().relList.supports("prefetch") ? viaDOM : viaXHR;
28
32
  const rIC = window.requestIdleCallback || setTimeout;
29
33
  let observer = null;
30
34
  const observeLinks = () => {
31
35
  if (observer) observer.disconnect();
32
36
  observer = new IntersectionObserver((entries) => {
33
37
  entries.forEach((entry) => {
34
- if (entry.isIntersecting) {
35
- const link = entry.target;
36
- observer.unobserve(link);
37
- const { pathname } = link;
38
- if (!hasFetched.has(pathname)) {
39
- hasFetched.add(pathname);
40
- const pageChunkPath = pathToFile(pathname);
41
- if (pageChunkPath) doFetch(pageChunkPath);
42
- }
43
- }
38
+ if (!entry.isIntersecting || isWeak.value) return;
39
+ const link = entry.target;
40
+ observer.unobserve(link);
41
+ const url = getRoutableLinkUrl(link);
42
+ const pageChunkPath = url && pathToFile(url.pathname);
43
+ if (!pageChunkPath || hasFetched.has(pageChunkPath)) return;
44
+ hasFetched.add(pageChunkPath);
45
+ prefetch(pageChunkPath, () => hasFetched.delete(pageChunkPath));
44
46
  });
45
47
  });
46
48
  rIC(() => {
47
49
  document.querySelectorAll("#app a").forEach((link) => {
48
- const { hostname, pathname } = new URL(link.href instanceof SVGAnimatedString ? link.href.animVal : link.href, link.baseURI);
49
- const extMatch = pathname.match(/\.\w+$/);
50
- if (extMatch && extMatch[0] !== ".html") return;
51
- if (link.target !== "_blank" && hostname === location.hostname) {
52
- if (pathname !== location.pathname) observer.observe(link);
53
- else hasFetched.add(pathname);
54
- }
50
+ const url = getRoutableLinkUrl(link);
51
+ if (url && url.pathname !== location.pathname) observer.observe(link);
55
52
  });
56
53
  });
57
54
  };
58
55
  onMounted(observeLinks);
59
56
  const route = useRoute();
60
- watch(() => route.path, observeLinks);
57
+ watch(() => route.path, () => {
58
+ const pageChunkPath = pathToFile(location.pathname);
59
+ if (pageChunkPath) hasFetched.add(pageChunkPath);
60
+ observeLinks();
61
+ });
61
62
  onUnmounted(() => {
62
- observer && observer.disconnect();
63
+ observer?.disconnect();
63
64
  });
64
65
  }
65
66
  //#endregion
@@ -1,9 +1,9 @@
1
1
  import { Route, SiteData, VitePressData } from "../shared.js";
2
2
  import { InjectionKey, Ref } from "vue";
3
3
  //#region src/client/app/data.d.ts
4
- declare const dataSymbol: InjectionKey<VitePressData>;
5
- declare const siteDataRef: Ref<SiteData>;
6
- declare function initData(route: Route): VitePressData;
7
- declare function useData<T = any>(): VitePressData<T>;
4
+ export declare const dataSymbol: InjectionKey<VitePressData>;
5
+ export declare const siteDataRef: Ref<SiteData>;
6
+ export declare function initData(route: Route): VitePressData;
7
+ export declare function useData<T = any>(): VitePressData<T>;
8
8
  //#endregion
9
- export { type VitePressData, dataSymbol, initData, siteDataRef, useData };
9
+ export type { VitePressData };
@@ -3,6 +3,5 @@ import "./data.js";
3
3
  import { Router } from "./router.js";
4
4
  import { App } from "vue";
5
5
  //#region src/client/app/devtools.d.ts
6
- declare const setupDevtools: (app: App, router: Router, data: VitePressData) => void;
7
- //#endregion
8
- export { setupDevtools };
6
+ export declare const setupDevtools: (app: App, router: Router, data: VitePressData) => void;
7
+ //#endregion
@@ -3,10 +3,9 @@ import "./data.js";
3
3
  import { Router } from "./router.js";
4
4
  import { App } from "vue";
5
5
  //#region src/client/app/index.d.ts
6
- declare function createApp(): Promise<{
6
+ export declare function createApp(): Promise<{
7
7
  app: App<any>;
8
8
  router: Router;
9
9
  data: VitePressData<any>;
10
10
  }>;
11
- //#endregion
12
- export { createApp };
11
+ //#endregion
@@ -8,7 +8,7 @@ import { useCodeGroups } from "./composables/codeGroups.js";
8
8
  import { useCopyCode } from "./composables/copyCode.js";
9
9
  import { useUpdateHead } from "./composables/head.js";
10
10
  import { usePrefetch } from "./composables/preFetch.js";
11
- import { createApp as createApp$1, createSSRApp, defineComponent, h, onMounted, watchEffect } from "vue";
11
+ import { createApp as createApp$1, createSSRApp, defineComponent, h, watchEffect } from "vue";
12
12
  import RawTheme from "@theme/index";
13
13
  //#region src/client/app/index.ts
14
14
  function resolveThemeExtends(theme) {
@@ -34,11 +34,9 @@ const VitePressApp = defineComponent({
34
34
  name: "VitePressApp",
35
35
  setup() {
36
36
  const { site, lang, dir } = useData();
37
- onMounted(() => {
38
- watchEffect(() => {
39
- document.documentElement.lang = lang.value;
40
- document.documentElement.dir = dir.value;
41
- });
37
+ if (inBrowser) watchEffect(() => {
38
+ document.documentElement.lang = lang.value;
39
+ document.documentElement.dir = dir.value;
42
40
  });
43
41
  if (import.meta.env.PROD && site.value.router.prefetchLinks) usePrefetch();
44
42
  useCopyCode();
@@ -1,7 +1,7 @@
1
1
  import { Awaitable, PageData, Route } from "../shared.js";
2
2
  import { Component, InjectionKey } from "vue";
3
3
  //#region src/client/app/router.d.ts
4
- interface Router {
4
+ export interface Router {
5
5
  /**
6
6
  * Current route.
7
7
  */
@@ -31,14 +31,19 @@ interface Router {
31
31
  */
32
32
  onAfterRouteChange?: (to: string) => Awaitable<void>;
33
33
  }
34
- declare const RouterSymbol: InjectionKey<Router>;
34
+ export declare const RouterSymbol: InjectionKey<Router>;
35
35
  interface PageModule {
36
36
  __pageData: PageData;
37
37
  default: Component;
38
38
  }
39
- declare function createRouter(loadPageModule: (path: string) => Awaitable<PageModule | null>, fallbackComponent?: Component): Router;
40
- declare function useRouter(): Router;
41
- declare function useRoute(): Route;
42
- declare function scrollTo(hash: string, scrollPosition?: number): void;
43
- //#endregion
44
- export { Router, RouterSymbol, createRouter, scrollTo, useRoute, useRouter };
39
+ export declare function createRouter(loadPageModule: (path: string) => Awaitable<PageModule | null>, fallbackComponent?: Component): Router;
40
+ export declare function useRouter(): Router;
41
+ export declare function useRoute(): Route;
42
+ export declare function scrollTo(hash: string, scrollPosition?: number): void;
43
+ /**
44
+ * Resolves the URL of a link the router handles on the client side, or `null`
45
+ * if it's left to the browser (explicit `target`, `download`, `.vp-raw`,
46
+ * other origins, non-html files).
47
+ */
48
+ export declare function getRoutableLinkUrl(link: HTMLAnchorElement | SVGAElement): URL | null;
49
+ //#endregion
@@ -95,13 +95,10 @@ function createRouter(loadPageModule, fallbackComponent) {
95
95
  window.addEventListener("click", (e) => {
96
96
  if (e.defaultPrevented || !(e.target instanceof Element) || e.target.closest("button") || e.button !== 0 || e.ctrlKey || e.shiftKey || e.altKey || e.metaKey) return;
97
97
  const link = e.target.closest("a");
98
- if (!link || link.closest(".vp-raw") || link.hasAttribute("download") || link.hasAttribute("target")) return;
99
- const linkHref = link.getAttribute("href") ?? (link instanceof SVGAElement ? link.getAttribute("xlink:href") : null);
100
- if (linkHref == null) return;
101
- const { href, origin, pathname } = new URL(linkHref, link.baseURI);
102
- if (origin === new URL(location.href).origin && treatAsHtml(pathname)) {
98
+ const url = link && getRoutableLinkUrl(link);
99
+ if (url) {
103
100
  e.preventDefault();
104
- router.go(href);
101
+ router.go(url.href);
105
102
  }
106
103
  }, { capture: true });
107
104
  window.addEventListener("popstate", async (e) => {
@@ -155,6 +152,18 @@ function scrollTo(hash, scrollPosition = 0) {
155
152
  };
156
153
  requestAnimationFrame(scrollToTarget);
157
154
  }
155
+ /**
156
+ * Resolves the URL of a link the router handles on the client side, or `null`
157
+ * if it's left to the browser (explicit `target`, `download`, `.vp-raw`,
158
+ * other origins, non-html files).
159
+ */
160
+ function getRoutableLinkUrl(link) {
161
+ if (link.closest(".vp-raw") || link.hasAttribute("download") || link.hasAttribute("target")) return null;
162
+ const href = link.getAttribute("href") ?? (link instanceof SVGAElement ? link.getAttribute("xlink:href") : null);
163
+ if (href == null) return null;
164
+ const url = new URL(href, link.baseURI);
165
+ return url.origin === location.origin && treatAsHtml(url.pathname) ? url : null;
166
+ }
158
167
  function handleHMR(route) {
159
168
  if (import.meta.hot) import.meta.hot.on("vitepress:pageData", (payload) => {
160
169
  if (shouldHotReload(payload)) route.data = payload.pageData;
@@ -199,4 +208,4 @@ async function changeRoute(href, { initialLoad = false, replace = false, hasText
199
208
  return true;
200
209
  }
201
210
  //#endregion
202
- export { RouterSymbol, createRouter, scrollTo, useRoute, useRouter };
211
+ export { RouterSymbol, createRouter, getRoutableLinkUrl, scrollTo, useRoute, useRouter };
@@ -1,5 +1,4 @@
1
1
  import { SSGContext } from "../shared.js";
2
2
  //#region src/client/app/ssr.d.ts
3
- declare function render(path: string): Promise<SSGContext>;
4
- //#endregion
5
- export { render };
3
+ export declare function render(path: string): Promise<SSGContext>;
4
+ //#endregion
@@ -2,12 +2,12 @@ import { Awaitable, SiteData } from "../shared.js";
2
2
  import { Router } from "./router.js";
3
3
  import { App, Component, Ref } from "vue";
4
4
  //#region src/client/app/theme.d.ts
5
- interface EnhanceAppContext {
5
+ export interface EnhanceAppContext {
6
6
  app: App;
7
7
  router: Router;
8
8
  siteData: Ref<SiteData>;
9
9
  }
10
- interface Theme {
10
+ export interface Theme {
11
11
  Layout?: Component;
12
12
  enhanceApp?: (ctx: EnhanceAppContext) => Awaitable<void>;
13
13
  extends?: Theme;
@@ -21,5 +21,4 @@ interface Theme {
21
21
  */
22
22
  NotFound?: Component;
23
23
  }
24
- //#endregion
25
- export { EnhanceAppContext, Theme };
24
+ //#endregion
@@ -1,5 +1,5 @@
1
1
  import { Awaitable, escapeHtml, inBrowser, joinPath } from "../shared.js";
2
- import { AsyncComponentLoader } from "vue";
2
+ import { AsyncComponentLoader, SetupContext } from "vue";
3
3
  //#region src/client/app/utils.d.ts
4
4
  /**
5
5
  * Runtime base path used by the app.
@@ -11,25 +11,25 @@ import { AsyncComponentLoader } from "vue";
11
11
  * - dev browser: uses `'/'` (dev server always mounts at root)
12
12
  * - prod browser: resolves from the page's `__VP_SITE_ROOT__`
13
13
  */
14
- declare function runtimeBase(): string;
14
+ export declare function runtimeBase(): string;
15
15
  /**
16
16
  * Prepend base to internal (non-relative) urls
17
17
  */
18
- declare function withBase(path: string): string;
18
+ export declare function withBase(path: string): string;
19
19
  /**
20
20
  * Converts a url path to the corresponding js chunk filename.
21
21
  */
22
- declare function pathToFile(path: string): string | null;
23
- declare let contentUpdatedCallbacks: (() => any)[];
22
+ export declare function pathToFile(path: string): string | null;
23
+ export declare let contentUpdatedCallbacks: (() => any)[];
24
24
  /**
25
25
  * Register callback that is called every time the markdown content is updated
26
26
  * in the DOM.
27
27
  */
28
- declare function onContentUpdated(fn: () => any): void;
29
- declare function defineClientComponent(loader: AsyncComponentLoader, args?: any[], cb?: () => Awaitable<void>): {
30
- setup(): () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
28
+ export declare function onContentUpdated(fn: () => any): void;
29
+ export declare function defineClientComponent(loader: AsyncComponentLoader, args?: any[], cb?: () => Awaitable<void>): {
30
+ setup(_: unknown, { slots }: SetupContext): () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
31
31
  [key: string]: any;
32
32
  }> | null;
33
33
  };
34
34
  //#endregion
35
- export { escapeHtml as _escapeHtml, contentUpdatedCallbacks, defineClientComponent, inBrowser, joinPath, onContentUpdated, pathToFile, runtimeBase, withBase };
35
+ export { escapeHtml as _escapeHtml, inBrowser, joinPath };
@@ -1,6 +1,6 @@
1
- import { EXTERNAL_URL_RE, RELATIVE_BASE_SENTINEL, escapeHtml, inBrowser, isRelativeBase, joinPath, sanitizeFileName } from "../shared.js";
1
+ import { EXTERNAL_URL_RE, RELATIVE_BASE_SENTINEL, escapeHtml, inBrowser, isRelativeBase, joinPath, pageChunkPath, sanitizeFileName } from "../shared.js";
2
2
  import { siteDataRef } from "./data.js";
3
- import { h, onMounted, shallowRef } from "vue";
3
+ import { h, isVNode, onMounted, shallowRef } from "vue";
4
4
  import { tryOnUnmounted } from "@vueuse/core";
5
5
  //#region src/client/app/utils.ts
6
6
  let resolvedBase;
@@ -50,7 +50,7 @@ function pathToFile(path) {
50
50
  pageHash = __VP_HASH_MAP__[pagePath.toLowerCase()];
51
51
  }
52
52
  if (!pageHash) return null;
53
- pagePath = `${__ASSETS_BASE__ || base}${__ASSETS_DIR__}/${pagePath}.${pageHash}.js`;
53
+ pagePath = `${__ASSETS_BASE__ || base}${__ASSETS_DIR__}/${pageChunkPath(pagePath, pageHash)}`;
54
54
  } else pagePath = `./${sanitizeFileName(pagePath.slice(1).replace(/\//g, "_"))}.md.js`;
55
55
  return pagePath;
56
56
  }
@@ -66,7 +66,7 @@ function onContentUpdated(fn) {
66
66
  });
67
67
  }
68
68
  function defineClientComponent(loader, args, cb) {
69
- return { setup() {
69
+ return { setup(_, { slots }) {
70
70
  const comp = shallowRef();
71
71
  onMounted(async () => {
72
72
  let res = await loader();
@@ -74,7 +74,12 @@ function defineClientComponent(loader, args, cb) {
74
74
  comp.value = res;
75
75
  await cb?.();
76
76
  });
77
- return () => comp.value ? h(comp.value, ...args ?? []) : null;
77
+ return () => {
78
+ if (!comp.value) return null;
79
+ const props = args?.[0];
80
+ if ((!args || args.length < 2) && (props == null || typeof props === "object" && !Array.isArray(props) && !isVNode(props))) return h(comp.value, props, slots);
81
+ return h(comp.value, ...args ?? []);
82
+ };
78
83
  } };
79
84
  }
80
85
  //#endregion
@@ -1,13 +1,13 @@
1
1
  import { AdditionalConfig, AdditionalConfigDict, AdditionalConfigLoader, Awaitable, CodeCopyButtonOptions, ContainerOptions, DefaultTheme, HeadConfig, HeadConfig as HeadConfig$1, Header, LocaleConfig, LocaleSpecificConfig, MarkdownEnv, MarkdownLocaleOptions, PageData, PageData as PageData$1, PageDataPayload, Route, SSGContext, SiteData, SiteData as SiteData$1, VitePressData } from "../../types/shared.js";
2
2
  //#region src/client/shared.d.ts
3
- declare const EXTERNAL_URL_RE: RegExp;
4
- declare const APPEARANCE_KEY = "vitepress-theme-appearance";
3
+ export declare const EXTERNAL_URL_RE: RegExp;
4
+ export declare const APPEARANCE_KEY = "vitepress-theme-appearance";
5
5
  /**
6
6
  * Parses a fully qualified `collection:name` icon name, corresponding to
7
7
  * the `vpi-<collection>-<name>` class. Returns null for anything else,
8
8
  * keeping malformed input out of generated selectors and class attributes.
9
9
  */
10
- declare function parseIconName(name: string): {
10
+ export declare function parseIconName(name: string): {
11
11
  collection: string;
12
12
  icon: string;
13
13
  } | null;
@@ -15,53 +15,74 @@ declare function parseIconName(name: string): {
15
15
  * Placeholder prepended to SSR-emitted URLs when base is relative, later
16
16
  * replaced with each page's `../` prefix back to the site root.
17
17
  */
18
- declare const RELATIVE_BASE_SENTINEL = "/__VP_BASE__/";
19
- declare function isRelativeBase(base: string): boolean;
18
+ export declare const RELATIVE_BASE_SENTINEL = "/__VP_BASE__/";
19
+ export declare function isRelativeBase(base: string): boolean;
20
20
  /**
21
21
  * The ../-prefix that leads from `relativePath`'s directory back to the
22
22
  * site root ('./' for root-level pages).
23
23
  */
24
- declare function relativePathToRoot(relativePath: string): string;
24
+ export declare function relativePathToRoot(relativePath: string): string;
25
25
  /**
26
26
  * Join two paths, collapsing slash collisions but keeping the `//` that
27
27
  * follows a protocol.
28
28
  */
29
- declare function joinPath(base: string, path: string): string;
30
- declare const VP_SOURCE_KEY = "[VP_SOURCE]";
31
- declare const inBrowser: boolean;
32
- declare const notFoundPageData: PageData$1;
33
- declare function isActive(currentPath: string, currentHash: string, matchPath: string, asRegex?: boolean, skipHashCheck?: boolean): boolean;
34
- declare function normalize(path: string): string;
35
- declare function isExternal(path: string): boolean;
36
- declare function getLocaleForPath(siteData: SiteData$1 | undefined, relativePath: string): string;
29
+ export declare function joinPath(base: string, path: string): string;
30
+ export declare const VP_SOURCE_KEY = "[VP_SOURCE]";
31
+ export declare const inBrowser: boolean;
32
+ export declare const notFoundPageData: PageData$1;
33
+ export declare function isActive(currentPath: string, currentHash: string, matchPath: string, asRegex?: boolean, skipHashCheck?: boolean): boolean;
34
+ export declare function normalize(path: string): string;
35
+ export declare function isExternal(path: string): boolean;
36
+ export declare function getLocaleForPath(siteData: SiteData$1 | undefined, relativePath: string): string;
37
37
  /**
38
38
  * Resolves the site data for a route, layering the matched locale and
39
39
  * additional configs over the root config.
40
40
  */
41
- declare function resolveSiteDataByRoute(siteData: SiteData$1, relativePath: string, filePath?: string): SiteData$1;
41
+ export declare function resolveSiteDataByRoute(siteData: SiteData$1, relativePath: string, filePath?: string): SiteData$1;
42
42
  /**
43
43
  * Create the page title string based on config.
44
44
  */
45
- declare function createTitle(siteData: SiteData$1, pageData: PageData$1): string;
46
- declare function mergeHead(...headArrays: HeadConfig$1[][]): HeadConfig$1[];
47
- declare function sanitizeFileName(name: string): string;
48
- declare function slash(p: string): string;
49
- declare function treatAsHtml(filename: string): boolean;
50
- declare function escapeRegExp(str: string): string;
45
+ export declare function createTitle(siteData: SiteData$1, pageData: PageData$1): string;
46
+ export declare function mergeHead(...headArrays: HeadConfig$1[][]): HeadConfig$1[];
47
+ export declare function sanitizeFileName(name: string): string;
48
+ /**
49
+ * Output path of a page's client chunk relative to `assetsDir`, from its hash
50
+ * map entry. The entry is the chunk's hash, prefixed with the subdirectory the
51
+ * build put the chunk in when `assetsShards` is set (`<shard>/<hash>`), so the
52
+ * client never has to guess the layout.
53
+ */
54
+ export declare function pageChunkPath(pageName: string, hashEntry: string, ext?: string): string;
55
+ export declare function slash(p: string): string;
56
+ export declare function treatAsHtml(filename: string): boolean;
57
+ /**
58
+ * Default `tokenize` of the local search. It splits on spaces and punctuation
59
+ * like MiniSearch does, and additionally segments the runs of Chinese or
60
+ * Japanese characters inside those words, as they are not separated by spaces.
61
+ * Everything else is kept as MiniSearch would.
62
+ *
63
+ * It is used both when building the index and when searching in the browser.
64
+ * A browser without `Intl.Segmenter` (e.g. Firefox < 125) falls back to the
65
+ * plain split, which can't match multi-word queries against an index that was
66
+ * built with segmentation.
67
+ *
68
+ * @internal
69
+ */
70
+ export declare function tokenizeSearchText(text: string): string[];
71
+ export declare function escapeRegExp(str: string): string;
51
72
  /**
52
73
  * @internal
53
74
  */
54
- declare function escapeHtml(str: string): string;
75
+ export declare function escapeHtml(str: string): string;
55
76
  /**
56
77
  * Creates a readonly proxy behaving like a deep merge of the given layers,
57
78
  * without mutating them. Earlier layers take precedence.
58
79
  */
59
- declare function stackView<T extends ObjectType>(..._layers: Partial<T>[]): T;
60
- declare namespace stackView {
80
+ export declare function stackView<T extends ObjectType>(..._layers: Partial<T>[]): T;
81
+ export declare namespace stackView {
61
82
  var unpack: <T>(obj: T) => T[] | undefined;
62
83
  }
63
84
  type ObjectType = Record<PropertyKey, any>;
64
- declare function isObject(value: unknown): value is ObjectType;
65
- declare function isShell(lang: string): boolean;
85
+ export declare function isObject(value: unknown): value is ObjectType;
86
+ export declare function isShell(lang: string): boolean;
66
87
  //#endregion
67
- export { APPEARANCE_KEY, type AdditionalConfig, type AdditionalConfigDict, type AdditionalConfigLoader, type Awaitable, type CodeCopyButtonOptions, type ContainerOptions, type DefaultTheme, EXTERNAL_URL_RE, type HeadConfig, type Header, type LocaleConfig, type LocaleSpecificConfig, type MarkdownEnv, type MarkdownLocaleOptions, type PageData, type PageDataPayload, RELATIVE_BASE_SENTINEL, type Route, type SSGContext, type SiteData, VP_SOURCE_KEY, type VitePressData, createTitle, escapeHtml, escapeRegExp, getLocaleForPath, inBrowser, isActive, isExternal, isObject, isRelativeBase, isShell, joinPath, mergeHead, normalize, notFoundPageData, parseIconName, relativePathToRoot, resolveSiteDataByRoute, sanitizeFileName, slash, stackView, treatAsHtml };
88
+ export type { AdditionalConfig, AdditionalConfigDict, AdditionalConfigLoader, Awaitable, CodeCopyButtonOptions, ContainerOptions, DefaultTheme, HeadConfig, Header, LocaleConfig, LocaleSpecificConfig, MarkdownEnv, MarkdownLocaleOptions, PageData, PageDataPayload, Route, SSGContext, SiteData, VitePressData };