vitepress 1.4.2 → 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.
@@ -0,0 +1,470 @@
1
+ import { createHash } from 'node:crypto';
2
+ import fs__default from 'node:fs';
3
+ import module, { createRequire } from 'node:module';
4
+ import path from 'node:path';
5
+ import { fileURLToPath, pathToFileURL } from 'node:url';
6
+ import { MessageChannel, Worker, workerData, parentPort, receiveMessageOnPort } from 'node:worker_threads';
7
+
8
+ /******************************************************************************
9
+ Copyright (c) Microsoft Corporation.
10
+
11
+ Permission to use, copy, modify, and/or distribute this software for any
12
+ purpose with or without fee is hereby granted.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
15
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
+ PERFORMANCE OF THIS SOFTWARE.
21
+ ***************************************************************************** */
22
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
23
+
24
+
25
+ function __rest(s, e) {
26
+ var t = {};
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
+ t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
+ t[p[i]] = s[p[i]];
33
+ }
34
+ return t;
35
+ }
36
+
37
+ function __awaiter(thisArg, _arguments, P, generator) {
38
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
39
+ return new (P || (P = Promise))(function (resolve, reject) {
40
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
41
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
42
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
43
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
44
+ });
45
+ }
46
+
47
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
48
+ var e = new Error(message);
49
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
50
+ };
51
+
52
+ const CWD = process.cwd();
53
+ const cjsRequire$1 = typeof require === 'undefined' ? createRequire(import.meta.url) : require;
54
+ const EXTENSIONS = ['.ts', '.tsx', ...Object.keys(cjsRequire$1.extensions)];
55
+
56
+ const tryPkg = (pkg) => {
57
+ try {
58
+ return cjsRequire$1.resolve(pkg);
59
+ }
60
+ catch (_a) { }
61
+ };
62
+ const isPkgAvailable = (pkg) => !!tryPkg(pkg);
63
+ const tryFile = (filePath, includeDir = false) => {
64
+ if (typeof filePath === 'string') {
65
+ return fs__default.existsSync(filePath) &&
66
+ (includeDir || fs__default.statSync(filePath).isFile())
67
+ ? filePath
68
+ : '';
69
+ }
70
+ for (const file of filePath !== null && filePath !== void 0 ? filePath : []) {
71
+ if (tryFile(file, includeDir)) {
72
+ return file;
73
+ }
74
+ }
75
+ return '';
76
+ };
77
+ const tryExtensions = (filepath, extensions = EXTENSIONS) => {
78
+ const ext = [...extensions, ''].find(ext => tryFile(filepath + ext));
79
+ return ext == null ? '' : filepath + ext;
80
+ };
81
+ const findUp = (searchEntry, searchFileOrIncludeDir, includeDir) => {
82
+ console.assert(path.isAbsolute(searchEntry));
83
+ if (!tryFile(searchEntry, true) ||
84
+ (searchEntry !== CWD && !searchEntry.startsWith(CWD + path.sep))) {
85
+ return '';
86
+ }
87
+ searchEntry = path.resolve(fs__default.statSync(searchEntry).isDirectory()
88
+ ? searchEntry
89
+ : path.resolve(searchEntry, '..'));
90
+ const isSearchFile = typeof searchFileOrIncludeDir === 'string';
91
+ const searchFile = 'package.json';
92
+ do {
93
+ const searched = tryFile(path.resolve(searchEntry, searchFile), isSearchFile);
94
+ if (searched) {
95
+ return searched;
96
+ }
97
+ searchEntry = path.resolve(searchEntry, '..');
98
+ } while (searchEntry === CWD || searchEntry.startsWith(CWD + path.sep));
99
+ return '';
100
+ };
101
+
102
+ const INT32_BYTES = 4;
103
+ const TsRunner = {
104
+ TsNode: 'ts-node',
105
+ EsbuildRegister: 'esbuild-register',
106
+ EsbuildRunner: 'esbuild-runner',
107
+ SWC: 'swc',
108
+ TSX: 'tsx',
109
+ };
110
+ const { NODE_OPTIONS, SYNCKIT_EXEC_ARGV, SYNCKIT_GLOBAL_SHIMS, SYNCKIT_TIMEOUT, SYNCKIT_TS_RUNNER, } = process.env;
111
+ const IS_NODE_20 = Number(process.versions.node.split('.')[0]) >= 20;
112
+ const DEFAULT_TIMEOUT = SYNCKIT_TIMEOUT ? +SYNCKIT_TIMEOUT : undefined;
113
+ const DEFAULT_EXEC_ARGV = (SYNCKIT_EXEC_ARGV === null || SYNCKIT_EXEC_ARGV === void 0 ? void 0 : SYNCKIT_EXEC_ARGV.split(',')) || [];
114
+ const DEFAULT_TS_RUNNER = SYNCKIT_TS_RUNNER;
115
+ const DEFAULT_GLOBAL_SHIMS = ['1', 'true'].includes(SYNCKIT_GLOBAL_SHIMS);
116
+ const DEFAULT_GLOBAL_SHIMS_PRESET = [
117
+ {
118
+ moduleName: 'node-fetch',
119
+ globalName: 'fetch',
120
+ },
121
+ {
122
+ moduleName: 'node:perf_hooks',
123
+ globalName: 'performance',
124
+ named: 'performance',
125
+ },
126
+ ];
127
+ const MTS_SUPPORTED_NODE_VERSION = 16;
128
+ let syncFnCache;
129
+ function extractProperties(object) {
130
+ if (object && typeof object === 'object') {
131
+ const properties = {};
132
+ for (const key in object) {
133
+ properties[key] = object[key];
134
+ }
135
+ return properties;
136
+ }
137
+ }
138
+ function createSyncFn(workerPath, timeoutOrOptions) {
139
+ syncFnCache !== null && syncFnCache !== void 0 ? syncFnCache : (syncFnCache = new Map());
140
+ const cachedSyncFn = syncFnCache.get(workerPath);
141
+ if (cachedSyncFn) {
142
+ return cachedSyncFn;
143
+ }
144
+ if (!path.isAbsolute(workerPath)) {
145
+ throw new Error('`workerPath` must be absolute');
146
+ }
147
+ const syncFn = startWorkerThread(workerPath, timeoutOrOptions);
148
+ syncFnCache.set(workerPath, syncFn);
149
+ return syncFn;
150
+ }
151
+ const cjsRequire = typeof require === 'undefined'
152
+ ? module.createRequire(import.meta.url)
153
+ : require;
154
+ const dataUrl = (code) => new URL(`data:text/javascript,${encodeURIComponent(code)}`);
155
+ const isFile = (path) => {
156
+ var _a;
157
+ try {
158
+ return !!((_a = fs__default.statSync(path, { throwIfNoEntry: false })) === null || _a === void 0 ? void 0 : _a.isFile());
159
+ }
160
+ catch (_b) {
161
+ return false;
162
+ }
163
+ };
164
+ const setupTsRunner = (workerPath, { execArgv, tsRunner }) => {
165
+ let ext = path.extname(workerPath);
166
+ if (!/[/\\]node_modules[/\\]/.test(workerPath) &&
167
+ (!ext || /^\.[cm]?js$/.test(ext))) {
168
+ const workPathWithoutExt = ext
169
+ ? workerPath.slice(0, -ext.length)
170
+ : workerPath;
171
+ let extensions;
172
+ switch (ext) {
173
+ case '.cjs': {
174
+ extensions = ['.cts', '.cjs'];
175
+ break;
176
+ }
177
+ case '.mjs': {
178
+ extensions = ['.mts', '.mjs'];
179
+ break;
180
+ }
181
+ default: {
182
+ extensions = ['.ts', '.js'];
183
+ break;
184
+ }
185
+ }
186
+ const found = tryExtensions(workPathWithoutExt, extensions);
187
+ let differentExt;
188
+ if (found && (!ext || (differentExt = found !== workPathWithoutExt))) {
189
+ workerPath = found;
190
+ if (differentExt) {
191
+ ext = path.extname(workerPath);
192
+ }
193
+ }
194
+ }
195
+ const isTs = /\.[cm]?ts$/.test(workerPath);
196
+ let jsUseEsm = workerPath.endsWith('.mjs');
197
+ let tsUseEsm = workerPath.endsWith('.mts');
198
+ if (isTs) {
199
+ if (!tsUseEsm) {
200
+ const pkg = findUp(workerPath);
201
+ if (pkg) {
202
+ tsUseEsm =
203
+ cjsRequire(pkg).type ===
204
+ 'module';
205
+ }
206
+ }
207
+ if (tsRunner == null && isPkgAvailable(TsRunner.TsNode)) {
208
+ tsRunner = TsRunner.TsNode;
209
+ }
210
+ switch (tsRunner) {
211
+ case TsRunner.TsNode: {
212
+ if (tsUseEsm) {
213
+ if (!execArgv.includes('--loader')) {
214
+ execArgv = ['--loader', `${TsRunner.TsNode}/esm`, ...execArgv];
215
+ }
216
+ }
217
+ else if (!execArgv.includes('-r')) {
218
+ execArgv = ['-r', `${TsRunner.TsNode}/register`, ...execArgv];
219
+ }
220
+ break;
221
+ }
222
+ case TsRunner.EsbuildRegister: {
223
+ if (!execArgv.includes('-r')) {
224
+ execArgv = ['-r', TsRunner.EsbuildRegister, ...execArgv];
225
+ }
226
+ break;
227
+ }
228
+ case TsRunner.EsbuildRunner: {
229
+ if (!execArgv.includes('-r')) {
230
+ execArgv = ['-r', `${TsRunner.EsbuildRunner}/register`, ...execArgv];
231
+ }
232
+ break;
233
+ }
234
+ case TsRunner.SWC: {
235
+ if (!execArgv.includes('-r')) {
236
+ execArgv = ['-r', `@${TsRunner.SWC}-node/register`, ...execArgv];
237
+ }
238
+ break;
239
+ }
240
+ case TsRunner.TSX: {
241
+ if (!execArgv.includes('--loader')) {
242
+ execArgv = ['--loader', TsRunner.TSX, ...execArgv];
243
+ }
244
+ break;
245
+ }
246
+ default: {
247
+ throw new Error(`Unknown ts runner: ${String(tsRunner)}`);
248
+ }
249
+ }
250
+ }
251
+ else if (!jsUseEsm) {
252
+ const pkg = findUp(workerPath);
253
+ if (pkg) {
254
+ jsUseEsm =
255
+ cjsRequire(pkg).type === 'module';
256
+ }
257
+ }
258
+ let resolvedPnpLoaderPath;
259
+ if (process.versions.pnp) {
260
+ const nodeOptions = NODE_OPTIONS === null || NODE_OPTIONS === void 0 ? void 0 : NODE_OPTIONS.split(/\s+/);
261
+ let pnpApiPath;
262
+ try {
263
+ pnpApiPath = cjsRequire.resolve('pnpapi');
264
+ }
265
+ catch (_a) { }
266
+ if (pnpApiPath &&
267
+ !(nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.some((option, index) => ['-r', '--require'].includes(option) &&
268
+ pnpApiPath === cjsRequire.resolve(nodeOptions[index + 1]))) &&
269
+ !execArgv.includes(pnpApiPath)) {
270
+ execArgv = ['-r', pnpApiPath, ...execArgv];
271
+ const pnpLoaderPath = path.resolve(pnpApiPath, '../.pnp.loader.mjs');
272
+ if (isFile(pnpLoaderPath)) {
273
+ resolvedPnpLoaderPath = pathToFileURL(pnpLoaderPath).toString();
274
+ if (!IS_NODE_20) {
275
+ execArgv = [
276
+ '--experimental-loader',
277
+ resolvedPnpLoaderPath,
278
+ ...execArgv,
279
+ ];
280
+ }
281
+ }
282
+ }
283
+ }
284
+ return {
285
+ ext,
286
+ isTs,
287
+ jsUseEsm,
288
+ tsRunner,
289
+ tsUseEsm,
290
+ workerPath,
291
+ pnpLoaderPath: resolvedPnpLoaderPath,
292
+ execArgv,
293
+ };
294
+ };
295
+ const md5Hash = (text) => createHash('md5').update(text).digest('hex');
296
+ const encodeImportModule = (moduleNameOrGlobalShim, type = 'import') => {
297
+ const { moduleName, globalName, named, conditional } = typeof moduleNameOrGlobalShim === 'string'
298
+ ? { moduleName: moduleNameOrGlobalShim }
299
+ : moduleNameOrGlobalShim;
300
+ const importStatement = type === 'import'
301
+ ? `import${globalName
302
+ ? ' ' +
303
+ (named === null
304
+ ? '* as ' + globalName
305
+ : (named === null || named === void 0 ? void 0 : named.trim())
306
+ ? `{${named}}`
307
+ : globalName) +
308
+ ' from'
309
+ : ''} '${path.isAbsolute(moduleName)
310
+ ? String(pathToFileURL(moduleName))
311
+ : moduleName}'`
312
+ : `${globalName
313
+ ? 'const ' + ((named === null || named === void 0 ? void 0 : named.trim()) ? `{${named}}` : globalName) + '='
314
+ : ''}require('${moduleName
315
+ .replace(/\\/g, '\\\\')}')`;
316
+ if (!globalName) {
317
+ return importStatement;
318
+ }
319
+ const overrideStatement = `globalThis.${globalName}=${(named === null || named === void 0 ? void 0 : named.trim()) ? named : globalName}`;
320
+ return (importStatement +
321
+ (conditional === false
322
+ ? `;${overrideStatement}`
323
+ : `;if(!globalThis.${globalName})${overrideStatement}`));
324
+ };
325
+ const _generateGlobals = (globalShims, type) => globalShims.reduce((acc, shim) => `${acc}${acc ? ';' : ''}${encodeImportModule(shim, type)}`, '');
326
+ let globalsCache;
327
+ let tmpdir;
328
+ const _dirname = typeof __dirname === 'undefined'
329
+ ? path.dirname(fileURLToPath(import.meta.url))
330
+ : __dirname;
331
+ let sharedBuffer;
332
+ let sharedBufferView;
333
+ const generateGlobals = (workerPath, globalShims, type = 'import') => {
334
+ globalsCache !== null && globalsCache !== void 0 ? globalsCache : (globalsCache = new Map());
335
+ const cached = globalsCache.get(workerPath);
336
+ if (cached) {
337
+ const [content, filepath] = cached;
338
+ if ((type === 'require' && !filepath) ||
339
+ (type === 'import' && filepath && isFile(filepath))) {
340
+ return content;
341
+ }
342
+ }
343
+ const globals = _generateGlobals(globalShims, type);
344
+ let content = globals;
345
+ let filepath;
346
+ if (type === 'import') {
347
+ if (!tmpdir) {
348
+ tmpdir = path.resolve(findUp(_dirname), '../node_modules/.synckit');
349
+ }
350
+ fs__default.mkdirSync(tmpdir, { recursive: true });
351
+ filepath = path.resolve(tmpdir, md5Hash(workerPath) + '.mjs');
352
+ content = encodeImportModule(filepath);
353
+ fs__default.writeFileSync(filepath, globals);
354
+ }
355
+ globalsCache.set(workerPath, [content, filepath]);
356
+ return content;
357
+ };
358
+ function startWorkerThread(workerPath, { timeout = DEFAULT_TIMEOUT, execArgv = DEFAULT_EXEC_ARGV, tsRunner = DEFAULT_TS_RUNNER, transferList = [], globalShims = DEFAULT_GLOBAL_SHIMS, } = {}) {
359
+ const { port1: mainPort, port2: workerPort } = new MessageChannel();
360
+ const { isTs, ext, jsUseEsm, tsUseEsm, tsRunner: finalTsRunner, workerPath: finalWorkerPath, pnpLoaderPath, execArgv: finalExecArgv, } = setupTsRunner(workerPath, { execArgv, tsRunner });
361
+ const workerPathUrl = pathToFileURL(finalWorkerPath);
362
+ if (/\.[cm]ts$/.test(finalWorkerPath)) {
363
+ const isTsxSupported = !tsUseEsm ||
364
+ Number.parseFloat(process.versions.node) >= MTS_SUPPORTED_NODE_VERSION;
365
+ if (!finalTsRunner) {
366
+ throw new Error('No ts runner specified, ts worker path is not supported');
367
+ }
368
+ else if ([
369
+ TsRunner.EsbuildRegister,
370
+ TsRunner.EsbuildRunner,
371
+ TsRunner.SWC,
372
+ ...(isTsxSupported ? [] : [TsRunner.TSX]),
373
+ ].includes(finalTsRunner)) {
374
+ throw new Error(`${finalTsRunner} is not supported for ${ext} files yet` +
375
+ (isTsxSupported
376
+ ? ', you can try [tsx](https://github.com/esbuild-kit/tsx) instead'
377
+ : ''));
378
+ }
379
+ }
380
+ const finalGlobalShims = (globalShims === true
381
+ ? DEFAULT_GLOBAL_SHIMS_PRESET
382
+ : Array.isArray(globalShims)
383
+ ? globalShims
384
+ : []).filter(({ moduleName }) => isPkgAvailable(moduleName));
385
+ sharedBufferView !== null && sharedBufferView !== void 0 ? sharedBufferView : (sharedBufferView = new Int32Array((sharedBuffer !== null && sharedBuffer !== void 0 ? sharedBuffer : (sharedBuffer = new SharedArrayBuffer(INT32_BYTES))), 0, 1));
386
+ const useGlobals = finalGlobalShims.length > 0;
387
+ const useEval = isTs ? !tsUseEsm : !jsUseEsm && useGlobals;
388
+ const worker = new Worker((jsUseEsm && useGlobals) || (tsUseEsm && finalTsRunner === TsRunner.TsNode)
389
+ ? dataUrl(`${generateGlobals(finalWorkerPath, finalGlobalShims)};import '${String(workerPathUrl)}'`)
390
+ : useEval
391
+ ? `${generateGlobals(finalWorkerPath, finalGlobalShims, 'require')};${encodeImportModule(finalWorkerPath, 'require')}`
392
+ : workerPathUrl, {
393
+ eval: useEval,
394
+ workerData: { sharedBuffer, workerPort, pnpLoaderPath },
395
+ transferList: [workerPort, ...transferList],
396
+ execArgv: finalExecArgv,
397
+ });
398
+ let nextID = 0;
399
+ const receiveMessageWithId = (port, expectedId, waitingTimeout) => {
400
+ const start = Date.now();
401
+ const status = Atomics.wait(sharedBufferView, 0, 0, waitingTimeout);
402
+ Atomics.store(sharedBufferView, 0, 0);
403
+ if (!['ok', 'not-equal'].includes(status)) {
404
+ const abortMsg = {
405
+ id: expectedId,
406
+ cmd: 'abort',
407
+ };
408
+ port.postMessage(abortMsg);
409
+ throw new Error('Internal error: Atomics.wait() failed: ' + status);
410
+ }
411
+ const _a = receiveMessageOnPort(mainPort).message, { id } = _a, message = __rest(_a, ["id"]);
412
+ if (id < expectedId) {
413
+ const waitingTime = Date.now() - start;
414
+ return receiveMessageWithId(port, expectedId, waitingTimeout ? waitingTimeout - waitingTime : undefined);
415
+ }
416
+ if (expectedId !== id) {
417
+ throw new Error(`Internal error: Expected id ${expectedId} but got id ${id}`);
418
+ }
419
+ return Object.assign({ id }, message);
420
+ };
421
+ const syncFn = (...args) => {
422
+ const id = nextID++;
423
+ const msg = { id, args };
424
+ worker.postMessage(msg);
425
+ const { result, error, properties } = receiveMessageWithId(mainPort, id, timeout);
426
+ if (error) {
427
+ throw Object.assign(error, properties);
428
+ }
429
+ return result;
430
+ };
431
+ worker.unref();
432
+ return syncFn;
433
+ }
434
+ function runAsWorker(fn) {
435
+ if (!workerData) {
436
+ return;
437
+ }
438
+ const { workerPort, sharedBuffer, pnpLoaderPath } = workerData;
439
+ if (pnpLoaderPath && IS_NODE_20) {
440
+ module.register(pnpLoaderPath);
441
+ }
442
+ const sharedBufferView = new Int32Array(sharedBuffer, 0, 1);
443
+ parentPort.on('message', ({ id, args }) => {
444
+ (() => __awaiter(this, void 0, void 0, function* () {
445
+ let isAborted = false;
446
+ const handleAbortMessage = (msg) => {
447
+ if (msg.id === id && msg.cmd === 'abort') {
448
+ isAborted = true;
449
+ }
450
+ };
451
+ workerPort.on('message', handleAbortMessage);
452
+ let msg;
453
+ try {
454
+ msg = { id, result: yield fn(...args) };
455
+ }
456
+ catch (error) {
457
+ msg = { id, error, properties: extractProperties(error) };
458
+ }
459
+ workerPort.off('message', handleAbortMessage);
460
+ if (isAborted) {
461
+ return;
462
+ }
463
+ workerPort.postMessage(msg);
464
+ Atomics.add(sharedBufferView, 0, 1);
465
+ Atomics.notify(sharedBufferView, 0);
466
+ }))();
467
+ });
468
+ }
469
+
470
+ export { createSyncFn as c, runAsWorker as r };
@@ -31,8 +31,10 @@ import require$$0$4 from 'tty';
31
31
  import require$$0$1 from 'constants';
