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,5 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
3
|
-
<path d="M12,22.2c-0.3,0-0.5-0.1-0.7-0.3l-8.8-8.8c-2.5-2.5-2.5-6.7,0-9.2c2.5-2.5,6.7-2.5,9.2,0L12,4.3l0.4-0.4c0,0,0,0,0,0C13.6,2.7,15.2,2,16.9,2c0,0,0,0,0,0c1.7,0,3.4,0.7,4.6,1.9l0,0c1.2,1.2,1.9,2.9,1.9,4.6c0,1.7-0.7,3.4-1.9,4.6l-8.8,8.8C12.5,22.1,12.3,22.2,12,22.2zM7,4C5.9,4,4.7,4.4,3.9,5.3c-1.8,1.8-1.8,4.6,0,6.4l8.1,8.1l8.1-8.1c0.9-0.9,1.3-2,1.3-3.2c0-1.2-0.5-2.3-1.3-3.2l0,0C19.3,4.5,18.2,4,17,4c0,0,0,0,0,0c-1.2,0-2.3,0.5-3.2,1.3c0,0,0,0,0,0l-1.1,1.1c-0.4,0.4-1,0.4-1.4,0l-1.1-1.1C9.4,4.4,8.2,4,7,4z" />
|
|
4
|
-
</svg>
|
|
5
|
-
</template>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewBox="0 0 24 24">
|
|
3
|
-
<path d="M0 0h24v24H0z" fill="none"></path>
|
|
4
|
-
<path
|
|
5
|
-
d=" M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z "
|
|
6
|
-
class="css-c4d79v"
|
|
7
|
-
></path>
|
|
8
|
-
</svg>
|
|
9
|
-
</template>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24">
|
|
3
|
-
<path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2zM20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z" />
|
|
4
|
-
<path d="M16,11H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h8c0.6,0,1-0.4,1-1S16.6,11,16,11z" />
|
|
5
|
-
</svg>
|
|
6
|
-
</template>
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewBox="0 0 24 24">
|
|
3
|
-
<path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z" />
|
|
4
|
-
</svg>
|
|
5
|
-
</template>
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewBox="0 0 24 24">
|
|
3
|
-
<path d="M18.9,10.9h-6v-6c0-0.6-0.4-1-1-1s-1,0.4-1,1v6h-6c-0.6,0-1,0.4-1,1s0.4,1,1,1h6v6c0,0.6,0.4,1,1,1s1-0.4,1-1v-6h6c0.6,0,1-0.4,1-1S19.5,10.9,18.9,10.9z" />
|
|
4
|
-
</svg>
|
|
5
|
-
</template>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
3
|
-
<path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2z M20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z" />
|
|
4
|
-
<path d="M16,11h-3V8c0-0.6-0.4-1-1-1s-1,0.4-1,1v3H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h3v3c0,0.6,0.4,1,1,1s1-0.4,1-1v-3h3c0.6,0,1-0.4,1-1S16.6,11,16,11z" />
|
|
5
|
-
</svg>
|
|
6
|
-
</template>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewBox="0 0 24 24">
|
|
3
|
-
<path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z" />
|
|
4
|
-
<path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z" />
|
|
5
|
-
<path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z" />
|
|
6
|
-
<path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z" />
|
|
7
|
-
<path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z" />
|
|
8
|
-
<path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z" />
|
|
9
|
-
<path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z" />
|
|
10
|
-
<path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z" />
|
|
11
|
-
<path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z" />
|
|
12
|
-
</svg>
|
|
13
|
-
</template>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useMediaQuery } from '@vueuse/core';
|
|
2
|
-
import { computed } from 'vue';
|
|
3
|
-
import { useSidebar } from './sidebar';
|
|
4
|
-
export function useAside() {
|
|
5
|
-
const { hasSidebar } = useSidebar();
|
|
6
|
-
const is960 = useMediaQuery('(min-width: 960px)');
|
|
7
|
-
const is1280 = useMediaQuery('(min-width: 1280px)');
|
|
8
|
-
const isAsideEnabled = computed(() => {
|
|
9
|
-
if (!is1280.value && !is960.value) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
return hasSidebar.value ? is1280.value : is960.value;
|
|
13
|
-
});
|
|
14
|
-
return {
|
|
15
|
-
isAsideEnabled
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { onContentUpdated } from 'vitepress';
|
|
2
|
-
import { computed, shallowRef } from 'vue';
|
|
3
|
-
import { getHeaders } from '../composables/outline';
|
|
4
|
-
import { useData } from './data';
|
|
5
|
-
export function useLocalNav() {
|
|
6
|
-
const { theme, frontmatter } = useData();
|
|
7
|
-
const headers = shallowRef([]);
|
|
8
|
-
const hasLocalNav = computed(() => {
|
|
9
|
-
return headers.value.length > 0;
|
|
10
|
-
});
|
|
11
|
-
onContentUpdated(() => {
|
|
12
|
-
headers.value = getHeaders(frontmatter.value.outline ?? theme.value.outline);
|
|
13
|
-
});
|
|
14
|
-
return {
|
|
15
|
-
headers,
|
|
16
|
-
hasLocalNav
|
|
17
|
-
};
|
|
18
|
-
}
|
|
@@ -1,470 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import fs__default from 'node:fs';
|
|
3
|
-
import module, { createRequire } from 'node:module';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
|
-
import { MessageChannel, Worker, workerData, parentPort, receiveMessageOnPort } from 'node:worker_threads';
|
|
7
|
-
|
|
8
|
-
/******************************************************************************
|
|
9
|
-
Copyright (c) Microsoft Corporation.
|
|
10
|
-
|
|
11
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
12
|
-
purpose with or without fee is hereby granted.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
15
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
16
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
17
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
18
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
-
***************************************************************************** */
|
|
22
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function __rest(s, e) {
|
|
26
|
-
var t = {};
|
|
27
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
-
t[p] = s[p];
|
|
29
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
-
t[p[i]] = s[p[i]];
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
38
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
39
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
40
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
41
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
42
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
43
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
48
|
-
var e = new Error(message);
|
|
49
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const CWD = process.cwd();
|
|
53
|
-
const cjsRequire$1 = typeof require === 'undefined' ? createRequire(import.meta.url) : require;
|
|
54
|
-
const EXTENSIONS = ['.ts', '.tsx', ...Object.keys(cjsRequire$1.extensions)];
|
|
55
|
-
|
|
56
|
-
const tryPkg = (pkg) => {
|
|
57
|
-
try {
|
|
58
|
-
return cjsRequire$1.resolve(pkg);
|
|
59
|
-
}
|
|
60
|
-
catch (_a) { }
|
|
61
|
-
};
|
|
62
|
-
const isPkgAvailable = (pkg) => !!tryPkg(pkg);
|
|
63
|
-
const tryFile = (filePath, includeDir = false) => {
|
|
64
|
-
if (typeof filePath === 'string') {
|
|
65
|
-
return fs__default.existsSync(filePath) &&
|
|
66
|
-
(includeDir || fs__default.statSync(filePath).isFile())
|
|
67
|
-
? filePath
|
|
68
|
-
: '';
|
|
69
|
-
}
|
|
70
|
-
for (const file of filePath !== null && filePath !== undefined ? filePath : []) {
|
|
71
|
-
if (tryFile(file, includeDir)) {
|
|
72
|
-
return file;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return '';
|
|
76
|
-
};
|
|
77
|
-
const tryExtensions = (filepath, extensions = EXTENSIONS) => {
|
|
78
|
-
const ext = [...extensions, ''].find(ext => tryFile(filepath + ext));
|
|
79
|
-
return ext == null ? '' : filepath + ext;
|
|
80
|
-
};
|
|
81
|
-
const findUp = (searchEntry, searchFileOrIncludeDir, includeDir) => {
|
|
82
|
-
console.assert(path.isAbsolute(searchEntry));
|
|
83
|
-
if (!tryFile(searchEntry, true) ||
|
|
84
|
-
(searchEntry !== CWD && !searchEntry.startsWith(CWD + path.sep))) {
|
|
85
|
-
return '';
|
|
86
|
-
}
|
|
87
|
-
searchEntry = path.resolve(fs__default.statSync(searchEntry).isDirectory()
|
|
88
|
-
? searchEntry
|
|
89
|
-
: path.resolve(searchEntry, '..'));
|
|
90
|
-
const isSearchFile = "undefined" === 'string';
|
|
91
|
-
const searchFile = 'package.json';
|
|
92
|
-
do {
|
|
93
|
-
const searched = tryFile(path.resolve(searchEntry, searchFile), isSearchFile);
|
|
94
|
-
if (searched) {
|
|
95
|
-
return searched;
|
|
96
|
-
}
|
|
97
|
-
searchEntry = path.resolve(searchEntry, '..');
|
|
98
|
-
} while (searchEntry === CWD || searchEntry.startsWith(CWD + path.sep));
|
|
99
|
-
return '';
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const INT32_BYTES = 4;
|
|
103
|
-
const TsRunner = {
|
|
104
|
-
TsNode: 'ts-node',
|
|
105
|
-
EsbuildRegister: 'esbuild-register',
|
|
106
|
-
EsbuildRunner: 'esbuild-runner',
|
|
107
|
-
SWC: 'swc',
|
|
108
|
-
TSX: 'tsx',
|
|
109
|
-
};
|
|
110
|
-
const { NODE_OPTIONS, SYNCKIT_EXEC_ARGV, SYNCKIT_GLOBAL_SHIMS, SYNCKIT_TIMEOUT, SYNCKIT_TS_RUNNER, } = process.env;
|
|
111
|
-
const IS_NODE_20 = Number(process.versions.node.split('.')[0]) >= 20;
|
|
112
|
-
const DEFAULT_TIMEOUT = SYNCKIT_TIMEOUT ? +SYNCKIT_TIMEOUT : undefined;
|
|
113
|
-
const DEFAULT_EXEC_ARGV = (SYNCKIT_EXEC_ARGV === null || SYNCKIT_EXEC_ARGV === undefined ? undefined : SYNCKIT_EXEC_ARGV.split(',')) || [];
|
|
114
|
-
const DEFAULT_TS_RUNNER = SYNCKIT_TS_RUNNER;
|
|
115
|
-
const DEFAULT_GLOBAL_SHIMS = ['1', 'true'].includes(SYNCKIT_GLOBAL_SHIMS);
|
|
116
|
-
const DEFAULT_GLOBAL_SHIMS_PRESET = [
|
|
117
|
-
{
|
|
118
|
-
moduleName: 'node-fetch',
|
|
119
|
-
globalName: 'fetch',
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
moduleName: 'node:perf_hooks',
|
|
123
|
-
globalName: 'performance',
|
|
124
|
-
named: 'performance',
|
|
125
|
-
},
|
|
126
|
-
];
|
|
127
|
-
const MTS_SUPPORTED_NODE_VERSION = 16;
|
|
128
|
-
let syncFnCache;
|
|
129
|
-
function extractProperties(object) {
|
|
130
|
-
if (object && typeof object === 'object') {
|
|
131
|
-
const properties = {};
|
|
132
|
-
for (const key in object) {
|
|
133
|
-
properties[key] = object[key];
|
|
134
|
-
}
|
|
135
|
-
return properties;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function createSyncFn(workerPath, timeoutOrOptions) {
|
|
139
|
-
syncFnCache !== null && syncFnCache !== undefined ? syncFnCache : (syncFnCache = new Map());
|
|
140
|
-
const cachedSyncFn = syncFnCache.get(workerPath);
|
|
141
|
-
if (cachedSyncFn) {
|
|
142
|
-
return cachedSyncFn;
|
|
143
|
-
}
|
|
144
|
-
if (!path.isAbsolute(workerPath)) {
|
|
145
|
-
throw new Error('`workerPath` must be absolute');
|
|
146
|
-
}
|
|
147
|
-
const syncFn = startWorkerThread(workerPath, timeoutOrOptions);
|
|
148
|
-
syncFnCache.set(workerPath, syncFn);
|
|
149
|
-
return syncFn;
|
|
150
|
-
}
|
|
151
|
-
const cjsRequire = typeof require === 'undefined'
|
|
152
|
-
? module.createRequire(import.meta.url)
|
|
153
|
-
: require;
|
|
154
|
-
const dataUrl = (code) => new URL(`data:text/javascript,${encodeURIComponent(code)}`);
|
|
155
|
-
const isFile = (path) => {
|
|
156
|
-
var _a;
|
|
157
|
-
try {
|
|
158
|
-
return !!((_a = fs__default.statSync(path, { throwIfNoEntry: false })) === null || _a === void 0 ? void 0 : _a.isFile());
|
|
159
|
-
}
|
|
160
|
-
catch (_b) {
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
const setupTsRunner = (workerPath, { execArgv, tsRunner }) => {
|
|
165
|
-
let ext = path.extname(workerPath);
|
|
166
|
-
if (!/[/\\]node_modules[/\\]/.test(workerPath) &&
|
|
167
|
-
(!ext || /^\.[cm]?js$/.test(ext))) {
|
|
168
|
-
const workPathWithoutExt = ext
|
|
169
|
-
? workerPath.slice(0, -ext.length)
|
|
170
|
-
: workerPath;
|
|
171
|
-
let extensions;
|
|
172
|
-
switch (ext) {
|
|
173
|
-
case '.cjs': {
|
|
174
|
-
extensions = ['.cts', '.cjs'];
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
case '.mjs': {
|
|
178
|
-
extensions = ['.mts', '.mjs'];
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
default: {
|
|
182
|
-
extensions = ['.ts', '.js'];
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
const found = tryExtensions(workPathWithoutExt, extensions);
|
|
187
|
-
let differentExt;
|
|
188
|
-
if (found && (!ext || (differentExt = found !== workPathWithoutExt))) {
|
|
189
|
-
workerPath = found;
|
|
190
|
-
if (differentExt) {
|
|
191
|
-
ext = path.extname(workerPath);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
const isTs = /\.[cm]?ts$/.test(workerPath);
|
|
196
|
-
let jsUseEsm = workerPath.endsWith('.mjs');
|
|
197
|
-
let tsUseEsm = workerPath.endsWith('.mts');
|
|
198
|
-
if (isTs) {
|
|
199
|
-
if (!tsUseEsm) {
|
|
200
|
-
const pkg = findUp(workerPath);
|
|
201
|
-
if (pkg) {
|
|
202
|
-
tsUseEsm =
|
|
203
|
-
cjsRequire(pkg).type ===
|
|
204
|
-
'module';
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
if (tsRunner == null && isPkgAvailable(TsRunner.TsNode)) {
|
|
208
|
-
tsRunner = TsRunner.TsNode;
|
|
209
|
-
}
|
|
210
|
-
switch (tsRunner) {
|
|
211
|
-
case TsRunner.TsNode: {
|
|
212
|
-
if (tsUseEsm) {
|
|
213
|
-
if (!execArgv.includes('--loader')) {
|
|
214
|
-
execArgv = ['--loader', `${TsRunner.TsNode}/esm`, ...execArgv];
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
else if (!execArgv.includes('-r')) {
|
|
218
|
-
execArgv = ['-r', `${TsRunner.TsNode}/register`, ...execArgv];
|
|
219
|
-
}
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
case TsRunner.EsbuildRegister: {
|
|
223
|
-
if (!execArgv.includes('-r')) {
|
|
224
|
-
execArgv = ['-r', TsRunner.EsbuildRegister, ...execArgv];
|
|
225
|
-
}
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
case TsRunner.EsbuildRunner: {
|
|
229
|
-
if (!execArgv.includes('-r')) {
|
|
230
|
-
execArgv = ['-r', `${TsRunner.EsbuildRunner}/register`, ...execArgv];
|
|
231
|
-
}
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
case TsRunner.SWC: {
|
|
235
|
-
if (!execArgv.includes('-r')) {
|
|
236
|
-
execArgv = ['-r', `@${TsRunner.SWC}-node/register`, ...execArgv];
|
|
237
|
-
}
|
|
238
|
-
break;
|
|
239
|
-
}
|
|
240
|
-
case TsRunner.TSX: {
|
|
241
|
-
if (!execArgv.includes('--loader')) {
|
|
242
|
-
execArgv = ['--loader', TsRunner.TSX, ...execArgv];
|
|
243
|
-
}
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
default: {
|
|
247
|
-
throw new Error(`Unknown ts runner: ${String(tsRunner)}`);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
else if (!jsUseEsm) {
|
|
252
|
-
const pkg = findUp(workerPath);
|
|
253
|
-
if (pkg) {
|
|
254
|
-
jsUseEsm =
|
|
255
|
-
cjsRequire(pkg).type === 'module';
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
let resolvedPnpLoaderPath;
|
|
259
|
-
if (process.versions.pnp) {
|
|
260
|
-
const nodeOptions = NODE_OPTIONS === null || NODE_OPTIONS === undefined ? undefined : NODE_OPTIONS.split(/\s+/);
|
|
261
|
-
let pnpApiPath;
|
|
262
|
-
try {
|
|
263
|
-
pnpApiPath = cjsRequire.resolve('pnpapi');
|
|
264
|
-
}
|
|
265
|
-
catch (_a) { }
|
|
266
|
-
if (pnpApiPath &&
|
|
267
|
-
!(nodeOptions === null || nodeOptions === undefined ? undefined : nodeOptions.some((option, index) => ['-r', '--require'].includes(option) &&
|
|
268
|
-
pnpApiPath === cjsRequire.resolve(nodeOptions[index + 1]))) &&
|
|
269
|
-
!execArgv.includes(pnpApiPath)) {
|
|
270
|
-
execArgv = ['-r', pnpApiPath, ...execArgv];
|
|
271
|
-
const pnpLoaderPath = path.resolve(pnpApiPath, '../.pnp.loader.mjs');
|
|
272
|
-
if (isFile(pnpLoaderPath)) {
|
|
273
|
-
resolvedPnpLoaderPath = pathToFileURL(pnpLoaderPath).toString();
|
|
274
|
-
if (!IS_NODE_20) {
|
|
275
|
-
execArgv = [
|
|
276
|
-
'--experimental-loader',
|
|
277
|
-
resolvedPnpLoaderPath,
|
|
278
|
-
...execArgv,
|
|
279
|
-
];
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return {
|
|
285
|
-
ext,
|
|
286
|
-
isTs,
|
|
287
|
-
jsUseEsm,
|
|
288
|
-
tsRunner,
|
|
289
|
-
tsUseEsm,
|
|
290
|
-
workerPath,
|
|
291
|
-
pnpLoaderPath: resolvedPnpLoaderPath,
|
|
292
|
-
execArgv,
|
|
293
|
-
};
|
|
294
|
-
};
|
|
295
|
-
const md5Hash = (text) => createHash('md5').update(text).digest('hex');
|
|
296
|
-
const encodeImportModule = (moduleNameOrGlobalShim, type = 'import') => {
|
|
297
|
-
const { moduleName, globalName, named, conditional } = typeof moduleNameOrGlobalShim === 'string'
|
|
298
|
-
? { moduleName: moduleNameOrGlobalShim }
|
|
299
|
-
: moduleNameOrGlobalShim;
|
|
300
|
-
const importStatement = type === 'import'
|
|
301
|
-
? `import${globalName
|
|
302
|
-
? ' ' +
|
|
303
|
-
(named === null
|
|
304
|
-
? '* as ' + globalName
|
|
305
|
-
: (named === null || named === undefined ? undefined : named.trim())
|
|
306
|
-
? `{${named}}`
|
|
307
|
-
: globalName) +
|
|
308
|
-
' from'
|
|
309
|
-
: ''} '${path.isAbsolute(moduleName)
|
|
310
|
-
? String(pathToFileURL(moduleName))
|
|
311
|
-
: moduleName}'`
|
|
312
|
-
: `${globalName
|
|
313
|
-
? 'const ' + ((named === null || named === undefined ? undefined : named.trim()) ? `{${named}}` : globalName) + '='
|
|
314
|
-
: ''}require('${moduleName
|
|
315
|
-
.replace(/\\/g, '\\\\')}')`;
|
|
316
|
-
if (!globalName) {
|
|
317
|
-
return importStatement;
|
|
318
|
-
}
|
|
319
|
-
const overrideStatement = `globalThis.${globalName}=${(named === null || named === undefined ? undefined : named.trim()) ? named : globalName}`;
|
|
320
|
-
return (importStatement +
|
|
321
|
-
(conditional === false
|
|
322
|
-
? `;${overrideStatement}`
|
|
323
|
-
: `;if(!globalThis.${globalName})${overrideStatement}`));
|
|
324
|
-
};
|
|
325
|
-
const _generateGlobals = (globalShims, type) => globalShims.reduce((acc, shim) => `${acc}${acc ? ';' : ''}${encodeImportModule(shim, type)}`, '');
|
|
326
|
-
let globalsCache;
|
|
327
|
-
let tmpdir;
|
|
328
|
-
const _dirname = typeof __dirname === 'undefined'
|
|
329
|
-
? path.dirname(fileURLToPath(import.meta.url))
|
|
330
|
-
: __dirname;
|
|
331
|
-
let sharedBuffer;
|
|
332
|
-
let sharedBufferView;
|
|
333
|
-
const generateGlobals = (workerPath, globalShims, type = 'import') => {
|
|
334
|
-
globalsCache !== null && globalsCache !== undefined ? globalsCache : (globalsCache = new Map());
|
|
335
|
-
const cached = globalsCache.get(workerPath);
|
|
336
|
-
if (cached) {
|
|
337
|
-
const [content, filepath] = cached;
|
|
338
|
-
if ((type === 'require' && !filepath) ||
|
|
339
|
-
(type === 'import' && filepath && isFile(filepath))) {
|
|
340
|
-
return content;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
const globals = _generateGlobals(globalShims, type);
|
|
344
|
-
let content = globals;
|
|
345
|
-
let filepath;
|
|
346
|
-
if (type === 'import') {
|
|
347
|
-
if (!tmpdir) {
|
|
348
|
-
tmpdir = path.resolve(findUp(_dirname), '../node_modules/.synckit');
|
|
349
|
-
}
|
|
350
|
-
fs__default.mkdirSync(tmpdir, { recursive: true });
|
|
351
|
-
filepath = path.resolve(tmpdir, md5Hash(workerPath) + '.mjs');
|
|
352
|
-
content = encodeImportModule(filepath);
|
|
353
|
-
fs__default.writeFileSync(filepath, globals);
|
|
354
|
-
}
|
|
355
|
-
globalsCache.set(workerPath, [content, filepath]);
|
|
356
|
-
return content;
|
|
357
|
-
};
|
|
358
|
-
function startWorkerThread(workerPath, { timeout = DEFAULT_TIMEOUT, execArgv = DEFAULT_EXEC_ARGV, tsRunner = DEFAULT_TS_RUNNER, transferList = [], globalShims = DEFAULT_GLOBAL_SHIMS, } = {}) {
|
|
359
|
-
const { port1: mainPort, port2: workerPort } = new MessageChannel();
|
|
360
|
-
const { isTs, ext, jsUseEsm, tsUseEsm, tsRunner: finalTsRunner, workerPath: finalWorkerPath, pnpLoaderPath, execArgv: finalExecArgv, } = setupTsRunner(workerPath, { execArgv, tsRunner });
|
|
361
|
-
const workerPathUrl = pathToFileURL(finalWorkerPath);
|
|
362
|
-
if (/\.[cm]ts$/.test(finalWorkerPath)) {
|
|
363
|
-
const isTsxSupported = !tsUseEsm ||
|
|
364
|
-
Number.parseFloat(process.versions.node) >= MTS_SUPPORTED_NODE_VERSION;
|
|
365
|
-
if (!finalTsRunner) {
|
|
366
|
-
throw new Error('No ts runner specified, ts worker path is not supported');
|
|
367
|
-
}
|
|
368
|
-
else if ([
|
|
369
|
-
TsRunner.EsbuildRegister,
|
|
370
|
-
TsRunner.EsbuildRunner,
|
|
371
|
-
TsRunner.SWC,
|
|
372
|
-
...(isTsxSupported ? [] : [TsRunner.TSX]),
|
|
373
|
-
].includes(finalTsRunner)) {
|
|
374
|
-
throw new Error(`${finalTsRunner} is not supported for ${ext} files yet` +
|
|
375
|
-
(isTsxSupported
|
|
376
|
-
? ', you can try [tsx](https://github.com/esbuild-kit/tsx) instead'
|
|
377
|
-
: ''));
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
const finalGlobalShims = (globalShims === true
|
|
381
|
-
? DEFAULT_GLOBAL_SHIMS_PRESET
|
|
382
|
-
: Array.isArray(globalShims)
|
|
383
|
-
? globalShims
|
|
384
|
-
: []).filter(({ moduleName }) => isPkgAvailable(moduleName));
|
|
385
|
-
sharedBufferView !== null && sharedBufferView !== undefined ? sharedBufferView : (sharedBufferView = new Int32Array((sharedBuffer !== null && sharedBuffer !== undefined ? sharedBuffer : (sharedBuffer = new SharedArrayBuffer(INT32_BYTES))), 0, 1));
|
|
386
|
-
const useGlobals = finalGlobalShims.length > 0;
|
|
387
|
-
const useEval = isTs ? !tsUseEsm : !jsUseEsm && useGlobals;
|
|
388
|
-
const worker = new Worker((jsUseEsm && useGlobals) || (tsUseEsm && finalTsRunner === TsRunner.TsNode)
|
|
389
|
-
? dataUrl(`${generateGlobals(finalWorkerPath, finalGlobalShims)};import '${String(workerPathUrl)}'`)
|
|
390
|
-
: useEval
|
|
391
|
-
? `${generateGlobals(finalWorkerPath, finalGlobalShims, 'require')};${encodeImportModule(finalWorkerPath, 'require')}`
|
|
392
|
-
: workerPathUrl, {
|
|
393
|
-
eval: useEval,
|
|
394
|
-
workerData: { sharedBuffer, workerPort, pnpLoaderPath },
|
|
395
|
-
transferList: [workerPort, ...transferList],
|
|
396
|
-
execArgv: finalExecArgv,
|
|
397
|
-
});
|
|
398
|
-
let nextID = 0;
|
|
399
|
-
const receiveMessageWithId = (port, expectedId, waitingTimeout) => {
|
|
400
|
-
const start = Date.now();
|
|
401
|
-
const status = Atomics.wait(sharedBufferView, 0, 0, waitingTimeout);
|
|
402
|
-
Atomics.store(sharedBufferView, 0, 0);
|
|
403
|
-
if (!['ok', 'not-equal'].includes(status)) {
|
|
404
|
-
const abortMsg = {
|
|
405
|
-
id: expectedId,
|
|
406
|
-
cmd: 'abort',
|
|
407
|
-
};
|
|
408
|
-
port.postMessage(abortMsg);
|
|
409
|
-
throw new Error('Internal error: Atomics.wait() failed: ' + status);
|
|
410
|
-
}
|
|
411
|
-
const _a = receiveMessageOnPort(mainPort).message, { id } = _a, message = __rest(_a, ["id"]);
|
|
412
|
-
if (id < expectedId) {
|
|
413
|
-
const waitingTime = Date.now() - start;
|
|
414
|
-
return receiveMessageWithId(port, expectedId, waitingTimeout ? waitingTimeout - waitingTime : undefined);
|
|
415
|
-
}
|
|
416
|
-
if (expectedId !== id) {
|
|
417
|
-
throw new Error(`Internal error: Expected id ${expectedId} but got id ${id}`);
|
|
418
|
-
}
|
|
419
|
-
return Object.assign({ id }, message);
|
|
420
|
-
};
|
|
421
|
-
const syncFn = (...args) => {
|
|
422
|
-
const id = nextID++;
|
|
423
|
-
const msg = { id, args };
|
|
424
|
-
worker.postMessage(msg);
|
|
425
|
-
const { result, error, properties } = receiveMessageWithId(mainPort, id, timeout);
|
|
426
|
-
if (error) {
|
|
427
|
-
throw Object.assign(error, properties);
|
|
428
|
-
}
|
|
429
|
-
return result;
|
|
430
|
-
};
|
|
431
|
-
worker.unref();
|
|
432
|
-
return syncFn;
|
|
433
|
-
}
|
|
434
|
-
function runAsWorker(fn) {
|
|
435
|
-
if (!workerData) {
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
const { workerPort, sharedBuffer, pnpLoaderPath } = workerData;
|
|
439
|
-
if (pnpLoaderPath && IS_NODE_20) {
|
|
440
|
-
module.register(pnpLoaderPath);
|
|
441
|
-
}
|
|
442
|
-
const sharedBufferView = new Int32Array(sharedBuffer, 0, 1);
|
|
443
|
-
parentPort.on('message', ({ id, args }) => {
|
|
444
|
-
(() => __awaiter(this, undefined, undefined, function* () {
|
|
445
|
-
let isAborted = false;
|
|
446
|
-
const handleAbortMessage = (msg) => {
|
|
447
|
-
if (msg.id === id && msg.cmd === 'abort') {
|
|
448
|
-
isAborted = true;
|
|
449
|
-
}
|
|
450
|
-
};
|
|
451
|
-
workerPort.on('message', handleAbortMessage);
|
|
452
|
-
let msg;
|
|
453
|
-
try {
|
|
454
|
-
msg = { id, result: yield fn(...args) };
|
|
455
|
-
}
|
|
456
|
-
catch (error) {
|
|
457
|
-
msg = { id, error, properties: extractProperties(error) };
|
|
458
|
-
}
|
|
459
|
-
workerPort.off('message', handleAbortMessage);
|
|
460
|
-
if (isAborted) {
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
workerPort.postMessage(msg);
|
|
464
|
-
Atomics.add(sharedBufferView, 0, 1);
|
|
465
|
-
Atomics.notify(sharedBufferView, 0);
|
|
466
|
-
}))();
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
export { createSyncFn as c, runAsWorker as r };
|