valaxy 0.22.17 → 0.23.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.
@@ -1,18 +1,10 @@
1
- import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
2
- import {
3
- createSyncFn
4
- } from "./chunk-J2BOKDJT.js";
5
- import {
6
- __require
7
- } from "./chunk-5DSTD5D3.js";
8
-
9
1
  // node/cli/index.ts
10
2
  import process14 from "node:process";
11
3
  import yargs from "yargs";
12
4
  import { hideBin } from "yargs/helpers";
13
5
 
14
6
  // package.json
15
- var version = "0.22.17";
7
+ var version = "0.23.0";
16
8
 
17
9
  // node/modules/fuse.ts
18
10
  import path4 from "node:path";
@@ -1313,7 +1305,7 @@ var clientDeps = [
1313
1305
  "dayjs/plugin/relativeTime",
1314
1306
  "dayjs/plugin/timezone",
1315
1307
  "dayjs/plugin/utc",
1316
- "@unhead/schema-org",
1308
+ "@unhead/schema-org/vue",
1317
1309
  "@unhead/vue",
1318
1310
  "defu",
1319
1311
  "katex",
@@ -1530,9 +1522,6 @@ import {
1530
1522
  createHighlighter,
1531
1523
  isSpecialLang
1532
1524
  } from "shiki";
1533
- var resolveLangSync = createSyncFn(
1534
- __require.resolve("valaxy/dist/node/worker_shikiResolveLang.js")
1535
- );
1536
1525
  var nanoid2 = customAlphabet("abcdefghijklmnopqrstuvwxyz", 10);
1537
1526
  function attrsToLines(attrs) {
1538
1527
  attrs = attrs.replace(/^(?:\[.*?\])?.*?([\d,-]+).*/, "$1").trim();
@@ -1568,22 +1557,6 @@ async function highlight(theme, options, logger2 = console) {
1568
1557
  ],
1569
1558
  langAlias: options.languageAlias
1570
1559
  });
1571
- function loadLanguage(name) {
1572
- const lang = typeof name === "string" ? name : name.name;
1573
- if (!isSpecialLang(lang) && !highlighter.getLoadedLanguages().includes(lang)) {
1574
- const resolvedLang = resolveLangSync(lang);
1575
- if (resolvedLang.length)
1576
- highlighter.loadLanguageSync(resolvedLang);
1577
- else return false;
1578
- }
1579
- return true;
1580
- }
1581
- const internal = highlighter.getInternalContext();
1582
- const getLanguage = internal.getLanguage;
1583
- internal.getLanguage = (name) => {
1584
- loadLanguage(name);
1585
- return getLanguage.call(internal, name);
1586
- };
1587
1560
  await options?.shikiSetup?.(highlighter);
