vitepress 1.4.1 → 1.4.3

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.
@@ -31,8 +31,10 @@ import require$$0$4 from 'tty';
31
31
  import require$$0$1 from 'constants';
32
32
  import require$$5 from 'assert';
33
33
  import { webcrypto } from 'node:crypto';
34
- import { createHighlighter, bundledLanguages, isSpecialLang } from 'shiki';
35
34
  import { transformerNotationDiff, transformerNotationFocus, transformerNotationHighlight, transformerNotationErrorLevel, transformerCompactLineOptions } from '@shikijs/transformers';
35
+ import { createRequire as createRequire$1 } from 'node:module';
36
+ import { createHighlighter, isSpecialLang } from 'shiki';
37
+ import { c as createSyncFn } from './chunk-DQlKmeN_.js';
36
38
  import MiniSearch from 'minisearch';
37
39
 
38
40
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -12826,10 +12828,6 @@ function requireSrc$1 () {
12826
12828
  var srcExports$1 = requireSrc$1();
12827
12829
  var _debug = /*@__PURE__*/getDefaultExportFromCjs(srcExports$1);
12828
12830
 
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
12831
  var picocolors = {exports: {}};
12834
12832
 
12835
12833
  var hasRequiredPicocolors;
@@ -12837,29 +12835,19 @@ var hasRequiredPicocolors;
12837
12835
  function requirePicocolors () {
12838
12836
  if (hasRequiredPicocolors) return picocolors.exports;
12839
12837
  hasRequiredPicocolors = 1;
12840
- let argv = process.argv || [],
12841
- env = process.env;
12838
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
12842
12839
  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) =>
12840
+ !(!!env.NO_COLOR || argv.includes("--no-color")) &&
12841
+ (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
12842
+
12843
+ let formatter = (open, close, replace = open) =>
12852
12844
  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
12845
+ let string = "" + input, index = string.indexOf(close, open.length);
12846
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
12858
12847
  };
12859
12848
 
12860
12849
  let replaceClose = (string, close, replace, index) => {
12861
- let result = "";
12862
- let cursor = 0;
12850
+ let result = "", cursor = 0;
12863
12851
  do {
12864
12852
  result += string.substring(cursor, index) + replace;
12865
12853
  cursor = index + close.length;
@@ -12869,54 +12857,54 @@ function requirePicocolors () {
12869
12857
  };
12870
12858
 
12871
12859
  let createColors = (enabled = isColorSupported) => {
12872
- let init = enabled ? formatter : () => String;
12860
+ let f = enabled ? formatter : () => String;
12873
12861
  return {
12874
12862
  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"),
12863
+ reset: f("\x1b[0m", "\x1b[0m"),
12864
+ bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
12865
+ dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
12866
+ italic: f("\x1b[3m", "\x1b[23m"),
12867
+ underline: f("\x1b[4m", "\x1b[24m"),
12868
+ inverse: f("\x1b[7m", "\x1b[27m"),
12869
+ hidden: f("\x1b[8m", "\x1b[28m"),
12870
+ strikethrough: f("\x1b[9m", "\x1b[29m"),
12871
+
12872
+ black: f("\x1b[30m", "\x1b[39m"),
12873
+ red: f("\x1b[31m", "\x1b[39m"),
12874
+ green: f("\x1b[32m", "\x1b[39m"),
12875
+ yellow: f("\x1b[33m", "\x1b[39m"),
12876
+ blue: f("\x1b[34m", "\x1b[39m"),
12877
+ magenta: f("\x1b[35m", "\x1b[39m"),
12878
+ cyan: f("\x1b[36m", "\x1b[39m"),
12879
+ white: f("\x1b[37m", "\x1b[39m"),
12880
+ gray: f("\x1b[90m", "\x1b[39m"),
12881
+
12882
+ bgBlack: f("\x1b[40m", "\x1b[49m"),
12883
+ bgRed: f("\x1b[41m", "\x1b[49m"),
12884
+ bgGreen: f("\x1b[42m", "\x1b[49m"),
12885
+ bgYellow: f("\x1b[43m", "\x1b[49m"),
12886
+ bgBlue: f("\x1b[44m", "\x1b[49m"),
12887
+ bgMagenta: f("\x1b[45m", "\x1b[49m"),
12888
+ bgCyan: f("\x1b[46m", "\x1b[49m"),
12889
+ bgWhite: f("\x1b[47m", "\x1b[49m"),
12890
+
12891
+ blackBright: f("\x1b[90m", "\x1b[39m"),
12892
+ redBright: f("\x1b[91m", "\x1b[39m"),
12893
+ greenBright: f("\x1b[92m", "\x1b[39m"),
12894
+ yellowBright: f("\x1b[93m", "\x1b[39m"),
12895
+ blueBright: f("\x1b[94m", "\x1b[39m"),
12896
+ magentaBright: f("\x1b[95m", "\x1b[39m"),
12897
+ cyanBright: f("\x1b[96m", "\x1b[39m"),
12898
+ whiteBright: f("\x1b[97m", "\x1b[39m"),
12899
+
12900
+ bgBlackBright: f("\x1b[100m", "\x1b[49m"),
12901
+ bgRedBright: f("\x1b[101m", "\x1b[49m"),
12902
+ bgGreenBright: f("\x1b[102m", "\x1b[49m"),
12903
+ bgYellowBright: f("\x1b[103m", "\x1b[49m"),
12904
+ bgBlueBright: f("\x1b[104m", "\x1b[49m"),
12905
+ bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
12906
+ bgCyanBright: f("\x1b[106m", "\x1b[49m"),
12907
+ bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
12920
12908
  }
12921
12909
  };
12922
12910
 
@@ -12928,7 +12916,7 @@ function requirePicocolors () {
12928
12916
  var picocolorsExports = /*@__PURE__*/ requirePicocolors();
12929
12917
  var c$1 = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
12930
12918
 
12931
- const require$1 = createRequire(import.meta.url);
12919
+ const require$2 = createRequire(import.meta.url);
12932
12920
  const PKG_ROOT = resolve$1(fileURLToPath$1(import.meta.url), "../..");
12933
12921
  const DIST_CLIENT_PATH = resolve$1(PKG_ROOT, "client");
12934
12922
  const APP_PATH = join(DIST_CLIENT_PATH, "app");
@@ -12957,15 +12945,15 @@ function resolveAliases({ root, themeDir }, ssr) {
12957
12945
  },
12958
12946
  {
12959
12947
  find: /^vue-demi$/,
12960
- replacement: require$1.resolve("vitepress/vue-demi")
12948
+ replacement: require$2.resolve("vitepress/vue-demi")
12961
12949
  }
12962
12950
  ];
12963
12951
  if (!ssr) {
12964
12952
  let vuePath;
12965
12953
  try {
12966
- vuePath = require$1.resolve(vueRuntimePath, { paths: [root] });
12954
+ vuePath = require$2.resolve(vueRuntimePath, { paths: [root] });
12967
12955
  } catch (e) {
12968
- vuePath = require$1.resolve(vueRuntimePath);
12956
+ vuePath = require$2.resolve(vueRuntimePath);
12969
12957
  }
12970
12958
  aliases.push({
12971
12959
  find: /^vue$/,
@@ -13214,63 +13202,66 @@ function requireResolveSymlink () {
13214
13202
  Object.defineProperty(resolveSymlink, "__esModule", { value: true });
13215
13203
  resolveSymlink.build = void 0;
13216
13204
  const fs_1 = __importDefault(fs$3);
13205
+ const path_1 = path$1;
13217
13206
  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
13207
  const { queue, options: { suppressErrors }, } = state;
13231
13208
  queue.enqueue();
13232
13209
  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) => {
13210
+ if (error)
13211
+ return queue.dequeue(suppressErrors ? null : error, state);
13212
+ fs_1.default.stat(resolvedPath, (error, stat) => {
13213
+ if (error)
13214
+ return queue.dequeue(suppressErrors ? null : error, state);
13215
+ if (stat.isDirectory() && isRecursive(path, resolvedPath, state))
13216
+ return queue.dequeue(null, state);
13238
13217
  callback(stat, resolvedPath);
13239
13218
  queue.dequeue(null, state);
13240
13219
  });
13241
13220
  });
13242
13221
  };
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) {
13222
+ const resolveSymlinks = function (path, state, callback) {
13223
+ const { queue, options: { suppressErrors }, } = state;
13224
+ queue.enqueue();
13254
13225
  try {
13255
13226
  const resolvedPath = fs_1.default.realpathSync(path);
13256
- const stat = fs_1.default.lstatSync(resolvedPath);
13227
+ const stat = fs_1.default.statSync(resolvedPath);
13228
+ if (stat.isDirectory() && isRecursive(path, resolvedPath, state))
13229
+ return;
13257
13230
  callback(stat, resolvedPath);
13258
13231
  }
13259
13232
  catch (e) {
13260
- if (!state.options.suppressErrors)
13233
+ if (!suppressErrors)
13261
13234
  throw e;
13262
13235
  }
13263
13236
  };
13264
13237
  function build(options, isSynchronous) {
13265
13238
  if (!options.resolveSymlinks || options.excludeSymlinks)
13266
13239
  return null;
13267
- if (options.useRealPaths)
13268
- return isSynchronous
13269
- ? resolveSymlinksWithRealPathsSync
13270
- : resolveSymlinksWithRealPathsAsync;
13271
- return isSynchronous ? resolveSymlinksSync : resolveSymlinksAsync;
13240
+ return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
13272
13241
  }
13273
13242
  resolveSymlink.build = build;
13243
+ function isRecursive(path, resolved, state) {
13244
+ if (state.options.useRealPaths)
13245
+ return isRecursiveUsingRealPaths(resolved, state);
13246
+ let parent = (0, path_1.dirname)(path);
13247
+ let depth = 1;
13248
+ while (parent !== state.root && depth < 2) {
13249
+ const resolvedPath = state.symlinks.get(parent);
13250
+ const isSameRoot = !!resolvedPath &&
13251
+ (resolvedPath === resolved ||
13252
+ resolvedPath.startsWith(resolved) ||
13253
+ resolved.startsWith(resolvedPath));
13254
+ if (isSameRoot)
13255
+ depth++;
13256
+ else
13257
+ parent = (0, path_1.dirname)(parent);
13258
+ }
13259
+ state.symlinks.set(path, resolved);
13260
+ return depth > 1;
13261
+ }
13262
+ function isRecursiveUsingRealPaths(resolved, state) {
13263
+ return state.visited.includes(resolved + state.options.pathSeparator);
13264
+ }
13274
13265
  return resolveSymlink;
13275
13266
  }
13276
13267
 
@@ -13354,28 +13345,27 @@ function requireWalkDirectory () {
13354
13345
  walkDirectory.build = void 0;
13355
13346
  const fs_1 = __importDefault(fs$3);
13356
13347
  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
- }
13348
+ const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback) => {
13349
+ if (currentDepth < 0)
13350
+ return state.queue.dequeue(null, state);
13351
+ state.visited.push(crawlPath);
13363
13352
  state.counts.directories++;
13353
+ state.queue.enqueue();
13364
13354
  // Perf: Node >= 10 introduced withFileTypes that helps us
13365
13355
  // skip an extra fs.stat call.
13366
- fs_1.default.readdir(directoryPath || ".", readdirOpts, function process(error, entries = []) {
13356
+ fs_1.default.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
13367
13357
  callback(entries, directoryPath, currentDepth);
13368
13358
  state.queue.dequeue(state.options.suppressErrors ? null : error, state);
13369
13359
  });
13370
13360
  };
13371
- const walkSync = (state, directoryPath, currentDepth, callback) => {
13372
- if (currentDepth < 0) {
13361
+ const walkSync = (state, crawlPath, directoryPath, currentDepth, callback) => {
13362
+ if (currentDepth < 0)
13373
13363
  return;
13374
- }
13364
+ state.visited.push(crawlPath);
13375
13365
  state.counts.directories++;
13376
13366
  let entries = [];
13377
13367
  try {
13378
- entries = fs_1.default.readdirSync(directoryPath || ".", readdirOpts);
13368
+ entries = fs_1.default.readdirSync(crawlPath || ".", readdirOpts);
13379
13369
  }
13380
13370
  catch (e) {
13381
13371
  if (!state.options.suppressErrors)
@@ -13414,7 +13404,7 @@ function requireQueue () {
13414
13404
  this.count++;
13415
13405
  }
13416
13406
  dequeue(error, output) {
13417
- if (--this.count === 0 || error)
13407
+ if (--this.count <= 0 || error)
13418
13408
  this.onQueueEmpty(error, output);
13419
13409
  }
13420
13410
  }
@@ -13515,15 +13505,18 @@ function requireWalker () {
13515
13505
  constructor(root, options, callback) {
13516
13506
  this.isSynchronous = !callback;
13517
13507
  this.callbackInvoker = invokeCallback.build(options, this.isSynchronous);
13508
+ this.root = (0, utils_1.normalizePath)(root, options);
13518
13509
  this.state = {
13510
+ root: this.root.slice(0, -1),
13519
13511
  // Perf: we explicitly tell the compiler to optimize for String arrays
13520
13512
  paths: [""].slice(0, 0),
13521
13513
  groups: [],
13522
13514
  counts: new counter_1.Counter(),
13523
13515
  options,
13524
13516
  queue: new queue_1.Queue((error, state) => this.callbackInvoker(state, error, callback)),
13517
+ symlinks: new Map(),
13518
+ visited: [""].slice(0, 0),
13525
13519
  };
13526
- this.root = (0, utils_1.normalizePath)(root, this.state.options);
13527
13520
  /*
13528
13521
  * Perf: We conditionally change functions according to options. This gives a slight
13529
13522
  * performance boost. Since these functions are so small, they are automatically inlined
@@ -13538,11 +13531,11 @@ function requireWalker () {
13538
13531
  this.walkDirectory = walkDirectory.build(this.isSynchronous);
13539
13532
  }
13540
13533
  start() {
13541
- this.walkDirectory(this.state, this.root, this.state.options.maxDepth, this.walk);
13534
+ this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
13542
13535
  return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
13543
13536
  }
13544
13537
  walk = (entries, directoryPath, depth) => {
13545
- const { paths, options: { filters, resolveSymlinks, excludeSymlinks, exclude, maxFiles, signal, }, } = this.state;
13538
+ const { paths, options: { filters, resolveSymlinks, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator, }, } = this.state;
13546
13539
  if ((signal && signal.aborted) || (maxFiles && paths.length > maxFiles))
13547
13540
  return;
13548
13541
  this.pushDirectory(directoryPath, paths, filters);
@@ -13558,7 +13551,7 @@ function requireWalker () {
13558
13551
  let path = joinPath.joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
13559
13552
  if (exclude && exclude(entry.name, path))
13560
13553
  continue;
13561
- this.walkDirectory(this.state, path, depth - 1, this.walk);
13554
+ this.walkDirectory(this.state, path, path, depth - 1, this.walk);
13562
13555
  }
13563
13556
  else if (entry.isSymbolicLink() && this.resolveSymlink) {
13564
13557
  let path = joinPath.joinPathWithBasePath(entry.name, directoryPath);
@@ -13567,9 +13560,10 @@ function requireWalker () {
13567
13560
  resolvedPath = (0, utils_1.normalizePath)(resolvedPath, this.state.options);
13568
13561
  if (exclude && exclude(entry.name, resolvedPath))
13569
13562
  return;
13570
- this.walkDirectory(this.state, resolvedPath, depth - 1, this.walk);
13563
+ this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
13571
13564
  }
13572
13565
  else {
13566
+ resolvedPath = useRealPaths ? resolvedPath : path;
13573
13567
  const filename = (0, path_1.basename)(resolvedPath);
13574
13568
  const directoryPath = (0, utils_1.normalizePath)((0, path_1.dirname)(resolvedPath), this.state.options);
13575
13569
  resolvedPath = this.joinPath(filename, directoryPath);
@@ -16049,21 +16043,27 @@ function normalizePattern(pattern, expandDirectories, cwd, properties, isIgnore)
16049
16043
  function processPatterns({ patterns, ignore = [], expandDirectories = true }, cwd, properties) {
16050
16044
  if (typeof patterns === "string") {
16051
16045
  patterns = [patterns];
16046
+ } else if (!patterns) {
16047
+ patterns = ["**/*"];
16052
16048
  }
16053
16049
  if (typeof ignore === "string") {
16054
16050
  ignore = [ignore];
16055
16051
  }
16056
16052
  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);
16053
+ const ignorePatterns = [];
16054
+ for (const pattern of ignore) {
16055
+ if (!pattern.startsWith("!") || pattern[1] === "(") {
16056
+ const newPattern = normalizePattern(pattern, expandDirectories, cwd, properties, true);
16057
+ ignorePatterns.push(newPattern);
16058
+ }
16059
+ }
16060
+ for (const pattern of patterns) {
16061
+ if (!pattern.startsWith("!") || pattern[1] === "(") {
16062
+ const newPattern = normalizePattern(pattern, expandDirectories, cwd, properties, false);
16063
+ matchPatterns.push(newPattern);
16064
+ } else if (pattern[1] !== "!" || pattern[2] === "(") {
16065
+ const newPattern = normalizePattern(pattern.slice(1), expandDirectories, cwd, properties, true);
16066
+ ignorePatterns.push(newPattern);
16067
16067
  }
16068
16068
  }
16069
16069
  return { match: matchPatterns, ignore: ignorePatterns };
@@ -16099,8 +16099,8 @@ function crawl(options, cwd, sync) {
16099
16099
  filters: [(p, isDirectory) => matcher(processPath(p, cwd, properties.root, isDirectory, options.absolute))],
16100
16100
  exclude: (_, p) => exclude(processPath(p, cwd, properties.root, true, true)),
16101
16101
  pathSeparator: "/",
16102
- relativePaths: true
16103
- // resolveSymlinks: true
16102
+ relativePaths: true,
16103
+ resolveSymlinks: true
16104
16104
  };
16105
16105
  if (options.deep) {
16106
16106
  fdirOptions.maxDepth = Math.round(options.deep - properties.depthOffset);
@@ -18821,6 +18821,10 @@ function requireMerge () {
18821
18821
  return merge;
18822
18822
  }
18823
18823
 
18824
+ function commonjsRequire(path) {
18825
+ 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.');
18826
+ }
18827
+
18824
18828
  var binary$1;
18825
18829
  var hasRequiredBinary;
18826
18830
 
@@ -34452,8 +34456,12 @@ function capitalize(str) {
34452
34456
  return str.charAt(0).toUpperCase() + str.slice(1);
34453
34457
  }
34454
34458
 
34459
+ const require$1 = createRequire$1(import.meta.url);
34460
+ const resolveLangSync = createSyncFn(
34461
+ require$1.resolve("vitepress/dist/node/worker_shikiResolveLang.js")
34462
+ );
34455
34463
  const nanoid = customAlphabet("abcdefghijklmnopqrstuvwxyz", 10);
34456
- const attrsToLines = (attrs) => {
34464
+ function attrsToLines(attrs) {
34457
34465
  attrs = attrs.replace(/^(?:\[.*?\])?.*?([\d,-]+).*/, "$1").trim();
34458
34466
  const result = [];
34459
34467
  if (!attrs) {
@@ -34472,7 +34480,7 @@ const attrsToLines = (attrs) => {
34472
34480
  line: v,
34473
34481
  classes: ["highlighted"]
34474
34482
  }));
34475
- };
34483
+ }
34476
34484
  async function highlight(theme, options, logger = console) {
34477
34485
  const {
34478
34486
  defaultHighlightLang: defaultLang = "",
@@ -34480,7 +34488,10 @@ async function highlight(theme, options, logger = console) {
34480
34488
  } = options;
34481
34489
  const highlighter = await createHighlighter({
34482
34490
  themes: typeof theme === "object" && "light" in theme && "dark" in theme ? [theme.light, theme.dark] : [theme],
34483
- langs: [...Object.keys(bundledLanguages), ...options.languages || []],
34491
+ langs: [
34492
+ ...options.languages || [],
34493
+ ...Object.values(options.languageAlias || {})
34494
+ ],
34484
34495
  langAlias: options.languageAlias
34485
34496
  });
34486
34497
  await options?.shikiSetup?.(highlighter);
@@ -34509,74 +34520,82 @@ async function highlight(theme, options, logger = console) {
34509
34520
  const lineNoStartRE = /=(\d*)/;
34510
34521
  const lineNoRE = /:(no-)?line-numbers(=\d*)?$/;
34511
34522
  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
- `
34523
+ return [
34524
+ (str, lang, attrs) => {
34525
+ const vPre = vueRE.test(lang) ? "" : "v-pre";
34526
+ lang = lang.replace(lineNoStartRE, "").replace(lineNoRE, "").replace(vueRE, "").toLowerCase() || defaultLang;
34527
+ if (lang) {
34528
+ const langLoaded = highlighter.getLoadedLanguages().includes(lang);
34529
+ if (!langLoaded && !isSpecialLang(lang)) {
34530
+ const resolvedLang = resolveLangSync(lang);
34531
+ if (!resolvedLang) {
34532
+ logger.warn(
34533
+ c$1.yellow(
34534
+ `
34521
34535
  The language '${lang}' is not loaded, falling back to '${defaultLang || "txt"}' for syntax highlighting.`
34522
- )
34523
- );
34524
- lang = defaultLang;
34525
- }
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"] = "";
34536
+ )
34537
+ );
34538
+ lang = defaultLang;
34539
+ } else {
34540
+ highlighter.loadLanguageSync(resolvedLang);
34556
34541
  }
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
- });
34542
+ }
34543
+ }
34544
+ const lineOptions = attrsToLines(attrs);
34545
+ const mustaches = /* @__PURE__ */ new Map();
34546
+ const removeMustache = (s) => {
34547
+ if (vPre) return s;
34548
+ return s.replace(mustacheRE, (match) => {
34549
+ let marker = mustaches.get(match);
34550
+ if (!marker) {
34551
+ marker = nanoid();
34552
+ mustaches.set(match, marker);
34571
34553
  }
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
- };
34554
+ return marker;
34555
+ });
34556
+ };
34557
+ const restoreMustache = (s) => {
34558
+ mustaches.forEach((marker, match) => {
34559
+ s = s.replaceAll(marker, match);
34560
+ });
34561
+ return s;
34562
+ };
34563
+ str = removeMustache(str).trimEnd();
34564
+ const highlighted = highlighter.codeToHtml(str, {
34565
+ lang,
34566
+ transformers: [
34567
+ ...transformers,
34568
+ transformerCompactLineOptions(lineOptions),
34569
+ {
34570
+ name: "vitepress:v-pre",
34571
+ pre(node) {
34572
+ if (vPre) node.properties["v-pre"] = "";
34573
+ }
34574
+ },
34575
+ {
34576
+ name: "vitepress:empty-line",
34577
+ code(hast) {
34578
+ hast.children.forEach((span) => {
34579
+ if (span.type === "element" && span.tagName === "span" && Array.isArray(span.properties.class) && span.properties.class.includes("line") && span.children.length === 0) {
34580
+ span.children.push({
34581
+ type: "element",
34582
+ tagName: "wbr",
34583
+ properties: {},
34584
+ children: []
34585
+ });
34586
+ }
34587
+ });
34588
+ }
34589
+ },
34590
+ ...userTransformers
34591
+ ],
34592
+ meta: { __raw: attrs },
34593
+ ...typeof theme === "object" && "light" in theme && "dark" in theme ? { themes: theme, defaultColor: false } : { theme }
34594
+ });
34595
+ return restoreMustache(highlighted);
34596
+ },
34597
+ highlighter.dispose
34598
+ ];
34580
34599
  }
34581
34600
 
34582
34601
  const RE = /{([\d,-]+)}/;
@@ -34872,16 +34891,23 @@ const snippetPlugin = (md, srcDir) => {
34872
34891
  md.block.ruler.before("fence", "snippet", parser);
34873
34892
  };
34874
34893
 
34875
- const createMarkdownRenderer = async (srcDir, options = {}, base = "/", logger = console) => {
34894
+ let md;
34895
+ let _disposeHighlighter;
34896
+ function disposeMdItInstance() {
34897
+ if (md) {
34898
+ md = void 0;
34899
+ _disposeHighlighter?.();
34900
+ }
34901
+ }
34902
+ async function createMarkdownRenderer(srcDir, options = {}, base = "/", logger = console) {
34903
+ if (md) return md;
34876
34904
  const theme = options.theme ?? { light: "github-light", dark: "github-dark" };
34877
34905
  const codeCopyButtonTitle = options.codeCopyButtonTitle || "Copy Code";
34878
34906
  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
- });
34907
+ let [highlight$1, dispose] = options.highlight ? [options.highlight, () => {
34908
+ }] : await highlight(theme, options, logger);
34909
+ _disposeHighlighter = dispose;
34910
+ md = MarkdownIt({ html: true, linkify: true, highlight: highlight$1, ...options });
34885
34911
  md.linkify.set({ fuzzyLink: false });
34886
34912
  md.use(restoreEntities);
34887
34913
  if (options.preConfig) {
@@ -34957,7 +34983,7 @@ const createMarkdownRenderer = async (srcDir, options = {}, base = "/", logger =
34957
34983
  options.config(md);
34958
34984
  }
34959
34985
  return md;
34960
- };
34986
+ }
34961
34987
 
34962
34988
  var crossSpawn = {exports: {}};
34963
34989
 
@@ -44282,6 +44308,7 @@ async function createVitePressPlugin(siteConfig, ssr = false, pageToHashMap, cli
44282
44308
  siteConfig.logger.error(err);
44283
44309
  return;
44284
44310
  }
44311
+ disposeMdItInstance();
44285
44312
  clearCache();
44286
44313
  await recreateServer?.();
44287
44314
  return;
@@ -44315,7 +44342,7 @@ async function createVitePressPlugin(siteConfig, ssr = false, pageToHashMap, cli
44315
44342
  return [
44316
44343
  ...modules,
44317
44344
  ...importers.map((id) => {
44318
- clearCache(id);
44345
+ clearCache(slash(path$1.relative(srcDir, id)));
44319
44346
  return server.moduleGraph.getModuleById(id);
44320
44347
  })
44321
44348
  ].filter(Boolean);
@@ -48508,7 +48535,7 @@ async function generateSitemap(siteConfig) {
48508
48535
  });
48509
48536
  }
48510
48537
 
48511
- var version = "1.4.1";
48538
+ var version = "1.4.3";
48512
48539
 
48513
48540
  async function renderPage(render, config, page, result, appChunk, cssChunk, assets, pageToHashMap, metadataScript, additionalHeadTags) {
48514
48541
  const routePath = `/${page.replace(/\.md$/, "")}`;
@@ -52331,4 +52358,4 @@ async function createServer(root = process.cwd(), serverOptions = {}, recreateSe
52331
52358
  });
52332
52359
  }
52333
52360
 
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 };
52361
+ 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 };