vitepress 1.2.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/client/app/data.js +1 -1
  2. package/dist/client/app/router.js +41 -40
  3. package/dist/client/theme-default/components/VPDocFooter.vue +29 -13
  4. package/dist/client/theme-default/components/VPDocFooterLastUpdated.vue +2 -2
  5. package/dist/client/theme-default/components/VPMenu.vue +7 -2
  6. package/dist/client/theme-default/components/VPNavBar.vue +10 -3
  7. package/dist/client/theme-default/components/VPNavBarAppearance.vue +8 -1
  8. package/dist/client/theme-default/components/VPNavBarExtra.vue +17 -3
  9. package/dist/client/theme-default/components/VPNavBarMenu.vue +14 -3
  10. package/dist/client/theme-default/components/VPNavBarMenuGroup.vue +7 -7
  11. package/dist/client/theme-default/components/VPNavScreen.vue +2 -2
  12. package/dist/client/theme-default/components/VPNavScreenAppearance.vue +8 -1
  13. package/dist/client/theme-default/components/VPNavScreenMenu.vue +7 -4
  14. package/dist/client/theme-default/components/VPNavScreenMenuGroup.vue +9 -8
  15. package/dist/client/theme-default/components/VPSidebar.vue +18 -19
  16. package/dist/client/theme-default/components/VPSidebarGroup.vue +56 -0
  17. package/dist/client/theme-default/components/VPSidebarItem.vue +3 -3
  18. package/dist/client/theme-default/components/VPSwitchAppearance.vue +5 -3
  19. package/dist/client/theme-default/styles/components/vp-doc.css +10 -2
  20. package/dist/client/theme-default/without-fonts.js +1 -0
  21. package/dist/node/cli.js +20 -14
  22. package/dist/node/index.d.ts +3 -3
  23. package/dist/node/index.js +2 -2
  24. package/dist/node/{serve-CEEKiiuH.js → serve-BhLFz9dF.js} +202 -64
  25. package/package.json +33 -36
  26. package/theme.d.ts +1 -0
  27. package/types/default-theme.d.ts +9 -4
  28. package/types/shared.d.ts +1 -0
package/dist/node/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as getDefaultExportFromCjs, q as c, t as clearCache, n as init, b as build, o as serve, v as version, p as createServer } from './serve-CEEKiiuH.js';
1
+ import { a as getDefaultExportFromCjs, q as c, t as clearCache, n as init, b as build, o as serve, v as version, p as createServer } from './serve-BhLFz9dF.js';
2
2
  import { createLogger } from 'vite';
3
3
  import 'path';
4
4
  import 'shiki';
@@ -401,24 +401,30 @@ if (!command || command === "dev") {
401
401
  delete argv.force;
402
402
  argv.optimizeDeps = { force: true };
403
403
  }