1588
1561
  const transformers = [
1589
1562
  transformerNotationDiff(),
@@ -1611,78 +1584,85 @@ async function highlight(theme, options, logger2 = console) {
1611
1584
  const lineNoStartRE = /=(\d*)/;
1612
1585
  const lineNoRE = /:(no-)?line-numbers(=\d*)?$/;
1613
1586
  const mustacheRE = /\{\{.*?\}\}/g;
1614
- return (str, lang, attrs) => {
1615
- const vPre = vueRE.test(lang) ? "" : "v-pre";
1616
- lang = lang.replace(lineNoStartRE, "").replace(lineNoRE, "").replace(vueRE, "").toLowerCase() || defaultLang;
1617
- if (!loadLanguage(lang)) {
1618
- logger2.warn(
1619
- colors9.yellow(
1620
- `
1621
- The language '${lang}' is not loaded, falling back to '${defaultLang}' for syntax highlighting.`
1622
- )
1623
- );
1624
- lang = defaultLang;
1625
- }
1626
- const lineOptions = attrsToLines(attrs);
1627
- const mustaches = /* @__PURE__ */ new Map();
1628
- const removeMustache = (s) => {
1629
- if (vPre)
1630
- return s;
1631
- return s.replace(mustacheRE, (match) => {
1632
- let marker = mustaches.get(match);
1633
- if (!marker) {
1634
- marker = nanoid2();
1635
- mustaches.set(match, marker);
1587
+ return [
1588
+ async (str, lang, attrs) => {
1589
+ const vPre = vueRE.test(lang) ? "" : "v-pre";
1590
+ lang = lang.replace(lineNoStartRE, "").replace(lineNoRE, "").replace(vueRE, "").toLowerCase() || defaultLang;
1591
+ try {
1592
+ if (!isSpecialLang(lang) && !highlighter.getLoadedLanguages().includes(lang)) {
1593
+ await highlighter.loadLanguage(lang);
1636
1594
  }
1637
- return marker;
1638
- });
1639
- };
1640
- const restoreMustache = (s) => {
1641
- mustaches.forEach((marker, match) => {
1642
- s = s.replaceAll(marker, match);
1643
- });
1644
- return s;
1645
- };
1646
- str = removeMustache(str).trimEnd();
1647
- const highlighted = highlighter.codeToHtml(str, {
1648
- lang,
1649
- transformers: [
1650
- ...transformers,
1651
- transformerCompactLineOptions(lineOptions),
1652
- {
1653
- name: "valaxy:v-pre",
1654
- pre(node) {
1655
- if (vPre)
1656
- node.properties["v-pre"] = "";
1657
- }
1658
- },
1659
- {
1660
- name: "valaxy:empty-line",
1661
- code(hast) {
1662
- hast.children.forEach((span) => {
1663
- if (span.type === "element" && span.tagName === "span" && Array.isArray(span.properties.class) && span.properties.class.includes("line") && span.children.length === 0) {
1664
- span.children.push({
1665
- type: "element",
1666
- tagName: "wbr",
1667
- properties: {},
1668
- children: []
1669
- });
1670
- }
1671
- });
1595
+ } catch {
1596
+ logger2.warn(
1597
+ colors9.yellow(
1598
+ `
1599
+ The language '${lang}' is not loaded, falling back to '${defaultLang}' for syntax highlighting.`
1600
+ )
1601
+ );
1602
+ lang = defaultLang;
1603
+ }
1604
+ const lineOptions = attrsToLines(attrs);
1605
+ const mustaches = /* @__PURE__ */ new Map();
1606
+ const removeMustache = (s) => {
1607
+ if (vPre)
1608
+ return s;
1609
+ return s.replace(mustacheRE, (match) => {
1610
+ let marker = mustaches.get(match);
1611
+ if (!marker) {
1612
+ marker = nanoid2();
1613
+ mustaches.set(match, marker);
1672
1614
  }
1615
+ return marker;
1616
+ });
1617
+ };
1618
+ const restoreMustache = (s) => {
1619
+ mustaches.forEach((marker, match) => {
1620
+ s = s.replaceAll(marker, match);
1621
+ });
1622
+ return s;
1623
+ };
1624
+ str = removeMustache(str).trimEnd();
1625
+ const highlighted = highlighter.codeToHtml(str, {
1626
+ lang,
1627
+ transformers: [
1628
+ ...transformers,
1629
+ transformerCompactLineOptions(lineOptions),
1630
+ {
1631
+ name: "valaxy:v-pre",
1632
+ pre(node) {
1633
+ if (vPre)
1634
+ node.properties["v-pre"] = "";
1635
+ }
1636
+ },
1637
+ {
1638
+ name: "valaxy:empty-line",
1639
+ code(hast) {
1640
+ hast.children.forEach((span) => {
1641
+ if (span.type === "element" && span.tagName === "span" && Array.isArray(span.properties.class) && span.properties.class.includes("line") && span.children.length === 0) {
1642
+ span.children.push({
1643
+ type: "element",
1644
+ tagName: "wbr",
1645
+ properties: {},
1646
+ children: []
1647
+ });
1648
+ }
1649
+ });
1650
+ }
1651
+ },
1652
+ ...userTransformers
1653
+ ],
1654
+ meta: {
1655
+ __raw: attrs
1673
1656
  },
1674
- ...userTransformers
1675
- ],
1676
- meta: {
1677
- __raw: attrs
1678
- },
1679
- ...typeof theme === "object" && "light" in theme && "dark" in theme ? { themes: theme, defaultColor: false } : { theme }
1680
- });
1681
- return restoreMustache(highlighted);
1682
- };
1657
+ ...typeof theme === "object" && "light" in theme && "dark" in theme ? { themes: theme, defaultColor: false } : { theme }
1658
+ });
1659
+ return restoreMustache(highlighted);
1660
+ },
1661
+ highlighter.dispose
1662
+ ];
1683
1663
  }
1684
1664
 
1685
- // ../../node_modules/.pnpm/@mdit-vue+shared@2.1.3/node_modules/@mdit-vue/shared/dist/index.mjs
1665
+ // ../../node_modules/.pnpm/@mdit-vue+shared@2.1.4/node_modules/@mdit-vue/shared/dist/index.mjs
1686
1666
  var htmlEscapeMap = {
1687
1667
  "&": "&",
1688
1668
  "<": "&lt;",
@@ -1772,15 +1752,15 @@ var rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'“”‘’<>,.?/]+/g;
1772
1752
  var rCombining = /[\u0300-\u036F]/g;
1773
1753
  var slugify = (str) => str.normalize("NFKD").replace(rCombining, "").replace(rControl, "").replace(rSpecial, "-").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "").replace(/^(\d)/, "_$1").toLowerCase();
1774
1754
 
1775
- // ../../node_modules/.pnpm/@mdit-vue+plugin-headers@2.1.3/node_modules/@mdit-vue/plugin-headers/dist/index.mjs
1776
- var headersPlugin = (md, {
1755
+ // ../../node_modules/.pnpm/@mdit-vue+plugin-headers@2.1.4/node_modules/@mdit-vue/plugin-headers/dist/index.mjs
1756
+ var headersPlugin = (md3, {
1777
1757
  level = [2, 3],
1778
1758
  shouldAllowNested = false,
1779
1759
  slugify: slugify$1 = slugify,
1780
1760
  format
1781
1761
  } = {}) => {
1782
- const render2 = md.renderer.render.bind(md.renderer);
1783
- md.renderer.render = (tokens, options, env) => {
1762
+ const render2 = md3.renderer.render.bind(md3.renderer);
1763
+ md3.renderer.render = (tokens, options, env) => {
1784
1764
  env.headers = resolveHeadersFromTokens(tokens, {
1785
1765
  level,
1786
1766
  shouldAllowHtml: false,
@@ -1793,7 +1773,7 @@ var headersPlugin = (md, {
1793
1773
  };
1794
1774
  };
1795
1775
 
1796
- // ../../node_modules/.pnpm/@mdit-vue+plugin-sfc@2.1.3/node_modules/@mdit-vue/plugin-sfc/dist/index.mjs
1776
+ // ../../node_modules/.pnpm/@mdit-vue+plugin-sfc@2.1.4/node_modules/@mdit-vue/plugin-sfc/dist/index.mjs
1797
1777
  var TAG_NAME_SCRIPT = "script";
1798
1778
  var TAG_NAME_STYLE = "style";
1799
1779
  var TAG_NAME_TEMPLATE = "template";
@@ -1809,10 +1789,10 @@ var createSfcRegexp = ({
1809
1789
  "is"
1810
1790
  );
1811
1791
  };
1812
- var sfcPlugin = (md, { customBlocks = [] } = {}) => {
1792
+ var sfcPlugin = (md3, { customBlocks = [] } = {}) => {
1813
1793
  const sfcRegexp = createSfcRegexp({ customBlocks });
1814
- const render2 = md.render.bind(md);
1815
- md.render = (src, env = {}) => {
1794
+ const render2 = md3.render.bind(md3);
1795
+ md3.render = (src, env = {}) => {
1816
1796
  env.sfcBlocks = {
1817
1797
  template: null,
1818
1798
  script: null,
@@ -1831,8 +1811,8 @@ var sfcPlugin = (md, { customBlocks = [] } = {}) => {
1831
1811
  };
1832
1812
  return rendered;
1833
1813
  };
1834
- const htmlBlockRule = md.renderer.rules.html_block;
1835
- md.renderer.rules.html_block = (tokens, idx, options, env, self) => {
1814
+ const htmlBlockRule = md3.renderer.rules.html_block;
1815
+ md3.renderer.rules.html_block = (tokens, idx, options, env, self) => {
1836
1816
  if (!env.sfcBlocks) {
1837
1817
  return htmlBlockRule(tokens, idx, options, env, self);
1838
1818
  }
@@ -1859,10 +1839,10 @@ var sfcPlugin = (md, { customBlocks = [] } = {}) => {
1859
1839
  };
1860
1840
  };
1861
1841
 
1862
- // ../../node_modules/.pnpm/@mdit-vue+plugin-title@2.1.3/node_modules/@mdit-vue/plugin-title/dist/index.mjs
1863
- var titlePlugin = (md) => {
1864
- const render2 = md.renderer.render.bind(md.renderer);
1865
- md.renderer.render = (tokens, options, env) => {
1842
+ // ../../node_modules/.pnpm/@mdit-vue+plugin-title@2.1.4/node_modules/@mdit-vue/plugin-title/dist/index.mjs
1843
+ var titlePlugin = (md3) => {
1844
+ const render2 = md3.renderer.render.bind(md3.renderer);
1845
+ md3.renderer.render = (tokens, options, env) => {
1866
1846
  const tokenIdx = tokens.findIndex((token) => token.tag === "h1");
1867
1847
  env.title = tokenIdx > -1 ? resolveTitleFromToken(tokens[tokenIdx + 1], {
1868
1848
  shouldAllowHtml: false,
@@ -1872,7 +1852,7 @@ var titlePlugin = (md) => {
1872
1852
  };
1873
1853
  };
1874
1854
 
1875
- // ../../node_modules/.pnpm/@mdit-vue+plugin-toc@2.1.3/node_modules/@mdit-vue/plugin-toc/dist/index.mjs
1855
+ // ../../node_modules/.pnpm/@mdit-vue+plugin-toc@2.1.4/node_modules/@mdit-vue/plugin-toc/dist/index.mjs
1876
1856
  var createRenderHeaders = ({
1877
1857
  listTag,
1878
1858
  listClass,
@@ -1903,10 +1883,8 @@ var createTocBlockRule = ({
1903
1883
  const pos = state.bMarks[startLine] + state.tShift[startLine];
1904
1884
  const max = state.eMarks[startLine];
1905
1885
  const lineFirstToken = state.src.slice(pos, max).split(" ")[0];
1906
- if (!pattern.test(lineFirstToken))
1907
- return false;
1908
- if (silent)
1909
- return true;
1886
+ if (!pattern.test(lineFirstToken)) return false;
1887
+ if (silent) return true;
1910
1888
  state.line = startLine + 1;
1911
1889
  const tokenOpen = state.push("toc_open", containerTag, 1);
1912
1890
  tokenOpen.markup = "";
@@ -1923,7 +1901,7 @@ var createTocBlockRule = ({
1923
1901
  tokenBody.map = [startLine, state.line];
1924
1902
  return true;
1925
1903
  };
1926
- var tocPlugin = (md, {
1904
+ var tocPlugin = (md3, {
1927
1905
  pattern = /^\[\[toc\]\]$/i,
1928
1906
  slugify: slugify$1 = slugify,
1929
1907
  format,
@@ -1937,7 +1915,7 @@ var tocPlugin = (md, {
1937
1915
  linkTag = "a",
1938
1916
  linkClass = ""
1939
1917
  } = {}) => {
1940
- md.block.ruler.before(
1918
+ md3.block.ruler.before(
1941
1919
  "heading",
1942
1920
  "toc",
1943
1921
  createTocBlockRule({
@@ -1956,7 +1934,7 @@ var tocPlugin = (md, {
1956
1934
  linkTag,
1957
1935
  linkClass
1958
1936
  });
1959
- md.renderer.rules.toc_body = (tokens) => renderHeaders(
1937
+ md3.renderer.rules.toc_body = (tokens) => renderHeaders(
1960
1938
  resolveHeadersFromTokens(tokens, {
1961
1939
  level,
1962
1940
  shouldAllowHtml: true,
@@ -1980,8 +1958,8 @@ import TaskLists from "markdown-it-task-lists";
1980
1958
  // node/plugins/markdown/plugins/link.ts
1981
1959
  import { URL as URL2 } from "node:url";
1982
1960
  var indexRE = /(^|.*\/)index.md(.*)$/i;
1983
- function linkPlugin(md, externalAttrs, base) {
1984
- md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
1961
+ function linkPlugin(md3, externalAttrs, base) {
1962
+ md3.renderer.rules.link_open = (tokens, idx, options, env, self) => {
1985
1963
  const token = tokens[idx];
1986
1964
  const hrefIndex = token.attrIndex("href");
1987
1965
  if (hrefIndex >= 0) {
@@ -2058,9 +2036,9 @@ function getCodeHeightLimitStyle(options, env) {
2058
2036
  return "";
2059
2037
  return `style="max-height: ${codeHeightLimit}px;"`;
2060
2038
  }
2061
- function preWrapperPlugin(md, options) {
2062
- const fence = md.renderer.rules.fence;
2063
- md.renderer.rules.fence = (...args) => {
2039
+ function preWrapperPlugin(md3, options) {
2040
+ const fence = md3.renderer.rules.fence;
2041
+ md3.renderer.rules.fence = (...args) => {
2064
2042
  const [tokens, idx, _, env] = args;
2065
2043
  const token = tokens[idx];
2066
2044
  token.info = token.info.replace(/\[.*\]/, "");
@@ -2138,18 +2116,18 @@ var defaultBlocksOptions = {
2138
2116
  }
2139
2117
  }
2140
2118
  };
2141
- function containerPlugin(md, options, containerOptions = {}) {
2119
+ function containerPlugin(md3, options, containerOptions = {}) {
2142
2120
  Object.keys(defaultBlocksOptions).forEach((optionKey) => {
2143
2121
  const option = {
2144
2122
  ...defaultBlocksOptions[optionKey],
2145
2123
  ...containerOptions[optionKey] || {}
2146
2124
  };
2147
- md.use(...createContainer(optionKey, option));
2125
+ md3.use(...createContainer(optionKey, option));
2148
2126
  });
2149
- md.use(...createCodeGroup(options));
2127
+ md3.use(...createCodeGroup(options));
2150
2128
  const languages = ["zh-CN", "en"];
2151
2129
  languages.forEach((lang) => {
2152
- md.use(container, lang, {
2130
+ md3.use(container, lang, {
2153
2131
  render: (tokens, idx) => tokens[idx].nesting === 1 ? `<div lang="${lang}">
2154
2132
  ` : "</div>\n"
2155
2133
  });
@@ -2194,27 +2172,27 @@ function createCodeGroup(options) {
2194
2172
  }
2195
2173
 
2196
2174
  // node/plugins/markdown/plugins/markdown-it/footnoteTooltip.ts
2197
- function footnoteTooltipPlugin(md) {
2198
- const originalFootnoteRef = md.renderer.rules.footnote_ref;
2199
- const originalFootnoteOpen = md.renderer.rules.footnote_open;
2200
- const originalFootnoteClose = md.renderer.rules.footnote_close;
2201
- const originalFootnoteAnchor = md.renderer.rules.footnote_anchor;
2202
- md.renderer.rules.footnote_ref = function(tokens, idx, options, env, self) {
2175
+ function footnoteTooltipPlugin(md3) {
2176
+ const originalFootnoteRef = md3.renderer.rules.footnote_ref;
2177
+ const originalFootnoteOpen = md3.renderer.rules.footnote_open;
2178
+ const originalFootnoteClose = md3.renderer.rules.footnote_close;
2179
+ const originalFootnoteAnchor = md3.renderer.rules.footnote_anchor;
2180
+ md3.renderer.rules.footnote_ref = function(tokens, idx, options, env, self) {
2203
2181
  const originalCode = originalFootnoteRef(tokens, idx, options, env, self);
2204
2182
  const href = originalCode.match(/href="(.*?)"/)[0];
2205
2183
  const id = originalCode.match(/id="(.*?)"/)[0];
2206
2184
  return `<ValaxyFootnoteRef ${href} ${id}>${originalCode}</ValaxyFootnoteRef>`;
2207
2185
  };
2208
- md.renderer.rules.footnote_open = function(tokens, idx, options, env, self) {
2186
+ md3.renderer.rules.footnote_open = function(tokens, idx, options, env, self) {
2209
2187
  const originalOpen = originalFootnoteOpen(tokens, idx, options, env, self);
2210
2188
  const id = originalOpen.match(/id="(.*?)"/)[0];
2211
2189
  return `<ValaxyFootnoteItem ${id}>${originalOpen}<ValaxyFootnoteContent>`;
2212
2190
  };
2213
- md.renderer.rules.footnote_close = function(tokens, idx, options, env, self) {
2191
+ md3.renderer.rules.footnote_close = function(tokens, idx, options, env, self) {
2214
2192
  const originalClose = originalFootnoteClose(tokens, idx, options, env, self);
2215
2193
  return `</ValaxyFootnoteContent>${originalClose}</ValaxyFootnoteItem>`;
2216
2194
  };
2217
- md.renderer.rules.footnote_anchor = function(tokens, idx, options, env, self) {
2195
+ md3.renderer.rules.footnote_anchor = function(tokens, idx, options, env, self) {
2218
2196
  const originalCode = originalFootnoteAnchor(tokens, idx, options, env, self);
2219
2197
  const href = originalCode.match(/href="(.*?)"/)[0];
2220
2198
  return `<ValaxyFootnoteAnchor ${href}>${originalCode}</ValaxyFootnoteAnchor>`;
@@ -2223,9 +2201,9 @@ function footnoteTooltipPlugin(md) {
2223
2201
 
2224
2202
  // node/plugins/markdown/plugins/markdown-it/highlightLines.ts
2225
2203
  var RE = /\{([\d,-]+)\}/;
2226
- function highlightLinePlugin(md) {
2227
- const fence = md.renderer.rules.fence;
2228
- md.renderer.rules.fence = (...args) => {
2204
+ function highlightLinePlugin(md3) {
2205
+ const fence = md3.renderer.rules.fence;
2206
+ md3.renderer.rules.fence = (...args) => {
2229
2207
  const [tokens, idx] = args;
2230
2208
  const token = tokens[idx];
2231
2209
  const attr = token.attrs && token.attrs[0];
@@ -2358,7 +2336,7 @@ function math_block(state, start, end, silent) {
2358
2336
  token.markup = "$$";
2359
2337
  return true;
2360
2338
  }
2361
- function math_plugin(md, options) {
2339
+ function math_plugin(md3, options) {
2362
2340
  options = options || {};
2363
2341
  const katexInline = function(latex) {
2364
2342
  options.displayMode = false;
@@ -2387,18 +2365,18 @@ function math_plugin(md, options) {
2387
2365
  return `${katexBlock(tokens[idx].content)}
2388
2366
  `;
2389
2367
  };
2390
- md.inline.ruler.after("escape", "math_inline", math_inline);
2391
- md.block.ruler.after("blockquote", "math_block", math_block, {
2368
+ md3.inline.ruler.after("escape", "math_inline", math_inline);
2369
+ md3.block.ruler.after("blockquote", "math_block", math_block, {
2392
2370
  alt: ["paragraph", "reference", "blockquote", "list"]
2393
2371
  });
2394
- md.renderer.rules.math_inline = inlineRenderer;
2395
- md.renderer.rules.math_block = blockRenderer;
2372
+ md3.renderer.rules.math_inline = inlineRenderer;
2373
+ md3.renderer.rules.math_block = blockRenderer;
2396
2374
  }
2397
2375
 
2398
2376
  // node/plugins/markdown/plugins/markdown-it/lineNumbers.ts
2399
- function lineNumberPlugin(md, enable = false) {
2400
- const fence = md.renderer.rules.fence;
2401
- md.renderer.rules.fence = (...args) => {
2377
+ function lineNumberPlugin(md3, enable = false) {
2378
+ const fence = md3.renderer.rules.fence;
2379
+ md3.renderer.rules.fence = (...args) => {
2402
2380
  const rawCode = fence(...args);
2403
2381
  const [tokens, idx] = args;
2404
2382
  const info = tokens[idx].info;
@@ -2493,7 +2471,7 @@ function findRegion(lines, regionName) {
2493
2471
  }
2494
2472
  return null;
2495
2473
  }
2496
- function snippetPlugin(md, srcDir) {
2474
+ function snippetPlugin(md3, srcDir) {
2497
2475
  const parser = (state, startLine, endLine, silent) => {
2498
2476
  const CH = "<".charCodeAt(0);
2499
2477
  const pos = state.bMarks[startLine] + state.tShift[startLine];
@@ -2521,8 +2499,8 @@ function snippetPlugin(md, srcDir) {
2521
2499
  token.map = [startLine, startLine + 1];
2522
2500
  return true;
2523
2501
  };
2524
- const fence = md.renderer.rules.fence;
2525
- md.renderer.rules.fence = (...args) => {
2502
+ const fence = md3.renderer.rules.fence;
2503
+ md3.renderer.rules.fence = (...args) => {
2526
2504
  const [tokens, idx, , { includes }] = args;
2527
2505
  const token = tokens[idx];
2528
2506
  const [src, regionName] = token.src ?? [];
@@ -2549,19 +2527,19 @@ function snippetPlugin(md, srcDir) {
2549
2527
  token.content = content;
2550
2528
  return fence(...args);
2551
2529
  };
2552
- md.block.ruler.before("fence", "snippet", parser);
2530
+ md3.block.ruler.before("fence", "snippet", parser);
2553
2531
  }
2554
2532
 
2555
2533
  // node/plugins/markdown/setup.ts
2556
2534
  var defaultCodeTheme = { light: "github-light", dark: "github-dark" };
2557
- async function setupMarkdownPlugins(md, options, base = "/") {
2535
+ async function setupMarkdownPlugins(md3, options, base = "/") {
2558
2536
  const mdOptions = options?.config.markdown || {};
2559
2537
  const theme = mdOptions.theme ?? defaultCodeTheme;
2560
2538
  const hasSingleTheme = typeof theme === "string" || "name" in theme;
2561
2539
  const siteConfig = options?.config.siteConfig || {};
2562
2540
  if (mdOptions.preConfig)
2563
- mdOptions.preConfig(md);
2564
- md.use(highlightLinePlugin).use(preWrapperPlugin, { theme, siteConfig }).use(snippetPlugin, options?.userRoot).use(containerPlugin, {
2541
+ mdOptions.preConfig(md3);
2542
+ md3.use(highlightLinePlugin).use(preWrapperPlugin, { theme, siteConfig }).use(snippetPlugin, options?.userRoot).use(containerPlugin, {
2565
2543
  hasSingleTheme
2566
2544
  }, {
2567
2545
  ...mdOptions.blocks,
@@ -2577,11 +2555,11 @@ async function setupMarkdownPlugins(md, options, base = "/") {
2577
2555
  },
2578
2556
  base
2579
2557
  );
2580
- md.use(lineNumberPlugin, mdOptions.lineNumbers);
2558
+ md3.use(lineNumberPlugin, mdOptions.lineNumbers);
2581
2559
  if (!mdOptions.attrs?.disable)
2582
- md.use(attrsPlugin, mdOptions.attrs);
2583
- md.use(emojiPlugin).use(footnotePlugin).use(footnoteTooltipPlugin);
2584
- md.use(anchorPlugin, {
2560
+ md3.use(attrsPlugin, mdOptions.attrs);
2561
+ md3.use(emojiPlugin).use(footnotePlugin).use(footnoteTooltipPlugin);
2562
+ md3.use(anchorPlugin, {
2585
2563
  slugify,
2586
2564
  permalink: anchorPlugin.permalink.linkInsideHeader({
2587
2565
  symbol: "&ZeroWidthSpace;",
@@ -2599,7 +2577,7 @@ async function setupMarkdownPlugins(md, options, base = "/") {
2599
2577
  }),
2600
2578
  ...mdOptions.anchor
2601
2579
  });
2602
- md.use(headersPlugin, {
2580
+ md3.use(headersPlugin, {
2603
2581
  slugify,
2604
2582
  ...typeof mdOptions.headers === "boolean" ? void 0 : mdOptions.headers
2605
2583
  }).use(sfcPlugin, {
@@ -2607,9 +2585,9 @@ async function setupMarkdownPlugins(md, options, base = "/") {
2607
2585
  }).use(titlePlugin).use(tocPlugin, {
2608
2586
  ...mdOptions.toc
2609
2587
  });
2610
- md.use(math_plugin, mdOptions.katex);
2588
+ md3.use(math_plugin, mdOptions.katex);
2611
2589
  const vanillaLazyload = options?.config.siteConfig.vanillaLazyload || { enable: false };
2612
- md.use(imageFigures, {
2590
+ md3.use(imageFigures, {
2613
2591
  figcaption: true,
2614
2592
  // default web performance recommended settings
2615
2593
  lazy: true,
@@ -2625,21 +2603,43 @@ async function setupMarkdownPlugins(md, options, base = "/") {
2625
2603
  } : {},
2626
2604
  ...mdOptions.imageFigures
2627
2605
  });
2628
- md.use(TaskLists);
2606
+ md3.use(TaskLists);
2629
2607
  if (options?.config.groupIcons) {
2630
2608
  const { groupIconMdPlugin } = await import("vitepress-plugin-group-icons");
2631
- md.use(groupIconMdPlugin, {
2609
+ md3.use(groupIconMdPlugin, {
2632
2610
  titleBar: { includeSnippet: true }
2633
2611
  });
2634
2612
  }
2635
2613
  if (mdOptions.config)
2636
- mdOptions.config(md);
2637
- return md;
2614
+ mdOptions.config(md3);
2615
+ return md3;
2638
2616
  }
2639
2617
 
2640
2618
  // node/plugins/markdown/transform/index.ts
2641
2619
  import Markdown from "unplugin-vue-markdown/vite";
2642
2620
 
2621
+ // node/app/state.ts
2622
+ var StateManager = class {
2623
+ /**
2624
+ * @zh 文章 ID 映射
2625
+ */
2626
+ idMap = /* @__PURE__ */ new Map();
2627
+ };
2628
+
2629
+ // node/app/class.ts
2630
+ var Valaxy = class {
2631
+ /**
2632
+ * version
2633
+ */
2634
+ static version = version;
2635
+ /**
2636
+ * file state
2637
+ */
2638
+ static state = new StateManager();
2639
+ constructor() {
2640
+ }
2641
+ };
2642
+
2643
2643
  // node/plugins/markdown/transform/include.ts
2644
2644
  import { slash as slash2 } from "@antfu/utils";
2645
2645
  import path7 from "pathe";
@@ -2714,24 +2714,34 @@ function resolveTransformIncludes(code, id, options) {
2714
2714
 
2715
2715
  // node/plugins/markdown/transform/mermaid.ts
2716
2716
  import * as base64 from "js-base64";
2717
- function transformMermaid(md) {
2718
- md = md.replace(/^````txt\n```mermaid/gm, "````txt\n\\`\\`\\`mermaid");
2719
- md = md.replace(/^```mermaid\s*?(\{.*?\})?\n([\s\S]+?)\n```/gm, (full, options = "", code = "") => {
2717
+ function transformMermaid(md3) {
2718
+ md3 = md3.replace(/^````txt\n```mermaid/gm, "````txt\n\\`\\`\\`mermaid");
2719
+ md3 = md3.replace(/^```mermaid\s*?(\{.*?\})?\n([\s\S]+?)\n```/gm, (full, options = "", code = "") => {
2720
2720
  code = code.trim();
2721
2721
  options = options.trim() || "{}";
2722
2722
  const encoded = base64.encode(code, true);
2723
2723
  return `<ValaxyMermaid :code="'${encoded}'" v-bind="${options}" />`;
2724
2724
  });
2725
- md = md.replace(/^````txt\n\\`\\`\\`mermaid/gm, "````txt\n```mermaid");
2726
- return md;
2725
+ md3 = md3.replace(/^````txt\n\\`\\`\\`mermaid/gm, "````txt\n```mermaid");
2726
+ return md3;
2727
2727
  }
2728
2728
 
2729
2729
  // node/plugins/markdown/transform/index.ts
2730
+ var md;
2731
+ var _disposeHighlighter;
2732
+ function disposeMdItInstance() {
2733
+ if (md) {
2734
+ md = void 0;
2735
+ _disposeHighlighter?.();
2736
+ }
2737
+ }
2730
2738
  async function createMarkdownPlugin(options) {
2731
2739
  const mdOptions = options?.config.markdown || {};
2732
2740
  const theme = mdOptions.theme ?? defaultCodeTheme;
2733
2741
  const transformIncludes = createTransformIncludes(options);
2734
- const mdItHighlight = await highlight(theme, mdOptions);
2742
+ const [highlight2, dispose] = mdOptions.highlight ? [mdOptions.highlight, () => {
2743
+ }] : await highlight(theme, mdOptions, logger);
2744
+ _disposeHighlighter = dispose;
2735
2745
  return Markdown({
2736
2746
  include: [/\.md$/],
2737
2747
  wrapperClasses: "",
@@ -2746,16 +2756,22 @@ async function createMarkdownPlugin(options) {
2746
2756
  html: true,
2747
2757
  xhtmlOut: true,
2748
2758
  linkify: true,
2749
- highlight: mdItHighlight,
2759
+ highlight: highlight2,
2750
2760
  ...mdOptions?.markdownItOptions
2751
2761
  },
2752
2762
  async markdownItSetup(mdIt) {
2753
2763
  mdIt.linkify.set({ fuzzyLink: false });
2754
2764
  await setupMarkdownPlugins(mdIt, options);
2755
2765
  options?.config.markdown?.markdownItSetup?.(mdIt);
2756
- function initEnv(md) {
2757
- md.core.ruler.push("valaxy_md_env", (state) => {
2758
- options.env = state.env;
2766
+ function initEnv(md3) {
2767
+ md3.core.ruler.push("valaxy_md_env", (state) => {
2768
+ Valaxy.state.idMap.set(state.env.id, {
2769
+ id: state.env.id,
2770
+ title: state.env.title,
2771
+ links: state.env.links,
2772
+ headers: state.env.headers,
2773
+ frontmatter: state.env.frontmatter
2774
+ });
2759
2775
  });
2760
2776
  }
2761
2777
  mdIt.use(initEnv);
@@ -2771,6 +2787,16 @@ async function createMarkdownPlugin(options) {
2771
2787
  });
2772
2788
  }
2773
2789
 
2790
+ // node/plugins/markdown/index.ts
2791
+ var md2;
2792
+ var _disposeHighlighter2;
2793
+ function disposePreviewMdItInstance() {
2794
+ if (md2) {
2795
+ md2 = void 0;
2796
+ _disposeHighlighter2?.();
2797
+ }
2798
+ }
2799
+
2774
2800
  // node/plugins/patchTransform.ts
2775
2801
  import { objectEntries } from "@antfu/utils";
2776
2802
  function createFixPlugins(options) {
@@ -3121,6 +3147,41 @@ import _debug2 from "debug";
3121
3147
  import { LRUCache } from "lru-cache";
3122
3148
  import path11 from "pathe";
3123
3149
 
3150
+ // node/app/index.ts
3151
+ import { createHooks } from "hookable";
3152
+ var buildHooks = [
3153
+ "build:before",
3154
+ "build:after"
3155
+ ];
3156
+ function createValaxyNode(options) {
3157
+ const hooks = createHooks();
3158
+ if (typeof options.config.hooks === "object") {
3159
+ Object.keys(options.config.hooks).forEach((name) => {
3160
+ const hookName = name;
3161
+ const hook = options.config.hooks[hookName];
3162
+ if (typeof hook !== "function")
3163
+ return;
3164
+ if (buildHooks.includes(hookName)) {
3165
+ if (options.mode === "build")
3166
+ hooks.hook(hookName, hook);
3167
+ } else {
3168
+ hooks.hook(hookName, hook);
3169
+ }
3170
+ });
3171
+ }
3172
+ const valaxyNode = {
3173
+ version,
3174
+ hooks,
3175
+ hook: hooks.hook,
3176
+ options
3177
+ };
3178
+ options.addons.forEach((addon) => {
3179
+ if (typeof addon.setup === "function")
3180
+ addon.setup(valaxyNode);
3181
+ });
3182
+ return valaxyNode;
3183
+ }
3184
+
3124
3185
  // node/plugins/markdown/transform/code-block.ts
3125
3186
  function handleCodeHeightLimit(mainContentMd, options, codeHeightLimit) {
3126
3187
  if (typeof codeHeightLimit !== "number" || codeHeightLimit <= 0)
@@ -3135,9 +3196,9 @@ function handleCodeHeightLimit(mainContentMd, options, codeHeightLimit) {
3135
3196
  return mainContentMd;
3136
3197
  }
3137
3198
  function createTransformCodeBlock(options) {
3138
- return (code) => {
3139
- const { frontmatter = {} } = options.env;
3140
- return handleCodeHeightLimit(code, options, frontmatter.codeHeightLimit);
3199
+ return (code, id) => {
3200
+ const fileInfo = Valaxy.state.idMap.get(id);
3201
+ return handleCodeHeightLimit(code, options, fileInfo?.frontmatter.codeHeightLimit);
3141
3202
  };
3142
3203
  }
3143
3204
 
@@ -3147,10 +3208,11 @@ import fs17 from "fs-extra";
3147
3208
  import path8 from "pathe";
3148
3209
  function createScanDeadLinks(options) {
3149
3210
  const srcDir = path8.resolve(options.userRoot, "pages");
3150
- const { ignoreDeadLinks } = options.config;
3211
+ const { ignoreDeadLinks } = options.config.build;
3151
3212
  const publicDir = options.config.vite?.publicDir || "public";
3152
3213
  return (code, id) => {
3153
- const { links = [] } = options.env;
3214
+ const fileInfo = Valaxy.state.idMap.get(id);
3215
+ const { links = [] } = fileInfo || {};
3154
3216
  const fileOrig = id;
3155
3217
  const file = id;
3156
3218
  const deadLinks = [];
@@ -3246,7 +3308,7 @@ async function encryptContent(content, options) {
3246
3308
  // node/plugins/markdown/transform/encrypt.ts
3247
3309
  function createTransformEncrypt(options) {
3248
3310
  const { config: { siteConfig: { encrypt } } } = options;
3249
- return async (code, _id, pageData) => {
3311
+ return async (code, id, pageData) => {
3250
3312
  const { frontmatter = {} } = pageData;
3251
3313
  if (encrypt.enable) {
3252
3314
  let getValaxyDecryptTemplate2 = function(options2) {
@@ -3323,7 +3385,7 @@ function createTransformEncrypt(options) {
3323
3385
  }
3324
3386
 
3325
3387
  // node/plugins/markdown/transform/footnoteTooltip.ts
3326
- function transformFootnoteTooltip(code) {
3388
+ function transformFootnoteTooltip(code, _id) {
3327
3389
  const footnoteContentMap = /* @__PURE__ */ new Map();
3328
3390
  return code.replace(/<ValaxyFootnoteItem id="(.*?)">(.*?)<\/ValaxyFootnoteItem>/gs, (_, id, content) => {
3329
3391
  const tooltipContent = content.match(/<ValaxyFootnoteContent>(.*?)<\/ValaxyFootnoteContent>/s)[1].replace(/<ValaxyFootnoteAnchor.*?>(.*?)<\/ValaxyFootnoteAnchor>/gs, "");
@@ -3440,16 +3502,16 @@ function inferDescription(frontmatter) {
3440
3502
  return head && getHeadMetaContent(head, "description") || "";
3441
3503
  }
3442
3504
  async function generatePageData(code, id, options) {
3443
- const { frontmatter = {} } = options.env;
3505
+ const fileInfo = Valaxy.state.idMap.get(id);
3444
3506
  const relativePath = path10.relative(options.userRoot, id);
3445
- const fm = JSON.parse(JSON.stringify(frontmatter));
3507
+ const fm = JSON.parse(JSON.stringify(fileInfo?.frontmatter));
3446
3508
  const pageData = {
3447
- title: fm.title || options.env.title || "",
3509
+ title: fm.title || fileInfo?.title || "",
3448
3510
  titleTemplate: fm.titleTemplate,
3449
3511
  description: inferDescription(fm),
3450
3512
  frontmatter: fm,
3451
3513
  // not be used
3452
- headers: options.env.headers || [],
3514
+ headers: fileInfo?.headers || [],
3453
3515
  relativePath,
3454
3516
  filePath: id
3455
3517
  };
@@ -3515,9 +3577,9 @@ async function createMarkdownToVueRenderFn(options, _viteConfig) {
3515
3577
  const data = resolveTransformIncludes(code, id, options);
3516
3578
  const includes = data.includes;
3517
3579
  code = data.code;
3518
- code = transformCodeBlock(code);
3580
+ code = transformCodeBlock(code, id);
3519
3581
  code = await transformEncrypt(code, id, pageData);
3520
- code = transformFootnoteTooltip(code);
3582
+ code = transformFootnoteTooltip(code, id);
3521
3583
  code = transformMarkdown(code, id, pageData);
3522
3584
  debug2(`[render] ${file} in ${Date.now() - start}ms.`);
3523
3585
  const result = {
@@ -3528,6 +3590,7 @@ async function createMarkdownToVueRenderFn(options, _viteConfig) {
3528
3590
  };
3529
3591
  if (isBuild)
3530
3592
  cache2.set(cacheKey, result);
3593
+ Valaxy.state.idMap.delete(id);
3531
3594
  return result;
3532
3595
  };
3533
3596
  }
@@ -3807,8 +3870,8 @@ async function createRouterPlugin(valaxyApp) {
3807
3870
  }
3808
3871
  const path17 = route.components.get("default") || "";
3809
3872
  if (path17.endsWith(".md")) {
3810
- const md = fs20.readFileSync(path17, "utf-8");
3811
- const { data, excerpt, content } = matter3(md, matterOptions);
3873
+ const md3 = fs20.readFileSync(path17, "utf-8");
3874
+ const { data, excerpt, content } = matter3(md3, matterOptions);
3812
3875
  const mdFm = data;
3813
3876
  const lastUpdated = options.config.siteConfig.lastUpdated;
3814
3877
  delete mdFm.password;
@@ -4128,41 +4191,6 @@ async function createServer(valaxyApp, viteConfig = {}, serverOptions = {}) {
4128
4191
  return server;
4129
4192
  }
4130
4193
 
4131
- // node/app/index.ts
4132
- import { createHooks } from "hookable";
4133
- var buildHooks = [
4134
- "build:before",
4135
- "build:after"
4136
- ];
4137
- function createValaxyNode(options) {
4138
- const hooks = createHooks();
4139
- if (typeof options.config.hooks === "object") {
4140
- Object.keys(options.config.hooks).forEach((name) => {
4141
- const hookName = name;
4142
- const hook = options.config.hooks[hookName];
4143
- if (typeof hook !== "function")
4144
- return;
4145
- if (buildHooks.includes(hookName)) {
4146
- if (options.mode === "build")
4147
- hooks.hook(hookName, hook);
4148
- } else {
4149
- hooks.hook(hookName, hook);
4150
- }
4151
- });
4152
- }
4153
- const valaxyNode = {
4154
- version,
4155
- hooks,
4156
- hook: hooks.hook,
4157
- options
4158
- };
4159
- options.addons.forEach((addon) => {
4160
- if (typeof addon.setup === "function")
4161
- addon.setup(valaxyNode);
4162
- });
4163
- return valaxyNode;
4164
- }
4165
-
4166
4194
  // node/cli/utils/cli.ts
4167
4195
  import os from "node:os";
4168
4196
  import path12 from "node:path";
@@ -4209,6 +4237,8 @@ function printInfo(options, port, remote) {
4209
4237
  }
4210
4238
  var serverSpinner = ora4(`${valaxyPrefix} creating server ...`);
4211
4239
  async function initServer(valaxyApp, viteConfig) {
4240
+ disposeMdItInstance();
4241
+ disposePreviewMdItInstance();
4212
4242
  if (GLOBAL_STATE.server) {
4213
4243
  vLogger.info("close server...");
4214
4244
  await GLOBAL_STATE.server.close();