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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/node/cli.js
CHANGED
|
@@ -1,477 +1,214 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createLogger } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import 'node:module';
|
|
7
|
-
import 'node:process';
|
|
8
|
-
import 'node:fs/promises';
|
|
9
|
-
import 'node:fs';
|
|
10
|
-
import 'fs';
|
|
11
|
-
import 'node:events';
|
|
12
|
-
import 'node:stream';
|
|
13
|
-
import 'node:string_decoder';
|
|
14
|
-
import 'path';
|
|
15
|
-
import 'util';
|
|
16
|
-
import 'os';
|
|
17
|
-
import 'stream';
|
|
18
|
-
import 'readline';
|
|
19
|
-
import 'url';
|
|
20
|
-
import 'child_process';
|
|
21
|
-
import 'string_decoder';
|
|
22
|
-
import 'zlib';
|
|
23
|
-
import '@vue/shared';
|
|
24
|
-
import 'node:util';
|
|
25
|
-
import 'node:readline';
|
|
26
|
-
import 'node:tty';
|
|
27
|
-
import 'node:zlib';
|
|
28
|
-
import 'node:http';
|
|
29
|
-
import 'node:timers';
|
|
30
|
-
import 'node:querystring';
|
|
31
|
-
import 'tty';
|
|
32
|
-
import 'constants';
|
|
33
|
-
import 'assert';
|
|
34
|
-
import '@shikijs/transformers';
|
|
35
|
-
import 'shiki';
|
|
36
|
-
import './chunk-C-d2RJOW.js';
|
|
37
|
-
import 'node:worker_threads';
|
|
38
|
-
import 'minisearch';
|
|
39
|
-
|
|
40
|
-
var minimist$1;
|
|
41
|
-
var hasRequiredMinimist;
|
|
42
|
-
|
|
43
|
-
function requireMinimist () {
|
|
44
|
-
if (hasRequiredMinimist) return minimist$1;
|
|
45
|
-
hasRequiredMinimist = 1;
|
|
46
|
-
|
|
1
|
+
import { M as __commonJSMin, N as __toESM, T as resolveConfig, d as logVersion, f as clearCache, g as disposeMdItInstance, j as require_picocolors, l as build$1, n as createServer$1, o as init, r as serve } from "./chunk-BjrVv9r8.js";
|
|
2
|
+
import { createLogger } from "vite";
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region src/node/shortcuts.ts
|
|
5
|
+
var import_minimist = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
47
6
|
function hasKey(obj, keys) {
|
|
48
7
|
var o = obj;
|
|
49
|
-
keys.slice(0, -1).forEach(function
|
|
8
|
+
return keys.slice(0, -1).forEach(function(key) {
|
|
50
9
|
o = o[key] || {};
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
var key = keys[keys.length - 1];
|
|
54
|
-
return key in o;
|
|
10
|
+
}), keys[keys.length - 1] in o;
|
|
55
11
|
}
|
|
56
|
-
|
|
57
12
|
function isNumber(x) {
|
|
58
|
-
|
|
59
|
-
if ((/^0x[0-9a-f]+$/i).test(x)) { return true; }
|
|
60
|
-
return (/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/).test(x);
|
|
13
|
+
return typeof x == "number" || /^0x[0-9a-f]+$/i.test(x) ? !0 : /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
|
61
14
|
}
|
|
62
|
-
|
|
63
15
|
function isConstructorOrProto(obj, key) {
|
|
64
|
-
return
|
|
16
|
+
return key === "constructor" && typeof obj[key] == "function" || key === "__proto__";
|
|
65
17
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (!opts) { opts = {}; }
|
|
69
|
-
|
|
18
|
+
module.exports = function(args, opts) {
|
|
19
|
+
opts ||= {};
|
|
70
20
|
var flags = {
|
|
71
21
|
bools: {},
|
|
72
22
|
strings: {},
|
|
73
|
-
unknownFn: null
|
|
23
|
+
unknownFn: null
|
|
74
24
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (typeof opts.boolean === 'boolean' && opts.boolean) {
|
|
81
|
-
flags.allBools = true;
|
|
82
|
-
} else {
|
|
83
|
-
[].concat(opts.boolean).filter(Boolean).forEach(function (key) {
|
|
84
|
-
flags.bools[key] = true;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
25
|
+
typeof opts.unknown == "function" && (flags.unknownFn = opts.unknown), typeof opts.boolean == "boolean" && opts.boolean ? flags.allBools = !0 : [].concat(opts.boolean).filter(Boolean).forEach(function(key) {
|
|
26
|
+
flags.bools[key] = !0;
|
|
27
|
+
});
|
|
88
28
|
var aliases = {};
|
|
89
|
-
|
|
90
29
|
function aliasIsBoolean(key) {
|
|
91
|
-
return aliases[key].some(function
|
|
30
|
+
return aliases[key].some(function(x) {
|
|
92
31
|
return flags.bools[x];
|
|
93
32
|
});
|
|
94
33
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
aliases[key].forEach(function (x) {
|
|
99
|
-
aliases[x] = [key].concat(aliases[key].filter(function (y) {
|
|
34
|
+
Object.keys(opts.alias || {}).forEach(function(key) {
|
|
35
|
+
aliases[key] = [].concat(opts.alias[key]), aliases[key].forEach(function(x) {
|
|
36
|
+
aliases[x] = [key].concat(aliases[key].filter(function(y) {
|
|
100
37
|
return x !== y;
|
|
101
38
|
}));
|
|
102
39
|
});
|
|
40
|
+
}), [].concat(opts.string).filter(Boolean).forEach(function(key) {
|
|
41
|
+
flags.strings[key] = !0, aliases[key] && [].concat(aliases[key]).forEach(function(k) {
|
|
42
|
+
flags.strings[k] = !0;
|
|
43
|
+
});
|
|
103
44
|
});
|
|
104
|
-
|
|
105
|
-
[].concat(opts.string).filter(Boolean).forEach(function (key) {
|
|
106
|
-
flags.strings[key] = true;
|
|
107
|
-
if (aliases[key]) {
|
|
108
|
-
[].concat(aliases[key]).forEach(function (k) {
|
|
109
|
-
flags.strings[k] = true;
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
var defaults = opts.default || {};
|
|
115
|
-
|
|
116
|
-
var argv = { _: [] };
|
|
117
|
-
|
|
45
|
+
var defaults = opts.default || {}, argv = { _: [] };
|
|
118
46
|
function argDefined(key, arg) {
|
|
119
|
-
return
|
|
120
|
-
|| flags.strings[key]
|
|
121
|
-
|| flags.bools[key]
|
|
122
|
-
|| aliases[key];
|
|
47
|
+
return flags.allBools && /^--[^=]+$/.test(arg) || flags.strings[key] || flags.bools[key] || aliases[key];
|
|
123
48
|
}
|
|
124
|
-
|
|
125
49
|
function setKey(obj, keys, value) {
|
|
126
|
-
var o = obj;
|
|
127
|
-
for (var i = 0; i < keys.length - 1; i++) {
|
|
50
|
+
for (var o = obj, i = 0; i < keys.length - 1; i++) {
|
|
128
51
|
var key = keys[i];
|
|
129
|
-
if (isConstructorOrProto(o, key))
|
|
130
|
-
|
|
131
|
-
if (
|
|
132
|
-
o[key] === Object.prototype
|
|
133
|
-
|| o[key] === Number.prototype
|
|
134
|
-
|| o[key] === String.prototype
|
|
135
|
-
) {
|
|
136
|
-
o[key] = {};
|
|
137
|
-
}
|
|
138
|
-
if (o[key] === Array.prototype) { o[key] = []; }
|
|
139
|
-
o = o[key];
|
|
52
|
+
if (isConstructorOrProto(o, key)) return;
|
|
53
|
+
o[key] === void 0 && (o[key] = {}), (o[key] === Object.prototype || o[key] === Number.prototype || o[key] === String.prototype) && (o[key] = {}), o[key] === Array.prototype && (o[key] = []), o = o[key];
|
|
140
54
|
}
|
|
141
|
-
|
|
142
55
|
var lastKey = keys[keys.length - 1];
|
|
143
|
-
|
|
144
|
-
if (
|
|
145
|
-
o === Object.prototype
|
|
146
|
-
|| o === Number.prototype
|
|
147
|
-
|| o === String.prototype
|
|
148
|
-
) {
|
|
149
|
-
o = {};
|
|
150
|
-
}
|
|
151
|
-
if (o === Array.prototype) { o = []; }
|
|
152
|
-
if (o[lastKey] === undefined || flags.bools[lastKey] || typeof o[lastKey] === 'boolean') {
|
|
153
|
-
o[lastKey] = value;
|
|
154
|
-
} else if (Array.isArray(o[lastKey])) {
|
|
155
|
-
o[lastKey].push(value);
|
|
156
|
-
} else {
|
|
157
|
-
o[lastKey] = [o[lastKey], value];
|
|
158
|
-
}
|
|
56
|
+
isConstructorOrProto(o, lastKey) || ((o === Object.prototype || o === Number.prototype || o === String.prototype) && (o = {}), o === Array.prototype && (o = []), o[lastKey] === void 0 || flags.bools[lastKey] || typeof o[lastKey] == "boolean" ? o[lastKey] = value : Array.isArray(o[lastKey]) ? o[lastKey].push(value) : o[lastKey] = [o[lastKey], value]);
|
|
159
57
|
}
|
|
160
|
-
|
|
161
58
|
function setArg(key, val, arg) {
|
|
162
|
-
if (arg && flags.unknownFn && !argDefined(key, arg)) {
|
|
163
|
-
|
|
59
|
+
if (!(arg && flags.unknownFn && !argDefined(key, arg) && flags.unknownFn(arg) === !1)) {
|
|
60
|
+
var value = !flags.strings[key] && isNumber(val) ? Number(val) : val;
|
|
61
|
+
setKey(argv, key.split("."), value), (aliases[key] || []).forEach(function(x) {
|
|
62
|
+
setKey(argv, x.split("."), value);
|
|
63
|
+
});
|
|
164
64
|
}
|
|
165
|
-
|
|
166
|
-
var value = !flags.strings[key] && isNumber(val)
|
|
167
|
-
? Number(val)
|
|
168
|
-
: val;
|
|
169
|
-
setKey(argv, key.split('.'), value);
|
|
170
|
-
|
|
171
|
-
(aliases[key] || []).forEach(function (x) {
|
|
172
|
-
setKey(argv, x.split('.'), value);
|
|
173
|
-
});
|
|
174
65
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
setArg(key, defaults[key] === undefined ? false : defaults[key]);
|
|
66
|
+
Object.keys(flags.bools).forEach(function(key) {
|
|
67
|
+
setArg(key, defaults[key] !== void 0 && defaults[key]);
|
|
178
68
|
});
|
|
179
|
-
|
|
180
69
|
var notFlags = [];
|
|
181
|
-
|
|
182
|
-
if (args.indexOf('--') !== -1) {
|
|
183
|
-
notFlags = args.slice(args.indexOf('--') + 1);
|
|
184
|
-
args = args.slice(0, args.indexOf('--'));
|
|
185
|
-
}
|
|
186
|
-
|
|
70
|
+
args.indexOf("--") !== -1 && (notFlags = args.slice(args.indexOf("--") + 1), args = args.slice(0, args.indexOf("--")));
|
|
187
71
|
for (var i = 0; i < args.length; i++) {
|
|
188
|
-
var arg = args[i];
|
|
189
|
-
|
|
190
|
-
var next;
|
|
191
|
-
|
|
192
|
-
if ((/^--.+=/).test(arg)) {
|
|
193
|
-
// Using [\s\S] instead of . because js doesn't support the
|
|
194
|
-
// 'dotall' regex modifier. See:
|
|
195
|
-
// http://stackoverflow.com/a/1068308/13216
|
|
72
|
+
var arg = args[i], key, next;
|
|
73
|
+
if (/^--.+=/.test(arg)) {
|
|
196
74
|
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
|
|
197
75
|
key = m[1];
|
|
198
76
|
var value = m[2];
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
key = arg.match(/^--(.+)/)[1];
|
|
208
|
-
next = args[i + 1];
|
|
209
|
-
if (
|
|
210
|
-
next !== undefined
|
|
211
|
-
&& !(/^(-|--)[^-]/).test(next)
|
|
212
|
-
&& !flags.bools[key]
|
|
213
|
-
&& !flags.allBools
|
|
214
|
-
&& (aliases[key] ? !aliasIsBoolean(key) : true)
|
|
215
|
-
) {
|
|
216
|
-
setArg(key, next, arg);
|
|
217
|
-
i += 1;
|
|
218
|
-
} else if ((/^(true|false)$/).test(next)) {
|
|
219
|
-
setArg(key, next === 'true', arg);
|
|
220
|
-
i += 1;
|
|
221
|
-
} else {
|
|
222
|
-
setArg(key, flags.strings[key] ? '' : true, arg);
|
|
223
|
-
}
|
|
224
|
-
} else if ((/^-[^-]+/).test(arg)) {
|
|
225
|
-
var letters = arg.slice(1, -1).split('');
|
|
226
|
-
|
|
227
|
-
var broken = false;
|
|
228
|
-
for (var j = 0; j < letters.length; j++) {
|
|
229
|
-
next = arg.slice(j + 2);
|
|
230
|
-
|
|
231
|
-
if (next === '-') {
|
|
232
|
-
setArg(letters[j], next, arg);
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if ((/[A-Za-z]/).test(letters[j]) && next[0] === '=') {
|
|
237
|
-
setArg(letters[j], next.slice(1), arg);
|
|
238
|
-
broken = true;
|
|
77
|
+
flags.bools[key] && (value = value !== "false"), setArg(key, value, arg);
|
|
78
|
+
} else if (/^--no-.+/.test(arg)) key = arg.match(/^--no-(.+)/)[1], setArg(key, !1, arg);
|
|
79
|
+
else if (/^--.+/.test(arg)) key = arg.match(/^--(.+)/)[1], next = args[i + 1], next !== void 0 && !/^(-|--)[^-]/.test(next) && !flags.bools[key] && !flags.allBools && (!aliases[key] || !aliasIsBoolean(key)) ? (setArg(key, next, arg), i += 1) : /^(true|false)$/.test(next) ? (setArg(key, next === "true", arg), i += 1) : setArg(key, !flags.strings[key] || "", arg);
|
|
80
|
+
else if (/^-[^-]+/.test(arg)) {
|
|
81
|
+
for (var letters = arg.slice(1, -1).split(""), broken = !1, j = 0; j < letters.length; j++) if (next = arg.slice(j + 2), next === "-") setArg(letters[j], next, arg);
|
|
82
|
+
else {
|
|
83
|
+
if (/[A-Za-z]/.test(letters[j]) && next[0] === "=") {
|
|
84
|
+
setArg(letters[j], next.slice(1), arg), broken = !0;
|
|
239
85
|
break;
|
|
240
86
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
(/[A-Za-z]/).test(letters[j])
|
|
244
|
-
&& (/-?\d+(\.\d*)?(e-?\d+)?$/).test(next)
|
|
245
|
-
) {
|
|
246
|
-
setArg(letters[j], next, arg);
|
|
247
|
-
broken = true;
|
|
87
|
+
if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
|
|
88
|
+
setArg(letters[j], next, arg), broken = !0;
|
|
248
89
|
break;
|
|
249
90
|
}
|
|
250
|
-
|
|
251
91
|
if (letters[j + 1] && letters[j + 1].match(/\W/)) {
|
|
252
|
-
setArg(letters[j], arg.slice(j + 2), arg);
|
|
253
|
-
broken = true;
|
|
92
|
+
setArg(letters[j], arg.slice(j + 2), arg), broken = !0;
|
|
254
93
|
break;
|
|
255
|
-
} else {
|
|
256
|
-
setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
|
|
257
94
|
}
|
|
95
|
+
setArg(letters[j], !flags.strings[letters[j]] || "", arg);
|
|
258
96
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
args[i + 1]
|
|
264
|
-
&& !(/^(-|--)[^-]/).test(args[i + 1])
|
|
265
|
-
&& !flags.bools[key]
|
|
266
|
-
&& (aliases[key] ? !aliasIsBoolean(key) : true)
|
|
267
|
-
) {
|
|
268
|
-
setArg(key, args[i + 1], arg);
|
|
269
|
-
i += 1;
|
|
270
|
-
} else if (args[i + 1] && (/^(true|false)$/).test(args[i + 1])) {
|
|
271
|
-
setArg(key, args[i + 1] === 'true', arg);
|
|
272
|
-
i += 1;
|
|
273
|
-
} else {
|
|
274
|
-
setArg(key, flags.strings[key] ? '' : true, arg);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
} else {
|
|
278
|
-
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
|
|
279
|
-
argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
|
|
280
|
-
}
|
|
281
|
-
if (opts.stopEarly) {
|
|
282
|
-
argv._.push.apply(argv._, args.slice(i + 1));
|
|
283
|
-
break;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
Object.keys(defaults).forEach(function (k) {
|
|
289
|
-
if (!hasKey(argv, k.split('.'))) {
|
|
290
|
-
setKey(argv, k.split('.'), defaults[k]);
|
|
291
|
-
|
|
292
|
-
(aliases[k] || []).forEach(function (x) {
|
|
293
|
-
setKey(argv, x.split('.'), defaults[k]);
|
|
294
|
-
});
|
|
97
|
+
key = arg.slice(-1)[0], !broken && key !== "-" && (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (!aliases[key] || !aliasIsBoolean(key)) ? (setArg(key, args[i + 1], arg), i += 1) : args[i + 1] && /^(true|false)$/.test(args[i + 1]) ? (setArg(key, args[i + 1] === "true", arg), i += 1) : setArg(key, !flags.strings[key] || "", arg));
|
|
98
|
+
} else if ((!flags.unknownFn || flags.unknownFn(arg) !== !1) && argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg)), opts.stopEarly) {
|
|
99
|
+
argv._.push.apply(argv._, args.slice(i + 1));
|
|
100
|
+
break;
|
|
295
101
|
}
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
if (opts['--']) {
|
|
299
|
-
argv['--'] = notFlags.slice();
|
|
300
|
-
} else {
|
|
301
|
-
notFlags.forEach(function (k) {
|
|
302
|
-
argv._.push(k);
|
|
303
|
-
});
|
|
304
102
|
}
|
|
305
|
-
|
|
306
|
-
|
|
103
|
+
return Object.keys(defaults).forEach(function(k) {
|
|
104
|
+
hasKey(argv, k.split(".")) || (setKey(argv, k.split("."), defaults[k]), (aliases[k] || []).forEach(function(x) {
|
|
105
|
+
setKey(argv, x.split("."), defaults[k]);
|
|
106
|
+
}));
|
|
107
|
+
}), opts["--"] ? argv["--"] = notFlags.slice() : notFlags.forEach(function(k) {
|
|
108
|
+
argv._.push(k);
|
|
109
|
+
}), argv;
|
|
307
110
|
};
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
var minimistExports = requireMinimist();
|
|
312
|
-
var minimist = /*@__PURE__*/getDefaultExportFromCjs(minimistExports);
|
|
313
|
-
|
|
314
|
-
function bindShortcuts(server, createDevServer) {
|
|
315
|
-
if (!server.httpServer || !process.stdin.isTTY || process.env.CI) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
server.config.logger.info(
|
|
319
|
-
c.dim(c.green(" \u279C")) + c.dim(" press ") + c.bold("h") + c.dim(" to show help")
|
|
320
|
-
);
|
|
321
|
-
let actionRunning = false;
|
|
322
|
-
const onInput = async (input) => {
|
|
323
|
-
if (input === "" || input === "") {
|
|
324
|
-
await server.close().finally(() => process.exit(1));
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
if (actionRunning) return;
|
|
328
|
-
if (input === "h") {
|
|
329
|
-
server.config.logger.info(
|
|
330
|
-
[
|
|
331
|
-
"",
|
|
332
|
-
c.bold(" Shortcuts"),
|
|
333
|
-
...SHORTCUTS.map(
|
|
334
|
-
(shortcut2) => c.dim(" press ") + c.bold(shortcut2.key) + c.dim(` to ${shortcut2.description}`)
|
|
335
|
-
)
|
|
336
|
-
].join("\n")
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
const shortcut = SHORTCUTS.find((shortcut2) => shortcut2.key === input);
|
|
340
|
-
if (!shortcut) return;
|
|
341
|
-
actionRunning = true;
|
|
342
|
-
await shortcut.action(server, createDevServer);
|
|
343
|
-
actionRunning = false;
|
|
344
|
-
};
|
|
345
|
-
process.stdin.setRawMode(true);
|
|
346
|
-
process.stdin.on("data", onInput).setEncoding("utf8").resume();
|
|
347
|
-
server.httpServer.on("close", () => {
|
|
348
|
-
process.stdin.off("data", onInput).pause();
|
|
349
|
-
process.stdin.setRawMode(false);
|
|
350
|
-
});
|
|
351
|
-
}
|
|
111
|
+
})))(), 1), import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
352
112
|
const SHORTCUTS = [
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
key: "q",
|
|
392
|
-
description: "quit",
|
|
393
|
-
async action(server) {
|
|
394
|
-
await server.close().finally(() => process.exit());
|
|
395
|
-
}
|
|
396
|
-
}
|
|
113
|
+
{
|
|
114
|
+
key: "r",
|
|
115
|
+
description: "restart the server",
|
|
116
|
+
async action(server, restartServer) {
|
|
117
|
+
server.config.logger.info(import_picocolors.default.green("restarting server...\n"), {
|
|
118
|
+
clear: !0,
|
|
119
|
+
timestamp: !0
|
|
120
|
+
}), await restartServer();
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
key: "u",
|
|
125
|
+
description: "show server url",
|
|
126
|
+
action(server) {
|
|
127
|
+
server.config.logger.info(""), server.printUrls();
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
key: "o",
|
|
132
|
+
description: "open in browser",
|
|
133
|
+
action(server) {
|
|
134
|
+
server.openBrowser();
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
key: "c",
|
|
139
|
+
description: "clear console",
|
|
140
|
+
action(server) {
|
|
141
|
+
server.config.logger.clearScreen("error");
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
key: "q",
|
|
146
|
+
description: "quit",
|
|
147
|
+
async action(server) {
|
|
148
|
+
await server.close().finally(() => process.exit());
|
|
149
|
+
}
|
|
150
|
+
}
|
|
397
151
|
];
|
|
398
|
-
|
|
399
|
-
if (process.env.
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
152
|
+
function bindShortcuts(server, restartServer) {
|
|
153
|
+
if (!server.httpServer || !process.stdin.isTTY || process.env.CI) return;
|
|
154
|
+
server.config.logger.info(import_picocolors.default.dim(import_picocolors.default.green(" ➜")) + import_picocolors.default.dim(" press ") + import_picocolors.default.bold("h") + import_picocolors.default.dim(" to show help"));
|
|
155
|
+
let actionRunning = !1, onInput = async (input) => {
|
|
156
|
+
if (input === "" || input === "") {
|
|
157
|
+
await server.close().finally(() => process.exit(1));
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (actionRunning) return;
|
|
161
|
+
input = input.trim().toLowerCase(), input === "h" && server.config.logger.info([
|
|
162
|
+
"",
|
|
163
|
+
import_picocolors.default.bold(" Shortcuts"),
|
|
164
|
+
...SHORTCUTS.map((shortcut) => import_picocolors.default.dim(" press ") + import_picocolors.default.bold(shortcut.key) + import_picocolors.default.dim(` to ${shortcut.description}`))
|
|
165
|
+
].join("\n"));
|
|
166
|
+
let shortcut = SHORTCUTS.find((shortcut) => shortcut.key === input);
|
|
167
|
+
shortcut && (actionRunning = !0, await shortcut.action(server, restartServer), actionRunning = !1);
|
|
168
|
+
};
|
|
169
|
+
process.stdin.setRawMode(!0), process.stdin.on("data", onInput).setEncoding("utf8").resume(), server.httpServer.on("close", () => {
|
|
170
|
+
process.stdin.off("data", onInput).pause(), process.stdin.setRawMode(!1);
|
|
171
|
+
});
|
|
414
172
|
}
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/node/cli.ts
|
|
175
|
+
const argv = (0, import_minimist.default)(process.argv.slice(2));
|
|
176
|
+
Object.keys(argv).forEach((key) => {
|
|
177
|
+
argv[key] === "true" ? argv[key] = !0 : argv[key] === "false" && (argv[key] = !1);
|
|
178
|
+
});
|
|
179
|
+
const command = argv._[0], root = argv._[+!!command];
|
|
180
|
+
root && (argv.root = root);
|
|
415
181
|
let restartPromise;
|
|
416
182
|
if (!command || command === "dev") {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
} else if (command === "init") {
|
|
447
|
-
createLogger().info("", { clear: true });
|
|
448
|
-
init(argv.root);
|
|
449
|
-
} else {
|
|
450
|
-
if (command === "build") {
|
|
451
|
-
build(root, {
|
|
452
|
-
...argv,
|
|
453
|
-
onAfterConfigResolve(siteConfig) {
|
|
454
|
-
logVersion(siteConfig.logger);
|
|
455
|
-
}
|
|
456
|
-
}).catch((err) => {
|
|
457
|
-
createLogger().error(
|
|
458
|
-
`${c.red(`build error:`)}
|
|
459
|
-
${err.message}
|
|
460
|
-
${err.stack}`
|
|
461
|
-
);
|
|
462
|
-
process.exit(1);
|
|
463
|
-
});
|
|
464
|
-
} else if (command === "serve" || command === "preview") {
|
|
465
|
-
serve(argv).catch((err) => {
|
|
466
|
-
createLogger().error(
|
|
467
|
-
`${c.red(`failed to start server. error:`)}
|
|
468
|
-
${err.message}
|
|
469
|
-
${err.stack}`
|
|
470
|
-
);
|
|
471
|
-
process.exit(1);
|
|
472
|
-
});
|
|
473
|
-
} else {
|
|
474
|
-
createLogger().error(c.red(`unknown command "${command}".`));
|
|
475
|
-
process.exit(1);
|
|
476
|
-
}
|
|
183
|
+
argv.force && (delete argv.force, argv.optimizeDeps = { force: !0 });
|
|
184
|
+
let config = await resolveConfig(root, argv).catch(logErrorAndExit.bind(null, "failed to resolve config. error:")), createDevServer = async (isRestart = !0) => {
|
|
185
|
+
let server = await createServer$1(root, argv, restartServer, config);
|
|
186
|
+
function restartServer() {
|
|
187
|
+
return restartPromise ||= (async () => {
|
|
188
|
+
try {
|
|
189
|
+
config = await resolveConfig(root, argv);
|
|
190
|
+
} catch (err) {
|
|
191
|
+
logError("failed to resolve config. error:", err);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
disposeMdItInstance(), clearCache(), await server.close(), await createDevServer();
|
|
195
|
+
})().finally(() => {
|
|
196
|
+
restartPromise = void 0;
|
|
197
|
+
}), restartPromise;
|
|
198
|
+
}
|
|
199
|
+
await server.listen(void 0, isRestart), logVersion(server.config.logger), server.printUrls(), bindShortcuts(server, restartServer);
|
|
200
|
+
};
|
|
201
|
+
createDevServer(!1).catch(logErrorAndExit.bind(null, "failed to start server. error:"));
|
|
202
|
+
} else command === "init" ? (createLogger().info("", { clear: !0 }), init(argv.root)) : command === "build" ? build$1(root, argv).catch(logErrorAndExit.bind(null, "build error:")) : command === "serve" || command === "preview" ? serve(argv).catch(logErrorAndExit.bind(null, "failed to start server. error:")) : logErrorAndExit(`unknown command "${command}".`);
|
|
203
|
+
function logErrorAndExit(message, err) {
|
|
204
|
+
logError(message, err), process.exit(1);
|
|
205
|
+
}
|
|
206
|
+
function logError(message, err) {
|
|
207
|
+
createLogger().error([
|
|
208
|
+
import_picocolors.default.red(message),
|
|
209
|
+
err && "message" in err && err.message,
|
|
210
|
+
err && "stack" in err && err.stack
|
|
211
|
+
].filter(Boolean).join("\n"));
|
|
477
212
|
}
|
|
213
|
+
//#endregion
|
|
214
|
+
export {};
|