vitepress 2.0.0-alpha.2 → 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.
- package/README.md +34 -2
- package/THIRD-PARTY-NOTICES.md +1736 -0
- package/bin/vitepress.js +14 -0
- package/client.d.ts +9 -0
- package/dist/client/app/components/ClientOnly.d.ts +5 -0
- package/dist/client/app/components/ClientOnly.js +11 -10
- package/dist/client/app/components/Content.d.ts +17 -0
- package/dist/client/app/components/Content.js +25 -22
- package/dist/client/app/composables/codeGroups.d.ts +3 -0
- package/dist/client/app/composables/codeGroups.js +36 -39
- package/dist/client/app/composables/copyCode.d.ts +3 -0
- package/dist/client/app/composables/copyCode.js +59 -70
- package/dist/client/app/composables/head.d.ts +5 -0
- package/dist/client/app/composables/head.js +56 -74
- package/dist/client/app/composables/icon.d.ts +12 -0
- package/dist/client/app/composables/icon.js +56 -0
- package/dist/client/app/composables/preFetch.d.ts +3 -0
- package/dist/client/app/composables/preFetch.js +64 -96
- package/dist/client/app/data.d.ts +9 -0
- package/dist/client/app/data.js +34 -59
- package/dist/client/app/devtools.d.ts +7 -0
- package/dist/client/app/devtools.js +29 -28
- package/dist/client/app/index.d.ts +11 -0
- package/dist/client/app/index.js +106 -131
- package/dist/client/app/router.d.ts +49 -0
- package/dist/client/app/router.js +198 -239
- package/dist/client/app/ssr.d.ts +4 -0
- package/dist/client/app/ssr.js +14 -9
- package/dist/client/app/theme.d.ts +24 -0
- package/dist/client/app/theme.js +0 -1
- package/dist/client/app/utils.d.ts +35 -0
- package/dist/client/app/utils.js +77 -110
- package/dist/client/index.d.ts +21 -137
- package/dist/client/index.js +8 -9
- package/dist/client/shared.d.ts +88 -0
- package/dist/client/shared.js +265 -141
- package/dist/client/theme-default/Layout.d.vue.ts +79 -0
- package/dist/client/theme-default/Layout.vue +33 -36
- package/dist/client/theme-default/NotFound.d.vue.ts +3 -0
- package/dist/client/theme-default/NotFound.vue +33 -35
- package/dist/client/theme-default/components/VPAlgoliaSearchBox.d.vue.ts +11 -0
- package/dist/client/theme-default/components/VPAlgoliaSearchBox.vue +202 -70
- package/dist/client/theme-default/components/VPBackdrop.d.vue.ts +6 -0
- package/dist/client/theme-default/components/VPBackdrop.vue +8 -12
- package/dist/client/theme-default/components/VPBadge.d.vue.ts +19 -0
- package/dist/client/theme-default/components/VPBadge.vue +49 -26
- package/dist/client/theme-default/components/VPButton.d.vue.ts +25 -0
- package/dist/client/theme-default/components/VPButton.vue +53 -36
- package/dist/client/theme-default/components/VPCarbonAds.d.vue.ts +7 -0
- package/dist/client/theme-default/components/VPCarbonAds.vue +51 -52
- package/dist/client/theme-default/components/VPContent.d.vue.ts +59 -0
- package/dist/client/theme-default/components/VPContent.vue +27 -26
- package/dist/client/theme-default/components/VPDoc.d.vue.ts +33 -0
- package/dist/client/theme-default/components/VPDoc.vue +52 -48
- package/dist/client/theme-default/components/VPDocAside.d.vue.ts +23 -0
- package/dist/client/theme-default/components/VPDocAside.vue +7 -8
- package/dist/client/theme-default/components/VPDocAsideCarbonAds.d.vue.ts +7 -0
- package/dist/client/theme-default/components/VPDocAsideCarbonAds.vue +7 -11
- package/dist/client/theme-default/components/VPDocAsideOutline.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPDocAsideOutline.vue +22 -38
- package/dist/client/theme-default/components/VPDocAsideSponsors.d.vue.ts +10 -0
- package/dist/client/theme-default/components/VPDocAsideSponsors.vue +17 -11
- package/dist/client/theme-default/components/VPDocFooter.d.vue.ts +13 -0
- package/dist/client/theme-default/components/VPDocFooter.vue +38 -45
- package/dist/client/theme-default/components/VPDocFooterLastUpdated.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPDocFooterLastUpdated.vue +30 -29
- package/dist/client/theme-default/components/VPDocOutlineItem.d.vue.ts +8 -0
- package/dist/client/theme-default/components/VPDocOutlineItem.vue +20 -19
- package/dist/client/theme-default/components/VPFeature.d.vue.ts +13 -0
- package/dist/client/theme-default/components/VPFeature.vue +62 -36
- package/dist/client/theme-default/components/VPFeatures.d.vue.ts +16 -0
- package/dist/client/theme-default/components/VPFeatures.vue +35 -48
- package/dist/client/theme-default/components/VPFlyout.d.vue.ts +26 -0
- package/dist/client/theme-default/components/VPFlyout.vue +111 -47
- package/dist/client/theme-default/components/VPFooter.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPFooter.vue +22 -15
- package/dist/client/theme-default/components/VPHero.d.vue.ts +38 -0
- package/dist/client/theme-default/components/VPHero.vue +109 -99
- package/dist/client/theme-default/components/VPHome.d.vue.ts +31 -0
- package/dist/client/theme-default/components/VPHome.vue +15 -15
- package/dist/client/theme-default/components/VPHomeContent.d.vue.ts +13 -0
- package/dist/client/theme-default/components/VPHomeContent.vue +9 -27
- package/dist/client/theme-default/components/VPHomeFeatures.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPHomeFeatures.vue +4 -5
- package/dist/client/theme-default/components/VPHomeHero.d.vue.ts +23 -0
- package/dist/client/theme-default/components/VPHomeHero.vue +5 -5
- package/dist/client/theme-default/components/VPHomeSponsors.d.vue.ts +21 -0
- package/dist/client/theme-default/components/VPHomeSponsors.vue +42 -43
- package/dist/client/theme-default/components/VPIcon.d.vue.ts +8 -0
- package/dist/client/theme-default/components/VPIcon.vue +29 -0
- package/dist/client/theme-default/components/VPImage.d.vue.ts +8 -0
- package/dist/client/theme-default/components/VPImage.vue +20 -14
- package/dist/client/theme-default/components/VPLink.d.vue.ts +23 -0
- package/dist/client/theme-default/components/VPLink.vue +42 -23
- package/dist/client/theme-default/components/VPLocalNav.d.vue.ts +10 -0
- package/dist/client/theme-default/components/VPLocalNav.vue +69 -86
- package/dist/client/theme-default/components/VPLocalNavOutlineDropdown.d.vue.ts +8 -0
- package/dist/client/theme-default/components/VPLocalNavOutlineDropdown.vue +98 -96
- package/dist/client/theme-default/components/VPLocalSearchBox.d.vue.ts +7 -0
- package/dist/client/theme-default/components/VPLocalSearchBox.vue +391 -454
- package/dist/client/theme-default/components/VPMenu.d.vue.ts +23 -0
- package/dist/client/theme-default/components/VPMenu.vue +19 -31
- package/dist/client/theme-default/components/VPMenuGroup.d.vue.ts +22 -0
- package/dist/client/theme-default/components/VPMenuGroup.vue +72 -18
- package/dist/client/theme-default/components/VPMenuLink.d.vue.ts +22 -0
- package/dist/client/theme-default/components/VPMenuLink.vue +65 -31
- package/dist/client/theme-default/components/VPNav.d.vue.ts +23 -0
- package/dist/client/theme-default/components/VPNav.vue +18 -24
- package/dist/client/theme-default/components/VPNavAppearance.d.vue.ts +9 -0
- package/dist/client/theme-default/components/VPNavAppearance.vue +88 -0
- package/dist/client/theme-default/components/VPNavBar.d.vue.ts +26 -0
- package/dist/client/theme-default/components/VPNavBar.vue +170 -142
- package/dist/client/theme-default/components/VPNavBarAskAiButton.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPNavBarAskAiButton.vue +31 -0
- package/dist/client/theme-default/components/VPNavBarExtra.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPNavBarExtra.vue +51 -73
- package/dist/client/theme-default/components/VPNavBarHamburger.d.vue.ts +10 -0
- package/dist/client/theme-default/components/VPNavBarHamburger.vue +38 -28
- package/dist/client/theme-default/components/VPNavBarSearch.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPNavBarSearch.vue +129 -160
- package/dist/client/theme-default/components/VPNavBarSearchButton.d.vue.ts +6 -0
- package/dist/client/theme-default/components/VPNavBarSearchButton.vue +48 -182
- package/dist/client/theme-default/components/VPNavBarTitle.d.vue.ts +15 -0
- package/dist/client/theme-default/components/VPNavBarTitle.vue +39 -38
- package/dist/client/theme-default/components/VPNavMenu.d.vue.ts +6 -0
- package/dist/client/theme-default/components/VPNavMenu.vue +76 -0
- package/dist/client/theme-default/components/VPNavMenuGroup.d.vue.ts +11 -0
- package/dist/client/theme-default/components/VPNavMenuGroup.vue +140 -0
- package/dist/client/theme-default/components/VPNavMenuLink.d.vue.ts +8 -0
- package/dist/client/theme-default/components/VPNavMenuLink.vue +69 -0
- package/dist/client/theme-default/components/VPNavScreen.d.vue.ts +18 -0
- package/dist/client/theme-default/components/VPNavScreen.vue +36 -34
- package/dist/client/theme-default/components/VPNavSocialLinks.d.vue.ts +6 -0
- package/dist/client/theme-default/components/VPNavSocialLinks.vue +36 -0
- package/dist/client/theme-default/components/VPNavTranslations.d.vue.ts +9 -0
- package/dist/client/theme-default/components/VPNavTranslations.vue +170 -0
- package/dist/client/theme-default/components/VPPage.d.vue.ts +15 -0
- package/dist/client/theme-default/components/VPSidebar.d.vue.ts +18 -0
- package/dist/client/theme-default/components/VPSidebar.vue +40 -53
- package/dist/client/theme-default/components/VPSidebarGroup.d.vue.ts +7 -0
- package/dist/client/theme-default/components/VPSidebarGroup.vue +24 -29
- package/dist/client/theme-default/components/VPSidebarItem.d.vue.ts +8 -0
- package/dist/client/theme-default/components/VPSidebarItem.vue +60 -93
- package/dist/client/theme-default/components/VPSkipLink.d.vue.ts +6 -0
- package/dist/client/theme-default/components/VPSkipLink.vue +23 -42
- package/dist/client/theme-default/components/VPSocialLink.d.vue.ts +11 -0
- package/dist/client/theme-default/components/VPSocialLink.vue +42 -49
- package/dist/client/theme-default/components/VPSocialLinks.d.vue.ts +10 -0
- package/dist/client/theme-default/components/VPSocialLinks.vue +26 -16
- package/dist/client/theme-default/components/VPSponsors.d.vue.ts +18 -0
- package/dist/client/theme-default/components/VPSponsors.vue +34 -33
- package/dist/client/theme-default/components/VPSponsorsGrid.d.vue.ts +15 -0
- package/dist/client/theme-default/components/VPSponsorsGrid.vue +23 -26
- package/dist/client/theme-default/components/VPSwitch.d.vue.ts +13 -0
- package/dist/client/theme-default/components/VPSwitch.vue +12 -13
- package/dist/client/theme-default/components/VPSwitchAppearance.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPSwitchAppearance.vue +16 -21
- package/dist/client/theme-default/components/VPTeamMembers.d.vue.ts +10 -0
- package/dist/client/theme-default/components/VPTeamMembers.vue +59 -32
- package/dist/client/theme-default/components/VPTeamMembersItem.d.vue.ts +10 -0
- package/dist/client/theme-default/components/VPTeamMembersItem.vue +62 -58
- package/dist/client/theme-default/components/VPTeamPage.d.vue.ts +13 -0
- package/dist/client/theme-default/components/VPTeamPage.vue +14 -14
- package/dist/client/theme-default/components/VPTeamPageSection.d.vue.ts +17 -0
- package/dist/client/theme-default/components/VPTeamPageSection.vue +20 -19
- package/dist/client/theme-default/components/VPTeamPageTitle.d.vue.ts +15 -0
- package/dist/client/theme-default/components/VPTeamPageTitle.vue +22 -22
- package/dist/client/theme-default/composables/data.d.ts +5 -0
- package/dist/client/theme-default/composables/data.js +5 -2
- package/dist/client/theme-default/composables/edit-link.d.ts +6 -0
- package/dist/client/theme-default/composables/edit-link.js +17 -15
- package/dist/client/theme-default/composables/flyout.d.ts +10 -0
- package/dist/client/theme-default/composables/flyout.js +33 -32
- package/dist/client/theme-default/composables/langs.d.ts +44 -0
- package/dist/client/theme-default/composables/langs.js +48 -24
- package/dist/client/theme-default/composables/layout.d.ts +13 -0
- package/dist/client/theme-default/composables/layout.js +68 -0
- package/dist/client/theme-default/composables/nav-overflow.d.ts +54 -0
- package/dist/client/theme-default/composables/nav-overflow.js +179 -0
- package/dist/client/theme-default/composables/nav.d.ts +25 -0
- package/dist/client/theme-default/composables/nav.js +58 -29
- package/dist/client/theme-default/composables/outline.d.ts +8 -0
- package/dist/client/theme-default/composables/outline.js +144 -166
- package/dist/client/theme-default/composables/prev-next.d.ts +16 -0
- package/dist/client/theme-default/composables/prev-next.js +34 -56
- package/dist/client/theme-default/composables/scroll-lock.d.ts +4 -0
- package/dist/client/theme-default/composables/scroll-lock.js +95 -0
- package/dist/client/theme-default/composables/sidebar.d.ts +25 -0
- package/dist/client/theme-default/composables/sidebar.js +96 -133
- package/dist/client/theme-default/composables/sponsor-grid.d.ts +10 -0
- package/dist/client/theme-default/composables/sponsor-grid.js +69 -76
- package/dist/client/theme-default/fonts/inter-italic-cyrillic-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-cyrillic.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-greek-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-greek.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-latin-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-latin.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-symbols.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-vietnamese.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-cyrillic-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-cyrillic.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-greek-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-greek.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-latin-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-latin.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-symbols.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-vietnamese.woff2 +0 -0
- package/dist/client/theme-default/index.d.ts +3 -0
- package/dist/client/theme-default/index.js +4 -3
- package/dist/client/theme-default/styles/base.css +279 -211
- package/dist/client/theme-default/styles/components/custom-block.css +12 -7
- package/dist/client/theme-default/styles/components/vp-code-group.css +13 -16
- package/dist/client/theme-default/styles/components/vp-code.css +10 -2
- package/dist/client/theme-default/styles/components/vp-doc.css +188 -142
- package/dist/client/theme-default/styles/components/vp-sponsor.css +48 -37
- package/dist/client/theme-default/styles/docsearch.css +138 -0
- package/dist/client/theme-default/styles/fonts.css +216 -55
- package/dist/client/theme-default/styles/icons.css +42 -22
- package/dist/client/theme-default/styles/vars.css +111 -46
- package/dist/client/theme-default/support/docsearch.d.ts +57 -0
- package/dist/client/theme-default/support/docsearch.js +145 -0
- package/dist/client/theme-default/support/local-search.d.ts +9 -0
- package/dist/client/theme-default/support/local-search.js +31 -0
- package/dist/client/theme-default/support/lru.d.ts +11 -0
- package/dist/client/theme-default/support/lru.js +30 -33
- package/dist/client/theme-default/support/reactivity.d.ts +4 -0
- package/dist/client/theme-default/support/reactivity.js +10 -0
- package/dist/client/theme-default/support/sidebar.d.ts +27 -0
- package/dist/client/theme-default/support/sidebar.js +69 -80
- package/dist/client/theme-default/support/translation.d.ts +6 -0
- package/dist/client/theme-default/support/translation.js +33 -47
- package/dist/client/theme-default/support/utils.d.ts +7 -0
- package/dist/client/theme-default/support/utils.js +39 -30
- package/dist/client/theme-default/without-fonts.d.ts +25 -0
- package/dist/client/theme-default/without-fonts.js +37 -36
- package/dist/node/chunk-BjrVv9r8.js +28627 -0
- package/dist/node/cli.d.ts +1 -0
- package/dist/node/cli.js +160 -423
- package/dist/node/index.d.ts +1761 -2476
- package/dist/node/index.js +1 -121
- package/dist/web-types.json +75 -0
- package/package.json +89 -98
- package/template/.vitepress/config.js +3 -1
- package/template/.vitepress/theme/style.css +3 -11
- package/theme.d.ts +30 -23
- package/types/default-theme.d.ts +109 -113
- package/types/docsearch.d.ts +61 -142
- package/types/shared.d.ts +469 -50
- package/dist/client/theme-default/components/VPNavBarAppearance.vue +0 -32
- package/dist/client/theme-default/components/VPNavBarMenu.vue +0 -40
- package/dist/client/theme-default/components/VPNavBarMenuGroup.vue +0 -42
- package/dist/client/theme-default/components/VPNavBarMenuLink.vue +0 -53
- package/dist/client/theme-default/components/VPNavBarSocialLinks.vue +0 -27
- package/dist/client/theme-default/components/VPNavBarTranslations.vue +0 -47
- package/dist/client/theme-default/components/VPNavScreenAppearance.vue +0 -40
- package/dist/client/theme-default/components/VPNavScreenMenu.vue +0 -26
- package/dist/client/theme-default/components/VPNavScreenMenuGroup.vue +0 -112
- package/dist/client/theme-default/components/VPNavScreenMenuGroupLink.vue +0 -40
- package/dist/client/theme-default/components/VPNavScreenMenuGroupSection.vue +0 -34
- package/dist/client/theme-default/components/VPNavScreenMenuLink.vue +0 -43
- package/dist/client/theme-default/components/VPNavScreenSocialLinks.vue +0 -14
- package/dist/client/theme-default/components/VPNavScreenTranslations.vue +0 -73
- package/dist/client/theme-default/components/icons/VPIconAlignJustify.vue +0 -8
- package/dist/client/theme-default/components/icons/VPIconAlignLeft.vue +0 -8
- package/dist/client/theme-default/components/icons/VPIconAlignRight.vue +0 -8
- package/dist/client/theme-default/components/icons/VPIconArrowLeft.vue +0 -7
- package/dist/client/theme-default/components/icons/VPIconArrowRight.vue +0 -7
- package/dist/client/theme-default/components/icons/VPIconChevronDown.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconChevronLeft.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconChevronRight.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconChevronUp.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconEdit.vue +0 -6
- package/dist/client/theme-default/components/icons/VPIconHeart.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconLanguages.vue +0 -9
- package/dist/client/theme-default/components/icons/VPIconMinus.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconMinusSquare.vue +0 -6
- package/dist/client/theme-default/components/icons/VPIconMoon.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconMoreHorizontal.vue +0 -7
- package/dist/client/theme-default/components/icons/VPIconPlus.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconPlusSquare.vue +0 -6
- package/dist/client/theme-default/components/icons/VPIconSun.vue +0 -13
- package/dist/client/theme-default/composables/aside.js +0 -17
- package/dist/client/theme-default/composables/local-nav.js +0 -18
- package/dist/node/chunk-C-d2RJOW.js +0 -470
- package/dist/node/chunk-CxQfvv8o.js +0 -49065
- package/dist/node/worker_shikiResolveLang.js +0 -13
|
@@ -1,252 +1,211 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const fakeHost = 'http://a.com';
|
|
1
|
+
import { inBrowser, notFoundPageData, treatAsHtml } from "../shared.js";
|
|
2
|
+
import { siteDataRef } from "./data.js";
|
|
3
|
+
import { runtimeBase, withBase } from "./utils.js";
|
|
4
|
+
import { inject, markRaw, nextTick, reactive, readonly } from "vue";
|
|
5
|
+
//#region src/client/app/router.ts
|
|
6
|
+
const RouterSymbol = Symbol();
|
|
7
|
+
const fakeHost = "http://a.com";
|
|
9
8
|
const getDefaultRoute = () => ({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
path: "/",
|
|
10
|
+
hash: "",
|
|
11
|
+
query: "",
|
|
12
|
+
component: null,
|
|
13
|
+
data: notFoundPageData
|
|
15
14
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const link = e.target.closest('a');
|
|
122
|
-
if (!link ||
|
|
123
|
-
link.closest('.vp-raw') ||
|
|
124
|
-
link.hasAttribute('download') ||
|
|
125
|
-
link.hasAttribute('target')) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const linkHref = link.getAttribute('href') ??
|
|
129
|
-
(link instanceof SVGAElement ? link.getAttribute('xlink:href') : null);
|
|
130
|
-
if (linkHref == null)
|
|
131
|
-
return;
|
|
132
|
-
const { href, origin, pathname } = new URL(linkHref, link.baseURI);
|
|
133
|
-
const currentLoc = new URL(location.href); // copy to keep old data
|
|
134
|
-
// only intercept inbound html links
|
|
135
|
-
if (origin === currentLoc.origin && treatAsHtml(pathname)) {
|
|
136
|
-
e.preventDefault();
|
|
137
|
-
router.go(href, {
|
|
138
|
-
// use smooth scroll when clicking on header anchor links
|
|
139
|
-
smoothScroll: link.classList.contains('header-anchor')
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}, { capture: true });
|
|
143
|
-
window.addEventListener('popstate', async (e) => {
|
|
144
|
-
if (e.state === null)
|
|
145
|
-
return;
|
|
146
|
-
const href = normalizeHref(location.href);
|
|
147
|
-
await loadPage(href, (e.state && e.state.scrollPosition) || 0);
|
|
148
|
-
syncRouteQueryAndHash();
|
|
149
|
-
await router.onAfterRouteChange?.(href);
|
|
150
|
-
});
|
|
151
|
-
window.addEventListener('hashchange', (e) => {
|
|
152
|
-
e.preventDefault();
|
|
153
|
-
syncRouteQueryAndHash();
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
handleHMR(route);
|
|
157
|
-
return router;
|
|
15
|
+
function createRouter(loadPageModule, fallbackComponent) {
|
|
16
|
+
const route = reactive(getDefaultRoute());
|
|
17
|
+
const router = {
|
|
18
|
+
route,
|
|
19
|
+
async go(href, options) {
|
|
20
|
+
const { hash } = new URL(href, fakeHost);
|
|
21
|
+
const hasTextFragment = inBrowser && document.fragmentDirective && hash.includes(":~:");
|
|
22
|
+
href = normalizeHref(href);
|
|
23
|
+
if (await router.onBeforeRouteChange?.(href) === false) return;
|
|
24
|
+
if (!inBrowser || await changeRoute(href, {
|
|
25
|
+
...options,
|
|
26
|
+
hasTextFragment
|
|
27
|
+
})) await loadPage(href, { initialLoad: !!options?.initialLoad });
|
|
28
|
+
if (hasTextFragment) location.hash = hash;
|
|
29
|
+
syncRouteQueryAndHash();
|
|
30
|
+
await router.onAfterRouteChange?.(href);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
let latestPendingPath = null;
|
|
34
|
+
async function loadPage(href, { scrollPosition = 0, isRetry = false, initialLoad = false } = {}) {
|
|
35
|
+
if (await router.onBeforePageLoad?.(href) === false) return;
|
|
36
|
+
const targetLoc = new URL(href, fakeHost);
|
|
37
|
+
const pendingPath = latestPendingPath = targetLoc.pathname;
|
|
38
|
+
try {
|
|
39
|
+
let page = await loadPageModule(pendingPath);
|
|
40
|
+
if (!page) throw new Error(`Page not found: ${pendingPath}`);
|
|
41
|
+
if (latestPendingPath === pendingPath) {
|
|
42
|
+
latestPendingPath = null;
|
|
43
|
+
const { default: comp, __pageData } = page;
|
|
44
|
+
if (!comp) throw new Error(`Invalid route component: ${comp}`);
|
|
45
|
+
await router.onAfterPageLoad?.(href);
|
|
46
|
+
route.path = inBrowser ? pendingPath : withBase(pendingPath);
|
|
47
|
+
route.component = markRaw(comp);
|
|
48
|
+
route.data = import.meta.env.PROD ? markRaw(__pageData) : readonly(__pageData);
|
|
49
|
+
syncRouteQueryAndHash(targetLoc);
|
|
50
|
+
if (inBrowser) nextTick(() => {
|
|
51
|
+
let actualPathname = runtimeBase() + __pageData.relativePath.replace(/(?:(^|\/)index)?\.md$/, "$1");
|
|
52
|
+
if (!siteDataRef.value.cleanUrls && !actualPathname.endsWith("/")) actualPathname += ".html";
|
|
53
|
+
if (actualPathname !== targetLoc.pathname) {
|
|
54
|
+
targetLoc.pathname = actualPathname;
|
|
55
|
+
href = actualPathname + targetLoc.search + targetLoc.hash;
|
|
56
|
+
history.replaceState({}, "", href);
|
|
57
|
+
}
|
|
58
|
+
if (!initialLoad) scrollTo(targetLoc.hash, scrollPosition);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
} catch (err) {
|
|
62
|
+
if (!/fetch|Page not found/.test(err.message) && !/^\/404(\.html|\/)?$/.test(href)) console.error(err);
|
|
63
|
+
if (!isRetry) try {
|
|
64
|
+
const res = await fetch(runtimeBase() + "hashmap.json");
|
|
65
|
+
window.__VP_HASH_MAP__ = await res.json();
|
|
66
|
+
await loadPage(href, {
|
|
67
|
+
scrollPosition,
|
|
68
|
+
isRetry: true,
|
|
69
|
+
initialLoad
|
|
70
|
+
});
|
|
71
|
+
return;
|
|
72
|
+
} catch (e) {}
|
|
73
|
+
if (latestPendingPath === pendingPath) {
|
|
74
|
+
latestPendingPath = null;
|
|
75
|
+
route.path = inBrowser ? pendingPath : withBase(pendingPath);
|
|
76
|
+
route.component = fallbackComponent ? markRaw(fallbackComponent) : null;
|
|
77
|
+
const relativePath = inBrowser ? route.path.replace(/(^|\/)$/, "$1index").replace(/(\.html)?$/, ".md").slice(runtimeBase().length) : "404.md";
|
|
78
|
+
route.data = {
|
|
79
|
+
...notFoundPageData,
|
|
80
|
+
relativePath
|
|
81
|
+
};
|
|
82
|
+
syncRouteQueryAndHash(targetLoc);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function syncRouteQueryAndHash(loc = inBrowser ? location : {
|
|
87
|
+
search: "",
|
|
88
|
+
hash: ""
|
|
89
|
+
}) {
|
|
90
|
+
route.query = loc.search;
|
|
91
|
+
route.hash = decodeURIComponent(loc.hash);
|
|
92
|
+
}
|
|
93
|
+
if (inBrowser) {
|
|
94
|
+
if (history.state === null) history.replaceState({}, "");
|
|
95
|
+
window.addEventListener("click", (e) => {
|
|
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
|
+
const link = e.target.closest("a");
|
|
98
|
+
const url = link && getRoutableLinkUrl(link);
|
|
99
|
+
if (url) {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
router.go(url.href);
|
|
102
|
+
}
|
|
103
|
+
}, { capture: true });
|
|
104
|
+
window.addEventListener("popstate", async (e) => {
|
|
105
|
+
if (e.state === null) return;
|
|
106
|
+
const href = normalizeHref(location.href);
|
|
107
|
+
await loadPage(href, { scrollPosition: e.state.scrollPosition || 0 });
|
|
108
|
+
syncRouteQueryAndHash();
|
|
109
|
+
await router.onAfterRouteChange?.(href);
|
|
110
|
+
});
|
|
111
|
+
window.addEventListener("hashchange", (e) => {
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
syncRouteQueryAndHash();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
handleHMR(route);
|
|
117
|
+
return router;
|
|
158
118
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return router;
|
|
119
|
+
function useRouter() {
|
|
120
|
+
const router = inject(RouterSymbol);
|
|
121
|
+
if (!router) throw new Error("useRouter() is called without provider.");
|
|
122
|
+
return router;
|
|
164
123
|
}
|
|
165
|
-
|
|
166
|
-
|
|
124
|
+
function useRoute() {
|
|
125
|
+
return useRouter().route;
|
|
167
126
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
127
|
+
function scrollTo(hash, scrollPosition = 0) {
|
|
128
|
+
if (!hash || scrollPosition) {
|
|
129
|
+
window.scrollTo(0, scrollPosition);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
let target = null;
|
|
133
|
+
try {
|
|
134
|
+
target = document.getElementById(decodeURIComponent(hash).slice(1));
|
|
135
|
+
} catch (e) {
|
|
136
|
+
console.warn(e);
|
|
137
|
+
}
|
|
138
|
+
if (!target) return;
|
|
139
|
+
const scrollToTarget = () => {
|
|
140
|
+
target.scrollIntoView({ block: "start" });
|
|
141
|
+
target.focus({ preventScroll: true });
|
|
142
|
+
if (document.activeElement === target) return;
|
|
143
|
+
if (target.hasAttribute("tabindex")) return;
|
|
144
|
+
const restoreTabindex = () => {
|
|
145
|
+
target.removeAttribute("tabindex");
|
|
146
|
+
target.removeEventListener("blur", restoreTabindex);
|
|
147
|
+
};
|
|
148
|
+
target.setAttribute("tabindex", "-1");
|
|
149
|
+
target.addEventListener("blur", restoreTabindex);
|
|
150
|
+
target.focus({ preventScroll: true });
|
|
151
|
+
if (document.activeElement !== target) restoreTabindex();
|
|
152
|
+
};
|
|
153
|
+
requestAnimationFrame(scrollToTarget);
|
|
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;
|
|
195
166
|
}
|
|
196
167
|
function handleHMR(route) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
import.meta.hot.on('vitepress:pageData', (payload) => {
|
|
201
|
-
if (shouldHotReload(payload))
|
|
202
|
-
route.data = payload.pageData;
|
|
203
|
-
});
|
|
204
|
-
}
|
|
168
|
+
if (import.meta.hot) import.meta.hot.on("vitepress:pageData", (payload) => {
|
|
169
|
+
if (shouldHotReload(payload)) route.data = payload.pageData;
|
|
170
|
+
});
|
|
205
171
|
}
|
|
206
172
|
function shouldHotReload(payload) {
|
|
207
|
-
|
|
208
|
-
const locationPath = location.pathname
|
|
209
|
-
.replace(/(?:(^|\/)index)?\.html$/, '')
|
|
210
|
-
.slice(siteDataRef.value.base.length - 1);
|
|
211
|
-
return payloadPath === locationPath;
|
|
173
|
+
return payload.path.replace(/(?:(^|\/)index)?\.md$/, "$1") === location.pathname.replace(/(?:(^|\/)index)?\.html$/, "").slice(runtimeBase().length - 1);
|
|
212
174
|
}
|
|
213
175
|
function normalizeHref(href) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
else if (!url.pathname.endsWith('/') && !url.pathname.endsWith('.html')) {
|
|
221
|
-
url.pathname += '.html';
|
|
222
|
-
}
|
|
223
|
-
return url.pathname + url.search + url.hash;
|
|
176
|
+
const url = new URL(href, fakeHost);
|
|
177
|
+
url.pathname = url.pathname.replace(/(^|\/)index(\.html)?$/, "$1");
|
|
178
|
+
if (siteDataRef.value.cleanUrls) url.pathname = url.pathname.replace(/\.html$/, "");
|
|
179
|
+
else if (!url.pathname.endsWith("/") && !url.pathname.endsWith(".html")) url.pathname += ".html";
|
|
180
|
+
return url.pathname + url.search + url.hash.split(":~:")[0];
|
|
224
181
|
}
|
|
225
|
-
async function changeRoute(href, {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
182
|
+
async function changeRoute(href, { initialLoad = false, replace = false, hasTextFragment = false } = {}) {
|
|
183
|
+
const loc = normalizeHref(location.href);
|
|
184
|
+
const nextUrl = new URL(href, location.origin);
|
|
185
|
+
const currentUrl = new URL(loc, location.origin);
|
|
186
|
+
if (href === loc) {
|
|
187
|
+
if (!initialLoad) {
|
|
188
|
+
if (!hasTextFragment) scrollTo(nextUrl.hash);
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
} else {
|
|
192
|
+
if (replace) history.replaceState({}, "", href);
|
|
193
|
+
else {
|
|
194
|
+
history.replaceState({ scrollPosition: window.scrollY }, "");
|
|
195
|
+
history.pushState({}, "", href);
|
|
196
|
+
}
|
|
197
|
+
if (nextUrl.pathname === currentUrl.pathname) {
|
|
198
|
+
if (nextUrl.hash !== currentUrl.hash) {
|
|
199
|
+
window.dispatchEvent(new HashChangeEvent("hashchange", {
|
|
200
|
+
oldURL: currentUrl.href,
|
|
201
|
+
newURL: nextUrl.href
|
|
202
|
+
}));
|
|
203
|
+
if (!hasTextFragment) scrollTo(nextUrl.hash);
|
|
204
|
+
}
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return true;
|
|
252
209
|
}
|
|
210
|
+
//#endregion
|
|
211
|
+
export { RouterSymbol, createRouter, getRoutableLinkUrl, scrollTo, useRoute, useRouter };
|
package/dist/client/app/ssr.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import { renderToString } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { createApp } from "./index.js";
|
|
2
|
+
import { renderToString } from "vue/server-renderer";
|
|
3
|
+
//#region src/client/app/ssr.ts
|
|
4
|
+
async function render(path) {
|
|
5
|
+
const { app, router } = await createApp();
|
|
6
|
+
await router.go(path);
|
|
7
|
+
const ctx = {
|
|
8
|
+
content: "",
|
|
9
|
+
vpIcons: /* @__PURE__ */ new Set()
|
|
10
|
+
};
|
|
11
|
+
ctx.content = await renderToString(app, ctx);
|
|
12
|
+
return ctx;
|
|
10
13
|
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { render };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Awaitable, SiteData } from "../shared.js";
|
|
2
|
+
import { Router } from "./router.js";
|
|
3
|
+
import { App, Component, Ref } from "vue";
|
|
4
|
+
//#region src/client/app/theme.d.ts
|
|
5
|
+
export interface EnhanceAppContext {
|
|
6
|
+
app: App;
|
|
7
|
+
router: Router;
|
|
8
|
+
siteData: Ref<SiteData>;
|
|
9
|
+
}
|
|
10
|
+
export interface Theme {
|
|
11
|
+
Layout?: Component;
|
|
12
|
+
enhanceApp?: (ctx: EnhanceAppContext) => Awaitable<void>;
|
|
13
|
+
extends?: Theme;
|
|
14
|
+
/**
|
|
15
|
+
* Runs inside the root component's `setup()` (during SSR too). With
|
|
16
|
+
* `extends`, setups run base-first, like `enhanceApp`.
|
|
17
|
+
*/
|
|
18
|
+
setup?: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Render not found page by checking `useData().page.value.isNotFound` in Layout instead.
|
|
21
|
+
*/
|
|
22
|
+
NotFound?: Component;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
package/dist/client/app/theme.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Awaitable, escapeHtml, inBrowser, joinPath } from "../shared.js";
|
|
2
|
+
import { AsyncComponentLoader, SetupContext } from "vue";
|
|
3
|
+
//#region src/client/app/utils.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Runtime base path used by the app.
|
|
6
|
+
*
|
|
7
|
+
* Usually this is the configured site base.
|
|
8
|
+
*
|
|
9
|
+
* For a relative base (`'./'`), the mount point is unknown at build time, so:
|
|
10
|
+
* - SSR: uses `RELATIVE_BASE_SENTINEL` (for per-page URL relativization)
|
|
11
|
+
* - dev browser: uses `'/'` (dev server always mounts at root)
|
|
12
|
+
* - prod browser: resolves from the page's `__VP_SITE_ROOT__`
|
|
13
|
+
*/
|
|
14
|
+
export declare function runtimeBase(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Prepend base to internal (non-relative) urls
|
|
17
|
+
*/
|
|
18
|
+
export declare function withBase(path: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Converts a url path to the corresponding js chunk filename.
|
|
21
|
+
*/
|
|
22
|
+
export declare function pathToFile(path: string): string | null;
|
|
23
|
+
export declare let contentUpdatedCallbacks: (() => any)[];
|
|
24
|
+
/**
|
|
25
|
+
* Register callback that is called every time the markdown content is updated
|
|
26
|
+
* in the DOM.
|
|
27
|
+
*/
|
|
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
|
+
[key: string]: any;
|
|
32
|
+
}> | null;
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { escapeHtml as _escapeHtml, inBrowser, joinPath };
|