vitepress 1.4.0 → 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.
@@ -1,14 +1,13 @@
1
1
  import { createHash } from 'crypto';
2
2
  import { createRequire } from 'module';
3
- import path$1, { resolve as resolve$1, parse as parse$4, basename, join, posix as posix$2, dirname, normalize as normalize$3 } from 'path';
4
- import path$2, { win32, posix as posix$1 } from 'node:path';
3
+ import path$1, { resolve as resolve$1, parse as parse$4, basename, join, posix as posix$2, dirname } from 'path';
4
+ import path$2, { win32, posix as posix$1, resolve as resolve$2, normalize as normalize$3, join as join$1 } from 'node:path';
5
5
  import process$2, { stdin, stdout } from 'node:process';
6
6
  import { lstat as lstat$4, readdir as readdir$3, readlink, realpath } from 'node:fs/promises';
7
7
  import { fileURLToPath } from 'node:url';
8
8
  import * as fs$2 from 'node:fs';
9
- import fs__default$1 from 'node:fs';
10
- import * as fs$3 from 'fs';
11
- import fs__default, { realpathSync as realpathSync$1, lstatSync, readdir as readdir$2, readdirSync as readdirSync$1, readlinkSync, unlinkSync, rmdirSync, chmodSync, statSync, renameSync, rmSync } from 'fs';
9
+ import fs__default from 'node:fs';
10
+ import fs$3, { realpathSync as realpathSync$1, lstatSync, readdir as readdir$2, readdirSync as readdirSync$1, readlinkSync, unlinkSync, rmdirSync, chmodSync, statSync, renameSync, rmSync } from 'fs';
12
11
  import { EventEmitter } from 'node:events';
13
12
  import Stream from 'node:stream';
14
13
  import { StringDecoder } from 'node:string_decoder';
