@vuepress/theme-default 2.0.0-rc.122 → 2.0.0-rc.124

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 (105) hide show
  1. package/lib/client/components/VPHomeHero.vue +9 -14
  2. package/lib/client/components/VPNavbar.vue +8 -11
  3. package/lib/client/components/VPNavbarBrand.vue +4 -5
  4. package/lib/client/components/VPNavbarDropdown.vue +4 -2
  5. package/lib/client/components/VPNavbarItems.vue +3 -3
  6. package/lib/client/components/VPPageNav.vue +3 -5
  7. package/lib/client/components/VPSidebarItem.vue +3 -3
  8. package/lib/client/composables/index.d.ts +12 -11
  9. package/lib/client/composables/index.js +1 -11
  10. package/lib/client/composables/useDarkMode.d.ts +13 -4
  11. package/lib/client/composables/useDarkMode.js +2 -60
  12. package/lib/client/composables/useDarkMode.js.map +1 -0
  13. package/lib/client/composables/useData.d.ts +12 -7
  14. package/lib/client/composables/useData.js +2 -7
  15. package/lib/client/composables/useData.js.map +1 -0
  16. package/lib/client/composables/useEditLink.d.ts +8 -3
  17. package/lib/client/composables/useEditLink.js +2 -28
  18. package/lib/client/composables/useEditLink.js.map +1 -0
  19. package/lib/client/composables/useHeaders.d.ts +15 -6
  20. package/lib/client/composables/useHeaders.js +2 -38
  21. package/lib/client/composables/useHeaders.js.map +1 -0
  22. package/lib/client/composables/useNavbarConfig.d.ts +8 -3
  23. package/lib/client/composables/useNavbarConfig.js +2 -29
  24. package/lib/client/composables/useNavbarConfig.js.map +1 -0
  25. package/lib/client/composables/useNavbarRepo.d.ts +11 -4
  26. package/lib/client/composables/useNavbarRepo.js +2 -38
  27. package/lib/client/composables/useNavbarRepo.js.map +1 -0
  28. package/lib/client/composables/useNavbarSelectLanguage.d.ts +10 -3
  29. package/lib/client/composables/useNavbarSelectLanguage.js +2 -59
  30. package/lib/client/composables/useNavbarSelectLanguage.js.map +1 -0
  31. package/lib/client/composables/useNavigate.d.ts +5 -1
  32. package/lib/client/composables/useNavigate.js +2 -22
  33. package/lib/client/composables/useNavigate.js.map +1 -0
  34. package/lib/client/composables/useRelatedLinks.d.ts +10 -6
  35. package/lib/client/composables/useRelatedLinks.js +2 -90
  36. package/lib/client/composables/useRelatedLinks.js.map +1 -0
  37. package/lib/client/composables/useScrollPromise.d.ts +9 -5
  38. package/lib/client/composables/useScrollPromise.js +2 -16
  39. package/lib/client/composables/useScrollPromise.js.map +1 -0
  40. package/lib/client/composables/useSidebarItems.d.ts +57 -14
  41. package/lib/client/composables/useSidebarItems.js +2 -127
  42. package/lib/client/composables/useSidebarItems.js.map +1 -0
  43. package/lib/client/composables/useUpdateDeviceStatus.d.ts +10 -3
  44. package/lib/client/composables/useUpdateDeviceStatus.js +2 -30
  45. package/lib/client/composables/useUpdateDeviceStatus.js.map +1 -0
  46. package/lib/client/config.d.ts +10 -5
  47. package/lib/client/config.js +2 -33
  48. package/lib/client/config.js.map +1 -0
  49. package/lib/client/index.d.ts +21 -4
  50. package/lib/client/index.js +1 -2
  51. package/lib/client/layouts/Layout.vue +9 -12
  52. package/lib/client/layouts/NotFound.vue +1 -2
  53. package/lib/client/styles/arrow.scss +1 -2
  54. package/lib/client/styles/vars.scss +1 -2
  55. package/lib/client/utils/index.d.ts +6 -5
  56. package/lib/client/utils/index.js +1 -5
  57. package/lib/client/utils/isActiveSidebarItem.d.ts +8 -3
  58. package/lib/client/utils/isActiveSidebarItem.js +2 -20
  59. package/lib/client/utils/isActiveSidebarItem.js.map +1 -0
  60. package/lib/client/utils/resolveAutoLink.d.ts +13 -2
  61. package/lib/client/utils/resolveAutoLink.js +2 -17
  62. package/lib/client/utils/resolveAutoLink.js.map +1 -0
  63. package/lib/client/utils/resolveEditLink.d.ts +19 -8
  64. package/lib/client/utils/resolveEditLink.js +2 -29
  65. package/lib/client/utils/resolveEditLink.js.map +1 -0
  66. package/lib/client/utils/resolvePrefix.d.ts +5 -1
  67. package/lib/client/utils/resolvePrefix.js +2 -4
  68. package/lib/client/utils/resolvePrefix.js.map +1 -0
  69. package/lib/client/utils/resolveRepoType.d.ts +6 -2
  70. package/lib/client/utils/resolveRepoType.js +2 -12
  71. package/lib/client/utils/resolveRepoType.js.map +1 -0
  72. package/lib/nav-DikslSJ_.d.ts +36 -0
  73. package/lib/node/index.d.ts +106 -4
  74. package/lib/node/index.js +2 -2
  75. package/lib/node/index.js.map +1 -0
  76. package/lib/page-F2gyvsdE.d.ts +292 -0
  77. package/lib/sidebar-FqrQ3PGy.d.ts +53 -0
  78. package/lib/typings-jKn48KwS.d.ts +19 -0
  79. package/package.json +47 -38
  80. package/lib/client/components/global/index.d.ts +0 -2
  81. package/lib/client/components/global/index.js +0 -2
  82. package/lib/client/typings.d.ts +0 -13
  83. package/lib/client/typings.js +0 -1
  84. package/lib/node/defaultTheme.d.ts +0 -15
  85. package/lib/node/defaultTheme.js +0 -140
  86. package/lib/node/typings.d.ts +0 -59
  87. package/lib/node/typings.js +0 -1
  88. package/lib/node/utils/assignDefaultLocaleOptions.d.ts +0 -7
  89. package/lib/node/utils/assignDefaultLocaleOptions.js +0 -51
  90. package/lib/node/utils/index.d.ts +0 -2
  91. package/lib/node/utils/index.js +0 -2
  92. package/lib/node/utils/resolveMarkdownHintLocales.d.ts +0 -9
  93. package/lib/node/utils/resolveMarkdownHintLocales.js +0 -19
  94. package/lib/shared/index.d.ts +0 -5
  95. package/lib/shared/index.js +0 -1
  96. package/lib/shared/nav.d.ts +0 -32
  97. package/lib/shared/nav.js +0 -1
  98. package/lib/shared/navbar.d.ts +0 -21
  99. package/lib/shared/navbar.js +0 -1
  100. package/lib/shared/options.d.ts +0 -244
  101. package/lib/shared/options.js +0 -1
  102. package/lib/shared/page.d.ts +0 -44
  103. package/lib/shared/page.js +0 -1
  104. package/lib/shared/sidebar.d.ts +0 -26
  105. package/lib/shared/sidebar.js +0 -1
