vitepress 1.4.3 → 1.4.4

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.
@@ -34483,17 +34483,31 @@ function attrsToLines(attrs) {
34483
34483
  }
34484
34484
  async function highlight(theme, options, logger = console) {
34485
34485
  const {
34486
- defaultHighlightLang: defaultLang = "",
34486
+ defaultHighlightLang: defaultLang = "txt",
34487
34487
  codeTransformers: userTransformers = []
34488
34488
  } = options;
34489
+ const usingTwoslash = userTransformers.some(
34490
+ ({ name }) => name === "@shikijs/vitepress-twoslash"
34491
+ );
34489
34492
  const highlighter = await createHighlighter({
34490
34493
  themes: typeof theme === "object" && "light" in theme && "dark" in theme ? [theme.light, theme.dark] : [theme],
34491
34494
  langs: [
34492
34495
  ...options.languages || [],
34493
- ...Object.values(options.languageAlias || {})
34496
+ ...Object.values(options.languageAlias || {}),
34497
+ // patch for twoslash - https://github.com/vuejs/vitepress/issues/4334
34498
+ ...usingTwoslash ? Object.keys((await import('shiki')).bundledLanguages) : []
34494
34499
  ],
34495
34500
  langAlias: options.languageAlias
34496
34501
  });
34502
+ function loadLanguage(name) {
34503
+ const lang = typeof name === "string" ? name : name.name;
34504
+ if (!isSpecialLang(lang) && !highlighter.getLoadedLanguages().includes(lang)) {
34505
+ const resolvedLang = resolveLangSync(lang);
34506
+ if (resolvedLang.length) highlighter.loadLanguageSync(resolvedLang);
34507
+ else return false;
34508
+ }
34509
+ return true;
34510
+ }
34497
34511
  await options?.shikiSetup?.(highlighter);
34498
34512
  const transformers = [
34499
34513
  transformerNotationDiff(),
@@ -34524,22 +34538,14 @@ async function highlight(theme, options, logger = console) {
34524
34538
  (str, lang, attrs) => {
34525
34539
  const vPre = vueRE.test(lang) ? "" : "v-pre";
34526
34540
  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
- `
34535
- The language '${lang}' is not loaded, falling back to '${defaultLang || "txt"}' for syntax highlighting.`
34536
- )
34537
- );
34538
- lang = defaultLang;
34539
- } else {
34540
- highlighter.loadLanguageSync(resolvedLang);
34541
- }
34542
- }
34541
+ if (!loadLanguage(lang)) {
34542
+ logger.warn(
34543
+ c$1.yellow(
34544
+ `
34545
+ The language '${lang}' is not loaded, falling back to '${defaultLang}' for syntax highlighting.`
34546
+ )
34547
+ );
34548
+ lang = defaultLang;
34543
34549
  }
34544
34550
  const lineOptions = attrsToLines(attrs);
34545
34551
  const mustaches = /* @__PURE__ */ new Map();
@@ -48535,7 +48541,7 @@ async function generateSitemap(siteConfig) {
48535
48541
  });
48536
48542
  }
48537
48543
 
48538
- var version = "1.4.3";
48544
+ var version = "1.4.4";
48539
48545
 
48540
48546
  async function renderPage(render, config, page, result, appChunk, cssChunk, assets, pageToHashMap, metadataScript, additionalHeadTags) {
48541
48547
  const routePath = `/${page.replace(/\.md$/, "")}`;
package/dist/node/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as getDefaultExportFromCjs, u as c, n as disposeMdItInstance, v as clearCache, l as init, b as build, o as serve, w as version, q as createServer } from './chunk-BGE1nmDJ.js';
1
+ import { t as getDefaultExportFromCjs, u as c, n as disposeMdItInstance, v as clearCache, l as init, b as build, o as serve, w as version, q as createServer } from './chunk-L6-oDwDi.js';
2
2
  import { createLogger } from 'vite';
3
3
  import 'path';
4
4
  import 'url';
@@ -397,6 +397,9 @@ const SHORTCUTS = [
397
397
  }
398
398
  ];
399
399
 
400
+ if (process.env.DEBUG) {
401
+ Error.stackTraceLimit = Infinity;
402
+ }
400
403
  const argv = minimist(process.argv.slice(2));
401
404
  const logVersion = (logger = createLogger()) => {
402
405
  logger.info(`
@@ -1,7 +1,7 @@
1
1
  import { normalizePath } from 'vite';
2
2
  export { loadEnv } from 'vite';
3
- import { g as glob, c as createMarkdownRenderer, f as fs, m as matter, p as postcssPrefixSelector } from './chunk-BGE1nmDJ.js';
4
- export { S as ScaffoldThemeType, b as build, q as createServer, a as defineConfig, e as defineConfigWithTheme, d as defineLoader, n as disposeMdItInstance, l as init, i as mergeConfig, r as resolveConfig, k as resolvePages, j as resolveSiteData, h as resolveUserConfig, s as scaffold, o as serve } from './chunk-BGE1nmDJ.js';
3
+ import { g as glob, c as createMarkdownRenderer, f as fs, m as matter, p as postcssPrefixSelector } from './chunk-L6-oDwDi.js';
4
+ export { S as ScaffoldThemeType, b as build, q as createServer, a as defineConfig, e as defineConfigWithTheme, d as defineLoader, n as disposeMdItInstance, l as init, i as mergeConfig, r as resolveConfig, k as resolvePages, j as resolveSiteData, h as resolveUserConfig, s as scaffold, o as serve } from './chunk-L6-oDwDi.js';
5
5
  import path from 'path';
6
6
  import 'crypto';
7
7
  import 'module';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitepress",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "Vite & Vue powered static site generator",
5
5
  "keywords": [
6
6
  "vite",