vitepress 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/client/app/data.js +13 -3
  2. package/dist/client/app/router.js +8 -11
  3. package/dist/client/index.d.ts +4 -0
  4. package/dist/client/theme-default/components/VPLocalNavOutlineDropdown.vue +1 -1
  5. package/dist/client/theme-default/composables/langs.js +2 -3
  6. package/dist/client/theme-default/composables/sidebar.js +2 -3
  7. package/dist/client/theme-default/fonts/inter-italic-cyrillic-ext.woff2 +0 -0
  8. package/dist/client/theme-default/fonts/inter-italic-cyrillic.woff2 +0 -0
  9. package/dist/client/theme-default/fonts/inter-italic-greek-ext.woff2 +0 -0
  10. package/dist/client/theme-default/fonts/inter-italic-greek.woff2 +0 -0
  11. package/dist/client/theme-default/fonts/inter-italic-latin-ext.woff2 +0 -0
  12. package/dist/client/theme-default/fonts/inter-italic-latin.woff2 +0 -0
  13. package/dist/client/theme-default/fonts/inter-italic-vietnamese.woff2 +0 -0
  14. package/dist/client/theme-default/fonts/inter-roman-cyrillic-ext.woff2 +0 -0
  15. package/dist/client/theme-default/fonts/inter-roman-cyrillic.woff2 +0 -0
  16. package/dist/client/theme-default/fonts/inter-roman-greek-ext.woff2 +0 -0
  17. package/dist/client/theme-default/fonts/inter-roman-greek.woff2 +0 -0
  18. package/dist/client/theme-default/fonts/inter-roman-latin-ext.woff2 +0 -0
  19. package/dist/client/theme-default/fonts/inter-roman-latin.woff2 +0 -0
  20. package/dist/client/theme-default/fonts/inter-roman-vietnamese.woff2 +0 -0
  21. package/dist/client/theme-default/styles/fonts.css +64 -72
  22. package/dist/client/theme-default/styles/vars.css +7 -6
  23. package/dist/node/cli.js +1 -1
  24. package/dist/node/index.js +2 -2
  25. package/dist/node/{serve-CEVH7KNu.js → serve-Csn-CKFx.js} +52 -19
  26. package/package.json +25 -25
  27. package/dist/client/theme-default/composables/hash.js +0 -9
@@ -1,7 +1,7 @@
1
1
  import siteData from '@siteData';
2
2
  import { useDark } from '@vueuse/core';
3
- import { computed, inject, readonly, ref, shallowRef } from 'vue';
4
- import { APPEARANCE_KEY, createTitle, resolveSiteDataByRoute } from '../shared';
3
+ import { computed, inject, readonly, ref, shallowRef, watch } from 'vue';
4
+ import { APPEARANCE_KEY, createTitle, inBrowser, resolveSiteDataByRoute } from '../shared';
5
5
  export const dataSymbol = Symbol();
6
6
  // site data is a singleton
7
7
  export const siteDataRef = shallowRef((import.meta.env.PROD ? siteData : readonly(siteData)));
@@ -26,6 +26,15 @@ export function initData(route) {
26
26
  ...(typeof appearance === 'object' ? appearance : {})
27
27
  })
28
28
  : ref(false);
29
+ const hashRef = ref(inBrowser ? location.hash : '');
30
+ if (inBrowser) {
31
+ window.addEventListener('hashchange', () => {
32
+ hashRef.value = location.hash;
33
+ });
34
+ }
35
+ watch(() => route.data, () => {
36
+ hashRef.value = inBrowser ? location.hash : '';
37
+ });
29
38
  return {
30
39
  site,
31
40
  theme: computed(() => site.value.themeConfig),
@@ -37,7 +46,8 @@ export function initData(route) {
37
46
  localeIndex: computed(() => site.value.localeIndex || 'root'),
38
47
  title: computed(() => createTitle(site.value, route.data)),
39
48
  description: computed(() => route.data.description || site.value.description),
40
- isDark
49
+ isDark,
50
+ hash: computed(() => hashRef.value)
41
51
  };
42
52
  }