@@ -1,59 +1,2 @@
1
- import { useData } from '@theme/useData';
2
- import { useRoutePaths } from '@vuepress/helper/client';
3
- import { useMounted } from '@vueuse/core';
4
- import { computed } from 'vue';
5
- import { useRoute } from 'vuepress/client';
6
- /**
7
- * Get navbar config of select language dropdown
8
- */
9
- export const useNavbarSelectLanguage = () => {
10
- const route = useRoute();
11
- const routePaths = useRoutePaths();
12
- const { routeLocale, site, siteLocale, theme, themeLocale } = useData();
13
- const isMounted = useMounted();
14
- return computed(() => {
15
- const localePaths = Object.keys(site.value.locales);
16
- // do not display language selection dropdown if there is only one language
17
- if (localePaths.length < 2) {
18
- return [];
19
- }
20
- const currentPath = route.path;
21
- const currentFullPath = route.fullPath;
22
- const languageDropdown = {
23
- text: `${themeLocale.value.selectLanguageText}`,
24
- ariaLabel: `${themeLocale.value.selectLanguageAriaLabel ??
25
- themeLocale.value.selectLanguageText}`,
26
- children: localePaths.map((targetLocalePath) => {
27
- // target locale config of this language link
28
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
29
- const targetSiteLocale = site.value.locales?.[targetLocalePath] ?? {};
30
- const targetThemeLocale = theme.value.locales?.[targetLocalePath] ?? {};
31
- const targetLang = `${targetSiteLocale.lang}`;
32
- const text = targetThemeLocale.selectLanguageName ?? targetLang;
33
- // if the target language is current language
34
- // stay at current link
35
- if (targetLang === siteLocale.value.lang) {
36
- return {
37
- text,
38
- activeMatch: '.',
39
- link: isMounted.value ? currentFullPath : currentPath,
40
- };
41
- }
42
- // if the target language is not current language
43
- // try to link to the corresponding page of current page
44
- // or fallback to homepage
45
- const targetLocalePage = currentPath.replace(routeLocale.value, targetLocalePath);
46
- return {
47
- text,
48
- // try to keep current hash and params across languages
49
- link: routePaths.value.some((item) => item === targetLocalePage)
50
- ? isMounted.value
51
- ? currentFullPath.replace(currentPath, targetLocalePage)
52
- : targetLocalePage
53
- : (targetThemeLocale.home ?? targetLocalePath),
54
- };
55
- }),
56
- };
57
- return [languageDropdown];
58
- });
59
- };
1
+ import{useRoutePaths as e}from"@vuepress/helper/client";import{useRoute as t}from"vuepress/client";import{useData as n}from"@theme/useData";import{useMounted as r}from"@vueuse/core";import{computed as i}from"vue";const a=()=>{let a=t(),o=e(),{routeLocale:s,site:c,siteLocale:l,theme:u,themeLocale:d}=n(),f=r();return i(()=>{let e=Object.keys(c.value.locales);if(e.length<2)return[];let t=a.path,n=a.fullPath;return[{text:`${d.value.selectLanguageText}`,ariaLabel:`${d.value.selectLanguageAriaLabel??d.value.selectLanguageText}`,children:e.map(e=>{let r=c.value.locales?.[e]??{},i=u.value.locales?.[e]??{},a=`${r.lang}`,d=i.selectLanguageName??a;if(a===l.value.lang)return{text:d,activeMatch:`.`,link:f.value?n:t};let p=t.replace(s.value,e);return{text:d,link:o.value.some(e=>e===p)?f.value?n.replace(t,p):p:i.home??e}})}]})};export{a as useNavbarSelectLanguage};
2
+ //# sourceMappingURL=useNavbarSelectLanguage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNavbarSelectLanguage.js","names":["useData"],"sources":["../../../src/client/composables/useNavbarSelectLanguage.ts"],"sourcesContent":["import { useData } from '@theme/useData'\nimport { useRoutePaths } from '@vuepress/helper/client'\nimport { useMounted } from '@vueuse/core'\nimport type { ComputedRef } from 'vue'\nimport { computed } from 'vue'\nimport { useRoute } from 'vuepress/client'\nimport type { NavbarItem } from '../typings.js'\n\n/**\n * Get navbar config of select language dropdown\n *\n * @returns Navbar config of select language dropdown\n */\nexport const useNavbarSelectLanguage = (): ComputedRef<NavbarItem[]> => {\n const route = useRoute()\n const routePaths = useRoutePaths()\n const { routeLocale, site, siteLocale, theme, themeLocale } = useData()\n\n const isMounted = useMounted()\n\n return computed<NavbarItem[]>(() => {\n const localePaths = Object.keys(site.value.locales)\n // do not display language selection dropdown if there is only one language\n if (localePaths.length < 2) return []\n\n const currentPath = route.path\n const currentFullPath = route.fullPath\n\n const languageDropdown: NavbarItem = {\n text: `${themeLocale.value.selectLanguageText}`,\n ariaLabel: `${\n themeLocale.value.selectLanguageAriaLabel ??\n themeLocale.value.selectLanguageText\n }`,\n children: localePaths.map((targetLocalePath) => {\n // target locale config of this language link\n const targetSiteLocale = site.value.locales?.[targetLocalePath] ?? {}\n const targetThemeLocale = theme.value.locales?.[targetLocalePath] ?? {}\n const targetLang = `${targetSiteLocale.lang}`\n\n const text = targetThemeLocale.selectLanguageName ?? targetLang\n\n // if the target language is current language\n // stay at current link\n if (targetLang === siteLocale.value.lang) {\n return {\n text,\n activeMatch: '.',\n link: isMounted.value ? currentFullPath : currentPath,\n }\n }\n\n // if the target language is not current language\n // try to link to the corresponding page of current page\n // or fallback to homepage\n const targetLocalePage = currentPath.replace(\n routeLocale.value,\n targetLocalePath,\n )\n\n return {\n text,\n // try to keep current hash and params across languages\n link: routePaths.value.some((item) => item === targetLocalePage)\n ? isMounted.value\n ? currentFullPath.replace(currentPath, targetLocalePage)\n : targetLocalePage\n : (targetThemeLocale.home ?? targetLocalePath),\n }\n }),\n }\n\n return [languageDropdown]\n })\n}\n"],"mappings":"qNAaA,MAAa,MAA2D,CACtE,IAAM,EAAQ,GAAU,CAClB,EAAa,GAAe,CAC5B,CAAE,cAAa,OAAM,aAAY,QAAO,eAAgBA,GAAS,CAEjE,EAAY,GAAY,CAE9B,OAAO,MAA6B,CAClC,IAAM,EAAc,OAAO,KAAK,EAAK,MAAM,QAAQ,CAEnD,GAAI,EAAY,OAAS,EAAG,MAAO,EAAE,CAErC,IAAM,EAAc,EAAM,KACpB,EAAkB,EAAM,SA8C9B,MAAO,CA5C8B,CACnC,KAAM,GAAG,EAAY,MAAM,qBAC3B,UAAW,GACT,EAAY,MAAM,yBAClB,EAAY,MAAM,qBAEpB,SAAU,EAAY,IAAK,GAAqB,CAE9C,IAAM,EAAmB,EAAK,MAAM,UAAU,IAAqB,EAAE,CAC/D,EAAoB,EAAM,MAAM,UAAU,IAAqB,EAAE,CACjE,EAAa,GAAG,EAAiB,OAEjC,EAAO,EAAkB,oBAAsB,EAIrD,GAAI,IAAe,EAAW,MAAM,KAClC,MAAO,CACL,OACA,YAAa,IACb,KAAM,EAAU,MAAQ,EAAkB,EAC3C,CAMH,IAAM,EAAmB,EAAY,QACnC,EAAY,MACZ,EACD,CAED,MAAO,CACL,OAEA,KAAM,EAAW,MAAM,KAAM,GAAS,IAAS,EAAiB,CAC5D,EAAU,MACR,EAAgB,QAAQ,EAAa,EAAiB,CACtD,EACD,EAAkB,MAAQ,EAChC,EACD,CACH,CAEwB,EACzB"}
@@ -1 +1,5 @@
1
- export declare const useNavigate: () => ((url: string) => void);
1
+ //#region src/client/composables/useNavigate.d.ts
2
+ declare const useNavigate: () => ((url: string) => void);
3
+ //#endregion
4
+ export { useNavigate };
5
+ //# sourceMappingURL=useNavigate.d.ts.map
@@ -1,22 +1,2 @@
1
- import { isLinkAbsolute, isLinkWithProtocol } from '@vuepress/helper/client';
2
- import { useRoute, useRouter } from 'vuepress/client';
3
- export const useNavigate = () => {
4
- const router = useRouter();
5
- const route = useRoute();
6
- return (url) => {
7
- if (url)
8
- if (isLinkAbsolute(url)) {
9
- // Inner absolute path
10
- if (route.fullPath !== url)
11
- router.push(url);
12
- }
13
- else if (isLinkWithProtocol(url)) {
14
- // external url
15
- window.open(url);
16
- }
17
- else {
18
- // relative url
19
- router.push(encodeURI(url));
20
- }
21
- };
22
- };
1
+ import{isLinkAbsolute as e,isLinkWithProtocol as t}from"@vuepress/helper/client";import{useRoute as n,useRouter as r}from"vuepress/client";const i=()=>{let i=r(),a=n();return n=>{n&&(e(n)?a.fullPath!==n&&i.push(n):t(n)?window.open(n):i.push(encodeURI(n)))}};export{i as useNavigate};
2
+ //# sourceMappingURL=useNavigate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNavigate.js","names":[],"sources":["../../../src/client/composables/useNavigate.ts"],"sourcesContent":["import { isLinkAbsolute, isLinkWithProtocol } from '@vuepress/helper/client'\nimport { useRoute, useRouter } from 'vuepress/client'\n\nexport const useNavigate = (): ((url: string) => void) => {\n const router = useRouter()\n const route = useRoute()\n\n return (url) => {\n if (url) {\n if (isLinkAbsolute(url)) {\n // Inner absolute path\n if (route.fullPath !== url) void router.push(url)\n } else if (isLinkWithProtocol(url)) {\n // external url\n window.open(url)\n } else {\n // relative url\n void router.push(encodeURI(url))\n }\n }\n }\n}\n"],"mappings":"2IAGA,MAAa,MAA6C,CACxD,IAAM,EAAS,GAAW,CACpB,EAAQ,GAAU,CAExB,MAAQ,IAAQ,CACV,IACE,EAAe,EAAI,CAEjB,EAAM,WAAa,GAAU,EAAO,KAAK,EAAI,CACxC,EAAmB,EAAI,CAEhC,OAAO,KAAK,EAAI,CAGX,EAAO,KAAK,UAAU,EAAI,CAAC"}
@@ -1,8 +1,12 @@
1
- import type { ComputedRef } from 'vue';
2
- import type { AutoLinkOptions } from '../../shared/index.js';
1
+ import { t as AutoLinkOptions } from "../../nav-DikslSJ_.js";
2
+ import { ComputedRef } from "vue";
3
+
4
+ //#region src/client/composables/useRelatedLinks.d.ts
3
5
  interface RelatedLinks {
4
- prevLink: ComputedRef<AutoLinkOptions | null>;
5
- nextLink: ComputedRef<AutoLinkOptions | null>;
6
+ prevLink: ComputedRef<AutoLinkOptions | null>;
7
+ nextLink: ComputedRef<AutoLinkOptions | null>;
6
8
  }
