vitepress 1.4.1 → 1.4.2

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.
@@ -281,7 +281,7 @@ function onSearchBarClick(event: PointerEvent) {
281
281
  /* Search keyboard selection */
282
282
 
283
283
  const selectedIndex = ref(-1)
284
- const disableMouseOver = ref(false)
284
+ const disableMouseOver = ref(true)
285
285
 
286
286
  watch(results, (r) => {
287
287
  selectedIndex.value = r.length ? 0 : -1
@@ -400,6 +400,16 @@ function formMarkRegex(terms: Set<string>) {
400
400
  'gi'
401
401
  )
402
402
  }
403
+
404
+ function onMouseMove(e: MouseEvent) {
405
+ if (!disableMouseOver.value) return
406
+ const el = (e.target as HTMLElement)?.closest<HTMLAnchorElement>('.result')
407
+ const index = Number.parseInt(el?.dataset.index!)
408
+ if (index >= 0 && index !== selectedIndex.value) {
409
+ selectedIndex.value = index
410
+ }
411
+ disableMouseOver.value = false
412
+ }
403
413
  </script>
404
414
 
405
415
  <template>
@@ -487,7 +497,7 @@ function formMarkRegex(terms: Set<string>) {
487
497
  :role="results?.length ? 'listbox' : undefined"
488
498
  :aria-labelledby="results?.length ? 'localsearch-label' : undefined"
489
499
  class="results"
490
- @mousemove="disableMouseOver = false"
500
+ @mousemove="onMouseMove"
491
501
  >
492
502
  <li
493
503
  v-for="(p, index) in results"
@@ -506,6 +516,7 @@ function formMarkRegex(terms: Set<string>) {
506
516
  @mouseenter="!disableMouseOver && (selectedIndex = index)"
507
517
  @focusin="selectedIndex = index"
508
518
  @click="$emit('close')"
519
+ :data-index="index"
509
520
  >
510
521
  <div>
511
522
  <div class="titles">
@@ -39,8 +39,8 @@ const target = computed(() =>
39
39
  >
40
40
  <slot name="nav-bar-title-before" />
41
41
  <VPImage v-if="theme.logo" class="logo" :image="theme.logo" />
42
- <template v-if="theme.siteTitle"><span>{{ theme.siteTitle }}</span></template>
43
- <template v-else-if="theme.siteTitle === undefined"><span>{{ site.title }}</span></template>
42
+ <span v-if="theme.siteTitle" v-html="theme.siteTitle"></span>
43
+ <span v-else-if="theme.siteTitle === undefined">{{ site.title }}</span>
44
44
  <slot name="nav-bar-title-after" />
45
45
  </a>
46
46
  </div>
@@ -514,6 +514,7 @@
514
514
  z-index: 2;
515
515
  font-size: 12px;
516
516
  font-weight: 500;
517
+ user-select: none;
517
518
  color: var(--vp-code-lang-color);
518
519
  transition:
519
520
  color 0.4s,
@@ -270,9 +270,8 @@
270
270
 
271
271
  :root:where(:lang(zh)) {
272
272
  --vp-font-family-base: 'Punctuation SC', 'Inter', ui-sans-serif, system-ui,
273
- 'PingFang SC', 'Noto Sans CJK SC', 'Noto Sans SC', 'Heiti SC',
274
- 'Microsoft YaHei', 'DengXian', sans-serif, 'Apple Color Emoji',
275
- 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
273
+ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
274
+ 'Noto Color Emoji';
276
275
  }
277
276
 
278
277
  /**
package/dist/node/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { q as getDefaultExportFromCjs, t as c, u as clearCache, l as init, b as build, n as serve, v as version, o as createServer } from './serve-4DnZ8_Si.js';
1
+ import { t as getDefaultExportFromCjs, u as c, n as disposeMdItInstance, v as clearCache, l as init, b as build, o as serve, w as version, q as createServer } from './serve-BSNQCR34.js';
2
2
  import { createLogger } from 'vite';
3
3
  import 'path';
4
4
  import 'shiki';
@@ -357,6 +357,7 @@ const SHORTCUTS = [
357
357
  clear: true,
358
358
  timestamp: true
359
359
  });
360
+ disposeMdItInstance();
360
361
  clearCache();
361
362
  await server.close();
362
363
  await createDevServer();
@@ -2164,7 +2164,7 @@ interface MarkdownOptions extends Options$2 {
2164
2164
  */
2165
2165
  container?: ContainerOptions;
2166
2166
  /**
2167
- * Math support (experimental)
2167
+ * Math support
2168
2168
  *
2169
2169
  * You need to install `markdown-it-mathjax3` and set `math` to `true` to enable it.
2170
2170
  * You can also pass options to `markdown-it-mathjax3` here.
@@ -2181,7 +2181,11 @@ interface MarkdownOptions extends Options$2 {
2181
2181
  gfmAlerts?: boolean;
2182
2182
  }
2183
2183
  type MarkdownRenderer = MarkdownIt;
2184
- declare const createMarkdownRenderer: (srcDir: string, options?: MarkdownOptions, base?: string, logger?: Pick<Logger, "warn">) => Promise<MarkdownRenderer>;
2184
+ declare function disposeMdItInstance(): void;
2185
+ /**
2186
+ * @experimental
2187
+ */
2188
+ declare function createMarkdownRenderer(srcDir: string, options?: MarkdownOptions, base?: string, logger?: Pick<Logger, 'warn'>): Promise<MarkdownRenderer>;
2185
2189
 
2186
2190
  type RawConfigExports<ThemeConfig = any> = Awaitable<UserConfig<ThemeConfig>> | (() => Awaitable<UserConfig<ThemeConfig>>);
2187
2191
  interface TransformContext {
@@ -2608,4 +2612,4 @@ declare function createServer(root?: string, serverOptions?: ServerOptions & {
2608
2612
  base?: string;
2609
2613
  }, recreateServer?: () => Promise<void>): Promise<vite.ViteDevServer>;
2610
2614
 
2611
- export { type ContentData, type ContentOptions, type LoaderModule, type MarkdownOptions, type MarkdownRenderer, type RawConfigExports, type ResolvedRouteConfig, type ScaffoldOptions, ScaffoldThemeType, type ServeOptions, type SiteConfig, type ThemeOptions, type TransformContext, type TransformPageContext, type UserConfig, type UserConfigExport, type UserConfigFn, build, createContentLoader, createMarkdownRenderer, createServer, defineConfig, defineConfigWithTheme, defineLoader, init, mergeConfig, postcssIsolateStyles, resolveConfig, resolvePages, resolveSiteData, resolveUserConfig, scaffold, serve };
2615
+ export { type ContentData, type ContentOptions, type LoaderModule, type MarkdownOptions, type MarkdownRenderer, type RawConfigExports, type ResolvedRouteConfig, type ScaffoldOptions, ScaffoldThemeType, type ServeOptions, type SiteConfig, type ThemeOptions, type TransformContext, type TransformPageContext, type UserConfig, type UserConfigExport, type UserConfigFn, build, createContentLoader, createMarkdownRenderer, createServer, defineConfig, defineConfigWithTheme, defineLoader, disposeMdItInstance, init, mergeConfig, postcssIsolateStyles, resolveConfig, resolvePages, resolveSiteData, resolveUserConfig, scaffold, serve };
@@ -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, p as postcssPrefixSelector } from './serve-4DnZ8_Si.js';
4
- export { S as ScaffoldThemeType, b as build, o as createServer, a as defineConfig, e as defineConfigWithTheme, d as defineLoader, l as init, i as mergeConfig, r as resolveConfig, k as resolvePages, j as resolveSiteData, h as resolveUserConfig, s as scaffold, n as serve } from './serve-4DnZ8_Si.js';
3
+ import { g as glob, c as createMarkdownRenderer, f as fs, m as matter, p as postcssPrefixSelector } from './serve-BSNQCR34.js';
4
+ export { S as ScaffoldThemeType, b as build, q as createServer, a as defineConfig, e as defineConfigWithTheme, d as defineLoader, n as disposeMdItInstance, l as init, i as mergeConfig, r as resolveConfig, k as resolvePages, j as resolveSiteData, h as resolveUserConfig, s as scaffold, o as serve } from './serve-BSNQCR34.js';
5
5
  import path from 'path';
6
6
  import 'crypto';
7
7
  import 'module';
@@ -52,7 +52,6 @@ function createContentLoader(pattern, {
52
52
  }
53
53
  if (typeof pattern === "string") pattern = [pattern];
54
54
  pattern = pattern.map((p) => normalizePath(path.join(config.srcDir, p)));
55
- let md;
56
55
  const cache = /* @__PURE__ */ new Map();
57
56
  return {
58
57
  watch: pattern,
@@ -64,7 +63,7 @@ function createContentLoader(pattern, {
64
63
  ...globOptions
65
64
  })).sort();
66
65
  }
67
- md = md || await createMarkdownRenderer(
66
+ const md = await createMarkdownRenderer(
68
67
  config.srcDir,
69
68
  config.markdown,
70
69
  config.site.base,
@@ -12826,10 +12826,6 @@ function requireSrc$1 () {
12826
12826
  var srcExports$1 = requireSrc$1();
12827
12827
  var _debug = /*@__PURE__*/getDefaultExportFromCjs(srcExports$1);
12828
12828
 
12829
- function commonjsRequire(path) {
12830
- throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
12831
- }
12832
-
12833
12829
  var picocolors = {exports: {}};
12834
12830
 
12835
12831
  var hasRequiredPicocolors;
@@ -12837,29 +12833,19 @@ var hasRequiredPicocolors;
12837
12833
  function requirePicocolors () {
12838
12834
  if (hasRequiredPicocolors) return picocolors.exports;
12839
12835
  hasRequiredPicocolors = 1;
12840
- let argv = process.argv || [],
12841
- env = process.env;
12836
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
12842
12837
  let isColorSupported =
12843
- !("NO_COLOR" in env || argv.includes("--no-color")) &&
12844
- ("FORCE_COLOR" in env ||
12845
- argv.includes("--color") ||
12846
- process.platform === "win32" ||
12847
- (commonjsRequire != null && require$$0$4.isatty(1) && env.TERM !== "dumb") ||
12848
- "CI" in env);
12849
-
12850
- let formatter =
12851
- (open, close, replace = open) =>
12838
+ !(!!env.NO_COLOR || argv.includes("--no-color")) &&
12839
+ (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
12840
+
12841
+ let formatter = (open, close, replace = open) =>
12852
12842
  input => {
12853
- let string = "" + input;
12854
- let index = string.indexOf(close, open.length);
12855
- return ~index
12856
- ? open + replaceClose(string, close, replace, index) + close
12857
- : open + string + close
12843
+ let string = "" + input, index = string.indexOf(close, open.length);
12844
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
12858
12845
  };
12859
12846
 
12860
12847
  let replaceClose = (string, close, replace, index) => {
12861
- let result = "";
12862
- let cursor = 0;
12848
+ let result = "", cursor = 0;
12863
12849
  do {
12864
12850
  result += string.substring(cursor, index) + replace;
12865
12851
  cursor = index + close.length;
@@ -12869,54 +12855,54 @@ function requirePicocolors () {
12869
12855
  };
12870
12856
 
12871
12857
  let createColors = (enabled = isColorSupported) => {
12872
- let init = enabled ? formatter : () => String;
12858
+ let f = enabled ? formatter : () => String;
12873
12859
  return {
12874
12860
  isColorSupported: enabled,
12875
- reset: init("\x1b[0m", "\x1b[0m"),
12876
- bold: init("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
12877
- dim: init("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
12878
- italic: init("\x1b[3m", "\x1b[23m"),
12879
- underline: init("\x1b[4m", "\x1b[24m"),
12880
- inverse: init("\x1b[7m", "\x1b[27m"),
12881
- hidden: init("\x1b[8m", "\x1b[28m"),
12882
- strikethrough: init("\x1b[9m", "\x1b[29m"),
12883
-
12884
- black: init("\x1b[30m", "\x1b[39m"),
12885
- red: init("\x1b[31m", "\x1b[39m"),
12886
- green: init("\x1b[32m", "\x1b[39m"),
12887
- yellow: init("\x1b[33m", "\x1b[39m"),
12888
- blue: init("\x1b[34m", "\x1b[39m"),
12889
- magenta: init("\x1b[35m", "\x1b[39m"),
12890
- cyan: init("\x1b[36m", "\x1b[39m"),
12891
- white: init("\x1b[37m", "\x1b[39m"),
12892
- gray: init("\x1b[90m", "\x1b[39m"),
12893
-
12894
- bgBlack: init("\x1b[40m", "\x1b[49m"),
12895
- bgRed: init("\x1b[41m", "\x1b[49m"),
12896
- bgGreen: init("\x1b[42m", "\x1b[49m"),
12897
- bgYellow: init("\x1b[43m", "\x1b[49m"),
12898
- bgBlue: init("\x1b[44m", "\x1b[49m"),
12899
- bgMagenta: init("\x1b[45m", "\x1b[49m"),
12900
- bgCyan: init("\x1b[46m", "\x1b[49m"),
12901
- bgWhite: init("\x1b[47m", "\x1b[49m"),
12902
-
12903
- blackBright: init("\x1b[90m", "\x1b[39m"),
12904
- redBright: init("\x1b[91m", "\x1b[39m"),
12905
- greenBright: init("\x1b[92m", "\x1b[39m"),
12906
- yellowBright: init("\x1b[93m", "\x1b[39m"),
12907
- blueBright: init("\x1b[94m", "\x1b[39m"),
12908
- magentaBright: init("\x1b[95m", "\x1b[39m"),
12909
- cyanBright: init("\x1b[96m", "\x1b[39m"),
12910
- whiteBright: init("\x1b[97m", "\x1b[39m"),
12911
-
12912
- bgBlackBright: init("\x1b[100m","\x1b[49m"),
12913
- bgRedBright: init("\x1b[101m","\x1b[49m"),
12914
- bgGreenBright: init("\x1b[102m","\x1b[49m"),
12915
- bgYellowBright: init("\x1b[103m","\x1b[49m"),
12916
- bgBlueBright: init("\x1b[104m","\x1b[49m"),
12917
- bgMagentaBright: init("\x1b[105m","\x1b[49m"),
12918
- bgCyanBright: init("\x1b[106m","\x1b[49m"),
12919
- bgWhiteBright: init("\x1b[107m","\x1b[49m"),
12861
+ reset: f("\x1b[0m", "\x1b[0m"),
12862
+ bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
12863
+ dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
12864
+ italic: f("\x1b[3m", "\x1b[23m"),
12865
+ underline: f("\x1b[4m", "\x1b[24m"),
12866
+ inverse: f("\x1b[7m", "\x1b[27m"),
12867
+ hidden: f("\x1b[8m", "\x1b[28m"),
12868
+ strikethrough: f("\x1b[9m", "\x1b[29m"),
12869
+
12870
+ black: f("\x1b[30m", "\x1b[39m"),
12871
+ red: f("\x1b[31m", "\x1b[39m"),
12872
+ green: f("\x1b[32m", "\x1b[39m"),
12873
+ yellow: f("\x1b[33m", "\x1b[39m"),
12874
+ blue: f("\x1b[34m", "\x1b[39m"),
12875
+ magenta: f("\x1b[35m", "\x1b[39m"),
12876
+ cyan: f("\x1b[36m", "\x1b[39m"),
12877
+ white: f("\x1b[37m", "\x1b[39m"),
12878
+ gray: f("\x1b[90m", "\x1b[39m"),
12879
+
12880
+ bgBlack: f("\x1b[40m", "\x1b[49m"),
12881
+ bgRed: f("\x1b[41m", "\x1b[49m"),
12882
+ bgGreen: f("\x1b[42m", "\x1b[49m"),
12883
+ bgYellow: f("\x1b[43m", "\x1b[49m"),
12884
+ bgBlue: f("\x1b[44m", "\x1b[49m"),
12885
+ bgMagenta: f("\x1b[45m", "\x1b[49m"),
12886
+ bgCyan: f("\x1b[46m", "\x1b[49m"),
12887
+ bgWhite: f("\x1b[47m", "\x1b[49m"),
12888
+
12889
+ blackBright: f("\x1b[90m", "\x1b[39m"),
12890
+ redBright: f("\x1b[91m", "\x1b[39m"),
12891
+ greenBright: f("\x1b[92m", "\x1b[39m"),
12892
+ yellowBright: f("\x1b[93m", "\x1b[39m"),
12893
+ blueBright: f("\x1b[94m", "\x1b[39m"),
12894
+ magentaBright: f("\x1b[95m", "\x1b[39m"),
12895
+ cyanBright: f("\x1b[96m", "\x1b[39m"),
12896
+ whiteBright: f("\x1b[97m", "\x1b[39m"),
12897
+
12898
+ bgBlackBright: f("\x1b[100m", "\x1b[49m"),
12899
+ bgRedBright: f("\x1b[101m", "\x1b[49m"),
12900
+ bgGreenBright: f("\x1b[102m", "\x1b[49m"),
12901
+ bgYellowBright: f("\x1b[103m", "\x1b[49m"),
12902
+ bgBlueBright: f("\x1b[104m", "\x1b[49m"),
12903
+ bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
12904
+ bgCyanBright: f("\x1b[106m", "\x1b[49m"),
12905
+ bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
12920
12906
  }
12921
12907
  };
12922
12908
 
@@ -13214,63 +13200,66 @@ function requireResolveSymlink () {
13214
13200
  Object.defineProperty(resolveSymlink, "__esModule", { value: true });
13215
13201
  resolveSymlink.build = void 0;
13216
13202
  const fs_1 = __importDefault(fs$3);
13203
+ const path_1 = path$1;
13217
13204
  const resolveSymlinksAsync = function (path, state, callback) {
13218
- const { queue, options: { suppressErrors }, } = state;
13219
- queue.enqueue();
13220
- fs_1.default.stat(path, (error, stat) => {
13221
- if (error) {
13222
- queue.dequeue(suppressErrors ? null : error, state);
13223
- return;
13224
- }
13225
- callback(stat, path);
13226
- queue.dequeue(null, state);
13227
- });
13228
- };
13229
- const resolveSymlinksWithRealPathsAsync = function (path, state, callback) {
13230
13205
  const { queue, options: { suppressErrors }, } = state;
13231
13206
  queue.enqueue();
13232
13207
  fs_1.default.realpath(path, (error, resolvedPath) => {
13233
- if (error) {
13234
- queue.dequeue(suppressErrors ? null : error, state);
13235
- return;
13236
- }
13237
- fs_1.default.lstat(resolvedPath, (_error, stat) => {
13208
+ if (error)
13209
+ return queue.dequeue(suppressErrors ? null : error, state);
13210
+ fs_1.default.stat(resolvedPath, (error, stat) => {
13211
+ if (error)
13212
+ return queue.dequeue(suppressErrors ? null : error, state);
13213
+ if (stat.isDirectory() && isRecursive(path, resolvedPath, state))
13214
+ return queue.dequeue(null, state);
13238
13215
  callback(stat, resolvedPath);
13239
13216
  queue.dequeue(null, state);
13240
13217
  });
13241
13218
  });
13242
13219
  };
13243
- const resolveSymlinksSync = function (path, state, callback) {
13244
- try {
13245
- const stat = fs_1.default.statSync(path);
13246
- callback(stat, path);
13247
- }
13248
- catch (e) {
13249
- if (!state.options.suppressErrors)
13250
- throw e;
13251
- }
13252
- };
13253
- const resolveSymlinksWithRealPathsSync = function (path, state, callback) {
13220
+ const resolveSymlinks = function (path, state, callback) {
13221
+ const { queue, options: { suppressErrors }, } = state;
13222
+ queue.enqueue();
13254
13223
  try {
13255
13224
  const resolvedPath = fs_1.default.realpathSync(path);
13256
- const stat = fs_1.default.lstatSync(resolvedPath);
13225
+ const stat = fs_1.default.statSync(resolvedPath);
13226
+ if (stat.isDirectory() && isRecursive(path, resolvedPath, state))
13227
+ return;
13257
13228
  callback(stat, resolvedPath);
13258
13229
  }
13259
13230
  catch (e) {
13260
- if (!state.options.suppressErrors)
13231
+ if (!suppressErrors)
13261
13232
  throw e;
13262
13233
  }
13263
13234
  };
13264
13235
  function build(options, isSynchronous) {
13265
13236
  if (!options.resolveSymlinks || options.excludeSymlinks)
13266
13237
  return null;
13267
- if (options.useRealPaths)
13268
- return isSynchronous
13269
- ? resolveSymlinksWithRealPathsSync
13270
- : resolveSymlinksWithRealPathsAsync;
13271
- return isSynchronous ? resolveSymlinksSync : resolveSymlinksAsync;
13238
+ return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
13272
13239
  }
13273
13240
  resolveSymlink.build = build;
13241
+ function isRecursive(path, resolved, state) {
13242
+ if (state.options.useRealPaths)
13243
+ return isRecursiveUsingRealPaths(resolved, state);
13244
+ let parent = (0, path_1.dirname)(path);
13245
+ let depth = 1;
13246
+ while (parent !== state.root && depth < 2) {
13247
+ const resolvedPath = state.symlinks.get(parent);
13248
+ const isSameRoot = !!resolvedPath &&
13249
+ (resolvedPath === resolved ||
13250
+ resolvedPath.startsWith(resolved) ||
13251
+ resolved.startsWith(resolvedPath));
13252
+ if (isSameRoot)
13253
+ depth++;
13254
+ else
13255
+ parent = (0, path_1.dirname)(parent);
13256
+ }
13257
+ state.symlinks.set(path, resolved);
13258
+ return depth > 1;
13259
+ }
13260
+ function isRecursiveUsingRealPaths(resolved, state) {
13261
+ return state.visited.includes(resolved + state.options.pathSeparator);
13262
+ }
13274
13263
  return resolveSymlink;
13275
13264
  }
13276
13265
 
@@ -13354,28 +13343,27 @@ function requireWalkDirectory () {
13354
13343
  walkDirectory.build = void 0;
13355
13344
  const fs_1 = __importDefault(fs$3);
13356
13345
  const readdirOpts = { withFileTypes: true };
13357
- const walkAsync = (state, directoryPath, currentDepth, callback) => {
13358
- state.queue.enqueue();
13359
- if (currentDepth < 0) {
13360
- state.queue.dequeue(null, state);
13361
- return;
13362
- }
13346
+ const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback) => {
13347
+ if (currentDepth < 0)
13348
+ return state.queue.dequeue(null, state);
13349
+ state.visited.push(crawlPath);
13363
13350
  state.counts.directories++;
13351
+ state.queue.enqueue();
13364
13352
  // Perf: Node >= 10 introduced withFileTypes that helps us
13365
13353
  // skip an extra fs.stat call.
13366
- fs_1.default.readdir(directoryPath || ".", readdirOpts, function process(error, entries = []) {
13354
+ fs_1.default.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
13367
13355
  callback(entries, directoryPath, currentDepth);
13368
13356
  state.queue.dequeue(state.options.suppressErrors ? null : error, state);
13369
13357
  });
13370
13358
  };
13371
- const walkSync = (state, directoryPath, currentDepth, callback) => {
13372
- if (currentDepth < 0) {
13359
+ const walkSync = (state, crawlPath, directoryPath, currentDepth, callback) => {
13360
+ if (currentDepth < 0)
13373
13361
  return;
13374
- }
13362
+ state.visited.push(crawlPath);
13375
13363
  state.counts.directories++;
13376
13364
  let entries = [];
13377
13365
  try {
13378
- entries = fs_1.default.readdirSync(directoryPath || ".", readdirOpts);
13366
+ entries = fs_1.default.readdirSync(crawlPath || ".", readdirOpts);
13379
13367
  }
13380
13368
  catch (e) {
13381
13369
  if (!state.options.suppressErrors)
@@ -13414,7 +13402,7 @@ function requireQueue () {
13414
13402
  this.count++;
13415
13403
  }
13416
13404
  dequeue(error, output) {
13417
- if (--this.count === 0 || error)
13405
+ if (--this.count <= 0 || error)
13418
13406
  this.onQueueEmpty(error, output);
13419
13407
  }
13420
13408
  }
@@ -13515,15 +13503,18 @@ function requireWalker () {
13515
13503
  constructor(root, options, callback) {
13516
13504
  this.isSynchronous = !callback;
13517
13505
  this.callbackInvoker = invokeCallback.build(options, this.isSynchronous);
13506
+ this.root = (0, utils_1.normalizePath)(root, options);
13518
13507
  this.state = {
13508
+ root: this.root.slice(0, -1),
13519
13509
  // Perf: we explicitly tell the compiler to optimize for String arrays
13520
13510
  paths: [""].slice(0, 0),
13521
13511
  groups: [],
13522
13512
  counts: new counter_1.Counter(),
13523
13513
  options,
13524
13514
  queue: new queue_1.Queue((error, state) => this.callbackInvoker(state, error, callback)),
13515
+ symlinks: new Map(),
13516
+ visited: [""].slice(0, 0),
13525
13517
  };
13526
- this.root = (0, utils_1.normalizePath)(root, this.state.options);
13527
13518
  /*
13528
13519
  * Perf: We conditionally change functions according to options. This gives a slight
13529
13520
  * performance boost. Since these functions are so small, they are automatically inlined
@@ -13538,11 +13529,11 @@ function requireWalker () {
13538
13529
  this.walkDirectory = walkDirectory.build(this.isSynchronous);
13539
13530
  }
13540
13531
  start() {
13541
- this.walkDirectory(this.state, this.root, this.state.options.maxDepth, this.walk);
13532
+ this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
13542
13533
  return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
13543
13534
  }
13544
13535
  walk = (entries, directoryPath, depth) => {
13545
- const { paths, options: { filters, resolveSymlinks, excludeSymlinks, exclude, maxFiles, signal, }, } = this.state;
13536
+ const { paths, options: { filters, resolveSymlinks, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator, }, } = this.state;
13546
13537
  if ((signal && signal.aborted) || (maxFiles && paths.length > maxFiles))
13547
13538
  return;
13548
13539
  this.pushDirectory(directoryPath, paths, filters);
@@ -13558,7 +13549,7 @@ function requireWalker () {
13558
13549
  let path = joinPath.joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
13559
13550
  if (exclude && exclude(entry.name, path))
13560
13551
  continue;
13561
- this.walkDirectory(this.state, path, depth - 1, this.walk);
13552
+ this.walkDirectory(this.state, path, path, depth - 1, this.walk);
13562
13553
  }
13563
13554
  else if (entry.isSymbolicLink() && this.resolveSymlink) {
13564
13555
  let path = joinPath.joinPathWithBasePath(entry.name, directoryPath);
@@ -13567,9 +13558,10 @@ function requireWalker () {
13567
13558
  resolvedPath = (0, utils_1.normalizePath)(resolvedPath, this.state.options);
13568
13559
  if (exclude && exclude(entry.name, resolvedPath))
13569
13560
  return;
13570
- this.walkDirectory(this.state, resolvedPath, depth - 1, this.walk);
13561
+ this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
13571
13562
  }
13572
13563
  else {
13564
+ resolvedPath = useRealPaths ? resolvedPath : path;
13573
13565
  const filename = (0, path_1.basename)(resolvedPath);
13574
13566
  const directoryPath = (0, utils_1.normalizePath)((0, path_1.dirname)(resolvedPath), this.state.options);
13575
13567
  resolvedPath = this.joinPath(filename, directoryPath);
@@ -16049,21 +16041,27 @@ function normalizePattern(pattern, expandDirectories, cwd, properties, isIgnore)
16049
16041
  function processPatterns({ patterns, ignore = [], expandDirectories = true }, cwd, properties) {
16050
16042
  if (typeof patterns === "string") {
16051
16043
  patterns = [patterns];
16044
+ } else if (!patterns) {
16045
+ patterns = ["**/*"];
16052
16046
  }
16053
16047
  if (typeof ignore === "string") {
16054
16048
  ignore = [ignore];
16055
16049
  }
16056
16050
  const matchPatterns = [];
16057
- const ignorePatterns = ignore.map((p) => normalizePattern(p, expandDirectories, cwd, properties, true));
16058
- if (!patterns) {
16059
- return { match: ["**/*"], ignore: ignorePatterns };
16060
- }
16061
- for (let pattern of patterns) {
16062
- pattern = normalizePattern(pattern, expandDirectories, cwd, properties, false);
16063
- if (pattern.startsWith("!") && pattern[1] !== "(") {
16064
- ignorePatterns.push(pattern.slice(1));
16065
- } else {
16066
- matchPatterns.push(pattern);
16051
+ const ignorePatterns = [];
16052
+ for (const pattern of ignore) {
16053
+ if (!pattern.startsWith("!") || pattern[1] === "(") {
16054
+ const newPattern = normalizePattern(pattern, expandDirectories, cwd, properties, true);
16055
+ ignorePatterns.push(newPattern);
16056
+ }
16057
+ }
16058
+ for (const pattern of patterns) {
16059
+ if (!pattern.startsWith("!") || pattern[1] === "(") {
16060
+ const newPattern = normalizePattern(pattern, expandDirectories, cwd, properties, false);
16061
+ matchPatterns.push(newPattern);
16062
+ } else if (pattern[1] !== "!" || pattern[2] === "(") {
16063
+ const newPattern = normalizePattern(pattern.slice(1), expandDirectories, cwd, properties, true);
16064
+ ignorePatterns.push(newPattern);
16067
16065
  }
16068
16066
  }
16069
16067
  return { match: matchPatterns, ignore: ignorePatterns };
@@ -16099,8 +16097,8 @@ function crawl(options, cwd, sync) {
16099
16097
  filters: [(p, isDirectory) => matcher(processPath(p, cwd, properties.root, isDirectory, options.absolute))],
16100
16098
  exclude: (_, p) => exclude(processPath(p, cwd, properties.root, true, true)),
16101
16099
  pathSeparator: "/",
16102
- relativePaths: true
16103
- // resolveSymlinks: true
16100
+ relativePaths: true,
16101
+ resolveSymlinks: true
16104
16102
  };
16105
16103
  if (options.deep) {
16106
16104
  fdirOptions.maxDepth = Math.round(options.deep - properties.depthOffset);
@@ -18821,6 +18819,10 @@ function requireMerge () {
18821
18819
  return merge;
18822
18820
  }
18823
18821
 
18822
+ function commonjsRequire(path) {
18823
+ throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
18824
+ }
18825
+
18824
18826
  var binary$1;
18825
18827
  var hasRequiredBinary;
18826
18828
 
@@ -34453,7 +34455,7 @@ function capitalize(str) {
34453
34455
  }
34454
34456
 
34455
34457
  const nanoid = customAlphabet("abcdefghijklmnopqrstuvwxyz", 10);
34456
- const attrsToLines = (attrs) => {
34458
+ function attrsToLines(attrs) {
34457
34459
  attrs = attrs.replace(/^(?:\[.*?\])?.*?([\d,-]+).*/, "$1").trim();
34458
34460
  const result = [];
34459
34461
  if (!attrs) {
@@ -34472,7 +34474,7 @@ const attrsToLines = (attrs) => {
34472
34474
  line: v,
34473
34475
  classes: ["highlighted"]
34474
34476
  }));
34475
- };
34477
+ }
34476
34478
  async function highlight(theme, options, logger = console) {
34477
34479
  const {
34478
34480
  defaultHighlightLang: defaultLang = "",
@@ -34509,74 +34511,77 @@ async function highlight(theme, options, logger = console) {
34509
34511
  const lineNoStartRE = /=(\d*)/;
34510
34512
  const lineNoRE = /:(no-)?line-numbers(=\d*)?$/;
34511
34513
  const mustacheRE = /\{\{.*?\}\}/g;
34512
- return (str, lang, attrs) => {
34513
- const vPre = vueRE.test(lang) ? "" : "v-pre";
34514
- lang = lang.replace(lineNoStartRE, "").replace(lineNoRE, "").replace(vueRE, "").toLowerCase() || defaultLang;
34515
- if (lang) {
34516
- const langLoaded = highlighter.getLoadedLanguages().includes(lang);
34517
- if (!langLoaded && !isSpecialLang(lang)) {
34518
- logger.warn(
34519
- c$1.yellow(
34520
- `
34514
+ return [
34515
+ (str, lang, attrs) => {
34516
+ const vPre = vueRE.test(lang) ? "" : "v-pre";
34517
+ lang = lang.replace(lineNoStartRE, "").replace(lineNoRE, "").replace(vueRE, "").toLowerCase() || defaultLang;
34518
+ if (lang) {
34519
+ const langLoaded = highlighter.getLoadedLanguages().includes(lang);
34520
+ if (!langLoaded && !isSpecialLang(lang)) {
34521
+ logger.warn(
34522
+ c$1.yellow(
34523
+ `
34521
34524
  The language '${lang}' is not loaded, falling back to '${defaultLang || "txt"}' for syntax highlighting.`
34522
- )
34523
- );
34524
- lang = defaultLang;
34525
+ )
34526
+ );
34527
+ lang = defaultLang;
34528
+ }
34525
34529
  }
34526
- }
34527
- const lineOptions = attrsToLines(attrs);
34528
- const mustaches = /* @__PURE__ */ new Map();
34529
- const removeMustache = (s) => {
34530
- if (vPre) return s;
34531
- return s.replace(mustacheRE, (match) => {
34532
- let marker = mustaches.get(match);
34533
- if (!marker) {
34534
- marker = nanoid();
34535
- mustaches.set(match, marker);
34536
- }
34537
- return marker;
34538
- });
34539
- };
34540
- const restoreMustache = (s) => {
34541
- mustaches.forEach((marker, match) => {
34542
- s = s.replaceAll(marker, match);
34543
- });
34544
- return s;
34545
- };
34546
- str = removeMustache(str).trimEnd();
34547
- const highlighted = highlighter.codeToHtml(str, {
34548
- lang,
34549
- transformers: [
34550
- ...transformers,
34551
- transformerCompactLineOptions(lineOptions),
34552
- {
34553
- name: "vitepress:v-pre",
34554
- pre(node) {
34555
- if (vPre) node.properties["v-pre"] = "";
34530
+ const lineOptions = attrsToLines(attrs);
34531
+ const mustaches = /* @__PURE__ */ new Map();
34532
+ const removeMustache = (s) => {
34533
+ if (vPre) return s;
34534
+ return s.replace(mustacheRE, (match) => {
34535
+ let marker = mustaches.get(match);
34536
+ if (!marker) {
34537
+ marker = nanoid();
34538
+ mustaches.set(match, marker);
34556
34539
  }
34557
- },
34558
- {
34559
- name: "vitepress:empty-line",
34560
- code(hast) {
34561
- hast.children.forEach((span) => {
34562
- if (span.type === "element" && span.tagName === "span" && Array.isArray(span.properties.class) && span.properties.class.includes("line") && span.children.length === 0) {
34563
- span.children.push({
34564
- type: "element",
34565
- tagName: "wbr",
34566
- properties: {},
34567
- children: []
34568
- });
34569
- }
34570
- });
34571
- }
34572
- },
34573
- ...userTransformers
34574
- ],
34575
- meta: { __raw: attrs },
34576
- ...typeof theme === "object" && "light" in theme && "dark" in theme ? { themes: theme, defaultColor: false } : { theme }
34577
- });
34578
- return restoreMustache(highlighted);
34579
- };
34540
+ return marker;
34541
+ });
34542
+ };
34543
+ const restoreMustache = (s) => {
34544
+ mustaches.forEach((marker, match) => {
34545
+ s = s.replaceAll(marker, match);
34546
+ });
34547
+ return s;
34548
+ };
34549
+ str = removeMustache(str).trimEnd();
34550
+ const highlighted = highlighter.codeToHtml(str, {
34551
+ lang,
34552
+ transformers: [
34553
+ ...transformers,
34554
+ transformerCompactLineOptions(lineOptions),
34555
+ {
34556
+ name: "vitepress:v-pre",
34557
+ pre(node) {
34558
+ if (vPre) node.properties["v-pre"] = "";
34559
+ }
34560
+ },
34561
+ {
34562
+ name: "vitepress:empty-line",
34563
+ code(hast) {
34564
+ hast.children.forEach((span) => {
34565
+ if (span.type === "element" && span.tagName === "span" && Array.isArray(span.properties.class) && span.properties.class.includes("line") && span.children.length === 0) {
34566
+ span.children.push({
34567
+ type: "element",
34568
+ tagName: "wbr",
34569
+ properties: {},
34570
+ children: []
34571
+ });
34572
+ }
34573
+ });
34574
+ }
34575
+ },
34576
+ ...userTransformers
34577
+ ],
34578
+ meta: { __raw: attrs },
34579
+ ...typeof theme === "object" && "light" in theme && "dark" in theme ? { themes: theme, defaultColor: false } : { theme }
34580
+ });
34581
+ return restoreMustache(highlighted);
34582
+ },
34583
+ highlighter.dispose
34584
+ ];
34580
34585
  }
34581
34586
 
34582
34587
  const RE = /{([\d,-]+)}/;
@@ -34872,16 +34877,23 @@ const snippetPlugin = (md, srcDir) => {
34872
34877
  md.block.ruler.before("fence", "snippet", parser);
34873
34878
  };
34874
34879
 
34875
- const createMarkdownRenderer = async (srcDir, options = {}, base = "/", logger = console) => {
34880
+ let md;
34881
+ let _disposeHighlighter;
34882
+ function disposeMdItInstance() {
34883
+ if (md) {
34884
+ md = void 0;
34885
+ _disposeHighlighter?.();
34886
+ }
34887
+ }
34888
+ async function createMarkdownRenderer(srcDir, options = {}, base = "/", logger = console) {
34889
+ if (md) return md;
34876
34890
  const theme = options.theme ?? { light: "github-light", dark: "github-dark" };
34877
34891
  const codeCopyButtonTitle = options.codeCopyButtonTitle || "Copy Code";
34878
34892
  const hasSingleTheme = typeof theme === "string" || "name" in theme;
34879
- const md = MarkdownIt({
34880
- html: true,
34881
- linkify: true,
34882
- highlight: options.highlight || await highlight(theme, options, logger),
34883
- ...options
34884
- });
34893
+ let [highlight$1, dispose] = options.highlight ? [options.highlight, () => {
34894
+ }] : await highlight(theme, options, logger);
34895
+ _disposeHighlighter = dispose;
34896
+ md = MarkdownIt({ html: true, linkify: true, highlight: highlight$1, ...options });
34885
34897
  md.linkify.set({ fuzzyLink: false });
34886
34898
  md.use(restoreEntities);
34887
34899
  if (options.preConfig) {
@@ -34957,7 +34969,7 @@ const createMarkdownRenderer = async (srcDir, options = {}, base = "/", logger =
34957
34969
  options.config(md);
34958
34970
  }
34959
34971
  return md;
34960
- };
34972
+ }
34961
34973
 
34962
34974
  var crossSpawn = {exports: {}};
34963
34975
 
@@ -44282,6 +44294,7 @@ async function createVitePressPlugin(siteConfig, ssr = false, pageToHashMap, cli
44282
44294
  siteConfig.logger.error(err);
44283
44295
  return;
44284
44296
  }
44297
+ disposeMdItInstance();
44285
44298
  clearCache();
44286
44299
  await recreateServer?.();
44287
44300
  return;
@@ -44315,7 +44328,7 @@ async function createVitePressPlugin(siteConfig, ssr = false, pageToHashMap, cli
44315
44328
  return [
44316
44329
  ...modules,
44317
44330
  ...importers.map((id) => {
44318
- clearCache(id);
44331
+ clearCache(slash(path$1.relative(srcDir, id)));
44319
44332
  return server.moduleGraph.getModuleById(id);
44320
44333
  })
44321
44334
  ].filter(Boolean);
@@ -48508,7 +48521,7 @@ async function generateSitemap(siteConfig) {
48508
48521
  });
48509
48522
  }
48510
48523
 
48511
- var version = "1.4.1";
48524
+ var version = "1.4.2";
48512
48525
 
48513
48526
  async function renderPage(render, config, page, result, appChunk, cssChunk, assets, pageToHashMap, metadataScript, additionalHeadTags) {
48514
48527
  const routePath = `/${page.replace(/\.md$/, "")}`;
@@ -52331,4 +52344,4 @@ async function createServer(root = process.cwd(), serverOptions = {}, recreateSe
52331
52344
  });
52332
52345
  }
52333
52346
 
52334
- export { ScaffoldThemeType as S, defineConfig as a, build as b, createMarkdownRenderer as c, defineLoader as d, defineConfigWithTheme as e, fs as f, glob as g, resolveUserConfig as h, mergeConfig as i, resolveSiteData as j, resolvePages as k, init as l, matter as m, serve as n, createServer as o, postcssPrefixSelector as p, getDefaultExportFromCjs as q, resolveConfig as r, scaffold as s, c$1 as t, clearCache as u, version as v };
52347
+ export { ScaffoldThemeType as S, defineConfig as a, build as b, createMarkdownRenderer as c, defineLoader as d, defineConfigWithTheme as e, fs as f, glob as g, resolveUserConfig as h, mergeConfig as i, resolveSiteData as j, resolvePages as k, init as l, matter as m, disposeMdItInstance as n, serve as o, postcssPrefixSelector as p, createServer as q, resolveConfig as r, scaffold as s, getDefaultExportFromCjs as t, c$1 as u, clearCache as v, version as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitepress",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Vite & Vue powered static site generator",
5
5
  "keywords": [
6
6
  "vite",
@@ -62,20 +62,20 @@
62
62
  "dependencies": {
63
63
  "@docsearch/css": "^3.6.2",
64
64
  "@docsearch/js": "^3.6.2",
65
- "@shikijs/core": "^1.22.0",
66
- "@shikijs/transformers": "^1.22.0",
67
- "@shikijs/types": "^1.22.0",
65
+ "@shikijs/core": "^1.22.2",
66
+ "@shikijs/transformers": "^1.22.2",
67
+ "@shikijs/types": "^1.22.2",
68
68
  "@types/markdown-it": "^14.1.2",
69
69
  "@vitejs/plugin-vue": "^5.1.4",
70
- "@vue/devtools-api": "^7.4.6",
70
+ "@vue/devtools-api": "^7.5.4",
71
71
  "@vue/shared": "^3.5.12",
72
72
  "@vueuse/core": "^11.1.0",
73
73
  "@vueuse/integrations": "^11.1.0",
74
74
  "focus-trap": "^7.6.0",
75
75
  "mark.js": "8.11.1",
76
76
  "minisearch": "^7.1.0",
77
- "shiki": "^1.22.0",
78
- "vite": "^5.4.8",
77
+ "shiki": "^1.22.2",
78
+ "vite": "^5.4.10",
79
79
  "vue": "^3.5.12"
80
80
  },
81
81
  "devDependencies": {
@@ -89,7 +89,7 @@
89
89
  "@mdit-vue/shared": "^2.1.3",
90
90
  "@polka/compression": "^1.0.0-next.28",
91
91
  "@rollup/plugin-alias": "^5.1.1",
92
- "@rollup/plugin-commonjs": "^28.0.0",
92
+ "@rollup/plugin-commonjs": "^28.0.1",
93
93
  "@rollup/plugin-json": "^6.1.0",
94
94
  "@rollup/plugin-node-resolve": "^15.3.0",
95
95
  "@rollup/plugin-replace": "^6.0.1",
@@ -103,7 +103,7 @@
103
103
  "@types/markdown-it-emoji": "^3.0.1",
104
104
  "@types/micromatch": "^4.0.9",
105
105
  "@types/minimist": "^1.2.5",
106
- "@types/node": "^22.7.5",
106
+ "@types/node": "^22.8.2",
107
107
  "@types/postcss-prefix-selector": "^1.16.3",
108
108
  "@types/prompts": "^2.4.9",
109
109
  "chokidar": "^3.6.0",
@@ -111,7 +111,7 @@
111
111
  "cross-spawn": "^7.0.3",
112
112
  "debug": "^4.3.7",
113
113
  "esbuild": "^0.24.0",
114
- "execa": "^9.4.0",
114
+ "execa": "^9.5.1",
115
115
  "fs-extra": "^11.2.0",
116
116
  "get-port": "^7.1.0",
117
117
  "gray-matter": "^4.0.3",
@@ -126,20 +126,20 @@
126
126
  "markdown-it-mathjax3": "^4.3.2",
127
127
  "micromatch": "^4.0.8",
128
128
  "minimist": "^1.2.8",
129
- "nanoid": "^5.0.7",
129
+ "nanoid": "^5.0.8",
130
130
  "ora": "^8.1.0",
131
131
  "p-map": "^7.0.2",
132
132
  "path-to-regexp": "^6.3.0",
133
- "picocolors": "^1.1.0",
133
+ "picocolors": "^1.1.1",
134
134
  "pkg-dir": "^8.0.0",
135
- "playwright-chromium": "^1.48.0",
135
+ "playwright-chromium": "^1.48.2",
136
136
  "polka": "^1.0.0-next.28",
137
137
  "postcss-prefix-selector": "^2.1.0",
138
138
  "prettier": "^3.3.3",
139
139
  "prompts": "^2.4.2",
140
140
  "punycode": "^2.3.1",
141
141
  "rimraf": "^6.0.1",
142
- "rollup": "^4.24.0",
142
+ "rollup": "^4.24.2",
143
143
  "rollup-plugin-dts": "^6.1.1",
144
144
  "rollup-plugin-esbuild": "^6.1.1",
145
145
  "semver": "^7.6.3",
@@ -147,10 +147,10 @@
147
147
  "sirv": "^3.0.0",
148
148
  "sitemap": "^8.0.0",
149
149
  "supports-color": "^9.4.0",
150
- "tinyglobby": "^0.2.9",
150
+ "tinyglobby": "^0.2.10",
151
151
  "typescript": "^5.6.3",
152
- "vitest": "^2.1.2",
153
- "vue-tsc": "^2.1.6",
152
+ "vitest": "^2.1.4",
153
+ "vue-tsc": "^2.1.8",
154
154
  "wait-on": "^8.0.1"
155
155
  },
156
156
  "peerDependencies": {
package/theme.d.ts CHANGED
@@ -24,6 +24,9 @@ export declare const VPHomeFeatures: DefineComponent
24
24
  export declare const VPHomeHero: DefineComponent
25
25
  export declare const VPHomeSponsors: DefineComponent
26
26
  export declare const VPImage: DefineComponent
27
+ export declare const VPLink: DefineComponent
28
+ export declare const VPSocialLink: DefineComponent
29
+ export declare const VPSocialLinks: DefineComponent
27
30
  export declare const VPSponsors: DefineComponent
28
31
  export declare const VPTeamMembers: DefineComponent
29
32
  export declare const VPTeamPage: DefineComponent