vitepress 1.4.1 → 1.4.3
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.
- package/dist/client/theme-default/components/VPLocalSearchBox.vue +13 -2
- package/dist/client/theme-default/components/VPNavBarTitle.vue +2 -2
- package/dist/client/theme-default/styles/components/vp-doc.css +1 -0
- package/dist/client/theme-default/styles/vars.css +2 -3
- package/dist/node/{serve-4DnZ8_Si.js → chunk-BGE1nmDJ.js} +243 -216
- package/dist/node/chunk-DQlKmeN_.js +470 -0
- package/dist/node/cli.js +7 -3
- package/dist/node/index.d.ts +7 -3
- package/dist/node/index.js +7 -5
- package/dist/node/worker_shikiResolveLang.js +13 -0
- package/package.json +18 -17
- package/theme.d.ts +3 -0
|
@@ -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 };
|
package/dist/node/cli.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
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';
|
|
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;
|
|
@@ -357,6 +360,7 @@ const SHORTCUTS = [
|
|
|
357
360
|
clear: true,
|
|
358
361
|
timestamp: true
|
|
359
362
|
});
|
|
363
|
+
disposeMdItInstance();
|
|
360
364
|
clearCache();
|
|
361
365
|
await server.close();
|
|
362
366
|
await createDevServer();
|
package/dist/node/index.d.ts
CHANGED
|
@@ -2164,7 +2164,7 @@ interface MarkdownOptions extends Options$2 {
|
|
|
2164
2164
|
*/
|
|
2165
2165
|
container?: ContainerOptions;
|
|
2166
2166
|
/**
|
|
2167
|
-
* Math support
|
|
2167
|
+
* Math support
|
|
2168
2168
|
*
|
|
2169
2169
|
* You need to install `markdown-it-mathjax3` and set `math` to `true` to enable it.
|
|
2170
2170
|
* You can also pass options to `markdown-it-mathjax3` here.
|
|
@@ -2181,7 +2181,11 @@ interface MarkdownOptions extends Options$2 {
|
|
|
2181
2181
|
gfmAlerts?: boolean;
|
|
2182
2182
|
}
|
|
2183
2183
|
type MarkdownRenderer = MarkdownIt;
|
|
2184
|
-
declare
|
|
2184
|
+
declare function disposeMdItInstance(): void;
|
|
2185
|
+
/**
|
|
2186
|
+
* @experimental
|
|
2187
|
+
*/
|
|
2188
|
+
declare function createMarkdownRenderer(srcDir: string, options?: MarkdownOptions, base?: string, logger?: Pick<Logger, 'warn'>): Promise<MarkdownRenderer>;
|
|
2185
2189
|
|
|
2186
2190
|
type RawConfigExports<ThemeConfig = any> = Awaitable<UserConfig<ThemeConfig>> | (() => Awaitable<UserConfig<ThemeConfig>>);
|
|
2187
2191
|
interface TransformContext {
|
|
@@ -2608,4 +2612,4 @@ declare function createServer(root?: string, serverOptions?: ServerOptions & {
|
|
|
2608
2612
|
base?: string;
|
|
2609
2613
|
}, recreateServer?: () => Promise<void>): Promise<vite.ViteDevServer>;
|
|
2610
2614
|
|
|
2611
|
-
export { type ContentData, type ContentOptions, type LoaderModule, type MarkdownOptions, type MarkdownRenderer, type RawConfigExports, type ResolvedRouteConfig, type ScaffoldOptions, ScaffoldThemeType, type ServeOptions, type SiteConfig, type ThemeOptions, type TransformContext, type TransformPageContext, type UserConfig, type UserConfigExport, type UserConfigFn, build, createContentLoader, createMarkdownRenderer, createServer, defineConfig, defineConfigWithTheme, defineLoader, init, mergeConfig, postcssIsolateStyles, resolveConfig, resolvePages, resolveSiteData, resolveUserConfig, scaffold, serve };
|
|
2615
|
+
export { type ContentData, type ContentOptions, type LoaderModule, type MarkdownOptions, type MarkdownRenderer, type RawConfigExports, type ResolvedRouteConfig, type ScaffoldOptions, ScaffoldThemeType, type ServeOptions, type SiteConfig, type ThemeOptions, type TransformContext, type TransformPageContext, type UserConfig, type UserConfigExport, type UserConfigFn, build, createContentLoader, createMarkdownRenderer, createServer, defineConfig, defineConfigWithTheme, defineLoader, disposeMdItInstance, init, mergeConfig, postcssIsolateStyles, resolveConfig, resolvePages, resolveSiteData, resolveUserConfig, scaffold, serve };
|
package/dist/node/index.js
CHANGED
|
@@ -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 './
|
|
4
|
-
export { S as ScaffoldThemeType, b as build,
|
|
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';
|
|
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, {
|
|
@@ -52,7 +55,6 @@ function createContentLoader(pattern, {
|
|
|
52
55
|
}
|
|
53
56
|
if (typeof pattern === "string") pattern = [pattern];
|
|
54
57
|
pattern = pattern.map((p) => normalizePath(path.join(config.srcDir, p)));
|
|
55
|
-
let md;
|
|
56
58
|
const cache = /* @__PURE__ */ new Map();
|
|
57
59
|
return {
|
|
58
60
|
watch: pattern,
|
|
@@ -64,7 +66,7 @@ function createContentLoader(pattern, {
|
|
|
64
66
|
...globOptions
|
|
65
67
|
})).sort();
|
|
66
68
|
}
|
|
67
|
-
md =
|
|
69
|
+
const md = await createMarkdownRenderer(
|
|
68
70
|
config.srcDir,
|
|
69
71
|
config.markdown,
|
|
70
72
|
config.site.base,
|
|
@@ -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.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "Vite & Vue powered static site generator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -62,20 +62,20 @@
|
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@docsearch/css": "^3.6.2",
|
|
64
64
|
"@docsearch/js": "^3.6.2",
|
|
65
|
-
"@shikijs/core": "^1.22.
|
|
66
|
-
"@shikijs/transformers": "^1.22.
|
|
67
|
-
"@shikijs/types": "^1.22.
|
|
65
|
+
"@shikijs/core": "^1.22.2",
|
|
66
|
+
"@shikijs/transformers": "^1.22.2",
|
|
67
|
+
"@shikijs/types": "^1.22.2",
|
|
68
68
|
"@types/markdown-it": "^14.1.2",
|
|
69
69
|
"@vitejs/plugin-vue": "^5.1.4",
|
|
70
|
-
"@vue/devtools-api": "^7.4
|
|
70
|
+
"@vue/devtools-api": "^7.5.4",
|
|
71
71
|
"@vue/shared": "^3.5.12",
|
|
72
72
|
"@vueuse/core": "^11.1.0",
|
|
73
73
|
"@vueuse/integrations": "^11.1.0",
|
|
74
74
|
"focus-trap": "^7.6.0",
|
|
75
75
|
"mark.js": "8.11.1",
|
|
76
76
|
"minisearch": "^7.1.0",
|
|
77
|
-
"shiki": "^1.22.
|
|
78
|
-
"vite": "^5.4.
|
|
77
|
+
"shiki": "^1.22.2",
|
|
78
|
+
"vite": "^5.4.10",
|
|
79
79
|
"vue": "^3.5.12"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@mdit-vue/shared": "^2.1.3",
|
|
90
90
|
"@polka/compression": "^1.0.0-next.28",
|
|
91
91
|
"@rollup/plugin-alias": "^5.1.1",
|
|
92
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
92
|
+
"@rollup/plugin-commonjs": "^28.0.1",
|
|
93
93
|
"@rollup/plugin-json": "^6.1.0",
|
|
94
94
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
95
95
|
"@rollup/plugin-replace": "^6.0.1",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"@types/markdown-it-emoji": "^3.0.1",
|
|
104
104
|
"@types/micromatch": "^4.0.9",
|
|
105
105
|
"@types/minimist": "^1.2.5",
|
|
106
|
-
"@types/node": "^22.
|
|
106
|
+
"@types/node": "^22.8.2",
|
|
107
107
|
"@types/postcss-prefix-selector": "^1.16.3",
|
|
108
108
|
"@types/prompts": "^2.4.9",
|
|
109
109
|
"chokidar": "^3.6.0",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"cross-spawn": "^7.0.3",
|
|
112
112
|
"debug": "^4.3.7",
|
|
113
113
|
"esbuild": "^0.24.0",
|
|
114
|
-
"execa": "^9.
|
|
114
|
+
"execa": "^9.5.1",
|
|
115
115
|
"fs-extra": "^11.2.0",
|
|
116
116
|
"get-port": "^7.1.0",
|
|
117
117
|
"gray-matter": "^4.0.3",
|
|
@@ -126,20 +126,20 @@
|
|
|
126
126
|
"markdown-it-mathjax3": "^4.3.2",
|
|
127
127
|
"micromatch": "^4.0.8",
|
|
128
128
|
"minimist": "^1.2.8",
|
|
129
|
-
"nanoid": "^5.0.
|
|
129
|
+
"nanoid": "^5.0.8",
|
|
130
130
|
"ora": "^8.1.0",
|
|
131
131
|
"p-map": "^7.0.2",
|
|
132
132
|
"path-to-regexp": "^6.3.0",
|
|
133
|
-
"picocolors": "^1.1.
|
|
133
|
+
"picocolors": "^1.1.1",
|
|
134
134
|
"pkg-dir": "^8.0.0",
|
|
135
|
-
"playwright-chromium": "^1.48.
|
|
135
|
+
"playwright-chromium": "^1.48.2",
|
|
136
136
|
"polka": "^1.0.0-next.28",
|
|
137
137
|
"postcss-prefix-selector": "^2.1.0",
|
|
138
138
|
"prettier": "^3.3.3",
|
|
139
139
|
"prompts": "^2.4.2",
|
|
140
140
|
"punycode": "^2.3.1",
|
|
141
141
|
"rimraf": "^6.0.1",
|
|
142
|
-
"rollup": "^4.24.
|
|
142
|
+
"rollup": "^4.24.2",
|
|
143
143
|
"rollup-plugin-dts": "^6.1.1",
|
|
144
144
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
145
145
|
"semver": "^7.6.3",
|
|
@@ -147,10 +147,11 @@
|
|
|
147
147
|
"sirv": "^3.0.0",
|
|
148
148
|
"sitemap": "^8.0.0",
|
|
149
149
|
"supports-color": "^9.4.0",
|
|
150
|
-
"
|
|
150
|
+
"synckit": "^0.9.2",
|
|
151
|
+
"tinyglobby": "^0.2.10",
|
|
151
152
|
"typescript": "^5.6.3",
|
|
152
|
-
"vitest": "^2.1.
|
|
153
|
-
"vue-tsc": "^2.1.
|
|
153
|
+
"vitest": "^2.1.4",
|
|
154
|
+
"vue-tsc": "^2.1.8",
|
|
154
155
|
"wait-on": "^8.0.1"
|
|
155
156
|
},
|
|
156
157
|
"peerDependencies": {
|