7
- export declare const useRelatedLinks: () => RelatedLinks;
8
- export {};
9
+ declare const useRelatedLinks: () => RelatedLinks;
10
+ //#endregion
11
+ export { useRelatedLinks };
12
+ //# sourceMappingURL=useRelatedLinks.d.ts.map
@@ -1,90 +1,2 @@
1
- import { resolveAutoLink } from '@theme/resolveAutoLink';
2
- import { useData } from '@theme/useData';
3
- import { useSidebarItems } from '@theme/useSidebarItems';
4
- import { computed } from 'vue';
5
- import { resolveRoute, useRoutePath } from 'vuepress/client';
6
- import { isPlainObject, isString } from 'vuepress/shared';
7
- const resolveFromFrontmatterConfig = (config, currentPath) => {
8
- if (config === false) {
9
- return false;
10
- }
11
- if (isString(config)) {
12
- return resolveAutoLink(config, currentPath);
13
- }
14
- if (isPlainObject(config)) {
15
- return {
16
- ...config,
17
- link: resolveAutoLink(config.link, currentPath).link,
18
- };
19
- }
20
- return null;
21
- };
22
- /**
23
- * Resolve `prev` or `next` config from sidebar items
24
- */
25
- const resolveFromSidebarItems = (sidebarItems, currentPath, offset) => {
26
- const linkIndex = sidebarItems.findIndex((item) => item.link === currentPath);
27
- if (linkIndex !== -1) {
28
- const targetItem = sidebarItems[linkIndex + offset];
29
- if (!targetItem)
30
- return null;
31
- if (targetItem.link)
32
- return targetItem;
33
- if ('prefix' in targetItem && !resolveRoute(targetItem.prefix).notFound)
34
- return {
35
- ...targetItem,
36
- link: targetItem.prefix,
37
- };
38
- return null;
39
- }
40
- for (const item of sidebarItems) {
41
- if ('children' in item) {
42
- const childResult = resolveFromSidebarItems(item.children, currentPath, offset);
43
- if (childResult) {
44
- return childResult;
45
- }
46
- }
47
- }
48
- const prefixIndex = sidebarItems.findIndex((item) => 'prefix' in item && item.prefix === currentPath);
49
- if (prefixIndex !== -1) {
50
- const targetItem = sidebarItems[prefixIndex + offset];
51
- if (!targetItem)
52
- return null;
53
- if (targetItem.link)
54
- return targetItem;
55
- if ('prefix' in targetItem && !resolveRoute(targetItem.prefix).notFound)
56
- return {
57
- ...targetItem,
58
- link: targetItem.prefix,
59
- };
60
- return null;
61
- }
62
- return null;
63
- };
64
- export const useRelatedLinks = () => {
65
- const { frontmatter, themeLocale } = useData();
66
- const sidebarItems = useSidebarItems();
67
- const routePath = useRoutePath();
68
- const prevLink = computed(() => {
69
- const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev, routePath.value);
70
- return prevConfig === false
71
- ? null
72
- : (prevConfig ??
73
- (themeLocale.value.prev === false
74
- ? null
75
- : resolveFromSidebarItems(sidebarItems.value, routePath.value, -1)));
76
- });
77
- const nextLink = computed(() => {
78
- const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next, routePath.value);
79
- return nextConfig === false
80
- ? null
81
- : (nextConfig ??
82
- (themeLocale.value.next === false
83
- ? null
84
- : resolveFromSidebarItems(sidebarItems.value, routePath.value, 1)));
85
- });
86
- return {
87
- prevLink,
88
- nextLink,
89
- };
90
- };
1
+ import{isPlainObject as e,isString as t}from"vuepress/shared";import{useSidebarItems as n}from"@theme/useSidebarItems";import{resolveRoute as r,useRoutePath as i}from"vuepress/client";import{useData as a}from"@theme/useData";import{computed as o}from"vue";import{resolveAutoLink as s}from"@theme/resolveAutoLink";const c=(n,r)=>n===!1?!1:t(n)?s(n,r):e(n)?{...n,link:s(n.link,r).link}:null,l=(e,t,n)=>{let i=e.findIndex(e=>e.link===t);if(i!==-1){let t=e[i+n];return t?t.link?t:`prefix`in t&&!r(t.prefix).notFound?{...t,link:t.prefix}:null:null}for(let r of e)if(`children`in r){let e=l(r.children,t,n);if(e)return e}let a=e.findIndex(e=>`prefix`in e&&e.prefix===t);if(a!==-1){let t=e[a+n];return t?t.link?t:`prefix`in t&&!r(t.prefix).notFound?{...t,link:t.prefix}:null:null}return null},u=()=>{let{frontmatter:e,themeLocale:t}=a(),r=n(),s=i();return{prevLink:o(()=>{let n=c(e.value.prev,s.value);return n===!1?null:n??(t.value.prev===!1?null:l(r.value,s.value,-1))}),nextLink:o(()=>{let n=c(e.value.next,s.value);return n===!1?null:n??(t.value.next===!1?null:l(r.value,s.value,1))})}};export{u as useRelatedLinks};
2
+ //# sourceMappingURL=useRelatedLinks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRelatedLinks.js","names":["useData"],"sources":["../../../src/client/composables/useRelatedLinks.ts"],"sourcesContent":["import { resolveAutoLink } from '@theme/resolveAutoLink'\nimport { useData } from '@theme/useData'\nimport { useSidebarItems } from '@theme/useSidebarItems'\nimport type { ComputedRef } from 'vue'\nimport { computed } from 'vue'\nimport { resolveRoute, useRoutePath } from 'vuepress/client'\nimport { isPlainObject, isString } from 'vuepress/shared'\nimport type { AutoLinkOptions } from '../../shared/index.js'\nimport type { SidebarItem } from '../typings.js'\n\nconst resolveFromFrontmatterConfig = (\n config: AutoLinkOptions | string | false | undefined,\n currentPath: string,\n): AutoLinkOptions | false | null => {\n if (config === false) return false\n\n if (isString(config)) return resolveAutoLink(config, currentPath)\n\n if (isPlainObject(config)) {\n return {\n ...config,\n link: resolveAutoLink(config.link, currentPath).link,\n }\n }\n\n return null\n}\n/**\n * Resolve `prev` or `next` config from sidebar items\n *\n * @param sidebarItems - Sidebar items / 侧边栏配置项\n * @param currentPath - Current route path / 当前路由路径\n * @param offset - The offset to find the target link, -1 for `prev` and 1 for `next` / 查找目标链接的偏移量,-1 表示查找 `prev`,1 表示查找 `next`\n * @returns Resolved link or null if not found\n */\nconst resolveFromSidebarItems = (\n sidebarItems: SidebarItem[],\n currentPath: string,\n offset: number,\n): AutoLinkOptions | null => {\n const linkIndex = sidebarItems.findIndex((item) => item.link === currentPath)\n\n if (linkIndex !== -1) {\n const targetItem = sidebarItems[linkIndex + offset] as\n | SidebarItem\n | undefined\n\n if (!targetItem) return null\n\n if (targetItem.link) return targetItem as AutoLinkOptions\n\n if ('prefix' in targetItem && !resolveRoute(targetItem.prefix!).notFound) {\n return {\n ...targetItem,\n link: targetItem.prefix!,\n }\n }\n\n return null\n }\n\n for (const item of sidebarItems) {\n if ('children' in item) {\n const childResult = resolveFromSidebarItems(\n item.children,\n currentPath,\n offset,\n )\n\n if (childResult) return childResult\n }\n }\n\n const prefixIndex = sidebarItems.findIndex(\n (item) => 'prefix' in item && item.prefix === currentPath,\n )\n\n if (prefixIndex !== -1) {\n const targetItem = sidebarItems[prefixIndex + offset] as\n | SidebarItem\n | undefined\n\n if (!targetItem) return null\n\n if (targetItem.link) return targetItem as AutoLinkOptions\n\n if ('prefix' in targetItem && !resolveRoute(targetItem.prefix!).notFound) {\n return {\n ...targetItem,\n link: targetItem.prefix!,\n }\n }\n\n return null\n }\n\n return null\n}\n\ninterface RelatedLinks {\n prevLink: ComputedRef<AutoLinkOptions | null>\n nextLink: ComputedRef<AutoLinkOptions | null>\n}\n\nexport const useRelatedLinks = (): RelatedLinks => {\n const { frontmatter, themeLocale } = useData()\n const sidebarItems = useSidebarItems()\n const routePath = useRoutePath()\n\n const prevLink = computed(() => {\n const prevConfig = resolveFromFrontmatterConfig(\n frontmatter.value.prev,\n routePath.value,\n )\n\n return prevConfig === false\n ? null\n : (prevConfig ??\n (themeLocale.value.prev === false\n ? null\n : resolveFromSidebarItems(sidebarItems.value, routePath.value, -1)))\n })\n\n const nextLink = computed(() => {\n const nextConfig = resolveFromFrontmatterConfig(\n frontmatter.value.next,\n routePath.value,\n )\n\n return nextConfig === false\n ? null\n : (nextConfig ??\n (themeLocale.value.next === false\n ? null\n : resolveFromSidebarItems(sidebarItems.value, routePath.value, 1)))\n })\n\n return {\n prevLink,\n nextLink,\n }\n}\n"],"mappings":"yTAUA,MAAM,GACJ,EACA,IAEI,IAAW,GAAc,GAEzB,EAAS,EAAO,CAAS,EAAgB,EAAQ,EAAY,CAE7D,EAAc,EAAO,CAChB,CACL,GAAG,EACH,KAAM,EAAgB,EAAO,KAAM,EAAY,CAAC,KACjD,CAGI,KAUH,GACJ,EACA,EACA,IAC2B,CAC3B,IAAM,EAAY,EAAa,UAAW,GAAS,EAAK,OAAS,EAAY,CAE7E,GAAI,IAAc,GAAI,CACpB,IAAM,EAAa,EAAa,EAAY,GAe5C,OAXK,EAED,EAAW,KAAa,EAExB,WAAY,GAAc,CAAC,EAAa,EAAW,OAAQ,CAAC,SACvD,CACL,GAAG,EACH,KAAM,EAAW,OAClB,CAGI,KAXiB,KAc1B,IAAK,IAAM,KAAQ,EACjB,GAAI,aAAc,EAAM,CACtB,IAAM,EAAc,EAClB,EAAK,SACL,EACA,EACD,CAED,GAAI,EAAa,OAAO,EAI5B,IAAM,EAAc,EAAa,UAC9B,GAAS,WAAY,GAAQ,EAAK,SAAW,EAC/C,CAED,GAAI,IAAgB,GAAI,CACtB,IAAM,EAAa,EAAa,EAAc,GAe9C,OAXK,EAED,EAAW,KAAa,EAExB,WAAY,GAAc,CAAC,EAAa,EAAW,OAAQ,CAAC,SACvD,CACL,GAAG,EACH,KAAM,EAAW,OAClB,CAGI,KAXiB,KAc1B,OAAO,MAQI,MAAsC,CACjD,GAAM,CAAE,cAAa,eAAgBA,GAAS,CACxC,EAAe,GAAiB,CAChC,EAAY,GAAc,CA8BhC,MAAO,CACL,SA7Be,MAAe,CAC9B,IAAM,EAAa,EACjB,EAAY,MAAM,KAClB,EAAU,MACX,CAED,OAAO,IAAe,GAClB,KACC,IACE,EAAY,MAAM,OAAS,GACxB,KACA,EAAwB,EAAa,MAAO,EAAU,MAAO,GAAG,GAC1E,CAkBA,SAhBe,MAAe,CAC9B,IAAM,EAAa,EACjB,EAAY,MAAM,KAClB,EAAU,MACX,CAED,OAAO,IAAe,GAClB,KACC,IACE,EAAY,MAAM,OAAS,GACxB,KACA,EAAwB,EAAa,MAAO,EAAU,MAAO,EAAE,GACzE,CAKD"}
@@ -1,6 +1,10 @@
1
- export interface ScrollPromise {
2
- wait(): Promise<void> | null;
3
- pending: () => void;
4
- resolve: () => void;
1
+ //#region src/client/composables/useScrollPromise.d.ts
2
+ interface ScrollPromise {
3
+ wait(): Promise<void> | null;
4
+ pending: () => void;
5
+ resolve: () => void;
5
6
  }
6
- export declare const useScrollPromise: () => ScrollPromise;
7
+ declare const useScrollPromise: () => ScrollPromise;
8
+ //#endregion
9
+ export { ScrollPromise, useScrollPromise };
10
+ //# sourceMappingURL=useScrollPromise.d.ts.map
@@ -1,16 +1,2 @@
1
- let promise = null;
2
- let promiseResolve = null;
3
- const scrollPromise = {
4
- wait: () => promise,
5
- pending: () => {
6
- promise = new Promise((resolve) => {
7
- promiseResolve = resolve;
8
- });
9
- },
10
- resolve: () => {
11
- promiseResolve?.();
12
- promise = null;
13
- promiseResolve = null;
14
- },
15
- };
16
- export const useScrollPromise = () => scrollPromise;
1
+ let e=null,t=null;const n={wait:()=>e,pending:()=>{e=new Promise(e=>{t=e})},resolve:()=>{t?.(),e=null,t=null}},r=()=>n;export{r as useScrollPromise};
2
+ //# sourceMappingURL=useScrollPromise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollPromise.js","names":[],"sources":["../../../src/client/composables/useScrollPromise.ts"],"sourcesContent":["export interface ScrollPromise {\n wait(): Promise<void> | null\n pending: () => void\n resolve: () => void\n}\n\nlet promise: Promise<void> | null = null\nlet promiseResolve: (() => void) | null = null\n\nconst scrollPromise: ScrollPromise = {\n wait: () => promise,\n pending: () => {\n promise = new Promise((resolve) => {\n promiseResolve = resolve\n })\n },\n resolve: () => {\n promiseResolve?.()\n promise = null\n promiseResolve = null\n },\n}\n\nexport const useScrollPromise = (): ScrollPromise => scrollPromise\n"],"mappings":"AAMA,IAAI,EAAgC,KAChC,EAAsC,KAE1C,MAAM,EAA+B,CACnC,SAAY,EACZ,YAAe,CACb,EAAU,IAAI,QAAS,GAAY,CACjC,EAAiB,GACjB,EAEJ,YAAe,CACb,KAAkB,CAClB,EAAU,KACV,EAAiB,MAEpB,CAEY,MAAwC"}
@@ -1,37 +1,80 @@
1
- import type { ComputedRef, InjectionKey } from 'vue';
2
- import type { PageData, PageHeader } from 'vuepress/client';
3
- import type { SidebarArrayOptions, SidebarObjectOptions, SidebarOptions } from '../../shared/index.js';
4
- import type { SidebarHeaderItem, SidebarItem } from '../typings.js';
1
+ import { a as SidebarObjectOptions, o as SidebarOptions, t as SidebarArrayOptions } from "../../sidebar-FqrQ3PGy.js";
2
+ import { i as SidebarItem, r as SidebarHeaderItem } from "../../typings-jKn48KwS.js";
3
+ import { PageData, PageHeader } from "vuepress/client";
4
+ import { ComputedRef, InjectionKey } from "vue";
5
+
6
+ //#region src/client/composables/useSidebarItems.d.ts
5
7
  /**
6
8
  * Util to transform page header to sidebar item
9
+ *
10
+ * @param header page header
11
+ * @returns sidebar item from header
12
+ */
13
+ declare const resolveSidebarPageHeader: (header: PageHeader) => SidebarHeaderItem;
14
+ /**
15
+ * get sidebar header items from page headers
16
+ *
17
+ * @param headers page headers
18
+ * @returns sidebar header items
7
19
  */
8
- export declare const resolveSidebarPageHeader: (header: PageHeader) => SidebarHeaderItem;
9
- export declare const resolveSidebarPageHeaders: (headers?: PageHeader[]) => SidebarHeaderItem[];
20
+ declare const resolveSidebarPageHeaders: (headers?: PageHeader[]) => SidebarHeaderItem[];
10
21
  /**
11
22
  * Resolve current page and its header to sidebar items if the config is `heading`
23
+ *
24
+ * @param page current page data
25
+ * @param headers current page headers
26
+ *
27
+ * @returns sidebar items
12
28
  */
13
- export declare const resolveSidebarHeadingItem: (page: PageData, headers: PageHeader[]) => SidebarItem[];
29
+ declare const resolveSidebarHeadingItem: (page: PageData, headers: PageHeader[]) => SidebarItem[];
14
30
  /**
15
31
  * Resolve sidebar items if the config is an array
32
+ *
33
+ * @param sidebarConfig sidebar config array
34
+ * @param headers current page headers
35
+ * @param path current page path
36
+ * @param prefix path prefix
37
+ *
38
+ * @returns resolved sidebar items
16
39
  */
17
- export declare const resolveArraySidebarItems: (sidebarConfig: SidebarArrayOptions, headers: PageHeader[], path: string, prefix?: string) => SidebarItem[];
40
+ declare const resolveArraySidebarItems: (sidebarConfig: SidebarArrayOptions, headers: PageHeader[], path: string, prefix?: string) => SidebarItem[];
18
41
  /**
19
42
  * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
43
+ *
44
+ * @param sidebarConfig sidebar config object
45
+ * @param page current page data
46
+ * @param headers current page headers
47
+ * @param path current page path
48
+ *
49
+ * @returns resolved sidebar items
20
50
  */
21
- export declare const resolveMultiSidebarItems: (sidebarConfig: SidebarObjectOptions, page: PageData, headers: PageHeader[], path: string) => SidebarItem[];
22
- export type SidebarItemsRef = ComputedRef<SidebarItem[]>;
23
- export declare const sidebarItemsSymbol: InjectionKey<SidebarItemsRef>;
51
+ declare const resolveMultiSidebarItems: (sidebarConfig: SidebarObjectOptions, page: PageData, headers: PageHeader[], path: string) => SidebarItem[];
52
+ type SidebarItemsRef = ComputedRef<SidebarItem[]>;
53
+ declare const sidebarItemsSymbol: InjectionKey<SidebarItemsRef>;
24
54
  /**
25
55
  * Inject sidebar items global computed
56
+ *
57
+ * @returns sidebar items global computed
26
58
  */
27
- export declare const useSidebarItems: () => SidebarItemsRef;
59
+ declare const useSidebarItems: () => SidebarItemsRef;
28
60
  /**
29
61
  * Resolve sidebar items global computed
30
62
  *
31
63
  * It should only be resolved and provided once
64
+ *
65
+ * @param sidebarConfig sidebar config
66
+ * @param page current page data
67
+ * @param path current page path
68
+ * @param routeLocale current route locale
69
+ * @param headers current page headers
70
+ *
71
+ * @returns resolved sidebar items
32
72
  */
33
- export declare const resolveSidebarItems: (sidebarConfig: SidebarOptions | false, page: PageData, path: string, routeLocale: string, headers: PageHeader[]) => SidebarItem[];
73
+ declare const resolveSidebarItems: (sidebarConfig: SidebarOptions | false, page: PageData, path: string, routeLocale: string, headers: PageHeader[]) => SidebarItem[];
34
74
  /**
35
75
  * Create sidebar items ref and provide as global computed in setup
36
76
  */
37
- export declare const setupSidebarItems: () => void;
77
+ declare const setupSidebarItems: () => void;
78
+ //#endregion
79
+ export { SidebarItemsRef, resolveArraySidebarItems, resolveMultiSidebarItems, resolveSidebarHeadingItem, resolveSidebarItems, resolveSidebarPageHeader, resolveSidebarPageHeaders, setupSidebarItems, sidebarItemsSymbol, useSidebarItems };
80
+ //# sourceMappingURL=useSidebarItems.d.ts.map
@@ -1,127 +1,2 @@
1
- import { resolveAutoLink } from '@theme/resolveAutoLink';
2
- import { resolvePrefix } from '@theme/resolvePrefix';
3
- import { useData } from '@theme/useData';
4
- import { useHeaders } from '@theme/useHeaders';
5
- import { isLinkRelative, keys, startsWith } from '@vuepress/helper/client';
6
- import { computed, inject, provide } from 'vue';
7
- import { useRoutePath } from 'vuepress/client';
8
- import { isPlainObject, isString } from 'vuepress/shared';
9
- /**
10
- * Util to transform page header to sidebar item
11
- */
12
- export const resolveSidebarPageHeader = (header) => ({
13
- text: header.title,
14
- link: header.link,
15
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
16
- children: resolveSidebarPageHeaders(header.children),
17
- });
18
- export const resolveSidebarPageHeaders = (headers) => headers ? headers.map((header) => resolveSidebarPageHeader(header)) : [];
19
- /**
20
- * Resolve current page and its header to sidebar items if the config is `heading`
21
- */
22
- export const resolveSidebarHeadingItem = (page, headers) => [
23
- {
24
- text: page.title,
25
- children: resolveSidebarPageHeaders(headers),
26
- },
27
- ];
28
- /**
29
- * Resolve sidebar items if the config is an array
30
- */
31
- export const resolveArraySidebarItems = (sidebarConfig, headers, path, prefix = '') => {
32
- const handleChildItem = (item, pathPrefix) => {
33
- const childItem = isString(item)
34
- ? resolveAutoLink(resolvePrefix(pathPrefix, item))
35
- : isString(item.link)
36
- ? {
37
- ...item,
38
- link: isLinkRelative(item.link)
39
- ? resolveAutoLink(resolvePrefix(pathPrefix, item.link)).link
40
- : item.link,
41
- }
42
- : item;
43
- if ('children' in childItem) {
44
- return {
45
- ...childItem,
46
- children: childItem.children.map((child) => handleChildItem(child, resolvePrefix(pathPrefix, childItem.prefix))),
47
- };
48
- }
49
- // if the sidebar item is current page and children is not set
50
- // use headers of current page as children
51
- if (childItem.link === path) {
52
- // skip h1 header
53
- const currentHeaders = headers[0]?.level === 1 ? headers[0].children : headers;
54
- return {
55
- ...childItem,
56
- children: resolveSidebarPageHeaders(currentHeaders),
57
- };
58
- }
59
- return childItem;
60
- };
61
- return sidebarConfig.map((item) => handleChildItem(item, prefix));
62
- };
63
- /**
64
- * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
65
- */
66
- export const resolveMultiSidebarItems = (sidebarConfig, page, headers, path) => {
67
- const sidebarRoutes = keys(sidebarConfig).sort((x, y) => y.length - x.length);
68
- // Find matching config
69
- for (const base of sidebarRoutes)
70
- if (startsWith(decodeURI(path), base)) {
71
- const matched = sidebarConfig[base];
72
- return matched
73
- ? matched === 'heading'
74
- ? resolveSidebarHeadingItem(page, headers)
75
- : resolveArraySidebarItems(matched, headers, path, base)
76
- : [];
77
- }
78
- // eslint-disable-next-line no-console
79
- console.warn(`${decodeURI(path)} is missing sidebar config.`);
80
- return [];
81
- };
82
- export const sidebarItemsSymbol = Symbol('sidebarItems');
83
- /**
84
- * Inject sidebar items global computed
85
- */
86
- export const useSidebarItems = () => {
87
- const sidebarItems = inject(sidebarItemsSymbol);
88
- if (!sidebarItems) {
89
- throw new Error('useSidebarItems() is called without provider.');
90
- }
91
- return sidebarItems;
92
- };
93
- /**
94
- * Resolve sidebar items global computed
95
- *
96
- * It should only be resolved and provided once
97
- */
98
- export const resolveSidebarItems = (sidebarConfig, page, path, routeLocale, headers) => {
99
- // resolve sidebar items according to the config
100
- if (sidebarConfig === false) {
101
- return [];
102
- }
103
- if (sidebarConfig === 'heading') {
104
- return resolveSidebarHeadingItem(page, headers);
105
- }
106
- if (Array.isArray(sidebarConfig)) {
107
- return resolveArraySidebarItems(sidebarConfig, headers, path, routeLocale);
108
- }
109
- if (isPlainObject(sidebarConfig)) {
110
- return resolveMultiSidebarItems(sidebarConfig, page, headers, path);
111
- }
112
- return [];
113
- };
114
- /**
115
- * Create sidebar items ref and provide as global computed in setup
116
- */
117
- export const setupSidebarItems = () => {
118
- const { frontmatter, page, routeLocale, themeLocale } = useData();
119
- const headers = useHeaders();
120
- const routePath = useRoutePath();
121
- const sidebarConfig = computed(() => !frontmatter.value.home &&
122
- (frontmatter.value.sidebar ??
123
- themeLocale.value.sidebar ??
124
- 'heading'));
125
- const sidebarItems = computed(() => resolveSidebarItems(sidebarConfig.value, page.value, routePath.value, routeLocale.value, headers.value));
126
- provide(sidebarItemsSymbol, sidebarItems);
127
- };
1
+ import{isPlainObject as e,isString as t}from"vuepress/shared";import{useHeaders as n}from"@theme/useHeaders";import{isLinkRelative as r,keys as i,startsWith as a}from"@vuepress/helper/client";import{useRoutePath as o}from"vuepress/client";import{useData as s}from"@theme/useData";import{computed as c,inject as l,provide as u}from"vue";import{resolveAutoLink as d}from"@theme/resolveAutoLink";import{resolvePrefix as f}from"@theme/resolvePrefix";const p=e=>({text:e.title,link:e.link,children:m(e.children)}),m=e=>e?e.map(e=>p(e)):[],h=(e,t)=>[{text:e.title,children:m(t)}],g=(e,n,i,a=``)=>{let o=(e,a)=>{let s=t(e)?d(f(a,e)):t(e.link)?{...e,link:r(e.link)?d(f(a,e.link)).link:e.link}:e;if(`children`in s)return{...s,children:s.children.map(e=>o(e,f(a,s.prefix)))};if(s.link===i){let e=n[0]?.level===1?n[0].children:n;return{...s,children:m(e)}}return s};return e.map(e=>o(e,a))},_=(e,t,n,r)=>{let o=i(e).sort((e,t)=>t.length-e.length);for(let i of o)if(a(decodeURI(r),i)){let a=e[i];return a===!1?[]:a===`heading`?h(t,n):g(a,n,r,i)}return console.warn(`${decodeURI(r)} is missing sidebar config.`),[]},v=Symbol(`sidebarItems`),y=()=>{let e=l(v);if(!e)throw Error(`useSidebarItems() is called without provider.`);return e},b=(t,n,r,i,a)=>t===!1?[]:t===`heading`?h(n,a):Array.isArray(t)?g(t,a,r,i):e(t)?_(t,n,a,r):[],x=()=>{let{frontmatter:e,page:t,routeLocale:r,themeLocale:i}=s(),a=n(),l=o(),d=c(()=>!e.value.home&&(e.value.sidebar??i.value.sidebar??`heading`));u(v,c(()=>b(d.value,t.value,l.value,r.value,a.value)))};export{g as resolveArraySidebarItems,_ as resolveMultiSidebarItems,h as resolveSidebarHeadingItem,b as resolveSidebarItems,p as resolveSidebarPageHeader,m as resolveSidebarPageHeaders,x as setupSidebarItems,v as sidebarItemsSymbol,y as useSidebarItems};
2
+ //# sourceMappingURL=useSidebarItems.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSidebarItems.js","names":["useData"],"sources":["../../../src/client/composables/useSidebarItems.ts"],"sourcesContent":["import { resolveAutoLink } from '@theme/resolveAutoLink'\nimport { resolvePrefix } from '@theme/resolvePrefix'\nimport { useData } from '@theme/useData'\nimport { useHeaders } from '@theme/useHeaders'\nimport { isLinkRelative, keys, startsWith } from '@vuepress/helper/client'\nimport type { ComputedRef, InjectionKey } from 'vue'\nimport { computed, inject, provide } from 'vue'\nimport type { PageData, PageHeader } from 'vuepress/client'\nimport { useRoutePath } from 'vuepress/client'\nimport { isPlainObject, isString } from 'vuepress/shared'\nimport type {\n DefaultThemeHomePageFrontmatter,\n DefaultThemeNormalPageFrontmatter,\n SidebarArrayOptions,\n SidebarItemOptions,\n SidebarObjectOptions,\n SidebarOptions,\n} from '../../shared/index.js'\nimport type { SidebarHeaderItem, SidebarItem } from '../typings.js'\n\n/**\n * Util to transform page header to sidebar item\n *\n * @param header page header\n * @returns sidebar item from header\n */\nexport const resolveSidebarPageHeader = (\n header: PageHeader,\n): SidebarHeaderItem => ({\n text: header.title,\n link: header.link,\n // oxlint-disable-next-line no-use-before-define\n children: resolveSidebarPageHeaders(header.children),\n})\n\n/**\n * get sidebar header items from page headers\n *\n * @param headers page headers\n * @returns sidebar header items\n */\nexport const resolveSidebarPageHeaders = (\n headers?: PageHeader[],\n): SidebarHeaderItem[] =>\n headers ? headers.map((header) => resolveSidebarPageHeader(header)) : []\n\n/**\n * Resolve current page and its header to sidebar items if the config is `heading`\n *\n * @param page current page data\n * @param headers current page headers\n *\n * @returns sidebar items\n */\nexport const resolveSidebarHeadingItem = (\n page: PageData,\n headers: PageHeader[],\n): SidebarItem[] => [\n {\n text: page.title,\n children: resolveSidebarPageHeaders(headers),\n },\n]\n\n/**\n * Resolve sidebar items if the config is an array\n *\n * @param sidebarConfig sidebar config array\n * @param headers current page headers\n * @param path current page path\n * @param prefix path prefix\n *\n * @returns resolved sidebar items\n */\nexport const resolveArraySidebarItems = (\n sidebarConfig: SidebarArrayOptions,\n headers: PageHeader[],\n path: string,\n prefix = '',\n): SidebarItem[] => {\n const handleChildItem = (\n item: SidebarItemOptions,\n pathPrefix: string,\n ): SidebarItem => {\n const childItem: SidebarItemOptions = isString(item)\n ? resolveAutoLink(resolvePrefix(pathPrefix, item))\n : isString(item.link)\n ? {\n ...item,\n link: isLinkRelative(item.link)\n ? resolveAutoLink(resolvePrefix(pathPrefix, item.link)).link\n : item.link,\n }\n : item\n\n if ('children' in childItem) {\n return {\n ...childItem,\n children: childItem.children.map((child) =>\n handleChildItem(child, resolvePrefix(pathPrefix, childItem.prefix)),\n ),\n }\n }\n\n // if the sidebar item is current page and children is not set\n // use headers of current page as children\n if (childItem.link === path) {\n // skip h1 header\n const currentHeaders =\n headers[0]?.level === 1 ? headers[0].children : headers\n\n return {\n ...childItem,\n children: resolveSidebarPageHeaders(currentHeaders),\n }\n }\n\n return childItem\n }\n\n return sidebarConfig.map((item) => handleChildItem(item, prefix))\n}\n\n/**\n * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object\n *\n * @param sidebarConfig sidebar config object\n * @param page current page data\n * @param headers current page headers\n * @param path current page path\n *\n * @returns resolved sidebar items\n */\nexport const resolveMultiSidebarItems = (\n sidebarConfig: SidebarObjectOptions,\n page: PageData,\n headers: PageHeader[],\n path: string,\n): SidebarItem[] => {\n const sidebarRoutes = keys(sidebarConfig).sort((a, b) => b.length - a.length)\n\n // Find matching config\n for (const base of sidebarRoutes) {\n if (startsWith(decodeURI(path), base)) {\n const matched = sidebarConfig[base]\n\n return matched === false\n ? []\n : matched === 'heading'\n ? resolveSidebarHeadingItem(page, headers)\n : resolveArraySidebarItems(matched, headers, path, base)\n }\n }\n\n // eslint-disable-next-line no-console\n console.warn(`${decodeURI(path)} is missing sidebar config.`)\n\n return []\n}\n\nexport type SidebarItemsRef = ComputedRef<SidebarItem[]>\n\nexport const sidebarItemsSymbol: InjectionKey<SidebarItemsRef> =\n Symbol('sidebarItems')\n\n/**\n * Inject sidebar items global computed\n *\n * @returns sidebar items global computed\n */\nexport const useSidebarItems = (): SidebarItemsRef => {\n const sidebarItems = inject(sidebarItemsSymbol)\n if (!sidebarItems)\n throw new Error('useSidebarItems() is called without provider.')\n\n return sidebarItems\n}\n\n/**\n * Resolve sidebar items global computed\n *\n * It should only be resolved and provided once\n *\n * @param sidebarConfig sidebar config\n * @param page current page data\n * @param path current page path\n * @param routeLocale current route locale\n * @param headers current page headers\n *\n * @returns resolved sidebar items\n */\n\nexport const resolveSidebarItems = (\n sidebarConfig: SidebarOptions | false,\n page: PageData,\n path: string,\n routeLocale: string,\n headers: PageHeader[],\n): SidebarItem[] => {\n // resolve sidebar items according to the config\n if (sidebarConfig === false) return []\n\n if (sidebarConfig === 'heading')\n return resolveSidebarHeadingItem(page, headers)\n\n if (Array.isArray(sidebarConfig))\n return resolveArraySidebarItems(sidebarConfig, headers, path, routeLocale)\n\n if (isPlainObject(sidebarConfig))\n return resolveMultiSidebarItems(sidebarConfig, page, headers, path)\n\n return []\n}\n\n/**\n * Create sidebar items ref and provide as global computed in setup\n */\nexport const setupSidebarItems = (): void => {\n const { frontmatter, page, routeLocale, themeLocale } = useData<\n DefaultThemeHomePageFrontmatter | DefaultThemeNormalPageFrontmatter\n >()\n const headers = useHeaders()\n const routePath = useRoutePath()\n\n const sidebarConfig = computed<SidebarOptions | false>(\n () =>\n !frontmatter.value.home &&\n ((frontmatter.value as DefaultThemeNormalPageFrontmatter).sidebar ??\n themeLocale.value.sidebar ??\n 'heading'),\n )\n\n const sidebarItems = computed(() =>\n resolveSidebarItems(\n sidebarConfig.value,\n page.value,\n routePath.value,\n routeLocale.value,\n headers.value,\n ),\n )\n provide(sidebarItemsSymbol, sidebarItems)\n}\n"],"mappings":"8bA0BA,MAAa,EACX,IACuB,CACvB,KAAM,EAAO,MACb,KAAM,EAAO,KAEb,SAAU,EAA0B,EAAO,SAAS,CACrD,EAQY,EACX,GAEA,EAAU,EAAQ,IAAK,GAAW,EAAyB,EAAO,CAAC,CAAG,EAAE,CAU7D,GACX,EACA,IACkB,CAClB,CACE,KAAM,EAAK,MACX,SAAU,EAA0B,EAAQ,CAC7C,CACF,CAYY,GACX,EACA,EACA,EACA,EAAS,KACS,CAClB,IAAM,GACJ,EACA,IACgB,CAChB,IAAM,EAAgC,EAAS,EAAK,CAChD,EAAgB,EAAc,EAAY,EAAK,CAAC,CAChD,EAAS,EAAK,KAAK,CACjB,CACE,GAAG,EACH,KAAM,EAAe,EAAK,KAAK,CAC3B,EAAgB,EAAc,EAAY,EAAK,KAAK,CAAC,CAAC,KACtD,EAAK,KACV,CACD,EAEN,GAAI,aAAc,EAChB,MAAO,CACL,GAAG,EACH,SAAU,EAAU,SAAS,IAAK,GAChC,EAAgB,EAAO,EAAc,EAAY,EAAU,OAAO,CAAC,CACpE,CACF,CAKH,GAAI,EAAU,OAAS,EAAM,CAE3B,IAAM,EACJ,EAAQ,IAAI,QAAU,EAAI,EAAQ,GAAG,SAAW,EAElD,MAAO,CACL,GAAG,EACH,SAAU,EAA0B,EAAe,CACpD,CAGH,OAAO,GAGT,OAAO,EAAc,IAAK,GAAS,EAAgB,EAAM,EAAO,CAAC,EAatD,GACX,EACA,EACA,EACA,IACkB,CAClB,IAAM,EAAgB,EAAK,EAAc,CAAC,MAAM,EAAG,IAAM,EAAE,OAAS,EAAE,OAAO,CAG7E,IAAK,IAAM,KAAQ,EACjB,GAAI,EAAW,UAAU,EAAK,CAAE,EAAK,CAAE,CACrC,IAAM,EAAU,EAAc,GAE9B,OAAO,IAAY,GACf,EAAE,CACF,IAAY,UACV,EAA0B,EAAM,EAAQ,CACxC,EAAyB,EAAS,EAAS,EAAM,EAAK,CAOhE,OAFA,QAAQ,KAAK,GAAG,UAAU,EAAK,CAAC,6BAA6B,CAEtD,EAAE,EAKE,EACX,OAAO,eAAe,CAOX,MAAyC,CACpD,IAAM,EAAe,EAAO,EAAmB,CAC/C,GAAI,CAAC,EACH,MAAU,MAAM,gDAAgD,CAElE,OAAO,GAiBI,GACX,EACA,EACA,EACA,EACA,IAGI,IAAkB,GAAc,EAAE,CAElC,IAAkB,UACb,EAA0B,EAAM,EAAQ,CAE7C,MAAM,QAAQ,EAAc,CACvB,EAAyB,EAAe,EAAS,EAAM,EAAY,CAExE,EAAc,EAAc,CACvB,EAAyB,EAAe,EAAM,EAAS,EAAK,CAE9D,EAAE,CAME,MAAgC,CAC3C,GAAM,CAAE,cAAa,OAAM,cAAa,eAAgBA,GAErD,CACG,EAAU,GAAY,CACtB,EAAY,GAAc,CAE1B,EAAgB,MAElB,CAAC,EAAY,MAAM,OACjB,EAAY,MAA4C,SACxD,EAAY,MAAM,SAClB,WACL,CAWD,EAAQ,EATa,MACnB,EACE,EAAc,MACd,EAAK,MACL,EAAU,MACV,EAAY,MACZ,EAAQ,MACT,CACF,CACwC"}
@@ -1,7 +1,14 @@
1
- export declare enum DeviceType {
2
- Mobile = "mobile"
1
+ //#region src/client/composables/useUpdateDeviceStatus.d.ts
2
+ declare enum DeviceType {
3
+ Mobile = "mobile"
3
4
  }
4
5
  /**
5
6
  * add listener to detect screen though device type
7
+ *
8
+ * @param deviceType - Device type to detect / 要检测的设备类型
9
+ * @param callback - Callback function to call when device status changes / 设备状态改变时调用的回调函数
6
10
  */
7
- export declare const useUpdateDeviceStatus: (deviceType: DeviceType, callback: (width: number) => void) => void;
11
+ declare const useUpdateDeviceStatus: (deviceType: DeviceType, callback: (width: number) => void) => void;
12
+ //#endregion
13
+ export { DeviceType, useUpdateDeviceStatus };
14
+ //# sourceMappingURL=useUpdateDeviceStatus.d.ts.map
@@ -1,30 +1,2 @@
1
- import { useEventListener } from '@vueuse/core';
2
- import { onMounted } from 'vue';
3
- import cssVariables from '../styles/_variables.module.scss';
4
- export var DeviceType;
5
- (function (DeviceType) {
6
- DeviceType["Mobile"] = "mobile";
7
- })(DeviceType || (DeviceType = {}));
8
- const DeviceTypeMap = {
9
- [DeviceType.Mobile]: Number.parseInt(cssVariables.mobile.replace('px', ''), 10),
10
- };
11
- /**
12
- * add listener to detect screen though device type
13
- */
14
- export const useUpdateDeviceStatus = (deviceType, callback) => {
15
- const width = DeviceTypeMap[deviceType];
16
- if (!Number.isInteger(width)) {
17
- if (__VUEPRESS_DEV__)
18
- throw new Error('device width must be a integer');
19
- return;
20
- }
21
- useEventListener('orientationchange', () => {
22
- callback(width);
23
- });
24
- useEventListener('resize', () => {
25
- callback(width);
26
- });
27
- onMounted(() => {
28
- callback(width);
29
- });
30
- };
1
+ import{useEventListener as e}from"@vueuse/core";import{onMounted as t}from"vue";import n from"../styles/_variables.module.scss";let r=function(e){return e.Mobile=`mobile`,e}({});const i={[r.Mobile]:Number.parseInt(n.mobile.replace(`px`,``),10)},a=(n,r)=>{let a=i[n];if(!Number.isInteger(a)){if(__VUEPRESS_DEV__)throw Error(`device width must be a integer`);return}e(`orientationchange`,()=>{r(a)}),e(`resize`,()=>{r(a)}),t(()=>{r(a)})};export{r as DeviceType,a as useUpdateDeviceStatus};
2
+ //# sourceMappingURL=useUpdateDeviceStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUpdateDeviceStatus.js","names":[],"sources":["../../../src/client/composables/useUpdateDeviceStatus.ts"],"sourcesContent":["// oxlint-disable promise/prefer-await-to-callbacks\nimport { useEventListener } from '@vueuse/core'\nimport { onMounted } from 'vue'\nimport cssVariables from '../styles/_variables.module.scss'\n\nexport enum DeviceType {\n Mobile = 'mobile',\n}\n\nconst DeviceTypeMap = {\n [DeviceType.Mobile]: Number.parseInt(\n cssVariables.mobile.replace('px', ''),\n 10,\n ),\n}\n\n/**\n * add listener to detect screen though device type\n *\n * @param deviceType - Device type to detect / 要检测的设备类型\n * @param callback - Callback function to call when device status changes / 设备状态改变时调用的回调函数\n */\nexport const useUpdateDeviceStatus = (\n deviceType: DeviceType,\n callback: (width: number) => void,\n): void => {\n const width = DeviceTypeMap[deviceType]\n if (!Number.isInteger(width)) {\n if (__VUEPRESS_DEV__) throw new Error('device width must be a integer')\n return\n }\n\n useEventListener('orientationchange', () => {\n callback(width)\n })\n useEventListener('resize', () => {\n callback(width)\n })\n\n onMounted(() => {\n callback(width)\n })\n}\n"],"mappings":"gIAKA,IAAY,EAAA,SAAA,EAAL,OACL,GAAA,OAAA,gBAGF,MAAM,EAAgB,EACnB,EAAW,QAAS,OAAO,SAC1B,EAAa,OAAO,QAAQ,KAAM,GAAG,CACrC,GACD,CACF,CAQY,GACX,EACA,IACS,CACT,IAAM,EAAQ,EAAc,GAC5B,GAAI,CAAC,OAAO,UAAU,EAAM,CAAE,CAC5B,GAAI,iBAAkB,MAAU,MAAM,iCAAiC,CACvE,OAGF,EAAiB,wBAA2B,CAC1C,EAAS,EAAM,EACf,CACF,EAAiB,aAAgB,CAC/B,EAAS,EAAM,EACf,CAEF,MAAgB,CACd,EAAS,EAAM,EACf"}
@@ -1,5 +1,10 @@
1
- import '@vuepress/helper/colors.css';
2
- import '@vuepress/helper/normalize.css';
3
- import './styles/index.scss';
4
- declare const _default: import("vuepress/client").ClientConfig;
5
- export default _default;
1
+ import * as vuepress_client0 from "vuepress/client";
2
+ import "@vuepress/helper/colors.css";
3
+ import "@vuepress/helper/normalize.css";
4
+ import "./styles/index.scss";
5
+
6
+ //#region src/client/config.d.ts
7
+ declare const _default: vuepress_client0.ClientConfig;
8
+ //#endregion
9
+ export { _default as default };
10
+ //# sourceMappingURL=config.d.ts.map