32
32
  import require$$5 from 'assert';
33
33
  import { webcrypto } from 'node:crypto';
34
- import { createHighlighter, bundledLanguages, isSpecialLang } from 'shiki';
35
34
  import { transformerNotationDiff, transformerNotationFocus, transformerNotationHighlight, transformerNotationErrorLevel, transformerCompactLineOptions } from '@shikijs/transformers';
35
+ import { createRequire as createRequire$1 } from 'node:module';
36
+ import { createHighlighter, isSpecialLang } from 'shiki';
37
+ import { c as createSyncFn } from './chunk-DQlKmeN_.js';
36
38
  import MiniSearch from 'minisearch';
37
39
 
38
40
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -12914,7 +12916,7 @@ function requirePicocolors () {
12914
12916
  var picocolorsExports = /*@__PURE__*/ requirePicocolors();
12915
12917
  var c$1 = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
12916
12918
 
12917
- const require$1 = createRequire(import.meta.url);
12919
+ const require$2 = createRequire(import.meta.url);
12918
12920
  const PKG_ROOT = resolve$1(fileURLToPath$1(import.meta.url), "../..");
12919
12921
  const DIST_CLIENT_PATH = resolve$1(PKG_ROOT, "client");
12920
12922
  const APP_PATH = join(DIST_CLIENT_PATH, "app");
@@ -12943,15 +12945,15 @@ function resolveAliases({ root, themeDir }, ssr) {
12943
12945
  },
12944
12946
  {
12945
12947
  find: /^vue-demi$/,
12946
- replacement: require$1.resolve("vitepress/vue-demi")
12948
+ replacement: require$2.resolve("vitepress/vue-demi")
12947
12949
  }
12948
12950
  ];