@@ -630,7 +629,7 @@ var hasRequiredGracefulFs;
630
629
  function requireGracefulFs () {
631
630
  if (hasRequiredGracefulFs) return gracefulFs;
632
631
  hasRequiredGracefulFs = 1;
633
- var fs = fs__default;
632
+ var fs = fs$3;
634
633
  var polyfills = requirePolyfills();
635
634
  var legacy = requireLegacyStreams();
636
635
  var clone = requireClone();
@@ -2420,7 +2419,7 @@ function requireJsonfile$1 () {
2420
2419
  try {
2421
2420
  _fs = requireGracefulFs();
2422
2421
  } catch (_) {
2423
- _fs = fs__default;
2422
+ _fs = fs$3;
2424
2423
  }
2425
2424
  const universalify = requireUniversalify();
2426
2425
  const { stringify, stripBom } = requireUtils$7();
@@ -2982,7 +2981,7 @@ function findUpSync(name, {
2982
2981
  const filePath = path$2.isAbsolute(name) ? name : path$2.join(directory, name);
2983
2982
 
2984
2983
  try {
2985
- const stats = fs__default$1.statSync(filePath, {throwIfNoEntry: false});
2984
+ const stats = fs__default.statSync(filePath, {throwIfNoEntry: false});
2986
2985
  if ((type === 'file' && stats?.isFile()) || (type === 'directory' && stats?.isDirectory())) {
2987
2986
  return filePath;
2988
2987
  }
@@ -10986,15 +10985,15 @@ const readdirSync = (path) => readdirSync$1(path, { withFileTypes: true });
10986
10985
  // than something like:
10987
10986
  // const makeCb = (res, rej) => (er, ...d) => er ? rej(er) : res(...d)
10988
10987
  // which would be a bit cleaner.
10989
- const chmod$2 = (path, mode) => new Promise((res, rej) => fs__default.chmod(path, mode, (er, ...d) => (er ? rej(er) : res(...d))));
10990
- const mkdir = (path, options) => new Promise((res, rej) => fs__default.mkdir(path, options, (er, made) => (er ? rej(er) : res(made))));
10991
- const readdir$1 = (path) => new Promise((res, rej) => fs__default.readdir(path, { withFileTypes: true }, (er, data) => er ? rej(er) : res(data)));
10992
- const rename$1 = (oldPath, newPath) => new Promise((res, rej) => fs__default.rename(oldPath, newPath, (er, ...d) => er ? rej(er) : res(...d)));
10993
- const rm$1 = (path, options) => new Promise((res, rej) => fs__default.rm(path, options, (er, ...d) => (er ? rej(er) : res(...d))));
10994
- const rmdir$3 = (path) => new Promise((res, rej) => fs__default.rmdir(path, (er, ...d) => (er ? rej(er) : res(...d))));
10995
- const stat$1 = (path) => new Promise((res, rej) => fs__default.stat(path, (er, data) => (er ? rej(er) : res(data))));
10996
- const lstat$3 = (path) => new Promise((res, rej) => fs__default.lstat(path, (er, data) => (er ? rej(er) : res(data))));
10997
- const unlink$3 = (path) => new Promise((res, rej) => fs__default.unlink(path, (er, ...d) => (er ? rej(er) : res(...d))));
10988
+ const chmod$2 = (path, mode) => new Promise((res, rej) => fs$3.chmod(path, mode, (er, ...d) => (er ? rej(er) : res(...d))));
10989
+ const mkdir = (path, options) => new Promise((res, rej) => fs$3.mkdir(path, options, (er, made) => (er ? rej(er) : res(made))));
10990
+ const readdir$1 = (path) => new Promise((res, rej) => fs$3.readdir(path, { withFileTypes: true }, (er, data) => er ? rej(er) : res(data)));
10991
+ const rename$1 = (oldPath, newPath) => new Promise((res, rej) => fs$3.rename(oldPath, newPath, (er, ...d) => er ? rej(er) : res(...d)));
10992
+ const rm$1 = (path, options) => new Promise((res, rej) => fs$3.rm(path, options, (er, ...d) => (er ? rej(er) : res(...d))));
10993
+ const rmdir$3 = (path) => new Promise((res, rej) => fs$3.rmdir(path, (er, ...d) => (er ? rej(er) : res(...d))));
10994
+ const stat$1 = (path) => new Promise((res, rej) => fs$3.stat(path, (er, data) => (er ? rej(er) : res(data))));
10995
+ const lstat$3 = (path) => new Promise((res, rej) => fs$3.lstat(path, (er, data) => (er ? rej(er) : res(data))));
10996
+ const unlink$3 = (path) => new Promise((res, rej) => fs$3.unlink(path, (er, ...d) => (er ? rej(er) : res(...d))));
10998
10997
  const promises = {
10999
10998
  chmod: chmod$2,
11000
10999
  mkdir,
@@ -12827,10 +12826,6 @@ function requireSrc$1 () {
12827
12826
  var srcExports$1 = requireSrc$1();
12828
12827
  var _debug = /*@__PURE__*/getDefaultExportFromCjs(srcExports$1);
12829
12828
 
12830
- function commonjsRequire(path) {
12831
- 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.');
12832
- }
12833
-
12834
12829
  var picocolors = {exports: {}};
12835
12830
 
12836
12831
  var hasRequiredPicocolors;
@@ -12838,29 +12833,19 @@ var hasRequiredPicocolors;
12838
12833
  function requirePicocolors () {
12839
12834
  if (hasRequiredPicocolors) return picocolors.exports;
12840
12835
  hasRequiredPicocolors = 1;
12841
- let argv = process.argv || [],
12842
- env = process.env;
12836
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
12843
12837
  let isColorSupported =
12844
- !("NO_COLOR" in env || argv.includes("--no-color")) &&
12845
- ("FORCE_COLOR" in env ||
12846
- argv.includes("--color") ||
12847
- process.platform === "win32" ||
12848
- (commonjsRequire != null && require$$0$4.isatty(1) && env.TERM !== "dumb") ||
12849
- "CI" in env);
12850
-
12851
- let formatter =
12852
- (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) =>
12853
12842
  input => {
12854
- let string = "" + input;
12855
- let index = string.indexOf(close, open.length);
12856
- return ~index
12857
- ? open + replaceClose(string, close, replace, index) + close
12858
- : 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
12859
12845
  };
12860
12846
 
12861
12847
  let replaceClose = (string, close, replace, index) => {
12862
- let result = "";
12863
- let cursor = 0;
12848
+ let result = "", cursor = 0;
12864
12849
  do {
12865
12850
  result += string.substring(cursor, index) + replace;
12866
12851
  cursor = index + close.length;
@@ -12870,54 +12855,54 @@ function requirePicocolors () {
12870
12855
  };
12871
12856
 
12872
12857
  let createColors = (enabled = isColorSupported) => {
12873
- let init = enabled ? formatter : () => String;
12858
+ let f = enabled ? formatter : () => String;
12874
12859
  return {
12875
12860
  isColorSupported: enabled,
12876
- reset: init("\x1b[0m", "\x1b[0m"),
12877
- bold: init("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
12878
- dim: init("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
12879
- italic: init("\x1b[3m", "\x1b[23m"),
12880
- underline: init("\x1b[4m", "\x1b[24m"),
12881
- inverse: init("\x1b[7m", "\x1b[27m"),
12882
- hidden: init("\x1b[8m", "\x1b[28m"),
12883
- strikethrough: init("\x1b[9m", "\x1b[29m"),
12884
-
12885
- black: init("\x1b[30m", "\x1b[39m"),
12886
- red: init("\x1b[31m", "\x1b[39m"),
12887
- green: init("\x1b[32m", "\x1b[39m"),
12888
- yellow: init("\x1b[33m", "\x1b[39m"),
12889
- blue: init("\x1b[34m", "\x1b[39m"),
12890
- magenta: init("\x1b[35m", "\x1b[39m"),
12891
- cyan: init("\x1b[36m", "\x1b[39m"),
12892
- white: init("\x1b[37m", "\x1b[39m"),
12893
- gray: init("\x1b[90m", "\x1b[39m"),
12894
-
12895
- bgBlack: init("\x1b[40m", "\x1b[49m"),
12896
- bgRed: init("\x1b[41m", "\x1b[49m"),
12897
- bgGreen: init("\x1b[42m", "\x1b[49m"),
12898
- bgYellow: init("\x1b[43m", "\x1b[49m"),
12899
- bgBlue: init("\x1b[44m", "\x1b[49m"),
12900
- bgMagenta: init("\x1b[45m", "\x1b[49m"),
12901
- bgCyan: init("\x1b[46m", "\x1b[49m"),
12902
- bgWhite: init("\x1b[47m", "\x1b[49m"),
12903
-
12904
- blackBright: init("\x1b[90m", "\x1b[39m"),
12905
- redBright: init("\x1b[91m", "\x1b[39m"),
12906
- greenBright: init("\x1b[92m", "\x1b[39m"),
12907
- yellowBright: init("\x1b[93m", "\x1b[39m"),
12908
- blueBright: init("\x1b[94m", "\x1b[39m"),
12909
- magentaBright: init("\x1b[95m", "\x1b[39m"),
12910
- cyanBright: init("\x1b[96m", "\x1b[39m"),
12911
- whiteBright: init("\x1b[97m", "\x1b[39m"),
12912
-
12913
- bgBlackBright: init("\x1b[100m","\x1b[49m"),
12914
- bgRedBright: init("\x1b[101m","\x1b[49m"),
12915
- bgGreenBright: init("\x1b[102m","\x1b[49m"),
12916
- bgYellowBright: init("\x1b[103m","\x1b[49m"),
12917
- bgBlueBright: init("\x1b[104m","\x1b[49m"),
12918
- bgMagentaBright: init("\x1b[105m","\x1b[49m"),
12919
- bgCyanBright: init("\x1b[106m","\x1b[49m"),
12920
- 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"),
12921
12906
  }
12922
12907
  };
12923
12908
 
@@ -13214,64 +13199,67 @@ function requireResolveSymlink () {
13214
13199
  };
13215
13200
  Object.defineProperty(resolveSymlink, "__esModule", { value: true });
13216
13201
  resolveSymlink.build = void 0;
13217
- const fs_1 = __importDefault(fs__default);
13202
+ const fs_1 = __importDefault(fs$3);
13203
+ const path_1 = path$1;
13218
13204
  const resolveSymlinksAsync = function (path, state, callback) {
13219
- const { queue, options: { suppressErrors }, } = state;
13220
- queue.enqueue();
13221
- fs_1.default.stat(path, (error, stat) => {
13222
- if (error) {
13223
- queue.dequeue(suppressErrors ? null : error, state);
13224
- return;
13225
- }
13226
- callback(stat, path);
13227
- queue.dequeue(null, state);
13228
- });
13229
- };
13230
- const resolveSymlinksWithRealPathsAsync = function (path, state, callback) {
13231
13205
  const { queue, options: { suppressErrors }, } = state;
13232
13206
  queue.enqueue();
13233
13207
  fs_1.default.realpath(path, (error, resolvedPath) => {
13234
- if (error) {
13235
- queue.dequeue(suppressErrors ? null : error, state);
13236
- return;
13237
- }
13238
- 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);
13239
13215
  callback(stat, resolvedPath);
13240
13216
  queue.dequeue(null, state);
13241
13217
  });
13242
13218
  });
13243
13219
  };
13244
- const resolveSymlinksSync = function (path, state, callback) {
13245
- try {
13246
- const stat = fs_1.default.statSync(path);
13247
- callback(stat, path);
13248
- }
13249
- catch (e) {
13250
- if (!state.options.suppressErrors)
13251
- throw e;
13252
- }
13253
- };
13254
- const resolveSymlinksWithRealPathsSync = function (path, state, callback) {
13220
+ const resolveSymlinks = function (path, state, callback) {
13221
+ const { queue, options: { suppressErrors }, } = state;
13222
+ queue.enqueue();
13255
13223
  try {
13256
13224
  const resolvedPath = fs_1.default.realpathSync(path);
13257
- 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;
13258
13228
  callback(stat, resolvedPath);
13259
13229
  }
13260
13230
  catch (e) {
13261
- if (!state.options.suppressErrors)
13231
+ if (!suppressErrors)
13262
13232
  throw e;
13263
13233
  }
13264
13234
  };
13265
13235
  function build(options, isSynchronous) {
13266
13236
  if (!options.resolveSymlinks || options.excludeSymlinks)
13267
13237
  return null;
13268
- if (options.useRealPaths)
13269
- return isSynchronous
13270
- ? resolveSymlinksWithRealPathsSync
13271
- : resolveSymlinksWithRealPathsAsync;
13272
- return isSynchronous ? resolveSymlinksSync : resolveSymlinksAsync;
13238
+ return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
13273
13239
  }
13274
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
+ }
13275
13263
  return resolveSymlink;
13276
13264
  }
13277
13265
 
@@ -13353,30 +13341,29 @@ function requireWalkDirectory () {
13353
13341
  };
13354
13342
  Object.defineProperty(walkDirectory, "__esModule", { value: true });
13355
13343
  walkDirectory.build = void 0;
13356
- const fs_1 = __importDefault(fs__default);
13344
+ const fs_1 = __importDefault(fs$3);
13357
13345
  const readdirOpts = { withFileTypes: true };
13358
- const walkAsync = (state, directoryPath, currentDepth, callback) => {
13359
- state.queue.enqueue();
13360
- if (currentDepth < 0) {
13361
- state.queue.dequeue(null, state);
13362
- return;
13363
- }
13346
+ const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback) => {
13347
+ if (currentDepth < 0)
13348
+ return state.queue.dequeue(null, state);
13349
+ state.visited.push(crawlPath);
13364
13350
  state.counts.directories++;
13351
+ state.queue.enqueue();
13365
13352
  // Perf: Node >= 10 introduced withFileTypes that helps us
13366
13353
  // skip an extra fs.stat call.
13367
- fs_1.default.readdir(directoryPath || ".", readdirOpts, function process(error, entries = []) {
13354
+ fs_1.default.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
13368
13355
  callback(entries, directoryPath, currentDepth);
13369
13356
  state.queue.dequeue(state.options.suppressErrors ? null : error, state);
13370
13357
  });
13371
13358
  };
13372
- const walkSync = (state, directoryPath, currentDepth, callback) => {
13373
- if (currentDepth < 0) {
13359
+ const walkSync = (state, crawlPath, directoryPath, currentDepth, callback) => {
13360
+ if (currentDepth < 0)
13374
13361
  return;
13375
- }
13362
+ state.visited.push(crawlPath);
13376
13363
  state.counts.directories++;
13377
13364
  let entries = [];
13378
13365
  try {
13379
- entries = fs_1.default.readdirSync(directoryPath || ".", readdirOpts);
13366
+ entries = fs_1.default.readdirSync(crawlPath || ".", readdirOpts);
13380
13367
  }
13381
13368
  catch (e) {
13382
13369
  if (!state.options.suppressErrors)
@@ -13415,7 +13402,7 @@ function requireQueue () {
13415
13402
  this.count++;
13416
13403
  }
13417
13404
  dequeue(error, output) {
13418
- if (--this.count === 0 || error)
13405
+ if (--this.count <= 0 || error)
13419
13406
  this.onQueueEmpty(error, output);
13420
13407
  }
13421
13408
  }
@@ -13516,15 +13503,18 @@ function requireWalker () {
13516
13503
  constructor(root, options, callback) {
13517
13504
  this.isSynchronous = !callback;
13518
13505
  this.callbackInvoker = invokeCallback.build(options, this.isSynchronous);
13506
+ this.root = (0, utils_1.normalizePath)(root, options);
13519
13507
  this.state = {
13508
+ root: this.root.slice(0, -1),
13520
13509
  // Perf: we explicitly tell the compiler to optimize for String arrays
13521
13510
  paths: [""].slice(0, 0),
13522
13511
  groups: [],
13523
13512
  counts: new counter_1.Counter(),
13524
13513
  options,
13525
13514
  queue: new queue_1.Queue((error, state) => this.callbackInvoker(state, error, callback)),
13515
+ symlinks: new Map(),
13516
+ visited: [""].slice(0, 0),
13526
13517
  };
13527
- this.root = (0, utils_1.normalizePath)(root, this.state.options);
13528
13518
  /*
13529
13519
  * Perf: We conditionally change functions according to options. This gives a slight
13530
13520
  * performance boost. Since these functions are so small, they are automatically inlined
@@ -13539,11 +13529,11 @@ function requireWalker () {
13539
13529
  this.walkDirectory = walkDirectory.build(this.isSynchronous);
13540
13530
  }
13541
13531
  start() {
13542
- 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);
13543
13533
  return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
13544
13534
  }
13545
13535
  walk = (entries, directoryPath, depth) => {
13546
- 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;
13547
13537
  if ((signal && signal.aborted) || (maxFiles && paths.length > maxFiles))
13548
13538
  return;
13549
13539
  this.pushDirectory(directoryPath, paths, filters);
@@ -13559,7 +13549,7 @@ function requireWalker () {
13559
13549
  let path = joinPath.joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
13560
13550
  if (exclude && exclude(entry.name, path))
13561
13551
  continue;
13562
- this.walkDirectory(this.state, path, depth - 1, this.walk);
13552
+ this.walkDirectory(this.state, path, path, depth - 1, this.walk);
13563
13553
  }
13564
13554
  else if (entry.isSymbolicLink() && this.resolveSymlink) {
13565
13555
  let path = joinPath.joinPathWithBasePath(entry.name, directoryPath);
@@ -13568,9 +13558,10 @@ function requireWalker () {
13568
13558
  resolvedPath = (0, utils_1.normalizePath)(resolvedPath, this.state.options);
13569
13559
  if (exclude && exclude(entry.name, resolvedPath))
13570
13560
  return;
13571
- this.walkDirectory(this.state, resolvedPath, depth - 1, this.walk);
13561
+ this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
13572
13562
  }
13573
13563
  else {
13564
+ resolvedPath = useRealPaths ? resolvedPath : path;
13574
13565
  const filename = (0, path_1.basename)(resolvedPath);
13575
13566
  const directoryPath = (0, utils_1.normalizePath)((0, path_1.dirname)(resolvedPath), this.state.options);
13576
13567
  resolvedPath = this.joinPath(filename, directoryPath);
@@ -16050,21 +16041,27 @@ function normalizePattern(pattern, expandDirectories, cwd, properties, isIgnore)
16050
16041
  function processPatterns({ patterns, ignore = [], expandDirectories = true }, cwd, properties) {
16051
16042
  if (typeof patterns === "string") {
16052
16043
  patterns = [patterns];
16044
+ } else if (!patterns) {
16045
+ patterns = ["**/*"];
16053
16046
  }
16054
16047
  if (typeof ignore === "string") {
16055
16048
  ignore = [ignore];
16056
16049
  }
16057
16050
  const matchPatterns = [];
16058
- const ignorePatterns = ignore.map((p) => normalizePattern(p, expandDirectories, cwd, properties, true));
16059
- if (!patterns) {
16060
- return { match: ["**/*"], ignore: ignorePatterns };
16061
- }
16062
- for (let pattern of patterns) {
16063
- pattern = normalizePattern(pattern, expandDirectories, cwd, properties, false);
16064
- if (pattern.startsWith("!") && pattern[1] !== "(") {
16065
- ignorePatterns.push(pattern.slice(1));
16066
- } else {
16067
- 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);
16068
16065
  }
16069
16066
  }
16070
16067
  return { match: matchPatterns, ignore: ignorePatterns };
@@ -16100,8 +16097,8 @@ function crawl(options, cwd, sync) {
16100
16097
  filters: [(p, isDirectory) => matcher(processPath(p, cwd, properties.root, isDirectory, options.absolute))],
16101
16098
  exclude: (_, p) => exclude(processPath(p, cwd, properties.root, true, true)),
16102
16099
  pathSeparator: "/",
16103
- relativePaths: true
16104
- // resolveSymlinks: true
16100
+ relativePaths: true,
16101
+ resolveSymlinks: true
16105
16102
  };
16106
16103
  if (options.deep) {
16107
16104
  fdirOptions.maxDepth = Math.round(options.deep - properties.depthOffset);
@@ -16553,21 +16550,33 @@ function pathToRegexp(path, keys, options) {
16553
16550
  }
16554
16551
 
16555
16552
  function resolveRewrites(pages, userRewrites) {
16556
- const rewriteRules = Object.entries(userRewrites || {}).map(([from, to]) => ({
16557
- toPath: compile$1(`/${to}`, { validate: false }),
16558
- matchUrl: match(from.startsWith("^") ? new RegExp(from) : from)
16559
- }));
16560
16553
  const pageToRewrite = {};
16561
16554
  const rewriteToPage = {};
16562
- if (rewriteRules.length) {
16555
+ if (typeof userRewrites === "function") {
16563
16556
  for (const page of pages) {
16564
- for (const { matchUrl, toPath } of rewriteRules) {
16565
- const res = matchUrl(page);
16566
- if (res) {
16567
- const dest = toPath(res.params).slice(1);
16568
- pageToRewrite[page] = dest;
16569
- rewriteToPage[dest] = page;
16570
- break;
16557
+ const dest = userRewrites(page);
16558
+ if (dest && dest !== page) {
16559
+ pageToRewrite[page] = dest;
16560
+ rewriteToPage[dest] = page;
16561
+ }
16562
+ }
16563
+ } else if (typeof userRewrites === "object") {
16564
+ const rewriteRules = Object.entries(userRewrites || {}).map(
16565
+ ([from, to]) => ({
16566
+ toPath: compile$1(`/${to}`, { validate: false }),
16567
+ matchUrl: match(from.startsWith("^") ? new RegExp(from) : from)
16568
+ })
16569
+ );
16570
+ if (rewriteRules.length) {
16571
+ for (const page of pages) {
16572
+ for (const { matchUrl, toPath } of rewriteRules) {
16573
+ const res = matchUrl(page);
16574
+ if (res) {
16575
+ const dest = toPath(res.params).slice(1);
16576
+ pageToRewrite[page] = dest;
16577
+ rewriteToPage[dest] = page;
16578
+ break;
16579
+ }
16571
16580
  }
16572
16581
  }
16573
16582
  }
@@ -18810,6 +18819,10 @@ function requireMerge () {
18810
18819
  return merge;
18811
18820
  }
18812
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
+
18813
18826
  var binary$1;
18814
18827
  var hasRequiredBinary;
18815
18828
 
@@ -22345,7 +22358,7 @@ function requireGrayMatter () {
22345
22358
  if (hasRequiredGrayMatter) return grayMatter;
22346
22359
  hasRequiredGrayMatter = 1;
22347
22360
 
22348
- const fs = fs__default;
22361
+ const fs = fs$3;
22349
22362
  const sections = requireSectionMatter();
22350
22363
  const defaults = requireDefaults();
22351
22364
  const stringify = requireStringify$1();
@@ -34442,7 +34455,7 @@ function capitalize(str) {
34442
34455
  }
34443
34456
 
34444
34457
  const nanoid = customAlphabet("abcdefghijklmnopqrstuvwxyz", 10);
34445
- const attrsToLines = (attrs) => {
34458
+ function attrsToLines(attrs) {
34446
34459
  attrs = attrs.replace(/^(?:\[.*?\])?.*?([\d,-]+).*/, "$1").trim();
34447
34460
  const result = [];
34448
34461
  if (!attrs) {
@@ -34461,7 +34474,7 @@ const attrsToLines = (attrs) => {
34461
34474
  line: v,
34462
34475
  classes: ["highlighted"]
34463
34476
  }));
34464
- };
34477
+ }
34465
34478
  async function highlight(theme, options, logger = console) {
34466
34479
  const {
34467
34480
  defaultHighlightLang: defaultLang = "",
@@ -34498,74 +34511,77 @@ async function highlight(theme, options, logger = console) {
34498
34511
  const lineNoStartRE = /=(\d*)/;
34499
34512
  const lineNoRE = /:(no-)?line-numbers(=\d*)?$/;
34500
34513
  const mustacheRE = /\{\{.*?\}\}/g;
34501
- return (str, lang, attrs) => {
34502
- const vPre = vueRE.test(lang) ? "" : "v-pre";
34503
- lang = lang.replace(lineNoStartRE, "").replace(lineNoRE, "").replace(vueRE, "").toLowerCase() || defaultLang;
34504
- if (lang) {
34505
- const langLoaded = highlighter.getLoadedLanguages().includes(lang);
34506
- if (!langLoaded && !isSpecialLang(lang)) {
34507
- logger.warn(
34508
- c$1.yellow(
34509
- `
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
+ `
34510
34524
  The language '${lang}' is not loaded, falling back to '${defaultLang || "txt"}' for syntax highlighting.`
34511
- )
34512
- );
34513
- lang = defaultLang;
34525
+ )
34526
+ );
34527
+ lang = defaultLang;
34528
+ }
34514
34529
  }
34515
- }
34516
- const lineOptions = attrsToLines(attrs);
34517
- const mustaches = /* @__PURE__ */ new Map();
34518
- const removeMustache = (s) => {
34519
- if (vPre) return s;
34520
- return s.replace(mustacheRE, (match) => {
34521
- let marker = mustaches.get(match);
34522
- if (!marker) {
34523
- marker = nanoid();
34524
- mustaches.set(match, marker);
34525
- }
34526
- return marker;
34527
- });
34528
- };
34529
- const restoreMustache = (s) => {
34530
- mustaches.forEach((marker, match) => {
34531
- s = s.replaceAll(marker, match);
34532
- });
34533
- return s;
34534
- };
34535
- str = removeMustache(str).trimEnd();
34536
- const highlighted = highlighter.codeToHtml(str, {
34537
- lang,
34538
- transformers: [
34539
- ...transformers,
34540
- transformerCompactLineOptions(lineOptions),
34541
- {
34542
- name: "vitepress:v-pre",
34543
- pre(node) {
34544
- if (vPre) node.properties["v-pre"] = "";
34545
- }
34546
- },
34547
- {
34548
- name: "vitepress:empty-line",
34549
- code(hast) {
34550
- hast.children.forEach((span) => {
34551
- if (span.type === "element" && span.tagName === "span" && Array.isArray(span.properties.class) && span.properties.class.includes("line") && span.children.length === 0) {
34552
- span.children.push({
34553
- type: "element",
34554
- tagName: "wbr",
34555
- properties: {},
34556
- children: []
34557
- });
34558
- }
34559
- });
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);
34560
34539
  }
34561
- },
34562
- ...userTransformers
34563
- ],
34564
- meta: { __raw: attrs },
34565
- ...typeof theme === "object" && "light" in theme && "dark" in theme ? { themes: theme, defaultColor: false } : { theme }
34566
- });
34567
- return restoreMustache(highlighted);
34568
- };
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
+ ];
34569
34585
  }
34570
34586
 
34571
34587
  const RE = /{([\d,-]+)}/;
@@ -34861,16 +34877,23 @@ const snippetPlugin = (md, srcDir) => {
34861
34877
  md.block.ruler.before("fence", "snippet", parser);
34862
34878
  };
34863
34879
 
34864
- 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;
34865
34890
  const theme = options.theme ?? { light: "github-light", dark: "github-dark" };
34866
34891
  const codeCopyButtonTitle = options.codeCopyButtonTitle || "Copy Code";
34867
34892
  const hasSingleTheme = typeof theme === "string" || "name" in theme;
34868
- const md = MarkdownIt({
34869
- html: true,
34870
- linkify: true,
34871
- highlight: options.highlight || await highlight(theme, options, logger),
34872
- ...options
34873
- });
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 });
34874
34897
  md.linkify.set({ fuzzyLink: false });
34875
34898
  md.use(restoreEntities);
34876
34899
  if (options.preConfig) {
@@ -34946,7 +34969,7 @@ const createMarkdownRenderer = async (srcDir, options = {}, base = "/", logger =
34946
34969
  options.config(md);
34947
34970
  }
34948
34971
  return md;
34949
- };
34972
+ }
34950
34973
 
34951
34974
  var crossSpawn = {exports: {}};
34952
34975
 
@@ -34959,7 +34982,7 @@ function requireWindows () {
34959
34982
  windows = isexe;
34960
34983
  isexe.sync = sync;
34961
34984
 
34962
- var fs = fs__default;
34985
+ var fs = fs$3;
34963
34986
 
34964
34987
  function checkPathExt (path, options) {
34965
34988
  var pathext = options.pathExt !== undefined ?
@@ -35010,7 +35033,7 @@ function requireMode () {
35010
35033
  mode = isexe;
35011
35034
  isexe.sync = sync;
35012
35035
 
35013
- var fs = fs__default;
35036
+ var fs = fs$3;
35014
35037
 
35015
35038
  function isexe (path, options, cb) {
35016
35039
  fs.stat(path, function (er, stat) {
@@ -35433,7 +35456,7 @@ function requireReadShebang () {
35433
35456
  if (hasRequiredReadShebang) return readShebang_1;
35434
35457
  hasRequiredReadShebang = 1;
35435
35458
 
35436
- const fs = fs__default;
35459
+ const fs = fs$3;
35437
35460
  const shebangCommand = requireShebangCommand();
35438
35461
 
35439
35462
  function readShebang(command) {
@@ -35760,13 +35783,13 @@ async function createMarkdownToVueRenderFn(srcDir, options = {}, pages, isBuild
35760
35783
  const dynamicRoutes = new Map(
35761
35784
  siteConfig?.dynamicRoutes?.routes.map((r) => [
35762
35785
  r.fullPath,
35763
- path$1.join(srcDir, r.route)
35786
+ slash(path$1.join(srcDir, r.route))
35764
35787
  ]) || []
35765
35788
  );
35766
35789
  const rewrites = new Map(
35767
35790
  Object.entries(siteConfig?.rewrites.map || {}).map(([key, value]) => [
35768
- path$1.join(srcDir, key),
35769
- path$1.join(srcDir, value)
35791
+ slash(path$1.join(srcDir, key)),
35792
+ slash(path$1.join(srcDir, value))
35770
35793
  ]) || []
35771
35794
  );
35772
35795
  return async (src, file, publicDir) => {
@@ -44271,6 +44294,7 @@ async function createVitePressPlugin(siteConfig, ssr = false, pageToHashMap, cli
44271
44294
  siteConfig.logger.error(err);
44272
44295
  return;
44273
44296
  }
44297
+ disposeMdItInstance();
44274
44298
  clearCache();
44275
44299
  await recreateServer?.();
44276
44300
  return;
@@ -44304,7 +44328,7 @@ async function createVitePressPlugin(siteConfig, ssr = false, pageToHashMap, cli
44304
44328
  return [
44305
44329
  ...modules,
44306
44330
  ...importers.map((id) => {
44307
- clearCache(id);
44331
+ clearCache(slash(path$1.relative(srcDir, id)));
44308
44332
  return server.moduleGraph.getModuleById(id);
44309
44333
  })
44310
44334
  ].filter(Boolean);
@@ -45207,7 +45231,7 @@ function requireUtils () {
45207
45231
  * Copyright(c) 2011 Eugene Kalinin
45208
45232
  * MIT Licensed
45209
45233
  */
45210
- const fs_1 = fs__default;
45234
+ const fs_1 = fs$3;
45211
45235
  const stream_1 = require$$0$2;
45212
45236
  const readline_1 = require$$2$1;
45213
45237
  const url_1 = require$$3;
@@ -48305,7 +48329,7 @@ function requireSitemapSimple () {
48305
48329
  const sitemap_stream_1 = requireSitemapStream();
48306
48330
  const utils_1 = requireUtils();
48307
48331
  const zlib_1 = require$$3$1;
48308
- const fs_1 = fs__default;
48332
+ const fs_1 = fs$3;
48309
48333
  const path_1 = path$1;
48310
48334
  const stream_1 = require$$0$2;
48311
48335
  const util_1 = require$$0$3;
@@ -48497,7 +48521,7 @@ async function generateSitemap(siteConfig) {
48497
48521
  });
48498
48522
  }
48499
48523
 
48500
- var version = "1.4.0";
48524
+ var version = "1.4.2";
48501
48525
 
48502
48526
  async function renderPage(render, config, page, result, appChunk, cssChunk, assets, pageToHashMap, metadataScript, additionalHeadTags) {
48503
48527
  const routePath = `/${page.replace(/\.md$/, "")}`;
@@ -51227,6 +51251,15 @@ function requirePostcssPrefixSelector () {
51227
51251
  );
51228
51252
  }
51229
51253
 
51254
+ // replace :root, body, html with the prefix
51255
+ if ([':root', 'body', 'html'].some(globalSel => selector.startsWith(globalSel))) {
51256
+ if (options.skipGlobalSelectors) {
51257
+ return selector;
51258
+ }
51259
+
51260
+ return selector.replace(/(html\s+body|:root\s+body|html|:root|body)/gm, prefix);
51261
+ }
51262
+
51230
51263
  return prefixWithSpace + selector;
51231
51264
  });
51232
51265
  }
@@ -52096,9 +52129,9 @@ function viaLocal(dir, isEtag, uri, extns) {
52096
52129
  let i=0, arr=toAssume(uri, extns);
52097
52130
  let abs, stats, name, headers;
52098
52131
  for (; i < arr.length; i++) {
52099
- abs = normalize$3(join(dir, name=arr[i]));
52100
- if (abs.startsWith(dir) && fs$3.existsSync(abs)) {
52101
- stats = fs$3.statSync(abs);
52132
+ abs = normalize$3(join$1(dir, name=arr[i]));
52133
+ if (abs.startsWith(dir) && fs$2.existsSync(abs)) {
52134
+ stats = fs$2.statSync(abs);
52102
52135
  if (stats.isDirectory()) continue;
52103
52136
  headers = toHeaders(name, stats, isEtag);
52104
52137
  headers['Cache-Control'] = isEtag ? 'no-cache' : 'no-store';
@@ -52146,7 +52179,7 @@ function send(req, res, file, stats, headers) {
52146
52179
  }
52147
52180
 
52148
52181
  res.writeHead(code, headers);
52149
- fs$3.createReadStream(file, opts).pipe(res);
52182
+ fs$2.createReadStream(file, opts).pipe(res);
52150
52183
  }
52151
52184
 
52152
52185
  const ENCODING = {
@@ -52173,7 +52206,7 @@ function toHeaders(name, stats, isEtag) {
52173
52206
  }
52174
52207
 
52175
52208
  function sirv (dir, opts={}) {
52176
- dir = resolve$1(dir || '.');
52209
+ dir = resolve$2(dir || '.');
52177
52210
 
52178
52211
  let isNotFound = opts.onNoMatch || is404;
52179
52212
  let setHeaders = opts.setHeaders || noop;
@@ -52311,4 +52344,4 @@ async function createServer(root = process.cwd(), serverOptions = {}, recreateSe
52311
52344
  });
52312
52345
  }
52313
52346
 
52314
- 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 };