43
53
  export function useData() {
@@ -21,16 +21,10 @@ export function createRouter(loadPageModule, fallbackComponent) {
21
21
  href = normalizeHref(href);
22
22
  if ((await router.onBeforeRouteChange?.(href)) === false)
23
23
  return;
24
- if (inBrowser) {
25
- const currentUrl = new URL(location.href);
26
- if (href !== normalizeHref(currentUrl.href)) {
27
- // save scroll position before changing url
28
- history.replaceState({ scrollPosition: window.scrollY }, document.title);
29
- history.pushState(null, '', href);
30
- if (new URL(href, fakeHost).hash !== currentUrl.hash) {
31
- window.dispatchEvent(new Event('hashchange'));
32
- }
33
- }
24
+ if (inBrowser && href !== normalizeHref(location.href)) {
25
+ // save scroll position before changing url
26
+ history.replaceState({ scrollPosition: window.scrollY }, document.title);
27
+ history.pushState(null, '', href);
34
28
  }
35
29
  await loadPage(href);
36
30
  await router.onAfterRouteChanged?.(href);
@@ -143,7 +137,10 @@ export function createRouter(loadPageModule, fallbackComponent) {
143
137
  if (hash !== currentUrl.hash) {
144
138
  history.pushState(null, '', href);
145
139
  // still emit the event so we can listen to it in themes
146
- window.dispatchEvent(new Event('hashchange'));
140
+ window.dispatchEvent(new HashChangeEvent('hashchange', {
141
+ oldURL: currentUrl.href,
142
+ newURL: href
143
+ }));
147
144
  }
148
145
  if (hash) {
149
146
  // use smooth scroll when clicking on header anchor links
@@ -64,6 +64,10 @@ interface VitePressData<T = any> {
64
64
  dir: Ref<string>;
65
65
  localeIndex: Ref<string>;
66
66
  isDark: Ref<boolean>;
67
+ /**
68
+ * Current location hash
69
+ */
70
+ hash: Ref<string>;
67
71
  }
68
72
  declare function useData<T = any>(): VitePressData<T>;
69
73
 
@@ -59,7 +59,7 @@ function scrollToTop() {
59
59
  ref="main"
60
60
  >
61
61
  <button @click="toggle" :class="{ open }" v-if="headers.length > 0">
62
- {{ resolveTitle(theme) }}
62
+ <span class="menu-text">{{ resolveTitle(theme) }}</span>
63
63
  <span class="vpi-chevron-right icon" />
64
64
  </button>
65
65
  <button @click="scrollToTop" v-else>
@@ -1,9 +1,8 @@
1
1
  import { computed } from 'vue';
2
2
  import { ensureStartingSlash } from '../support/utils';
3
3
  import { useData } from './data';
4
- import { hashRef } from './hash';
5
4
  export function useLangs({ removeCurrent = true, correspondingLink = false } = {}) {
6
- const { site, localeIndex, page, theme } = useData();
5
+ const { site, localeIndex, page, theme, hash } = useData();
7
6
  const currentLang = computed(() => ({
8
7
  label: site.value.locales[localeIndex.value]?.label,
9
8
  link: site.value.locales[localeIndex.value]?.link ||
@@ -13,7 +12,7 @@ export function useLangs({ removeCurrent = true, correspondingLink = false } = {
13
12
  ? []
14
13
  : {
15
14
  text: value.label,
16
- link: normalizeLink(value.link || (key === 'root' ? '/' : `/${key}/`), theme.value.i18nRouting !== false && correspondingLink, page.value.relativePath.slice(currentLang.value.link.length - 1), !site.value.cleanUrls) + hashRef.value
15
+ link: normalizeLink(value.link || (key === 'root' ? '/' : `/${key}/`), theme.value.i18nRouting !== false && correspondingLink, page.value.relativePath.slice(currentLang.value.link.length - 1), !site.value.cleanUrls) + hash.value
17
16
  }));
18
17
  return { localeLinks, currentLang };
19
18
  }
@@ -3,7 +3,6 @@ import { computed, onMounted, onUnmounted, ref, watch, watchEffect, watchPostEff
3
3
  import { isActive } from '../../shared';
4
4
  import { hasActiveLink as containsActiveLink, getSidebar, getSidebarGroups } from '../support/sidebar';
5
5
  import { useData } from './data';
6
- import { hashRef } from './hash';
7
6
  export function useSidebar() {
8
7
  const { frontmatter, page, theme } = useData();
9
8
  const is960 = useMediaQuery('(min-width: 960px)');
@@ -88,7 +87,7 @@ export function useCloseSidebarOnEscape(isOpen, close) {
88
87
  }
89
88
  }
90
89
  export function useSidebarControl(item) {
91
- const { page } = useData();
90
+ const { page, hash } = useData();
92
91
  const collapsed = ref(false);
93
92
  const collapsible = computed(() => {
94
93
  return item.value.collapsed != null;
@@ -100,7 +99,7 @@ export function useSidebarControl(item) {
100
99
  const updateIsActiveLink = () => {
101
100
  isActiveLink.value = isActive(page.value.relativePath, item.value.link);
102
101
  };
103
- watch([page, item, hashRef], updateIsActiveLink);
102
+ watch([page, item, hash], updateIsActiveLink);
104
103
  onMounted(updateIsActiveLink);
105
104
  const hasActiveLink = computed(() => {
106
105
  if (isActiveLink.value) {
@@ -7,153 +7,143 @@ html body {
7
7
  /* webfont-marker-end */
8
8
 
9
9
  @font-face {
10
- font-family: 'Inter var';
11
- font-weight: 100 900;
12
- font-display: swap;
10
+ font-family: Inter;
13
11
  font-style: normal;
14
- font-named-instance: 'Regular';
15
- src: url('../fonts/inter-roman-cyrillic.woff2') format('woff2');
16
- unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
17
- }
18
-
19
- @font-face {
20
- font-family: 'Inter var';
21
12
  font-weight: 100 900;
22
13
  font-display: swap;
23
- font-style: normal;
24
- font-named-instance: 'Regular';
25
14
  src: url('../fonts/inter-roman-cyrillic-ext.woff2') format('woff2');
26
15
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F,
27
16
  U+FE2E-FE2F;
28
17
  }
29
18
 
30
19
  @font-face {
31
- font-family: 'Inter var';
20
+ font-family: Inter;
21
+ font-style: normal;
32
22
  font-weight: 100 900;
33
23
  font-display: swap;
34
- font-style: normal;
35
- font-named-instance: 'Regular';
36
- src: url('../fonts/inter-roman-greek.woff2') format('woff2');
37
- unicode-range: U+0370-03FF;
24
+ src: url('../fonts/inter-roman-cyrillic.woff2') format('woff2');
25
+ unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
38
26
  }
39
27
 
40
28
  @font-face {
41
- font-family: 'Inter var';
29
+ font-family: Inter;
30
+ font-style: normal;
42
31
  font-weight: 100 900;
43
32
  font-display: swap;
44
- font-style: normal;
45
- font-named-instance: 'Regular';
46
33
  src: url('../fonts/inter-roman-greek-ext.woff2') format('woff2');
47
34
  unicode-range: U+1F00-1FFF;
48
35
  }
49
36
 
50
37
  @font-face {
51
- font-family: 'Inter var';
38
+ font-family: Inter;
39
+ font-style: normal;
52
40
  font-weight: 100 900;
53
41
  font-display: swap;
54
- font-style: normal;
55
- font-named-instance: 'Regular';
56
- src: url('../fonts/inter-roman-latin.woff2') format('woff2');
57
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
58
- U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
59
- U+FEFF, U+FFFD;
42
+ src: url('../fonts/inter-roman-greek.woff2') format('woff2');
43
+ unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1,
44
+ U+03A3-03FF;
60
45
  }
61
46
 
62
47
  @font-face {
63
- font-family: 'Inter var';
48
+ font-family: Inter;
49
+ font-style: normal;
64
50
  font-weight: 100 900;
65
51
  font-display: swap;
66
- font-style: normal;
67
- font-named-instance: 'Regular';
68
- src: url('../fonts/inter-roman-latin-ext.woff2') format('woff2');
69
- unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB,
70
- U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
52
+ src: url('../fonts/inter-roman-vietnamese.woff2') format('woff2');
53
+ unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
54
+ U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329,
55
+ U+1EA0-1EF9, U+20AB;
71
56
  }
72
57
 
73
58
  @font-face {
74
- font-family: 'Inter var';
59
+ font-family: Inter;
60
+ font-style: normal;
75
61
  font-weight: 100 900;
76
62
  font-display: swap;
77
- font-style: normal;
78
- font-named-instance: 'Regular';
79
- src: url('../fonts/inter-roman-vietnamese.woff2') format('woff2');
80
- unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
81
- U+01AF-01B0, U+1EA0-1EF9, U+20AB;
63
+ src: url('../fonts/inter-roman-latin-ext.woff2') format('woff2');
64
+ unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
65
+ U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
82
66
  }
83
67
 
84
68
  @font-face {
85
- font-family: 'Inter var';
69
+ font-family: Inter;
70
+ font-style: normal;
86
71
  font-weight: 100 900;
87
72
  font-display: swap;
88
- font-style: italic;
89
- font-named-instance: 'Italic';
90
- src: url('../fonts/inter-italic-cyrillic.woff2') format('woff2');
91
- unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
73
+ src: url('../fonts/inter-roman-latin.woff2') format('woff2');
74
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
75
+ U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
76
+ U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
92
77
  }
93
78
 
94
79
  @font-face {
95
- font-family: 'Inter var';
80
+ font-family: Inter;
81
+ font-style: italic;
96
82
  font-weight: 100 900;
97
83
  font-display: swap;
98
- font-style: italic;
99
- font-named-instance: 'Italic';
100
84
  src: url('../fonts/inter-italic-cyrillic-ext.woff2') format('woff2');
101
85
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F,
102
86
  U+FE2E-FE2F;
103
87
  }
104
88
 
105
89
  @font-face {
106
- font-family: 'Inter var';
90
+ font-family: Inter;
91
+ font-style: italic;
107
92
  font-weight: 100 900;
108
93
  font-display: swap;
109
- font-style: italic;
110
- font-named-instance: 'Italic';
111
- src: url('../fonts/inter-italic-greek.woff2') format('woff2');
112
- unicode-range: U+0370-03FF;
94
+ src: url('../fonts/inter-italic-cyrillic.woff2') format('woff2');
95
+ unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
113
96
  }
114
97
 
115
98
  @font-face {
116
- font-family: 'Inter var';
99
+ font-family: Inter;
100
+ font-style: italic;
117
101
  font-weight: 100 900;
118
102
  font-display: swap;
119
- font-style: italic;
120
- font-named-instance: 'Italic';
121
103
  src: url('../fonts/inter-italic-greek-ext.woff2') format('woff2');
122
104
  unicode-range: U+1F00-1FFF;
123
105
  }
124
106
 
125
107
  @font-face {
126
- font-family: 'Inter var';
108
+ font-family: Inter;
109
+ font-style: italic;
127
110
  font-weight: 100 900;
128
111
  font-display: swap;
129
- font-style: italic;
130
- font-named-instance: 'Italic';
131
- src: url('../fonts/inter-italic-latin.woff2') format('woff2');
132
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
133
- U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
134
- U+FEFF, U+FFFD;
112
+ src: url('../fonts/inter-italic-greek.woff2') format('woff2');
113
+ unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1,
114
+ U+03A3-03FF;
135
115
  }
136
116
 
137
117
  @font-face {
138
- font-family: 'Inter var';
118
+ font-family: Inter;
119
+ font-style: italic;
139
120
  font-weight: 100 900;
140
121
  font-display: swap;
122
+ src: url('../fonts/inter-italic-vietnamese.woff2') format('woff2');
123
+ unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
124
+ U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329,
125
+ U+1EA0-1EF9, U+20AB;
126
+ }
127
+
128
+ @font-face {
129
+ font-family: Inter;
141
130
  font-style: italic;
142
- font-named-instance: 'Italic';
131
+ font-weight: 100 900;
132
+ font-display: swap;
143
133
  src: url('../fonts/inter-italic-latin-ext.woff2') format('woff2');
144
- unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB,
145
- U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
134
+ unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
135
+ U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
146
136
  }
147
137
 
148
138
  @font-face {
149
- font-family: 'Inter var';
139
+ font-family: Inter;
140
+ font-style: italic;
150
141
  font-weight: 100 900;
151
142
  font-display: swap;
152
- font-style: italic;
153
- font-named-instance: 'Italic';
154
- src: url('../fonts/inter-italic-vietnamese.woff2') format('woff2');
155
- unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
156
- U+01AF-01B0, U+1EA0-1EF9, U+20AB;
143
+ src: url('../fonts/inter-italic-latin.woff2') format('woff2');
144
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
145
+ U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
146
+ U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
157
147
  }
158
148
 
159
149
  /* Chinese quotes rendering fix. 中英文弯引号共享 Unicode 码位,确保引号使用中文字体渲染 */
@@ -163,3 +153,5 @@ html body {
163
153
  local('Source Han Sans SC');
164
154
  unicode-range: U+2018, U+2019, U+201C, U+201D; /* 分别是 ‘’“” */
165
155
  }
156
+
157
+ /* Generate the subsetted fonts using: `pyftsubset <file>.woff2 --unicodes="<range>" --output-file="inter-<style>-<subset>.woff2" --flavor=woff2` */
@@ -261,12 +261,13 @@
261
261
  * -------------------------------------------------------------------------- */
262
262
 
263
263
  :root {
264
- --vp-font-family-base: 'Chinese Quotes', 'Inter var', 'Inter', ui-sans-serif,
265
- system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
266
- 'Helvetica Neue', Helvetica, Arial, 'Noto Sans', sans-serif,
267
- 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
268
- --vp-font-family-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco,
269
- Consolas, 'Liberation Mono', 'Courier New', monospace;
264
+ --vp-font-family-base: 'Chinese Quotes', Inter, ui-sans-serif, system-ui,
265
+ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
266
+ 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
267
+ 'Noto Color Emoji';
268
+ --vp-font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
269
+ 'Liberation Mono', 'Courier New', monospace;
270
+ font-optical-sizing: auto;
270
271
  }
271
272
 
272
273
  /**
package/dist/node/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as getDefaultExportFromCjs, q as c, t as clearCache, n as init, b as build, o as serve, v as version, p as createServer } from './serve-CEVH7KNu.js';
1
+ import { a as getDefaultExportFromCjs, q as c, t as clearCache, n as init, b as build, o as serve, v as version, p as createServer } from './serve-Csn-CKFx.js';
2
2
  import { createLogger } from 'vite';
3
3
  import 'path';
4
4
  import 'url';
@@ -1,7 +1,7 @@
1
1
  import { normalizePath } from 'vite';
2
2
  export { loadEnv } from 'vite';
3
- import { g as glob, c as createMarkdownRenderer, f as fs, m as matter, a as getDefaultExportFromCjs } from './serve-CEVH7KNu.js';
4
- export { S as ScaffoldThemeType, b as build, p as createServer, e as defineConfig, h as defineConfigWithTheme, d as defineLoader, n as init, j as mergeConfig, r as resolveConfig, l as resolvePages, k as resolveSiteData, i as resolveUserConfig, s as scaffold, o as serve } from './serve-CEVH7KNu.js';
3
+ import { g as glob, c as createMarkdownRenderer, f as fs, m as matter, a as getDefaultExportFromCjs } from './serve-Csn-CKFx.js';
4
+ export { S as ScaffoldThemeType, b as build, p as createServer, e as defineConfig, h as defineConfigWithTheme, d as defineLoader, n as init, j as mergeConfig, r as resolveConfig, l as resolvePages, k as resolveSiteData, i as resolveUserConfig, s as scaffold, o as serve } from './serve-Csn-CKFx.js';
5
5
  import path from 'path';
6
6
  import 'crypto';
7
7
  import 'module';
@@ -3479,6 +3479,9 @@ class AST {
3479
3479
  _glob: glob,
3480
3480
  });
3481
3481
  }
3482
+ get options() {
3483
+ return this.#options;
3484
+ }
3482
3485
  // returns the string match, the regexp source, whether there's magic
3483
3486
  // in the regexp (so a regular expression is required) and whether or
3484
3487
  // not the uflag is needed for the regular expression (for posix classes)
@@ -4074,6 +4077,7 @@ class Minimatch {
4074
4077
  globParts = this.levelOneOptimize(globParts);
4075
4078
  }
4076
4079
  else {
4080
+ // just collapse multiple ** portions into one
4077
4081
  globParts = this.adjascentGlobstarOptimize(globParts);
4078
4082
  }
4079
4083
  return globParts;
@@ -4563,7 +4567,11 @@ class Minimatch {
4563
4567
  fastTest = dotStarTest;
4564
4568
  }
4565
4569
  const re = AST.fromGlob(pattern, this.options).toMMPattern();
4566
- return fastTest ? Object.assign(re, { test: fastTest }) : re;
4570
+ if (fastTest && typeof re === 'object') {
4571
+ // Avoids overriding in frozen environments
4572
+ Reflect.defineProperty(re, 'test', { value: fastTest });
4573
+ }
4574
+ return re;
4567
4575
  }
4568
4576
  makeRe() {
4569
4577
  if (this.regexp || this.regexp === false)
@@ -7229,21 +7237,21 @@ const IFMT = 0b1111;
7229
7237
  // mask to unset low 4 bits
7230
7238
  const IFMT_UNKNOWN = ~IFMT;
7231
7239
  // set after successfully calling readdir() and getting entries.
7232
- const READDIR_CALLED = 16;
7240
+ const READDIR_CALLED = 0b0000_0001_0000;
7233
7241
  // set after a successful lstat()
7234
- const LSTAT_CALLED = 32;
7242
+ const LSTAT_CALLED = 0b0000_0010_0000;
7235
7243
  // set if an entry (or one of its parents) is definitely not a dir
7236
- const ENOTDIR = 64;
7244
+ const ENOTDIR = 0b0000_0100_0000;
7237
7245
  // set if an entry (or one of its parents) does not exist
7238
7246
  // (can also be set on lstat errors like EACCES or ENAMETOOLONG)
7239
- const ENOENT = 128;
7247
+ const ENOENT = 0b0000_1000_0000;
7240
7248
  // cannot have child entries -- also verify &IFMT is either IFDIR or IFLNK
7241
7249
  // set if we fail to readlink
7242
- const ENOREADLINK = 256;
7250
+ const ENOREADLINK = 0b0001_0000_0000;
7243
7251
  // set if we know realpath() will fail
7244
- const ENOREALPATH = 512;
7252
+ const ENOREALPATH = 0b0010_0000_0000;
7245
7253
  const ENOCHILD = ENOTDIR | ENOENT | ENOREALPATH;
7246
- const TYPEMASK = 1023;
7254
+ const TYPEMASK = 0b0011_1111_1111;
7247
7255
  const entToType = (s) => s.isFile()
7248
7256
  ? IFREG
7249
7257
  : s.isDirectory()
@@ -7855,7 +7863,7 @@ class PathBase {
7855
7863
  /* c8 ignore stop */
7856
7864
  try {
7857
7865
  const read = await this.#fs.promises.readlink(this.fullpath());
7858
- const linkTarget = this.parent.resolve(read);
7866
+ const linkTarget = (await this.parent.realpath())?.resolve(read);
7859
7867
  if (linkTarget) {
7860
7868
  return (this.#linkTarget = linkTarget);
7861
7869
  }
@@ -7884,7 +7892,7 @@ class PathBase {
7884
7892
  /* c8 ignore stop */
7885
7893
  try {
7886
7894
  const read = this.#fs.readlinkSync(this.fullpath());
7887
- const linkTarget = this.parent.resolve(read);
7895
+ const linkTarget = (this.parent.realpathSync())?.resolve(read);
7888
7896
  if (linkTarget) {
7889
7897
  return (this.#linkTarget = linkTarget);
7890
7898
  }
@@ -7899,7 +7907,9 @@ class PathBase {
7899
7907
  this.#type |= READDIR_CALLED;
7900
7908
  // mark all remaining provisional children as ENOENT
7901
7909
  for (let p = children.provisional; p < children.length; p++) {
7902
- children[p].#markENOENT();
7910
+ const c = children[p];
7911
+ if (c)
7912
+ c.#markENOENT();
7903
7913
  }
7904
7914
  }
7905
7915
  #markENOENT() {
@@ -9429,6 +9439,12 @@ class Ignore {
9429
9439
  if (!parsed || !globParts) {
9430
9440
  throw new Error('invalid pattern object');
9431
9441
  }
9442
+ // strip off leading ./ portions
9443
+ // https://github.com/isaacs/node-glob/issues/570
9444
+ while (parsed[0] === '.' && globParts[0] === '.') {
9445
+ parsed.shift();
9446
+ globParts.shift();
9447
+ }
9432
9448
  /* c8 ignore stop */
9433
9449
  const p = new Pattern(parsed, globParts, 0, platform);
9434
9450
  const m = new Minimatch(p.globString(), mmopts);
@@ -9863,13 +9879,26 @@ class GlobUtil {
9863
9879
  e = rpc;
9864
9880
  }
9865
9881
  const needStat = e.isUnknown() || this.opts.stat;
9866
- return this.matchCheckTest(needStat ? await e.lstat() : e, ifDir);
9882
+ const s = needStat ? await e.lstat() : e;
9883
+ if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
9884
+ const target = await s.realpath();
9885
+ /* c8 ignore start */
9886
+ if (target && (target.isUnknown() || this.opts.stat)) {
9887
+ await target.lstat();
9888
+ }
9889
+ /* c8 ignore stop */
9890
+ }
9891
+ return this.matchCheckTest(s, ifDir);
9867
9892
  }
9868
9893
  matchCheckTest(e, ifDir) {
9869
9894
  return e &&
9870
9895
  (this.maxDepth === Infinity || e.depth() <= this.maxDepth) &&
9871
9896
  (!ifDir || e.canReaddir()) &&
9872
9897
  (!this.opts.nodir || !e.isDirectory()) &&
9898
+ (!this.opts.nodir ||
9899
+ !this.opts.follow ||
9900
+ !e.isSymbolicLink() ||
9901
+ !e.realpathCached()?.isDirectory()) &&
9873
9902
  !this.#ignored(e)
9874
9903
  ? e
9875
9904
  : undefined;
@@ -9885,7 +9914,14 @@ class GlobUtil {
9885
9914
  e = rpc;
9886
9915
  }
9887
9916
  const needStat = e.isUnknown() || this.opts.stat;
9888
- return this.matchCheckTest(needStat ? e.lstatSync() : e, ifDir);
9917
+ const s = needStat ? e.lstatSync() : e;
9918
+ if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
9919
+ const target = s.realpathSync();
9920
+ if (target && (target?.isUnknown() || this.opts.stat)) {
9921
+ target.lstatSync();
9922
+ }
9923
+ }
9924
+ return this.matchCheckTest(s, ifDir);
9889
9925
  }
9890
9926
  matchFinish(e, absolute) {
9891
9927
  if (this.#ignored(e))
@@ -46506,7 +46542,7 @@ function escapeHtml(string) {
46506
46542
 
46507
46543
  var escape$1 = /*@__PURE__*/getDefaultExportFromCjs(escapeHtml_1);
46508
46544
 
46509
- var version = "1.0.2";
46545
+ var version = "1.1.0";
46510
46546
 
46511
46547
  async function renderPage(render, config, page, result, appChunk, cssChunk, assets, pageToHashMap, metadataScript, additionalHeadTags) {
46512
46548
  const routePath = `/${page.replace(/\.md$/, "")}`;
@@ -48999,9 +49035,6 @@ var ScaffoldThemeType = /* @__PURE__ */ ((ScaffoldThemeType2) => {
48999
49035
  })(ScaffoldThemeType || {});
49000
49036
  const getPackageManger = () => {
49001
49037
  const name = process.env?.npm_config_user_agent || "npm";
49002
- if (name === "npm") {
49003
- return "npm";
49004
- }
49005
49038
  return name.split("/")[0];
49006
49039
  };
49007
49040
  async function init() {
@@ -49143,9 +49176,9 @@ Tips:`, ...tips].join("\n- ")) : ``;
49143
49176
  `${getPackageManger()} run docs:dev`
49144
49177
  )} and start writing.${tip}`;
49145
49178
  } else {
49146
- const execCommand = getPackageManger() === "bun" ? "bunx" : "npx";
49179
+ const pm = getPackageManger();
49147
49180
  return `You're all set! Now run ${picocolorsExports.cyan(
49148
- `${execCommand} vitepress dev${dir}`
49181
+ `${pm === "npm" ? "npx" : pm} vitepress dev${dir}`
49149
49182
  )} and start writing.${tip}`;
49150
49183
  }
49151
49184
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "vitepress",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Vite & Vue powered static site generator",
5
5
  "type": "module",
6
- "packageManager": "pnpm@8.15.5",
6
+ "packageManager": "pnpm@8.15.6",
7
7
  "main": "dist/node/index.js",
8
8
  "types": "types/index.d.ts",
9
9
  "exports": {
@@ -60,18 +60,18 @@
60
60
  "dependencies": {
61
61
  "@docsearch/css": "^3.6.0",
62
62
  "@docsearch/js": "^3.6.0",
63
- "@shikijs/core": "^1.2.0",
64
- "@shikijs/transformers": "^1.2.0",
63
+ "@shikijs/core": "^1.2.4",
64
+ "@shikijs/transformers": "^1.2.4",
65
65
  "@types/markdown-it": "^13.0.7",
66
66
  "@vitejs/plugin-vue": "^5.0.4",
67
- "@vue/devtools-api": "^7.0.16",
67
+ "@vue/devtools-api": "^7.0.25",
68
68
  "@vueuse/core": "^10.9.0",
69
69
  "@vueuse/integrations": "^10.9.0",
70
70
  "focus-trap": "^7.5.4",
71
71
  "mark.js": "8.11.1",
72
72
  "minisearch": "^6.3.0",
73
- "shiki": "^1.2.0",
74
- "vite": "^5.2.2",
73
+ "shiki": "^1.2.4",
74
+ "vite": "^5.2.8",
75
75
  "vue": "^3.4.21"
76
76
  },
77
77
  "peerDependencies": {
@@ -88,13 +88,13 @@
88
88
  },
89
89
  "devDependencies": {
90
90
  "@clack/prompts": "^0.7.0",
91
- "@mdit-vue/plugin-component": "^2.0.0",
92
- "@mdit-vue/plugin-frontmatter": "^2.0.0",
93
- "@mdit-vue/plugin-headers": "^2.0.0",
94
- "@mdit-vue/plugin-sfc": "^2.0.0",
95
- "@mdit-vue/plugin-title": "^2.0.0",
96
- "@mdit-vue/plugin-toc": "^2.0.0",
97
- "@mdit-vue/shared": "^2.0.0",
91
+ "@mdit-vue/plugin-component": "2.0.0",
92
+ "@mdit-vue/plugin-frontmatter": "2.0.0",
93
+ "@mdit-vue/plugin-headers": "2.0.0",
94
+ "@mdit-vue/plugin-sfc": "2.0.0",
95
+ "@mdit-vue/plugin-title": "2.0.0",
96
+ "@mdit-vue/plugin-toc": "2.0.0",
97
+ "@mdit-vue/shared": "2.0.0",
98
98
  "@polka/compression": "1.0.0-next.25",
99
99
  "@rollup/plugin-alias": "^5.1.0",
100
100
  "@rollup/plugin-commonjs": "^25.0.7",
@@ -108,11 +108,11 @@
108
108
  "@types/lodash.template": "^4.5.3",
109
109
  "@types/mark.js": "^8.11.12",
110
110
  "@types/markdown-it-attrs": "^4.1.3",
111
- "@types/markdown-it-container": "^2.0.9",
112
- "@types/markdown-it-emoji": "^2.0.4",
111
+ "@types/markdown-it-container": "^2.0.10",
112
+ "@types/markdown-it-emoji": "^2.0.5",
113
113
  "@types/micromatch": "^4.0.6",
114
114
  "@types/minimist": "^1.2.5",
115
- "@types/node": "^20.11.30",
115
+ "@types/node": "^20.12.6",
116
116
  "@types/postcss-prefix-selector": "^1.16.3",
117
117
  "@types/prompts": "^2.4.9",
118
118
  "@vue/shared": "^3.4.21",
@@ -138,31 +138,31 @@
138
138
  "markdown-it-mathjax3": "^4.3.2",
139
139
  "micromatch": "^4.0.5",
140
140
  "minimist": "^1.2.8",
141
- "nanoid": "^5.0.6",
141
+ "nanoid": "^5.0.7",
142
142
  "npm-run-all": "^4.1.5",
143
143
  "ora": "^8.0.1",
144
- "p-map": "^7.0.1",
145
- "path-to-regexp": "^6.2.1",
144
+ "p-map": "^7.0.2",
145
+ "path-to-regexp": "^6.2.2",
146
146
  "picocolors": "^1.0.0",
147
147
  "pkg-dir": "^8.0.0",
148
- "playwright-chromium": "^1.42.1",
148
+ "playwright-chromium": "^1.43.0",
149
149
  "polka": "1.0.0-next.25",
150
150
  "postcss-prefix-selector": "^1.16.0",
151
151
  "prettier": "^3.2.5",
152
152
  "prompts": "^2.4.2",
153
153
  "punycode": "^2.3.1",
154
154
  "rimraf": "^5.0.5",
155
- "rollup": "^4.13.0",
155
+ "rollup": "^4.14.1",
156
156
  "rollup-plugin-dts": "^6.1.0",
157
157
  "rollup-plugin-esbuild": "^6.1.1",
158
158
  "semver": "^7.6.0",
159
- "simple-git-hooks": "^2.11.0",
159
+ "simple-git-hooks": "^2.11.1",
160
160
  "sirv": "^2.0.4",
161
161
  "sitemap": "^7.1.1",
162
162
  "supports-color": "^9.4.0",
163
- "typescript": "^5.4.3",
163
+ "typescript": "^5.4.4",
164
164
  "vitest": "^1.4.0",
165
- "vue-tsc": "^2.0.7",
165
+ "vue-tsc": "^2.0.11",
166
166
  "wait-on": "^7.2.0"
167
167
  },
168
168
  "simple-git-hooks": {
@@ -1,9 +0,0 @@
1
- import { inBrowser } from '../../shared';
2
- import { ref } from 'vue';
3
- const hashRef = ref(inBrowser ? location.hash : '');
4
- if (inBrowser) {
5
- window.addEventListener('hashchange', () => {
6
- hashRef.value = location.hash;
7
- });
8
- }
9
- export { hashRef };