12949
12951
  if (!ssr) {
12950
12952
  let vuePath;
12951
12953
  try {
12952
- vuePath = require$1.resolve(vueRuntimePath, { paths: [root] });
12954
+ vuePath = require$2.resolve(vueRuntimePath, { paths: [root] });
12953
12955
  } catch (e) {
12954
- vuePath = require$1.resolve(vueRuntimePath);
12956
+ vuePath = require$2.resolve(vueRuntimePath);
12955
12957
  }
12956
12958
  aliases.push({
12957
12959
  find: /^vue$/,
@@ -34454,6 +34456,10 @@ function capitalize(str) {
34454
34456
  return str.charAt(0).toUpperCase() + str.slice(1);
34455
34457
  }
34456
34458
 
34459
+ const require$1 = createRequire$1(import.meta.url);
34460
+ const resolveLangSync = createSyncFn(
34461
+ require$1.resolve("vitepress/dist/node/worker_shikiResolveLang.js")
34462
+ );
34457
34463
  const nanoid = customAlphabet("abcdefghijklmnopqrstuvwxyz", 10);
34458
34464
  function attrsToLines(attrs) {
34459
34465
  attrs = attrs.replace(/^(?:\[.*?\])?.*?([\d,-]+).*/, "$1").trim();
@@ -34477,14 +34483,31 @@ function attrsToLines(attrs) {
34477
34483
  }
34478
34484
  async function highlight(theme, options, logger = console) {
34479
34485
  const {
34480
- defaultHighlightLang: defaultLang = "",
34486
+ defaultHighlightLang: defaultLang = "txt",
34481
34487
  codeTransformers: userTransformers = []
34482
34488
  } = options;
34489
+ const usingTwoslash = userTransformers.some(
34490
+ ({ name }) => name === "@shikijs/vitepress-twoslash"
34491
+ );
34483
34492
  const highlighter = await createHighlighter({
34484
34493
  themes: typeof theme === "object" && "light" in theme && "dark" in theme ? [theme.light, theme.dark] : [theme],
34485
- langs: [...Object.keys(bundledLanguages), ...options.languages || []],
34494
+ langs: [
34495
+ ...options.languages || [],
34496
+ ...Object.values(options.languageAlias || {}),
34497
+ // patch for twoslash - https://github.com/vuejs/vitepress/issues/4334
34498
+ ...usingTwoslash ? Object.keys((await import('shiki')).bundledLanguages) : []
34499
+ ],
34486
34500
  langAlias: options.languageAlias
34487
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
+ }
34488
34511
  await options?.shikiSetup?.(highlighter);
34489
34512
  const transformers = [
34490
34513
  transformerNotationDiff(),
@@ -34515,17 +34538,14 @@ async function highlight(theme, options, logger = console) {
34515
34538
  (str, lang, attrs) => {
34516
34539
  const vPre = vueRE.test(lang) ? "" : "v-pre";
34517
34540
  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
- `
34524
- The language '${lang}' is not loaded, falling back to '${defaultLang || "txt"}' for syntax highlighting.`
34525
- )
34526
- );
34527
- lang = defaultLang;
34528
- }
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;
34529
34549
  }
34530
34550
  const lineOptions = attrsToLines(attrs);
34531
34551
  const mustaches = /* @__PURE__ */ new Map();
@@ -48521,7 +48541,7 @@ async function generateSitemap(siteConfig) {
48521
48541
  });
48522
48542
  }
48523
48543
 
48524
- var version = "1.4.2";
48544
+ var version = "1.4.4";
48525
48545
 
48526
48546
  async function renderPage(render, config, page, result, appChunk, cssChunk, assets, pageToHashMap, metadataScript, additionalHeadTags) {
48527
48547
  const routePath = `/${page.replace(/\.md$/, "")}`;
package/dist/node/cli.js CHANGED
@@ -1,8 +1,6 @@
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 './serve-BSNQCR34.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
- import 'shiki';
5
- import '@shikijs/transformers';
6
4
  import 'url';
7
5
  import 'crypto';
8
6
  import 'module';
@@ -33,6 +31,11 @@ import 'tty';
33
31
  import 'constants';
34
32
  import 'assert';
35
33
  import 'node:crypto';
34
+ import '@shikijs/transformers';
35
+ import 'node:module';
36
+ import 'shiki';
37
+ import './chunk-DQlKmeN_.js';
38
+ import 'node:worker_threads';
36
39
  import 'minisearch';
37
40
 
38
41
  var minimist$1;
@@ -394,6 +397,9 @@ const SHORTCUTS = [
394
397
  }
395
398
  ];
396
399
 
400
+ if (process.env.DEBUG) {
401
+ Error.stackTraceLimit = Infinity;
402
+ }
397
403
  const argv = minimist(process.argv.slice(2));
398
404
  const logVersion = (logger = createLogger()) => {
399
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 './serve-BSNQCR34.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 './serve-BSNQCR34.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';
@@ -33,8 +33,11 @@ import 'tty';
33
33
  import 'constants';
34
34
  import 'assert';
35
35
  import 'node:crypto';
36
- import 'shiki';
37
36
  import '@shikijs/transformers';
37
+ import 'node:module';
38
+ import 'shiki';
39
+ import './chunk-DQlKmeN_.js';
40
+ import 'node:worker_threads';
38
41
  import 'minisearch';
39
42
 
40
43
  function createContentLoader(pattern, {
@@ -0,0 +1,13 @@
1
+ import { bundledLanguages } from 'shiki';
2
+ import { r as runAsWorker } from './chunk-DQlKmeN_.js';
3
+ import 'node:crypto';
4
+ import 'node:fs';
5
+ import 'node:module';
6
+ import 'node:path';
7
+ import 'node:url';
8
+ import 'node:worker_threads';
9
+
10
+ async function resolveLang(lang) {
11
+ return bundledLanguages[lang]?.().then((m) => m.default) || [];
12
+ }
13
+ runAsWorker(resolveLang);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitepress",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Vite & Vue powered static site generator",
5
5
  "keywords": [
6
6
  "vite",
@@ -147,6 +147,7 @@
147
147
  "sirv": "^3.0.0",
148
148
  "sitemap": "^8.0.0",
149
149
  "supports-color": "^9.4.0",
150
+ "synckit": "^0.9.2",
150
151
  "tinyglobby": "^0.2.10",
151
152
  "typescript": "^5.6.3",
152
153
  "vitest": "^2.1.4",