404
- const createDevServer = async () => {
405
- const server = await createServer(root, argv, async () => {
406
- if (!restartPromise) {
407
- restartPromise = (async () => {
408
- await server.close();
409
- await createDevServer();
410
- })().finally(() => {
411
- restartPromise = void 0;
412
- });
404
+ const open = argv.open;
405
+ delete argv.open;
406
+ const createDevServer = async (isRestart = true) => {
407
+ const server = await createServer(
408
+ root,
409
+ !isRestart ? { ...argv, open } : argv,
410
+ async () => {
411
+ if (!restartPromise) {
412
+ restartPromise = (async () => {
413
+ await server.close();
414
+ await createDevServer();
415
+ })().finally(() => {
416
+ restartPromise = void 0;
417
+ });
418
+ }
419
+ return restartPromise;
413
420
  }
414
- return restartPromise;
415
- });
421
+ );
416
422
  await server.listen();
417
423
  logVersion(server.config.logger);
418
424
  server.printUrls();
419
425
  bindShortcuts(server, createDevServer);
420
426
  };
421
- createDevServer().catch((err) => {
427
+ createDevServer(false).catch((err) => {
422
428
  createLogger().error(
423
429
  `${c.red(`failed to start server. error:`)}
424
430
  ${err.message}
@@ -428,7 +434,7 @@ ${err.stack}`
428
434
  });
429
435
  } else if (command === "init") {
430
436
  createLogger().info("", { clear: true });
431
- init();
437
+ init(argv.root);
432
438
  } else {
433
439
  logVersion();
434
440
  if (command === "build") {
@@ -2179,7 +2179,7 @@ interface MarkdownOptions extends Options$2 {
2179
2179
  gfmAlerts?: boolean;
2180
2180
  }
2181
2181
  type MarkdownRenderer = MarkdownIt;
2182
- declare const createMarkdownRenderer: (srcDir: string, options?: MarkdownOptions, base?: string, logger?: Pick<Logger, 'warn'>) => Promise<MarkdownRenderer>;
2182
+ declare const createMarkdownRenderer: (srcDir: string, options?: MarkdownOptions, base?: string, logger?: Pick<Logger, "warn">) => Promise<MarkdownRenderer>;
2183
2183
 
2184
2184
  type RawConfigExports<ThemeConfig = any> = Awaitable<UserConfig<ThemeConfig>> | (() => Awaitable<UserConfig<ThemeConfig>>);
2185
2185
  interface TransformContext {
@@ -2227,7 +2227,7 @@ interface UserConfig<ThemeConfig = any> extends LocaleSpecificConfig<ThemeConfig
2227
2227
  router?: {
2228
2228
  prefetchLinks?: boolean;
2229
2229
  };
2230
- appearance?: boolean | 'dark' | 'force-dark' | (Omit<UseDarkOptions, 'initialValue'> & {
2230
+ appearance?: boolean | 'dark' | 'force-dark' | 'force-auto' | (Omit<UseDarkOptions, 'initialValue'> & {
2231
2231
  initialValue?: 'dark';
2232
2232
  });
2233
2233
  lastUpdated?: boolean;
@@ -2464,7 +2464,7 @@ interface ScaffoldOptions {
2464
2464
  useTs: boolean;
2465
2465
  injectNpmScripts: boolean;
2466
2466
  }
2467
- declare function init(): Promise<void>;
2467
+ declare function init(root: string | undefined): Promise<void>;
2468
2468
  declare function scaffold({ root, title, description, theme, useTs, injectNpmScripts }: ScaffoldOptions): string;
2469
2469
 
2470
2470
  interface LoaderModule {
@@ -1,7 +1,7 @@
1
1
  import { normalizePath } from 'vite';
2
2
  export { loadEnv } from 'vite';
3
- import { g as glob, c as createMarkdownRenderer, f as fs, m as matter, a as getDefaultExportFromCjs } from './serve-CEEKiiuH.js';
4
- export { S as ScaffoldThemeType, b as build, p as createServer, e as defineConfig, h as defineConfigWithTheme, d as defineLoader, n as init, j as mergeConfig, r as resolveConfig, l as resolvePages, k as resolveSiteData, i as resolveUserConfig, s as scaffold, o as serve } from './serve-CEEKiiuH.js';
3
+ import { g as glob, c as createMarkdownRenderer, f as fs, m as matter, a as getDefaultExportFromCjs } from './serve-BhLFz9dF.js';
4
+ export { S as ScaffoldThemeType, b as build, p as createServer, e as defineConfig, h as defineConfigWithTheme, d as defineLoader, n as init, j as mergeConfig, r as resolveConfig, l as resolvePages, k as resolveSiteData, i as resolveUserConfig, s as scaffold, o as serve } from './serve-BhLFz9dF.js';
5
5
  import path from 'path';
6
6
  import 'crypto';
7
7
  import 'module';
@@ -4268,10 +4268,11 @@ class Minimatch {
4268
4268
  for (let i = 0; i < globParts.length - 1; i++) {
4269
4269
  for (let j = i + 1; j < globParts.length; j++) {
4270
4270
  const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
4271
- if (!matched)
4272
- continue;
4273
- globParts[i] = matched;
4274
- globParts[j] = [];
4271
+ if (matched) {
4272
+ globParts[i] = [];
4273
+ globParts[j] = matched;
4274
+ break;
4275
+ }
4275
4276
  }
4276
4277
  }
4277
4278
  return globParts.filter(gs => gs.length);
@@ -4871,21 +4872,26 @@ class Stack {
4871
4872
  /**
4872
4873
  * Default export, the thing you're using this module to get.
4873
4874
  *
4874
- * All properties from the options object (with the exception of
4875
- * {@link OptionsBase.max} and {@link OptionsBase.maxSize}) are added as
4876
- * normal public members. (`max` and `maxBase` are read-only getters.)
4877
- * Changing any of these will alter the defaults for subsequent method calls,
4878
- * but is otherwise safe.
4875
+ * The `K` and `V` types define the key and value types, respectively. The
4876
+ * optional `FC` type defines the type of the `context` object passed to
4877
+ * `cache.fetch()` and `cache.memo()`.
4878
+ *
4879
+ * Keys and values **must not** be `null` or `undefined`.
4880
+ *
4881
+ * All properties from the options object (with the exception of `max`,
4882
+ * `maxSize`, `fetchMethod`, `memoMethod`, `dispose` and `disposeAfter`) are
4883
+ * added as normal public members. (The listed options are read-only getters.)
4884
+ *
4885
+ * Changing any of these will alter the defaults for subsequent method calls.
4879
4886
  */
4880
4887
  class LRUCache {
4881
- // properties coming in from the options of these, only max and maxSize
4882
- // really *need* to be protected. The rest can be modified, as they just
4883
- // set defaults for various methods.
4888
+ // options that cannot be changed without disaster
4884
4889
  #max;
4885
4890
  #maxSize;
4886
4891
  #dispose;
4887
4892
  #disposeAfter;
4888
4893
  #fetchMethod;
4894
+ #memoMethod;
4889
4895
  /**
4890
4896
  * {@link LRUCache.OptionsBase.ttl}
4891
4897
  */
@@ -5031,6 +5037,9 @@ class LRUCache {
5031
5037
  get fetchMethod() {
5032
5038
  return this.#fetchMethod;
5033
5039
  }
5040
+ get memoMethod() {
5041
+ return this.#memoMethod;
5042
+ }
5034
5043
  /**
5035
5044
  * {@link LRUCache.OptionsBase.dispose} (read-only)
5036
5045
  */
@@ -5044,7 +5053,7 @@ class LRUCache {
5044
5053
  return this.#disposeAfter;
5045
5054
  }
5046
5055
  constructor(options) {
5047
- const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, } = options;
5056
+ const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, } = options;
5048
5057
  if (max !== 0 && !isPosInt(max)) {
5049
5058
  throw new TypeError('max option must be a nonnegative integer');
5050
5059
  }
@@ -5064,6 +5073,11 @@ class LRUCache {
5064
5073
  throw new TypeError('sizeCalculation set to non-function');
5065
5074
  }
5066
5075
  }
5076
+ if (memoMethod !== undefined &&
5077
+ typeof memoMethod !== 'function') {
5078
+ throw new TypeError('memoMethod must be a function if defined');
5079
+ }
5080
+ this.#memoMethod = memoMethod;
5067
5081
  if (fetchMethod !== undefined &&
5068
5082
  typeof fetchMethod !== 'function') {
5069
5083
  throw new TypeError('fetchMethod must be a function if specified');
@@ -5142,7 +5156,8 @@ class LRUCache {
5142
5156
  }
5143
5157
  }
5144
5158
  /**
5145
- * Return the remaining TTL time for a given entry key
5159
+ * Return the number of ms left in the item's TTL. If item is not in cache,
5160
+ * returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
5146
5161
  */
5147
5162
  getRemainingTTL(key) {
5148
5163
  return this.#keyMap.has(key) ? Infinity : 0;
@@ -5158,7 +5173,7 @@ class LRUCache {
5158
5173
  if (ttl !== 0 && this.ttlAutopurge) {
5159
5174
  const t = setTimeout(() => {
5160
5175
  if (this.#isStale(index)) {
5161
- this.delete(this.#keyList[index]);
5176
+ this.#delete(this.#keyList[index], 'expire');
5162
5177
  }
5163
5178
  }, ttl + 1);
5164
5179
  // unref() not supported on all platforms
@@ -5415,13 +5430,14 @@ class LRUCache {
5415
5430
  return this.entries();
5416
5431
  }
5417
5432
  /**
5418
- * A String value that is used in the creation of the default string description of an object.
5419
- * Called by the built-in method Object.prototype.toString.
5433
+ * A String value that is used in the creation of the default string
5434
+ * description of an object. Called by the built-in method
5435
+ * `Object.prototype.toString`.
5420
5436
  */
5421
5437
  [Symbol.toStringTag] = 'LRUCache';
5422
5438
  /**
5423
5439
  * Find a value for which the supplied fn method returns a truthy value,
5424
- * similar to Array.find(). fn is called as fn(value, key, cache).
5440
+ * similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
5425
5441
  */
5426
5442
  find(fn, getOptions = {}) {
5427
5443
  for (const i of this.#indexes()) {
@@ -5437,10 +5453,15 @@ class LRUCache {
5437
5453
  }
5438
5454
  }
5439
5455
  /**
5440
- * Call the supplied function on each item in the cache, in order from
5441
- * most recently used to least recently used. fn is called as
5442
- * fn(value, key, cache). Does not update age or recenty of use.
5443
- * Does not iterate over stale values.
5456
+ * Call the supplied function on each item in the cache, in order from most
5457
+ * recently used to least recently used.
5458
+ *
5459
+ * `fn` is called as `fn(value, key, cache)`.
5460
+ *
5461
+ * If `thisp` is provided, function will be called in the `this`-context of
5462
+ * the provided object, or the cache if no `thisp` object is provided.
5463
+ *
5464
+ * Does not update age or recenty of use, or iterate over stale values.
5444
5465
  */
5445
5466
  forEach(fn, thisp = this) {
5446
5467
  for (const i of this.#indexes()) {
@@ -5476,7 +5497,7 @@ class LRUCache {
5476
5497
  let deleted = false;
5477
5498
  for (const i of this.#rindexes({ allowStale: true })) {
5478
5499
  if (this.#isStale(i)) {
5479
- this.delete(this.#keyList[i]);
5500
+ this.#delete(this.#keyList[i], 'expire');
5480
5501
  deleted = true;
5481
5502
  }
5482
5503
  }
@@ -5484,9 +5505,15 @@ class LRUCache {
5484
5505
  }
5485
5506
  /**
5486
5507
  * Get the extended info about a given entry, to get its value, size, and
5487
- * TTL info simultaneously. Like {@link LRUCache#dump}, but just for a
5488
- * single key. Always returns stale values, if their info is found in the
5489
- * cache, so be sure to check for expired TTLs if relevant.
5508
+ * TTL info simultaneously. Returns `undefined` if the key is not present.
5509
+ *
5510
+ * Unlike {@link LRUCache#dump}, which is designed to be portable and survive
5511
+ * serialization, the `start` value is always the current timestamp, and the
5512
+ * `ttl` is a calculated remaining time to live (negative if expired).
5513
+ *
5514
+ * Always returns stale values, if their info is found in the cache, so be
5515
+ * sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
5516
+ * if relevant.
5490
5517
  */
5491
5518
  info(key) {
5492
5519
  const i = this.#keyMap.get(key);
@@ -5515,7 +5542,16 @@ class LRUCache {
5515
5542
  }
5516
5543
  /**
5517
5544
  * Return an array of [key, {@link LRUCache.Entry}] tuples which can be
5518
- * passed to cache.load()
5545
+ * passed to {@link LRLUCache#load}.
5546
+ *
5547
+ * The `start` fields are calculated relative to a portable `Date.now()`
5548
+ * timestamp, even if `performance.now()` is available.
5549
+ *
5550
+ * Stale entries are always included in the `dump`, even if
5551
+ * {@link LRUCache.OptionsBase.allowStale} is false.
5552
+ *
5553
+ * Note: this returns an actual array, not a generator, so it can be more
5554
+ * easily passed around.
5519
5555
  */
5520
5556
  dump() {
5521
5557
  const arr = [];
@@ -5544,8 +5580,12 @@ class LRUCache {
5544
5580
  }
5545
5581
  /**
5546
5582
  * Reset the cache and load in the items in entries in the order listed.
5547
- * Note that the shape of the resulting cache may be different if the
5548
- * same options are not used in both caches.
5583
+ *
5584
+ * The shape of the resulting cache may be different if the same options are
5585
+ * not used in both caches.
5586
+ *
5587
+ * The `start` fields are assumed to be calculated relative to a portable
5588
+ * `Date.now()` timestamp, even if `performance.now()` is available.
5549
5589
  */
5550
5590
  load(arr) {
5551
5591
  this.clear();
@@ -5568,6 +5608,30 @@ class LRUCache {
5568
5608
  *
5569
5609
  * Note: if `undefined` is specified as a value, this is an alias for
5570
5610
  * {@link LRUCache#delete}
5611
+ *
5612
+ * Fields on the {@link LRUCache.SetOptions} options param will override
5613
+ * their corresponding values in the constructor options for the scope
5614
+ * of this single `set()` operation.
5615
+ *
5616
+ * If `start` is provided, then that will set the effective start
5617
+ * time for the TTL calculation. Note that this must be a previous
5618
+ * value of `performance.now()` if supported, or a previous value of
5619
+ * `Date.now()` if not.
5620
+ *
5621
+ * Options object may also include `size`, which will prevent
5622
+ * calling the `sizeCalculation` function and just use the specified
5623
+ * number if it is a positive integer, and `noDisposeOnSet` which
5624
+ * will prevent calling a `dispose` function in the case of
5625
+ * overwrites.
5626
+ *
5627
+ * If the `size` (or return value of `sizeCalculation`) for a given
5628
+ * entry is greater than `maxEntrySize`, then the item will not be
5629
+ * added to the cache.
5630
+ *
5631
+ * Will update the recency of the entry.
5632
+ *
5633
+ * If the value is `undefined`, then this is an alias for
5634
+ * `cache.delete(key)`. `undefined` is never stored in the cache.
5571
5635
  */
5572
5636
  set(k, v, setOptions = {}) {
5573
5637
  if (v === undefined) {
@@ -5585,7 +5649,7 @@ class LRUCache {
5585
5649
  status.maxEntrySizeExceeded = true;
5586
5650
  }
5587
5651
  // have to delete, in case something is there already.
5588
- this.delete(k);
5652
+ this.#delete(k, 'set');
5589
5653
  return this;
5590
5654
  }
5591
5655
  let index = this.#size === 0 ? undefined : this.#keyMap.get(k);
@@ -5737,6 +5801,14 @@ class LRUCache {
5737
5801
  * Will return false if the item is stale, even though it is technically
5738
5802
  * in the cache.
5739
5803
  *
5804
+ * Check if a key is in the cache, without updating the recency of
5805
+ * use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
5806
+ * to `true` in either the options or the constructor.
5807
+ *
5808
+ * Will return `false` if the item is stale, even though it is technically in
5809
+ * the cache. The difference can be determined (if it matters) by using a
5810
+ * `status` argument, and inspecting the `has` field.
5811
+ *
5740
5812
  * Will not update item age unless
5741
5813
  * {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
5742
5814
  */
@@ -5828,7 +5900,7 @@ class LRUCache {
5828
5900
  this.#valList[index] = bf.__staleWhileFetching;
5829
5901
  }
5830
5902
  else {
5831
- this.delete(k);
5903
+ this.#delete(k, 'fetch');
5832
5904
  }
5833
5905
  }
5834
5906
  else {
@@ -5857,7 +5929,7 @@ class LRUCache {
5857
5929
  // the stale value is not removed from the cache when the fetch fails.
5858
5930
  const del = !noDelete || bf.__staleWhileFetching === undefined;
5859
5931
  if (del) {
5860
- this.delete(k);
5932
+ this.#delete(k, 'fetch');
5861
5933
  }
5862
5934
  else if (!allowStaleAborted) {
5863
5935
  // still replace the *promise* with the stale value,
@@ -6003,6 +6075,28 @@ class LRUCache {
6003
6075
  return staleVal ? p.__staleWhileFetching : (p.__returned = p);
6004
6076
  }
6005
6077
  }
6078
+ async forceFetch(k, fetchOptions = {}) {
6079
+ const v = await this.fetch(k, fetchOptions);
6080
+ if (v === undefined)
6081
+ throw new Error('fetch() returned undefined');
6082
+ return v;
6083
+ }
6084
+ memo(k, memoOptions = {}) {
6085
+ const memoMethod = this.#memoMethod;
6086
+ if (!memoMethod) {
6087
+ throw new Error('no memoMethod provided to constructor');
6088
+ }
6089
+ const { context, forceRefresh, ...options } = memoOptions;
6090
+ const v = this.get(k, options);
6091
+ if (!forceRefresh && v !== undefined)
6092
+ return v;
6093
+ const vv = memoMethod(k, v, {
6094
+ options,
6095
+ context,
6096
+ });
6097
+ this.set(k, vv, options);
6098
+ return vv;
6099
+ }
6006
6100
  /**
6007
6101
  * Return a value from the cache. Will update the recency of the cache
6008
6102
  * entry found.
@@ -6023,7 +6117,7 @@ class LRUCache {
6023
6117
  // delete only if not an in-flight background fetch
6024
6118
  if (!fetching) {
6025
6119
  if (!noDeleteOnStaleGet) {
6026
- this.delete(k);
6120
+ this.#delete(k, 'expire');
6027
6121
  }
6028
6122
  if (status && allowStale)
6029
6123
  status.returnedStale = true;
@@ -6086,16 +6180,20 @@ class LRUCache {
6086
6180
  }
6087
6181
  /**
6088
6182
  * Deletes a key out of the cache.
6183
+ *
6089
6184
  * Returns true if the key was deleted, false otherwise.
6090
6185
  */
6091
6186
  delete(k) {
6187
+ return this.#delete(k, 'delete');
6188
+ }
6189
+ #delete(k, reason) {
6092
6190
  let deleted = false;
6093
6191
  if (this.#size !== 0) {
6094
6192
  const index = this.#keyMap.get(k);
6095
6193
  if (index !== undefined) {
6096
6194
  deleted = true;
6097
6195
  if (this.#size === 1) {
6098
- this.clear();
6196
+ this.#clear(reason);
6099
6197
  }
6100
6198
  else {
6101
6199
  this.#removeItemSize(index);
@@ -6105,10 +6203,10 @@ class LRUCache {
6105
6203
  }
6106
6204
  else if (this.#hasDispose || this.#hasDisposeAfter) {
6107
6205
  if (this.#hasDispose) {
6108
- this.#dispose?.(v, k, 'delete');
6206
+ this.#dispose?.(v, k, reason);
6109
6207
  }
6110
6208
  if (this.#hasDisposeAfter) {
6111
- this.#disposed?.push([v, k, 'delete']);
6209
+ this.#disposed?.push([v, k, reason]);
6112
6210
  }
6113
6211
  }
6114
6212
  this.#keyMap.delete(k);
@@ -6144,6 +6242,9 @@ class LRUCache {
6144
6242
  * Clear the cache entirely, throwing away all values.
6145
6243
  */
6146
6244
  clear() {
6245
+ return this.#clear('delete');
6246
+ }
6247
+ #clear(reason) {
6147
6248
  for (const index of this.#rindexes({ allowStale: true })) {
6148
6249
  const v = this.#valList[index];
6149
6250
  if (this.#isBackgroundFetch(v)) {
@@ -6152,10 +6253,10 @@ class LRUCache {
6152
6253
  else {
6153
6254
  const k = this.#keyList[index];
6154
6255
  if (this.#hasDispose) {
6155
- this.#dispose?.(v, k, 'delete');
6256
+ this.#dispose?.(v, k, reason);
6156
6257
  }
6157
6258
  if (this.#hasDisposeAfter) {
6158
- this.#disposed?.push([v, k, 'delete']);
6259
+ this.#disposed?.push([v, k, reason]);
6159
6260
  }
6160
6261
  }
6161
6262
  }
@@ -20142,12 +20243,15 @@ function resolveSiteDataHead(userConfig) {
20142
20243
  head.push([
20143
20244
  "script",
20144
20245
  { id: "check-dark-mode" },
20145
- fallbackPreference === "force-dark" ? `document.documentElement.classList.add('dark')` : `;(() => {
20146
- const preference = localStorage.getItem('${APPEARANCE_KEY}') || '${fallbackPreference}'
20147
- const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
20148
- if (!preference || preference === 'auto' ? prefersDark : preference === 'dark')
20149
- document.documentElement.classList.add('dark')
20150
- })()`
20246
+ fallbackPreference === "force-dark" ? `document.documentElement.classList.add('dark')` : fallbackPreference === "force-auto" ? `;(() => {
20247
+ if (window.matchMedia('(prefers-color-scheme: dark)').matches)
20248
+ document.documentElement.classList.add('dark')
20249
+ })()` : `;(() => {
20250
+ const preference = localStorage.getItem('${APPEARANCE_KEY}') || '${fallbackPreference}'
20251
+ const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
20252
+ if (!preference || preference === 'auto' ? prefersDark : preference === 'dark')
20253
+ document.documentElement.classList.add('dark')
20254
+ })()`
20151
20255
  ]);
20152
20256
  }
20153
20257
  head.push([
@@ -37325,7 +37429,9 @@ const linkPlugin = (md, externalAttrs, base) => {
37325
37429
  md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
37326
37430
  const token = tokens[idx];
37327
37431
  const hrefIndex = token.attrIndex("href");
37328
- if (hrefIndex >= 0) {
37432
+ const targetIndex = token.attrIndex("target");
37433
+ const downloadIndex = token.attrIndex("download");
37434
+ if (hrefIndex >= 0 && targetIndex < 0 && downloadIndex < 0) {
37329
37435
  const hrefAttr = token.attrs[hrefIndex];
37330
37436
  const url = hrefAttr[1];
37331
37437
  if (isExternal(url)) {
@@ -38260,13 +38366,13 @@ const cache$2 = /* @__PURE__ */ new Map();
38260
38366
  function getGitTimestamp(file) {
38261
38367
  const cached = cache$2.get(file);
38262
38368
  if (cached) return cached;
38369
+ if (!fs$a.existsSync(file)) return 0;
38263
38370
  return new Promise((resolve, reject) => {
38264
- const cwd = dirname(file);
38265
- if (!fs$a.existsSync(cwd)) return resolve(0);
38266
- const fileName = basename(file);
38267
- const child = spawn_1("git", ["log", "-1", '--pretty="%ai"', fileName], {
38268
- cwd
38269
- });
38371
+ const child = spawn_1(
38372
+ "git",
38373
+ ["log", "-1", '--pretty="%ai"', basename(file)],
38374
+ { cwd: dirname(file) }
38375
+ );
38270
38376
  let output = "";
38271
38377
  child.stdout.on("data", (d) => output += String(d));
38272
38378
  child.on("close", () => {
@@ -38280,15 +38386,27 @@ function getGitTimestamp(file) {
38280
38386
 
38281
38387
  function processIncludes(srcDir, src, file, includes) {
38282
38388
  const includesRE = /<!--\s*@include:\s*(.*?)\s*-->/g;
38389
+ const regionRE = /(#[\w-]+)/;
38283
38390
  const rangeRE = /\{(\d*),(\d*)\}$/;
38284
38391
  return src.replace(includesRE, (m, m1) => {
38285
38392
  if (!m1.length) return m;
38286
38393
  const range = m1.match(rangeRE);
38287
- range && (m1 = m1.slice(0, -range[0].length));
38394
+ const region = m1.match(regionRE);
38395
+ const hasMeta = !!(region || range);
38396
+ if (hasMeta) {
38397
+ const len = (region?.[0].length || 0) + (range?.[0].length || 0);
38398
+ m1 = m1.slice(0, -len);
38399
+ }
38288
38400
  const atPresent = m1[0] === "@";
38289
38401
  try {
38290
38402
  const includePath = atPresent ? path$q.join(srcDir, m1.slice(m1[1] === "/" ? 2 : 1)) : path$q.join(path$q.dirname(file), m1);
38291
38403
  let content = fs$a.readFileSync(includePath, "utf-8");
38404
+ if (region) {
38405
+ const [regionName] = region;
38406
+ const lines = content.split(/\r?\n/);
38407
+ const regionLines = findRegion(lines, regionName.slice(1));
38408
+ content = lines.slice(regionLines?.start, regionLines?.end).join("\n");
38409
+ }
38292
38410
  if (range) {
38293
38411
  const [, startLine, endLine] = range;
38294
38412
  const lines = content.split(/\r?\n/);
@@ -38296,12 +38414,17 @@ function processIncludes(srcDir, src, file, includes) {
38296
38414
  startLine ? parseInt(startLine, 10) - 1 : void 0,
38297
38415
  endLine ? parseInt(endLine, 10) : void 0
38298
38416
  ).join("\n");
38299
- } else {
38417
+ }
38418
+ if (!hasMeta && path$q.extname(includePath) === ".md") {
38300
38419
  content = matter$1(content).content;
38301
38420
  }
38302
38421
  includes.push(slash(includePath));
38303
38422
  return processIncludes(srcDir, content, includePath, includes);
38304
38423
  } catch (error) {
38424
+ if (process.env.DEBUG) {
38425
+ process.stderr.write(c$1.yellow(`
38426
+ Include file not found: ${m1}`));
38427
+ }
38305
38428
  return m;
38306
38429
  }
38307
38430
  });
@@ -38422,8 +38545,12 @@ async function createMarkdownToVueRenderFn(srcDir, options = {}, pages, isBuild
38422
38545
  relativePath,
38423
38546
  filePath: slash(path$q.relative(srcDir, fileOrig))
38424
38547
  };
38425
- if (includeLastUpdatedData) {
38426
- pageData.lastUpdated = await getGitTimestamp(fileOrig);
38548
+ if (includeLastUpdatedData && frontmatter.lastUpdated !== false) {
38549
+ if (frontmatter.lastUpdated instanceof Date) {
38550
+ pageData.lastUpdated = +frontmatter.lastUpdated;
38551
+ } else {
38552
+ pageData.lastUpdated = await getGitTimestamp(fileOrig);
38553
+ }
38427
38554
  }
38428
38555
  if (siteConfig?.transformPageData) {
38429
38556
  const dataToMerge = await siteConfig.transformPageData(pageData, {
@@ -42789,7 +42916,11 @@ async function bundle(config, options) {
42789
42916
  clientResult = await buildMPAClient(clientJSMap, config);
42790
42917
  }
42791
42918
  }
42792
- return { clientResult, serverResult, pageToHashMap };
42919
+ const sortedPageToHashMap = /* @__PURE__ */ Object.create(null);
42920
+ Object.keys(pageToHashMap).sort().forEach((key) => {
42921
+ sortedPageToHashMap[key] = pageToHashMap[key];
42922
+ });
42923
+ return { clientResult, serverResult, pageToHashMap: sortedPageToHashMap };
42793
42924
  }
42794
42925
  const cache = /* @__PURE__ */ new Map();
42795
42926
  const cacheTheme = /* @__PURE__ */ new Map();
@@ -46656,6 +46787,10 @@ async function generateSitemap(siteConfig) {
46656
46787
  file = file.replace(/(\.html)?$/, ".md");
46657
46788
  file = siteConfig.rewrites.inv[file] || file;
46658
46789
  file = path$q.join(siteConfig.srcDir, file);
46790
+ if (!fs$a.existsSync(file)) return void 0;
46791
+ const { data } = matter$1.read(file);
46792
+ if (data.lastUpdated === false) return void 0;
46793
+ if (data.lastUpdated instanceof Date) return +data.lastUpdated;
46659
46794
  return await getGitTimestamp(file) || void 0;
46660
46795
  };
46661
46796
  await task("generating sitemap", async () => {
@@ -46699,7 +46834,7 @@ async function generateSitemap(siteConfig) {
46699
46834
  });
46700
46835
  }
46701
46836
 
46702
- var version = "1.2.3";
46837
+ var version = "1.3.0";
46703
46838
 
46704
46839
  async function renderPage(render, config, page, result, appChunk, cssChunk, assets, pageToHashMap, metadataScript, additionalHeadTags) {
46705
46840
  const routePath = `/${page.replace(/\.md$/, "")}`;
@@ -49192,16 +49327,19 @@ const getPackageManger = () => {
49192
49327
  const name = process.env?.npm_config_user_agent || "npm";
49193
49328
  return name.split("/")[0];
49194
49329
  };
49195
- async function init() {
49330
+ async function init(root) {
49196
49331
  oe(picocolorsExports.bold(picocolorsExports.cyan("Welcome to VitePress!")));
49197
49332
  const options = await he(
49198
49333
  {
49199
- root: () => te({
49200
- message: "Where should VitePress initialize the config?",
49201
- initialValue: "./",
49202
- validate(value) {
49203
- }
49204
- }),
49334
+ root: async () => {
49335
+ if (root) return root;
49336
+ return te({
49337
+ message: "Where should VitePress initialize the config?",
49338
+ initialValue: "./",
49339
+ validate(value) {
49340
+ }
49341
+ });
49342
+ },
49205
49343
  title: () => te({
49206
49344
  message: "Site title:",
49207
49345
  placeholder: "My Awesome Project"