@rspress/core 1.0.0-beta.5 → 1.0.1

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/index.js CHANGED
@@ -1,13 +1,41 @@
1
1
  import { createRequire } from "module";
2
2
  const { url } = import.meta;
3
3
  const require = createRequire(url);
4
+ var __defProp = Object.defineProperty;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
6
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
7
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
8
  }) : x)(function(x) {
7
9
  if (typeof require !== "undefined")
8
10
  return require.apply(this, arguments);
9
- throw new Error('Dynamic require of "' + x + '" is not supported');
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
10
12
  });
13
+ var __publicField = (obj, key, value) => {
14
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
15
+ return value;
16
+ };
17
+ var __accessCheck = (obj, member, msg) => {
18
+ if (!member.has(obj))
19
+ throw TypeError("Cannot " + msg);
20
+ };
21
+ var __privateGet = (obj, member, getter) => {
22
+ __accessCheck(obj, member, "read from private field");
23
+ return getter ? getter.call(obj) : member.get(obj);
24
+ };
25
+ var __privateAdd = (obj, member, value) => {
26
+ if (member.has(obj))
27
+ throw TypeError("Cannot add the same private member more than once");
28
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
29
+ };
30
+ var __privateSet = (obj, member, value, setter) => {
31
+ __accessCheck(obj, member, "write to private field");
32
+ setter ? setter.call(obj, value) : member.set(obj, value);
33
+ return value;
34
+ };
35
+ var __privateMethod = (obj, member, method) => {
36
+ __accessCheck(obj, member, "access private method");
37
+ return method;
38
+ };
11
39
 
12
40
  // src/node/dev.ts
13
41
  import { removeLeadingSlash as removeLeadingSlash2 } from "@rspress/shared";
@@ -16,7 +44,11 @@ import { logger as logger3 } from "@rspress/shared/logger";
16
44
  // src/node/createBuilder.ts
17
45
  import path8 from "path";
18
46
  import fs8 from "@modern-js/utils/fs-extra";
19
- import { RSPRESS_TEMP_DIR as RSPRESS_TEMP_DIR2, isDebugMode, removeTrailingSlash } from "@rspress/shared";
47
+ import {
48
+ RSPRESS_TEMP_DIR as RSPRESS_TEMP_DIR2,
49
+ isDebugMode,
50
+ removeTrailingSlash
51
+ } from "@rspress/shared";
20
52
  import sirv from "sirv";
21
53
 
22
54
  // tailwind.config.ts
@@ -96,15 +128,29 @@ var isProduction = () => process.env.NODE_ENV === "production";
96
128
  var importStatementRegex = /import\s+(.*?)\s+from\s+['"](.*?)['"];?/gm;
97
129
  var dirname = path.dirname(fileURLToPath(new URL(import.meta.url)));
98
130
  var PACKAGE_ROOT = path.join(dirname, "..");
99
- var CLIENT_ENTRY = path.join(PACKAGE_ROOT, "dist", "runtime", "clientEntry.js");
100
- var SSR_ENTRY = path.join(PACKAGE_ROOT, "dist", "runtime", "ssrEntry.js");
131
+ var CLIENT_ENTRY = path.join(
132
+ PACKAGE_ROOT,
133
+ "dist",
134
+ "runtime",
135
+ "clientEntry.js"
136
+ );
137
+ var SSR_ENTRY = path.join(
138
+ PACKAGE_ROOT,
139
+ "dist",
140
+ "runtime",
141
+ "ssrEntry.js"
142
+ );
101
143
  var OUTPUT_DIR = "doc_build";
102
144
  var APP_HTML_MARKER = "<!--<?- DOC_CONTENT ?>-->";
103
145
  var HEAD_MARKER = "<!--<?- HEAD ?>-->";
104
146
  var HTML_START_TAG = "<html";
105
147
  var BODY_START_TAG = "<body";
106
148
  var PUBLIC_DIR = "public";
107
- var TEMP_DIR = path.join(process.cwd(), "node_modules", RSPRESS_TEMP_DIR);
149
+ var TEMP_DIR = path.join(
150
+ process.cwd(),
151
+ "node_modules",
152
+ RSPRESS_TEMP_DIR
153
+ );
108
154
 
109
155
  // src/node/runtimeModule/index.ts
110
156
  import { RspackVirtualModulePlugin } from "rspack-plugin-virtual-module";
@@ -114,14 +160,21 @@ import { addLeadingSlash } from "@rspress/shared";
114
160
  async function routeVMPlugin(context) {
115
161
  const { routeService: routeService2 } = context;
116
162
  return {
117
- [RuntimeModuleID.RouteForClient]: routeService2.generateRoutesCode(false),
118
- [RuntimeModuleID.RouteForSSR]: routeService2.generateRoutesCode(true)
163
+ ["virtual-routes" /* RouteForClient */]: routeService2.generateRoutesCode(false),
164
+ ["virtual-routes-ssr" /* RouteForSSR */]: routeService2.generateRoutesCode(true)
119
165
  };
120
166
  }
121
167
 
122
168
  // src/node/runtimeModule/siteData.ts
123
169
  import path5 from "path";
124
- import { withBase, MDX_REGEXP as MDX_REGEXP2, SEARCH_INDEX_NAME, addLeadingSlash as addLeadingSlash2, isExternalUrl, withoutBase } from "@rspress/shared";
170
+ import {
171
+ withBase,
172
+ MDX_REGEXP as MDX_REGEXP2,
173
+ SEARCH_INDEX_NAME,
174
+ addLeadingSlash as addLeadingSlash2,
175
+ isExternalUrl,
176
+ withoutBase
177
+ } from "@rspress/shared";
125
178
  import yamlFrontMatter from "yaml-front-matter";
126
179
  import { htmlToText } from "html-to-text";
127
180
  import fs3 from "@modern-js/utils/fs-extra";
@@ -193,28 +246,32 @@ async function resolveReactAlias(reactVersion) {
193
246
  const alias = {};
194
247
  const resolver2 = ResolverFactory.createResolver({
195
248
  fileSystem: new CachedInputFileSystem(fs),
196
- extensions: [
197
- ".js"
198
- ],
249
+ extensions: [".js"],
199
250
  alias
200
251
  });
201
- await Promise.all(libPaths.map(async (lib) => {
202
- try {
203
- alias[lib] = await new Promise((resolve, reject) => {
204
- resolver2.resolve({
205
- importer: basedir
206
- }, basedir, lib, {}, (err, filePath) => {
207
- if (err || filePath === false) {
208
- return reject(err);
209
- }
210
- return resolve(filePath);
252
+ await Promise.all(
253
+ libPaths.map(async (lib) => {
254
+ try {
255
+ alias[lib] = await new Promise((resolve, reject) => {
256
+ resolver2.resolve(
257
+ { importer: basedir },
258
+ basedir,
259
+ lib,
260
+ {},
261
+ (err, filePath) => {
262
+ if (err || filePath === false) {
263
+ return reject(err);
264
+ }
265
+ return resolve(filePath);
266
+ }
267
+ );
211
268
  });
212
- });
213
- } catch (e) {
214
- console.log(e);
215
- logger.warn(`${lib} not found`);
216
- }
217
- }));
269
+ } catch (e) {
270
+ console.log(e);
271
+ logger.warn(`${lib} not found`);
272
+ }
273
+ })
274
+ );
218
275
  return alias;
219
276
  }
220
277
 
@@ -232,25 +289,32 @@ async function resolveDepPath(importPath, importer, alias) {
232
289
  if (!resolver) {
233
290
  resolver = ResolverFactory2.createResolver({
234
291
  fileSystem: new CachedInputFileSystem2(fs2),
235
- extensions: [
236
- ".mdx",
237
- ".md"
238
- ],
292
+ extensions: [".mdx", ".md"],
239
293
  alias
240
294
  });
241
295
  }
242
296
  const resolveResult = await new Promise((resolve, reject) => {
243
- resolver.resolve({
244
- importer
245
- }, importer, importPath, {}, (err, filePath) => {
246
- if (err) {
247
- return reject(err);
248
- }
249
- if (!filePath) {
250
- return reject(new Error(`Empty result when resolving ${importPath} from ${importer}`));
297
+ resolver.resolve(
298
+ {
299
+ importer
300
+ },
301
+ importer,
302
+ importPath,
303
+ {},
304
+ (err, filePath) => {
305
+ if (err) {
306
+ return reject(err);
307
+ }
308
+ if (!filePath) {
309
+ return reject(
310
+ new Error(
311
+ `Empty result when resolving ${importPath} from ${importer}`
312
+ )
313
+ );
314
+ }
315
+ return resolve(filePath);
251
316
  }
252
- return resolve(filePath);
253
- });
317
+ );
254
318
  });
255
319
  return resolveResult;
256
320
  }
@@ -259,11 +323,7 @@ async function flattenMdxContent(content, basePath, alias) {
259
323
  if (!startFlatten) {
260
324
  resolver = ResolverFactory2.createResolver({
261
325
  fileSystem: new CachedInputFileSystem2(fs2),
262
- extensions: [
263
- ".mdx",
264
- ".md",
265
- ".js"
266
- ],
326
+ extensions: [".mdx", ".md", ".js"],
267
327
  alias
268
328
  });
269
329
  startFlatten = true;
@@ -283,13 +343,21 @@ async function flattenMdxContent(content, basePath, alias) {
283
343
  const importPath = importNode.source.value;
284
344
  let absoluteImportPath;
285
345
  try {
286
- absoluteImportPath = await resolveDepPath(importPath, path4.dirname(basePath), alias);
346
+ absoluteImportPath = await resolveDepPath(
347
+ importPath,
348
+ path4.dirname(basePath),
349
+ alias
350
+ );
287
351
  } catch (e) {
288
352
  continue;
289
353
  }
290
354
  if (MDX_REGEXP.test(absoluteImportPath)) {
291
355
  const importedContent = fs2.readFileSync(absoluteImportPath, "utf-8");
292
- const replacedValue = await flattenMdxContent(importedContent, absoluteImportPath, alias);
356
+ const replacedValue = await flattenMdxContent(
357
+ importedContent,
358
+ absoluteImportPath,
359
+ alias
360
+ );
293
361
  result = result.replace(new RegExp(`<${id}\\s*/>`), () => replacedValue);
294
362
  }
295
363
  }
@@ -312,7 +380,7 @@ function i18nVMPlugin(context) {
312
380
  const { config } = context;
313
381
  const i18nData = getI18nData(config);
314
382
  return {
315
- [RuntimeModuleID.I18nText]: `export default ${JSON.stringify(i18nData)}`
383
+ ["virtual-i18n-text" /* I18nText */]: `export default ${JSON.stringify(i18nData)}`
316
384
  };
317
385
  }
318
386
 
@@ -322,9 +390,7 @@ function deletePriviteKey(obj) {
322
390
  if (typeof obj !== "object" || obj === null) {
323
391
  return obj;
324
392
  }
325
- const newObj = {
326
- ...obj
327
- };
393
+ const newObj = { ...obj };
328
394
  Object.keys(newObj).forEach((key) => {
329
395
  if (key.startsWith("_")) {
330
396
  delete newObj[key];
@@ -333,7 +399,12 @@ function deletePriviteKey(obj) {
333
399
  return newObj;
334
400
  }
335
401
  function normalizeThemeConfig(docConfig, pages = []) {
336
- const { locales: siteLocales, base = "", lang, replaceRules = [] } = docConfig;
402
+ const {
403
+ locales: siteLocales,
404
+ base = "",
405
+ lang,
406
+ replaceRules = []
407
+ } = docConfig;
337
408
  docConfig.themeConfig = docConfig.themeConfig || {};
338
409
  const { themeConfig } = docConfig;
339
410
  const locales = siteLocales ?? (themeConfig?.locales || []);
@@ -356,7 +427,10 @@ function normalizeThemeConfig(docConfig, pages = []) {
356
427
  const normalizeSidebarItem = (item) => {
357
428
  if (typeof item === "object" && "items" in item) {
358
429
  return {
359
- text: applyReplaceRules(getI18nText(item.text, currentLang), replaceRules),
430
+ text: applyReplaceRules(
431
+ getI18nText(item.text, currentLang),
432
+ replaceRules
433
+ ),
360
434
  link: normalizeLangPrefix(item.link, currentLang),
361
435
  collapsed: item.collapsed ?? false,
362
436
  collapsible: item.collapsible ?? true,
@@ -368,14 +442,19 @@ function normalizeThemeConfig(docConfig, pages = []) {
368
442
  }
369
443
  if (typeof item === "string") {
370
444
  const normalizedItem = normalizeLangPrefix(item, currentLang);
371
- const page = pages.find((page2) => page2.routePath === withBase(normalizedItem, base));
445
+ const page = pages.find(
446
+ (page2) => page2.routePath === withBase(normalizedItem, base)
447
+ );
372
448
  return {
373
449
  text: applyReplaceRules(page?.title || "", replaceRules),
374
450
  link: normalizedItem
375
451
  };
376
452
  }
377
453
  return {
378
- text: applyReplaceRules(getI18nText(item.text, currentLang), replaceRules),
454
+ text: applyReplaceRules(
455
+ getI18nText(item.text, currentLang),
456
+ replaceRules
457
+ ),
379
458
  link: normalizeLangPrefix(item.link, currentLang),
380
459
  tag: item.tag
381
460
  };
@@ -392,7 +471,10 @@ function normalizeThemeConfig(docConfig, pages = []) {
392
471
  return [];
393
472
  }
394
473
  return nav?.map((navItem) => {
395
- const text = applyReplaceRules(getI18nText(navItem.text, currentLang), replaceRules);
474
+ const text = applyReplaceRules(
475
+ getI18nText(navItem.text, currentLang),
476
+ replaceRules
477
+ );
396
478
  if ("link" in navItem) {
397
479
  return {
398
480
  ...navItem,
@@ -407,7 +489,10 @@ function normalizeThemeConfig(docConfig, pages = []) {
407
489
  items: navItem.items.map((item) => {
408
490
  return {
409
491
  ...item,
410
- text: applyReplaceRules(getI18nText(item.text, currentLang), replaceRules),
492
+ text: applyReplaceRules(
493
+ getI18nText(item.text, currentLang),
494
+ replaceRules
495
+ ),
411
496
  link: normalizeLangPrefix(item.link, currentLang)
412
497
  };
413
498
  })
@@ -418,13 +503,21 @@ function normalizeThemeConfig(docConfig, pages = []) {
418
503
  };
419
504
  if (locales.length) {
420
505
  themeConfig.locales = locales.map(({ lang: currentLang, label }) => {
421
- const localeInThemeConfig = themeConfig.locales?.find((locale) => locale.lang === currentLang);
506
+ const localeInThemeConfig = themeConfig.locales?.find(
507
+ (locale) => locale.lang === currentLang
508
+ );
422
509
  return {
423
510
  lang: currentLang,
424
511
  label,
425
512
  ...localeInThemeConfig || {},
426
- sidebar: normalizeSidebar(localeInThemeConfig?.sidebar ?? themeConfig.sidebar, currentLang),
427
- nav: normalizeNav(localeInThemeConfig?.nav ?? themeConfig.nav, currentLang)
513
+ sidebar: normalizeSidebar(
514
+ localeInThemeConfig?.sidebar ?? themeConfig.sidebar,
515
+ currentLang
516
+ ),
517
+ nav: normalizeNav(
518
+ localeInThemeConfig?.nav ?? themeConfig.nav,
519
+ currentLang
520
+ )
428
521
  };
429
522
  });
430
523
  } else {
@@ -434,106 +527,118 @@ function normalizeThemeConfig(docConfig, pages = []) {
434
527
  return themeConfig;
435
528
  }
436
529
  async function extractPageData(replaceRules, alias, domain, root, routeService2) {
437
- return Promise.all(routeService2.getRoutes().filter((route) => MDX_REGEXP2.test(route.absolutePath)).map(async (route, index) => {
438
- let content = await fs3.readFile(route.absolutePath, "utf8");
439
- const frontmatter = {
440
- ...loadFront(content)
441
- };
442
- Object.keys(frontmatter).forEach((key) => {
443
- if (typeof frontmatter[key] === "string") {
444
- frontmatter[key] = applyReplaceRules(frontmatter[key], replaceRules);
530
+ return Promise.all(
531
+ routeService2.getRoutes().filter((route) => MDX_REGEXP2.test(route.absolutePath)).map(async (route, index) => {
532
+ let content = await fs3.readFile(route.absolutePath, "utf8");
533
+ const frontmatter = {
534
+ ...loadFront(content)
535
+ };
536
+ Object.keys(frontmatter).forEach((key) => {
537
+ if (typeof frontmatter[key] === "string") {
538
+ frontmatter[key] = applyReplaceRules(
539
+ frontmatter[key],
540
+ replaceRules
541
+ );
542
+ }
543
+ });
544
+ const flattenContent = await flattenMdxContent(
545
+ frontmatter.__content,
546
+ route.absolutePath,
547
+ alias
548
+ );
549
+ content = flattenContent.replace(importStatementRegex, "");
550
+ const {
551
+ html,
552
+ title,
553
+ toc: rawToc
554
+ } = await compile({
555
+ value: content,
556
+ filepath: route.absolutePath,
557
+ development: process.env.NODE_ENV !== "production",
558
+ root
559
+ });
560
+ if (!title?.length && !frontmatter && !frontmatter.title?.length) {
561
+ return null;
445
562
  }
446
- });
447
- const flattenContent = await flattenMdxContent(frontmatter.__content, route.absolutePath, alias);
448
- content = flattenContent.replace(importStatementRegex, "");
449
- const { html, title, toc: rawToc } = await compile({
450
- value: content,
451
- filepath: route.absolutePath,
452
- development: process.env.NODE_ENV !== "production",
453
- root
454
- });
455
- if (!title?.length && !frontmatter && !frontmatter.title?.length) {
456
- return null;
457
- }
458
- content = htmlToText(String(html), {
459
- wordwrap: 80,
460
- selectors: [
461
- {
462
- selector: "a",
463
- options: {
464
- ignoreHref: true
465
- }
466
- },
467
- {
468
- selector: "img",
469
- format: "skip"
470
- },
471
- ...[
472
- "h1",
473
- "h2",
474
- "h3",
475
- "h4",
476
- "h5",
477
- "h6"
478
- ].map((tag) => ({
479
- selector: tag,
480
- options: {
481
- uppercase: false
482
- }
483
- }))
484
- ],
485
- tables: true,
486
- longWordSplit: {
487
- forceWrapOnLimit: true
563
+ content = htmlToText(String(html), {
564
+ wordwrap: 80,
565
+ selectors: [
566
+ {
567
+ selector: "a",
568
+ options: {
569
+ ignoreHref: true
570
+ }
571
+ },
572
+ {
573
+ selector: "img",
574
+ format: "skip"
575
+ },
576
+ ...["h1", "h2", "h3", "h4", "h5", "h6"].map((tag) => ({
577
+ selector: tag,
578
+ options: {
579
+ uppercase: false
580
+ }
581
+ }))
582
+ ],
583
+ tables: true,
584
+ longWordSplit: {
585
+ forceWrapOnLimit: true
586
+ }
587
+ });
588
+ if (content.startsWith(title)) {
589
+ content = content.slice(title.length);
488
590
  }
489
- });
490
- if (content.startsWith(title)) {
491
- content = content.slice(title.length);
492
- }
493
- const toc = rawToc.map((item) => {
494
- const match = item.id.match(/-(\d+)$/);
495
- let position = -1;
496
- if (match) {
497
- for (let i = 0; i < Number(match[1]); i++) {
498
- position = content.indexOf(`
591
+ const toc = rawToc.map((item) => {
592
+ const match = item.id.match(/-(\d+)$/);
593
+ let position = -1;
594
+ if (match) {
595
+ for (let i = 0; i < Number(match[1]); i++) {
596
+ position = content.indexOf(`
499
597
  ${item.text}#
500
598
 
501
599
  `, position + 1);
600
+ }
502
601
  }
503
- }
504
- return {
505
- ...item,
506
- charIndex: content.indexOf(`
602
+ return {
603
+ ...item,
604
+ charIndex: content.indexOf(`
507
605
  ${item.text}#
508
606
 
509
607
  `, position + 1)
608
+ };
609
+ });
610
+ return {
611
+ id: index,
612
+ title: frontmatter.title || title,
613
+ routePath: route.routePath,
614
+ lang: route.lang,
615
+ toc,
616
+ domain,
617
+ // Stripped frontmatter content
618
+ content,
619
+ frontmatter: {
620
+ ...frontmatter,
621
+ __content: void 0
622
+ },
623
+ version: route.version,
624
+ _filepath: route.absolutePath,
625
+ _relativePath: path5.relative(root, route.absolutePath)
510
626
  };
511
- });
512
- return {
513
- id: index,
514
- title: frontmatter.title || title,
515
- routePath: route.routePath,
516
- lang: route.lang,
517
- toc,
518
- domain,
519
- // Stripped frontmatter content
520
- content,
521
- frontmatter: {
522
- ...frontmatter,
523
- __content: void 0
524
- },
525
- version: route.version,
526
- _filepath: route.absolutePath,
527
- _relativePath: path5.relative(root, route.absolutePath)
528
- };
529
- }));
627
+ })
628
+ );
530
629
  }
531
630
  async function siteDataVMPlugin(context) {
532
631
  const { config, alias, userDocRoot, routeService: routeService2, pluginDriver } = context;
533
632
  const userConfig = config;
534
633
  const replaceRules = userConfig?.replaceRules || [];
535
634
  const domain = userConfig?.search && userConfig?.search?.mode === "remote" ? userConfig?.search.domain ?? "" : "";
536
- const pages = (await extractPageData(replaceRules, alias, domain, userDocRoot, routeService2)).filter(Boolean);
635
+ const pages = (await extractPageData(
636
+ replaceRules,
637
+ alias,
638
+ domain,
639
+ userDocRoot,
640
+ routeService2
641
+ )).filter(Boolean);
537
642
  await pluginDriver.modifySearchIndexData(pages);
538
643
  const pagesByLang = pages.reduce((acc, page) => {
539
644
  if (!acc[page.lang]) {
@@ -546,14 +651,23 @@ async function siteDataVMPlugin(context) {
546
651
  return acc;
547
652
  }, {});
548
653
  const indexHashByLang = {};
549
- await Promise.all(Object.keys(pagesByLang).map(async (lang) => {
550
- const stringfiedIndex = JSON.stringify(pagesByLang[lang].map(deletePriviteKey));
551
- const indexHash = createHash(stringfiedIndex);
552
- indexHashByLang[lang] = indexHash;
553
- await fs3.ensureDir(TEMP_DIR);
554
- await fs3.writeFile(path5.join(TEMP_DIR, `${SEARCH_INDEX_NAME}.${lang}.${indexHash}.json`), stringfiedIndex);
555
- }));
556
- await Promise.all(pages.map(async (pageData) => pluginDriver.extendPageData(pageData)));
654
+ await Promise.all(
655
+ Object.keys(pagesByLang).map(async (lang) => {
656
+ const stringfiedIndex = JSON.stringify(
657
+ pagesByLang[lang].map(deletePriviteKey)
658
+ );
659
+ const indexHash = createHash(stringfiedIndex);
660
+ indexHashByLang[lang] = indexHash;
661
+ await fs3.ensureDir(TEMP_DIR);
662
+ await fs3.writeFile(
663
+ path5.join(TEMP_DIR, `${SEARCH_INDEX_NAME}.${lang}.${indexHash}.json`),
664
+ stringfiedIndex
665
+ );
666
+ })
667
+ );
668
+ await Promise.all(
669
+ pages.map(async (pageData) => pluginDriver.extendPageData(pageData))
670
+ );
557
671
  const siteData = {
558
672
  title: userConfig?.title || "",
559
673
  description: userConfig?.description || "",
@@ -568,9 +682,7 @@ async function siteDataVMPlugin(context) {
568
682
  default: userConfig?.multiVersion?.default || "",
569
683
  versions: userConfig?.multiVersion?.versions || []
570
684
  },
571
- search: userConfig?.search ?? {
572
- mode: "local"
573
- },
685
+ search: userConfig?.search ?? { mode: "local" },
574
686
  pages: pages.map((page) => {
575
687
  const { content, id, domain: domain2, _filepath, ...rest } = page;
576
688
  return rest;
@@ -580,8 +692,12 @@ async function siteDataVMPlugin(context) {
580
692
  }
581
693
  };
582
694
  return {
583
- [`${RuntimeModuleID.SiteData}.mjs`]: `export default ${JSON.stringify(siteData)}`,
584
- [RuntimeModuleID.SearchIndexHash]: `export default ${JSON.stringify(indexHashByLang)}`
695
+ [`${"virtual-site-data" /* SiteData */}.mjs`]: `export default ${JSON.stringify(
696
+ siteData
697
+ )}`,
698
+ ["virtual-search-index-hash" /* SearchIndexHash */]: `export default ${JSON.stringify(
699
+ indexHashByLang
700
+ )}`
585
701
  };
586
702
  }
587
703
 
@@ -605,17 +721,17 @@ const Props_${index++} = ${JSON.stringify(source[1])};
605
721
  return `import ${name} from '${source}';
606
722
  `;
607
723
  }
608
- }).concat(`export default [${Array.from({
609
- length: index
610
- }, (_, i) => {
611
- if (Array.isArray(globalComponents[i])) {
612
- return `[${`Comp_${i}`}, Props_${i}]`;
613
- } else {
614
- return `Comp_${i}`;
615
- }
616
- }).join(", ")}];`).join("");
724
+ }).concat(
725
+ `export default [${Array.from({ length: index }, (_, i) => {
726
+ if (Array.isArray(globalComponents[i])) {
727
+ return `[${`Comp_${i}`}, Props_${i}]`;
728
+ } else {
729
+ return `Comp_${i}`;
730
+ }
731
+ }).join(", ")}];`
732
+ ).join("");
617
733
  return {
618
- [RuntimeModuleID.GlobalComponents]: moduleContent
734
+ ["virtual-global-components" /* GlobalComponents */]: moduleContent
619
735
  };
620
736
  }
621
737
 
@@ -630,14 +746,13 @@ async function globalStylesVMPlugin(context) {
630
746
  const patchedStyleContent = styleContent.replace(/--modern-/g, "--rp-").replace(/\.modern-doc/g, ".rspress").replace(/\.modern-/g, ".rspress-");
631
747
  await fs4.writeFile(source, patchedStyleContent, "utf-8");
632
748
  }
633
- const moduleContent = (await Promise.all([
634
- config?.globalStyles || "",
635
- ...globalStylesByPlugins
636
- ].filter((source) => source.length > 0).map(async (source) => {
637
- return `import ${JSON.stringify(source)};`;
638
- }))).join("");
749
+ const moduleContent = (await Promise.all(
750
+ [config?.globalStyles || "", ...globalStylesByPlugins].filter((source) => source.length > 0).map(async (source) => {
751
+ return `import ${JSON.stringify(source)};`;
752
+ })
753
+ )).join("");
639
754
  return {
640
- [RuntimeModuleID.GlobalStyles]: moduleContent
755
+ ["virtual-global-styles" /* GlobalStyles */]: moduleContent
641
756
  };
642
757
  }
643
758
 
@@ -650,35 +765,35 @@ async function searchHookVMPlugin(context) {
650
765
  content = await fs5.readFile(config.search.searchHooks, "utf-8");
651
766
  }
652
767
  return {
653
- [RuntimeModuleID.SearchHooks]: content
768
+ ["virtual-search-hooks" /* SearchHooks */]: content
654
769
  };
655
770
  }
656
771
 
657
772
  // src/node/runtimeModule/index.ts
658
773
  var runtimeModuleFactory = [
659
774
  /**
660
- * Generate route data for client and server runtime
661
- */
775
+ * Generate route data for client and server runtime
776
+ */
662
777
  routeVMPlugin,
663
778
  /**
664
- * Generate search index and site data for client runtime
665
- */
779
+ * Generate search index and site data for client runtime
780
+ */
666
781
  siteDataVMPlugin,
667
782
  /**
668
- * Generate global components from config and plugins
669
- */
783
+ * Generate global components from config and plugins
784
+ */
670
785
  globalUIComponentsVMPlugin,
671
786
  /**
672
- * Generate global styles from config and plugins
673
- */
787
+ * Generate global styles from config and plugins
788
+ */
674
789
  globalStylesVMPlugin,
675
790
  /**
676
- * Generate i18n text for client runtime
677
- */
791
+ * Generate i18n text for client runtime
792
+ */
678
793
  i18nVMPlugin,
679
794
  /**
680
- * Generate search hook module
681
- */
795
+ * Generate search hook module
796
+ */
682
797
  searchHookVMPlugin
683
798
  ];
684
799
  function builderDocVMPlugin(factoryContext) {
@@ -695,32 +810,16 @@ function builderDocVMPlugin(factoryContext) {
695
810
  });
696
811
  Object.assign(runtimeModule, moduleResult);
697
812
  }
698
- bundlerChain.plugin(`rspress-runtime-module`).use(new RspackVirtualModulePlugin(runtimeModule, factoryContext.runtimeTempDir));
813
+ bundlerChain.plugin(`rspress-runtime-module`).use(
814
+ new RspackVirtualModulePlugin(
815
+ runtimeModule,
816
+ factoryContext.runtimeTempDir
817
+ )
818
+ );
699
819
  });
700
820
  }
701
821
  };
702
822
  }
703
- var RuntimeModuleID;
704
- (function(RuntimeModuleID2) {
705
- RuntimeModuleID2["GlobalStyles"] = "virtual-global-styles";
706
- RuntimeModuleID2["GlobalComponents"] = "virtual-global-components";
707
- RuntimeModuleID2["RouteForClient"] = "virtual-routes";
708
- RuntimeModuleID2["RouteForSSR"] = "virtual-routes-ssr";
709
- RuntimeModuleID2["SiteData"] = "virtual-site-data";
710
- RuntimeModuleID2["SearchIndexHash"] = "virtual-search-index-hash";
711
- RuntimeModuleID2["I18nText"] = "virtual-i18n-text";
712
- RuntimeModuleID2["SearchHooks"] = "virtual-search-hooks";
713
- })(RuntimeModuleID || (RuntimeModuleID = {}));
714
- var runtimeModuleIDs = [
715
- RuntimeModuleID.GlobalStyles,
716
- RuntimeModuleID.GlobalComponents,
717
- RuntimeModuleID.RouteForClient,
718
- RuntimeModuleID.RouteForSSR,
719
- RuntimeModuleID.SiteData,
720
- RuntimeModuleID.SearchIndexHash,
721
- RuntimeModuleID.I18nText,
722
- RuntimeModuleID.SearchHooks
723
- ];
724
823
 
725
824
  // src/node/searchIndex.ts
726
825
  import path6, { join as join2 } from "path";
@@ -744,11 +843,12 @@ async function writeSearchIndex(config) {
744
843
  }
745
844
  const source = join2(TEMP_DIR, searchIndexFile);
746
845
  const target = join2(outDir, "static", searchIndexFile);
747
- const searchIndex = await fs6.readFile(join2(TEMP_DIR, searchIndexFile), "utf-8");
846
+ const searchIndex = await fs6.readFile(
847
+ join2(TEMP_DIR, searchIndexFile),
848
+ "utf-8"
849
+ );
748
850
  searchIndexData = `${searchIndexData.slice(0, -1)}${scaning ? "," : ""}${searchIndex.slice(1)}`;
749
- await fs6.move(source, target, {
750
- overwrite: true
751
- });
851
+ await fs6.move(source, target, { overwrite: true });
752
852
  scaning = true;
753
853
  }
754
854
  if (isProduction() && isSCM() && config?.search?.mode === "remote") {
@@ -757,14 +857,20 @@ async function writeSearchIndex(config) {
757
857
  await fetch(`${apiUrl}?index=${indexName}`, {
758
858
  method: "PUT",
759
859
  body: searchIndexData,
760
- headers: {
761
- "Content-Type": "application/json"
762
- }
860
+ headers: { "Content-Type": "application/json" }
763
861
  });
764
- logger2.info(chalk.green(`[doc-tools] Search index uploaded to ${apiUrl}, indexName: ${indexName}`));
862
+ logger2.info(
863
+ chalk.green(
864
+ `[doc-tools] Search index uploaded to ${apiUrl}, indexName: ${indexName}`
865
+ )
866
+ );
765
867
  } catch (e) {
766
- logger2.info(chalk.red(`[doc-tools] Upload search index \`${indexName}\` failed:
767
- ${e}`));
868
+ logger2.info(
869
+ chalk.red(
870
+ `[doc-tools] Upload search index \`${indexName}\` failed:
871
+ ${e}`
872
+ )
873
+ );
768
874
  }
769
875
  }
770
876
  }
@@ -774,7 +880,15 @@ function serveSearchIndexMiddleware(config) {
774
880
  if (req.url?.includes(searchIndexRequestMatch)) {
775
881
  res.setHeader("Content-Type", "application/json");
776
882
  const searchIndexFile = req.url?.split("/").pop();
777
- const searchIndex = fs6.readFileSync(path6.join(process.cwd(), config?.outDir || OUTPUT_DIR, "static", searchIndexFile), "utf-8");
883
+ const searchIndex = fs6.readFileSync(
884
+ path6.join(
885
+ process.cwd(),
886
+ config?.outDir || OUTPUT_DIR,
887
+ "static",
888
+ searchIndexFile
889
+ ),
890
+ "utf-8"
891
+ );
778
892
  res.end(searchIndex);
779
893
  } else {
780
894
  next?.();
@@ -786,77 +900,7 @@ function serveSearchIndexMiddleware(config) {
786
900
  import path7 from "path";
787
901
  import fs7 from "@modern-js/utils/fs-extra";
788
902
  import { withBase as withBase2 } from "@rspress/shared";
789
- function _check_private_redeclaration(obj, privateCollection) {
790
- if (privateCollection.has(obj)) {
791
- throw new TypeError("Cannot initialize the same private elements twice on an object");
792
- }
793
- }
794
- function _class_apply_descriptor_get(receiver, descriptor) {
795
- if (descriptor.get) {
796
- return descriptor.get.call(receiver);
797
- }
798
- return descriptor.value;
799
- }
800
- function _class_apply_descriptor_set(receiver, descriptor, value) {
801
- if (descriptor.set) {
802
- descriptor.set.call(receiver, value);
803
- } else {
804
- if (!descriptor.writable) {
805
- throw new TypeError("attempted to set read only private field");
806
- }
807
- descriptor.value = value;
808
- }
809
- }
810
- function _class_extract_field_descriptor(receiver, privateMap, action) {
811
- if (!privateMap.has(receiver)) {
812
- throw new TypeError("attempted to " + action + " private field on non-instance");
813
- }
814
- return privateMap.get(receiver);
815
- }
816
- function _class_private_field_get(receiver, privateMap) {
817
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
818
- return _class_apply_descriptor_get(receiver, descriptor);
819
- }
820
- function _class_private_field_init(obj, privateMap, value) {
821
- _check_private_redeclaration(obj, privateMap);
822
- privateMap.set(obj, value);
823
- }
824
- function _class_private_field_set(receiver, privateMap, value) {
825
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
826
- _class_apply_descriptor_set(receiver, descriptor, value);
827
- return value;
828
- }
829
- function _class_private_method_get(receiver, privateSet, fn) {
830
- if (!privateSet.has(receiver)) {
831
- throw new TypeError("attempted to get private field on non-instance");
832
- }
833
- return fn;
834
- }
835
- function _class_private_method_init(obj, privateSet) {
836
- _check_private_redeclaration(obj, privateSet);
837
- privateSet.add(obj);
838
- }
839
- function _define_property(obj, key, value) {
840
- if (key in obj) {
841
- Object.defineProperty(obj, key, {
842
- value,
843
- enumerable: true,
844
- configurable: true,
845
- writable: true
846
- });
847
- } else {
848
- obj[key] = value;
849
- }
850
- return obj;
851
- }
852
- var DEFAULT_PAGE_EXTENSIONS = [
853
- "js",
854
- "jsx",
855
- "ts",
856
- "tsx",
857
- "md",
858
- "mdx"
859
- ];
903
+ var DEFAULT_PAGE_EXTENSIONS = ["js", "jsx", "ts", "tsx", "md", "mdx"];
860
904
  var addLeadingSlash3 = (str) => {
861
905
  return str.startsWith("/") ? str : `/${str}`;
862
906
  };
@@ -879,11 +923,9 @@ var normalizeRoutePath = (routePath, lang, base, version) => {
879
923
  }
880
924
  }
881
925
  purePathPart = parts.join("/");
882
- let normalizedRoutePath = addLeadingSlash3([
883
- versionPart,
884
- langPart,
885
- purePathPart
886
- ].filter(Boolean).join("/")).replace(/\.[^.]+$/, "").replace(/\/index$/, "/");
926
+ let normalizedRoutePath = addLeadingSlash3(
927
+ [versionPart, langPart, purePathPart].filter(Boolean).join("/")
928
+ ).replace(/\.[^.]+$/, "").replace(/\/index$/, "/");
887
929
  if (hasTrailSlash && !normalizedRoutePath.endsWith("/")) {
888
930
  normalizedRoutePath = `${normalizedRoutePath}/`;
889
931
  }
@@ -893,37 +935,57 @@ var normalizeRoutePath = (routePath, lang, base, version) => {
893
935
  version: versionPart || version
894
936
  };
895
937
  };
896
- var _scanDir = /* @__PURE__ */ new WeakMap();
897
- var _defaultLang = /* @__PURE__ */ new WeakMap();
898
- var _defaultVersion = /* @__PURE__ */ new WeakMap();
899
- var _extensions = /* @__PURE__ */ new WeakMap();
900
- var _include = /* @__PURE__ */ new WeakMap();
901
- var _exclude = /* @__PURE__ */ new WeakMap();
902
- var _base = /* @__PURE__ */ new WeakMap();
903
- var _tempDir = /* @__PURE__ */ new WeakMap();
904
- var _pluginDriver = /* @__PURE__ */ new WeakMap();
905
- var _writeTempFile = /* @__PURE__ */ new WeakSet();
906
- var _generateRouteInfo = /* @__PURE__ */ new WeakSet();
938
+ var _scanDir, _defaultLang, _defaultVersion, _extensions, _include, _exclude, _base, _tempDir, _pluginDriver, _writeTempFile, writeTempFile_fn, _generateRouteInfo, generateRouteInfo_fn;
907
939
  var RouteService = class {
940
+ constructor(scanDir, userConfig, tempDir, pluginDriver) {
941
+ __privateAdd(this, _writeTempFile);
942
+ __privateAdd(this, _generateRouteInfo);
943
+ __publicField(this, "routeData", /* @__PURE__ */ new Map());
944
+ __privateAdd(this, _scanDir, void 0);
945
+ __privateAdd(this, _defaultLang, void 0);
946
+ __privateAdd(this, _defaultVersion, "");
947
+ __privateAdd(this, _extensions, []);
948
+ __privateAdd(this, _include, []);
949
+ __privateAdd(this, _exclude, []);
950
+ __privateAdd(this, _base, "");
951
+ __privateAdd(this, _tempDir, "");
952
+ __privateAdd(this, _pluginDriver, void 0);
953
+ const routeOptions = userConfig?.route || {};
954
+ __privateSet(this, _scanDir, scanDir);
955
+ __privateSet(this, _extensions, routeOptions.extensions || DEFAULT_PAGE_EXTENSIONS);
956
+ __privateSet(this, _include, routeOptions.include || []);
957
+ __privateSet(this, _exclude, routeOptions.exclude || []);
958
+ __privateSet(this, _defaultLang, userConfig?.lang || "");
959
+ __privateSet(this, _base, userConfig?.base || "");
960
+ __privateSet(this, _tempDir, tempDir);
961
+ __privateSet(this, _pluginDriver, pluginDriver);
962
+ if (userConfig.multiVersion) {
963
+ __privateSet(this, _defaultVersion, userConfig.multiVersion.default || "");
964
+ }
965
+ }
908
966
  async init() {
909
967
  const { default: globby } = await import("@modern-js/utils/globby");
910
- const files = globby.sync([
911
- `**/*.{${_class_private_field_get(this, _extensions).join(",")}}`,
912
- ..._class_private_field_get(this, _include)
913
- ], {
914
- cwd: _class_private_field_get(this, _scanDir),
968
+ const files = globby.sync([`**/*.{${__privateGet(this, _extensions).join(",")}}`, ...__privateGet(this, _include)], {
969
+ cwd: __privateGet(this, _scanDir),
915
970
  absolute: true,
916
971
  ignore: [
917
- ..._class_private_field_get(this, _exclude),
972
+ ...__privateGet(this, _exclude),
918
973
  "**/node_modules/**",
919
974
  "**/.eslintrc.js",
920
975
  "**/.turbo/**"
921
976
  ]
922
977
  }).sort();
923
978
  files.forEach((filePath) => {
924
- const fileRelativePath = normalizePath(path7.relative(_class_private_field_get(this, _scanDir), filePath));
925
- const { routePath, lang, version } = normalizeRoutePath(fileRelativePath, _class_private_field_get(this, _defaultLang), _class_private_field_get(this, _base), _class_private_field_get(this, _defaultVersion));
926
- const absolutePath = path7.join(_class_private_field_get(this, _scanDir), fileRelativePath);
979
+ const fileRelativePath = normalizePath(
980
+ path7.relative(__privateGet(this, _scanDir), filePath)
981
+ );
982
+ const { routePath, lang, version } = normalizeRoutePath(
983
+ fileRelativePath,
984
+ __privateGet(this, _defaultLang),
985
+ __privateGet(this, _base),
986
+ __privateGet(this, _defaultVersion)
987
+ );
988
+ const absolutePath = path7.join(__privateGet(this, _scanDir), fileRelativePath);
927
989
  const routeInfo = {
928
990
  routePath,
929
991
  absolutePath: normalizePath(absolutePath),
@@ -934,27 +996,33 @@ var RouteService = class {
934
996
  };
935
997
  this.addRoute(routeInfo);
936
998
  });
937
- const externalPages = await _class_private_field_get(this, _pluginDriver).addPages();
938
- await Promise.all(externalPages.map(async (route, index) => {
939
- const { routePath, content, filepath } = route;
940
- if (filepath) {
941
- const routeInfo = _class_private_method_get(this, _generateRouteInfo, generateRouteInfo).call(this, routePath, filepath);
942
- this.addRoute(routeInfo);
943
- return;
944
- }
945
- if (content) {
946
- const filepath2 = await _class_private_method_get(this, _writeTempFile, writeTempFile).call(this, index, content);
947
- const routeInfo = _class_private_method_get(this, _generateRouteInfo, generateRouteInfo).call(this, routePath, filepath2);
948
- this.addRoute(routeInfo);
949
- }
950
- }));
951
- await _class_private_field_get(this, _pluginDriver).routeGenerated(this.getRoutes());
999
+ const externalPages = await __privateGet(this, _pluginDriver).addPages();
1000
+ await Promise.all(
1001
+ externalPages.map(async (route, index) => {
1002
+ const { routePath, content, filepath } = route;
1003
+ if (filepath) {
1004
+ const routeInfo = __privateMethod(this, _generateRouteInfo, generateRouteInfo_fn).call(this, routePath, filepath);
1005
+ this.addRoute(routeInfo);
1006
+ return;
1007
+ }
1008
+ if (content) {
1009
+ const filepath2 = await __privateMethod(this, _writeTempFile, writeTempFile_fn).call(this, index, content);
1010
+ const routeInfo = __privateMethod(this, _generateRouteInfo, generateRouteInfo_fn).call(this, routePath, filepath2);
1011
+ this.addRoute(routeInfo);
1012
+ }
1013
+ })
1014
+ );
1015
+ await __privateGet(this, _pluginDriver).routeGenerated(this.getRoutes());
952
1016
  }
953
1017
  addRoute(routeInfo) {
954
1018
  const { routePath, absolutePath } = routeInfo;
955
1019
  if (this.routeData.has(routePath)) {
956
- const preRouteExtIndex = _class_private_field_get(this, _extensions).indexOf(path7.extname(this.routeData.get(routePath).absolutePath).slice(1));
957
- const currRouteExtIndex = _class_private_field_get(this, _extensions).indexOf(path7.extname(absolutePath).slice(1));
1020
+ const preRouteExtIndex = __privateGet(this, _extensions).indexOf(
1021
+ path7.extname(this.routeData.get(routePath).absolutePath).slice(1)
1022
+ );
1023
+ const currRouteExtIndex = __privateGet(this, _extensions).indexOf(
1024
+ path7.extname(absolutePath).slice(1)
1025
+ );
958
1026
  if (currRouteExtIndex !== -1 && (currRouteExtIndex < preRouteExtIndex || preRouteExtIndex === -1)) {
959
1027
  this.routeData.set(routePath, routeInfo);
960
1028
  }
@@ -963,15 +1031,25 @@ var RouteService = class {
963
1031
  }
964
1032
  }
965
1033
  removeRoute(filePath) {
966
- const fileRelativePath = path7.relative(_class_private_field_get(this, _scanDir), filePath);
967
- const { routePath } = normalizeRoutePath(fileRelativePath, _class_private_field_get(this, _defaultLang), _class_private_field_get(this, _base), _class_private_field_get(this, _defaultVersion));
1034
+ const fileRelativePath = path7.relative(__privateGet(this, _scanDir), filePath);
1035
+ const { routePath } = normalizeRoutePath(
1036
+ fileRelativePath,
1037
+ __privateGet(this, _defaultLang),
1038
+ __privateGet(this, _base),
1039
+ __privateGet(this, _defaultVersion)
1040
+ );
968
1041
  this.routeData.delete(routePath);
969
1042
  }
970
1043
  getRoutes() {
971
1044
  return Array.from(this.routeData.values());
972
1045
  }
973
1046
  isExistRoute(routePath) {
974
- const { routePath: normalizedRoute } = normalizeRoutePath(routePath, _class_private_field_get(this, _defaultLang), _class_private_field_get(this, _base), _class_private_field_get(this, _defaultVersion));
1047
+ const { routePath: normalizedRoute } = normalizeRoutePath(
1048
+ routePath,
1049
+ __privateGet(this, _defaultLang),
1050
+ __privateGet(this, _base),
1051
+ __privateGet(this, _defaultVersion)
1052
+ );
975
1053
  return this.routeData.get(normalizedRoute);
976
1054
  }
977
1055
  isEmpty() {
@@ -999,82 +1077,54 @@ ${routeMeta.map((route, index) => {
999
1077
  ];
1000
1078
  `;
1001
1079
  }
1002
- constructor(scanDir, userConfig, tempDir, pluginDriver) {
1003
- _class_private_method_init(this, _writeTempFile);
1004
- _class_private_method_init(this, _generateRouteInfo);
1005
- _define_property(this, "routeData", /* @__PURE__ */ new Map());
1006
- _class_private_field_init(this, _scanDir, {
1007
- writable: true,
1008
- value: void 0
1009
- });
1010
- _class_private_field_init(this, _defaultLang, {
1011
- writable: true,
1012
- value: void 0
1013
- });
1014
- _class_private_field_init(this, _defaultVersion, {
1015
- writable: true,
1016
- value: ""
1017
- });
1018
- _class_private_field_init(this, _extensions, {
1019
- writable: true,
1020
- value: []
1021
- });
1022
- _class_private_field_init(this, _include, {
1023
- writable: true,
1024
- value: []
1025
- });
1026
- _class_private_field_init(this, _exclude, {
1027
- writable: true,
1028
- value: []
1029
- });
1030
- _class_private_field_init(this, _base, {
1031
- writable: true,
1032
- value: ""
1033
- });
1034
- _class_private_field_init(this, _tempDir, {
1035
- writable: true,
1036
- value: ""
1037
- });
1038
- _class_private_field_init(this, _pluginDriver, {
1039
- writable: true,
1040
- value: void 0
1041
- });
1042
- const routeOptions = userConfig?.route || {};
1043
- _class_private_field_set(this, _scanDir, scanDir);
1044
- _class_private_field_set(this, _extensions, routeOptions.extensions || DEFAULT_PAGE_EXTENSIONS);
1045
- _class_private_field_set(this, _include, routeOptions.include || []);
1046
- _class_private_field_set(this, _exclude, routeOptions.exclude || []);
1047
- _class_private_field_set(this, _defaultLang, userConfig?.lang || "");
1048
- _class_private_field_set(this, _base, userConfig?.base || "");
1049
- _class_private_field_set(this, _tempDir, tempDir);
1050
- _class_private_field_set(this, _pluginDriver, pluginDriver);
1051
- if (userConfig.multiVersion) {
1052
- _class_private_field_set(this, _defaultVersion, userConfig.multiVersion.default || "");
1053
- }
1054
- }
1055
1080
  };
1056
- async function writeTempFile(index, content) {
1057
- const tempFilePath = path7.join(_class_private_field_get(this, _tempDir), `temp-${index}.mdx`);
1081
+ _scanDir = new WeakMap();
1082
+ _defaultLang = new WeakMap();
1083
+ _defaultVersion = new WeakMap();
1084
+ _extensions = new WeakMap();
1085
+ _include = new WeakMap();
1086
+ _exclude = new WeakMap();
1087
+ _base = new WeakMap();
1088
+ _tempDir = new WeakMap();
1089
+ _pluginDriver = new WeakMap();
1090
+ _writeTempFile = new WeakSet();
1091
+ writeTempFile_fn = async function(index, content) {
1092
+ const tempFilePath = path7.join(__privateGet(this, _tempDir), `temp-${index}.mdx`);
1058
1093
  await fs7.writeFile(tempFilePath, content);
1059
1094
  return tempFilePath;
1060
- }
1061
- function generateRouteInfo(routePath, filepath) {
1062
- const { routePath: normalizedPath, lang, version } = normalizeRoutePath(routePath, _class_private_field_get(this, _defaultLang), _class_private_field_get(this, _base), _class_private_field_get(this, _defaultVersion));
1095
+ };
1096
+ _generateRouteInfo = new WeakSet();
1097
+ generateRouteInfo_fn = function(routePath, filepath) {
1098
+ const {
1099
+ routePath: normalizedPath,
1100
+ lang,
1101
+ version
1102
+ } = normalizeRoutePath(
1103
+ routePath,
1104
+ __privateGet(this, _defaultLang),
1105
+ __privateGet(this, _base),
1106
+ __privateGet(this, _defaultVersion)
1107
+ );
1063
1108
  return {
1064
1109
  routePath: normalizedPath,
1065
1110
  absolutePath: normalizePath(filepath),
1066
- relativePath: normalizePath(path7.relative(_class_private_field_get(this, _scanDir), filepath)),
1111
+ relativePath: normalizePath(path7.relative(__privateGet(this, _scanDir), filepath)),
1067
1112
  pageName: getPageKey(routePath),
1068
1113
  lang,
1069
1114
  version
1070
1115
  };
1071
- }
1116
+ };
1072
1117
 
1073
1118
  // src/node/route/init.ts
1074
1119
  var routeService = null;
1075
1120
  async function initRouteService(options) {
1076
1121
  const { scanDir, config, runtimeTempDir, pluginDriver } = options;
1077
- routeService = new RouteService(scanDir, config, runtimeTempDir, pluginDriver);
1122
+ routeService = new RouteService(
1123
+ scanDir,
1124
+ config,
1125
+ runtimeTempDir,
1126
+ pluginDriver
1127
+ );
1078
1128
  await routeService.init();
1079
1129
  return routeService;
1080
1130
  }
@@ -1115,9 +1165,7 @@ async function createInternalBuildConfig(userDocRoot, config, isSSR, routeServic
1115
1165
  "last 1 firefox version",
1116
1166
  "last 1 safari version"
1117
1167
  ],
1118
- node: [
1119
- "node >= 14"
1120
- ]
1168
+ node: ["node >= 14"]
1121
1169
  };
1122
1170
  return {
1123
1171
  dev: {
@@ -1152,9 +1200,7 @@ async function createInternalBuildConfig(userDocRoot, config, isSSR, routeServic
1152
1200
  "react-lazy-with-preload": __require.resolve("react-lazy-with-preload"),
1153
1201
  ...await resolveReactAlias(reactVersion)
1154
1202
  },
1155
- include: [
1156
- PACKAGE_ROOT
1157
- ],
1203
+ include: [PACKAGE_ROOT],
1158
1204
  define: {
1159
1205
  "process.env.__ASSET_PREFIX__": JSON.stringify(assetPrefix),
1160
1206
  "process.env.__SSR__": JSON.stringify(isSSR),
@@ -1170,23 +1216,23 @@ async function createInternalBuildConfig(userDocRoot, config, isSSR, routeServic
1170
1216
  devServer: {
1171
1217
  // Serve static files
1172
1218
  after: [
1173
- ...isPublicDirExist ? [
1174
- sirv(publicDir)
1175
- ] : [],
1219
+ ...isPublicDirExist ? [sirv(publicDir)] : [],
1176
1220
  serveSearchIndexMiddleware(config)
1177
1221
  ],
1178
1222
  historyApiFallback: true
1179
1223
  },
1180
1224
  postcss(config2) {
1181
1225
  if (isDebugMode()) {
1182
- config2.postcssOptions.plugins.push(__require("tailwindcss")({
1183
- config: {
1184
- ...tailwindConfig,
1185
- content: [
1186
- path8.join(PACKAGE_ROOT, "src", "theme-default", "**/*")
1187
- ]
1188
- }
1189
- }));
1226
+ config2.postcssOptions.plugins.push(
1227
+ __require("tailwindcss")({
1228
+ config: {
1229
+ ...tailwindConfig,
1230
+ content: [
1231
+ path8.join(PACKAGE_ROOT, "src", "theme-default", "**/*")
1232
+ ]
1233
+ }
1234
+ })
1235
+ );
1190
1236
  }
1191
1237
  },
1192
1238
  rspack: {
@@ -1225,11 +1271,26 @@ async function createModernBuilder(rootDir, config, pluginDriver, isSSR = false,
1225
1271
  scanDir: userDocRoot,
1226
1272
  pluginDriver
1227
1273
  });
1228
- const { default: { createBuilder, mergeBuilderConfig } } = await import("@modern-js/builder");
1229
- const { default: { builderRspackProvider } } = await import("@modern-js/builder-rspack-provider");
1230
- const internalBuilderConfig = await createInternalBuildConfig(userDocRoot, config, isSSR, routeService2, pluginDriver);
1274
+ const {
1275
+ default: { createBuilder, mergeBuilderConfig }
1276
+ } = await import("@modern-js/builder");
1277
+ const {
1278
+ default: { builderRspackProvider }
1279
+ } = await import("@modern-js/builder-rspack-provider");
1280
+ const internalBuilderConfig = await createInternalBuildConfig(
1281
+ userDocRoot,
1282
+ config,
1283
+ isSSR,
1284
+ routeService2,
1285
+ pluginDriver
1286
+ );
1231
1287
  const builderProvider = builderRspackProvider({
1232
- builderConfig: mergeBuilderConfig(internalBuilderConfig, ...config?.plugins?.map((plugin) => plugin.builderConfig ?? {}) || [], config?.builderConfig || {}, extraBuilderConfig || {})
1288
+ builderConfig: mergeBuilderConfig(
1289
+ internalBuilderConfig,
1290
+ ...config?.plugins?.map((plugin) => plugin.builderConfig ?? {}) || [],
1291
+ config?.builderConfig || {},
1292
+ extraBuilderConfig || {}
1293
+ )
1233
1294
  });
1234
1295
  const builder = await createBuilder(builderProvider, {
1235
1296
  target: isSSR ? "node" : "web",
@@ -1254,54 +1315,20 @@ async function createModernBuilder(rootDir, config, pluginDriver, isSSR = false,
1254
1315
 
1255
1316
  // src/node/PluginDriver.ts
1256
1317
  import { pluginContainerSyntax } from "@rspress/plugin-container-syntax";
1257
- function _check_private_redeclaration2(obj, privateCollection) {
1258
- if (privateCollection.has(obj)) {
1259
- throw new TypeError("Cannot initialize the same private elements twice on an object");
1260
- }
1261
- }
1262
- function _class_apply_descriptor_get2(receiver, descriptor) {
1263
- if (descriptor.get) {
1264
- return descriptor.get.call(receiver);
1265
- }
1266
- return descriptor.value;
1267
- }
1268
- function _class_apply_descriptor_set2(receiver, descriptor, value) {
1269
- if (descriptor.set) {
1270
- descriptor.set.call(receiver, value);
1271
- } else {
1272
- if (!descriptor.writable) {
1273
- throw new TypeError("attempted to set read only private field");
1274
- }
1275
- descriptor.value = value;
1276
- }
1277
- }
1278
- function _class_extract_field_descriptor2(receiver, privateMap, action) {
1279
- if (!privateMap.has(receiver)) {
1280
- throw new TypeError("attempted to " + action + " private field on non-instance");
1281
- }
1282
- return privateMap.get(receiver);
1283
- }
1284
- function _class_private_field_get2(receiver, privateMap) {
1285
- var descriptor = _class_extract_field_descriptor2(receiver, privateMap, "get");
1286
- return _class_apply_descriptor_get2(receiver, descriptor);
1287
- }
1288
- function _class_private_field_init2(obj, privateMap, value) {
1289
- _check_private_redeclaration2(obj, privateMap);
1290
- privateMap.set(obj, value);
1291
- }
1292
- function _class_private_field_set2(receiver, privateMap, value) {
1293
- var descriptor = _class_extract_field_descriptor2(receiver, privateMap, "set");
1294
- _class_apply_descriptor_set2(receiver, descriptor, value);
1295
- return value;
1296
- }
1297
- var _config = /* @__PURE__ */ new WeakMap();
1298
- var _plugins = /* @__PURE__ */ new WeakMap();
1299
- var _isProd = /* @__PURE__ */ new WeakMap();
1318
+ var _config, _plugins, _isProd;
1300
1319
  var PluginDriver = class {
1320
+ constructor(config, isProd) {
1321
+ __privateAdd(this, _config, void 0);
1322
+ __privateAdd(this, _plugins, void 0);
1323
+ __privateAdd(this, _isProd, void 0);
1324
+ __privateSet(this, _config, config);
1325
+ __privateSet(this, _isProd, isProd);
1326
+ __privateSet(this, _plugins, []);
1327
+ }
1301
1328
  // The init function is used to initialize the doc plugins and will execute before the build process.
1302
1329
  async init() {
1303
1330
  this.clearPlugins();
1304
- const config = _class_private_field_get2(this, _config);
1331
+ const config = __privateGet(this, _config);
1305
1332
  const themeConfig = config?.themeConfig || {};
1306
1333
  const enableLastUpdated = themeConfig?.lastUpdated || themeConfig?.locales?.some((locale) => locale.lastUpdated);
1307
1334
  const mediumZoomConfig = config?.mediumZoom ?? true;
@@ -1312,7 +1339,11 @@ var PluginDriver = class {
1312
1339
  }
1313
1340
  if (mediumZoomConfig) {
1314
1341
  const { pluginMediumZoom } = await import("@rspress/plugin-medium-zoom");
1315
- this.addPlugin(pluginMediumZoom(typeof mediumZoomConfig === "object" ? mediumZoomConfig : void 0));
1342
+ this.addPlugin(
1343
+ pluginMediumZoom(
1344
+ typeof mediumZoomConfig === "object" ? mediumZoomConfig : void 0
1345
+ )
1346
+ );
1316
1347
  }
1317
1348
  if (!haveNavSidebarConfig) {
1318
1349
  const { pluginAutoNavSidebar } = await import("@rspress/plugin-auto-nav-sidebar");
@@ -1324,34 +1355,44 @@ var PluginDriver = class {
1324
1355
  });
1325
1356
  }
1326
1357
  addPlugin(plugin) {
1327
- const exsitedIndex = _class_private_field_get2(this, _plugins).findIndex((item) => item.name === plugin.name);
1358
+ const exsitedIndex = __privateGet(this, _plugins).findIndex(
1359
+ (item) => item.name === plugin.name
1360
+ );
1328
1361
  if (exsitedIndex !== -1) {
1329
1362
  throw new Error(`The plugin "${plugin.name}" has been registered`);
1330
1363
  } else {
1331
- _class_private_field_get2(this, _plugins).push(plugin);
1364
+ __privateGet(this, _plugins).push(plugin);
1332
1365
  }
1333
1366
  }
1334
1367
  getPlugins() {
1335
- return _class_private_field_get2(this, _plugins);
1368
+ return __privateGet(this, _plugins);
1336
1369
  }
1337
1370
  clearPlugins() {
1338
- _class_private_field_set2(this, _plugins, []);
1371
+ __privateSet(this, _plugins, []);
1339
1372
  }
1340
1373
  async modifyConfig() {
1341
- let config = _class_private_field_get2(this, _config);
1342
- for (const plugin of _class_private_field_get2(this, _plugins)) {
1374
+ let config = __privateGet(this, _config);
1375
+ for (const plugin of __privateGet(this, _plugins)) {
1343
1376
  if (typeof plugin.config === "function") {
1344
1377
  config = await plugin.config(config || {});
1345
1378
  }
1346
1379
  }
1347
- _class_private_field_set2(this, _config, config);
1348
- return _class_private_field_get2(this, _config);
1380
+ __privateSet(this, _config, config);
1381
+ return __privateGet(this, _config);
1349
1382
  }
1350
1383
  async beforeBuild() {
1351
- return this._runParallelAsyncHook("beforeBuild", _class_private_field_get2(this, _config) || {}, _class_private_field_get2(this, _isProd));
1384
+ return this._runParallelAsyncHook(
1385
+ "beforeBuild",
1386
+ __privateGet(this, _config) || {},
1387
+ __privateGet(this, _isProd)
1388
+ );
1352
1389
  }
1353
1390
  async afterBuild() {
1354
- return this._runParallelAsyncHook("afterBuild", _class_private_field_get2(this, _config) || {}, _class_private_field_get2(this, _isProd));
1391
+ return this._runParallelAsyncHook(
1392
+ "afterBuild",
1393
+ __privateGet(this, _config) || {},
1394
+ __privateGet(this, _isProd)
1395
+ );
1355
1396
  }
1356
1397
  async modifySearchIndexData(pages) {
1357
1398
  return this._runParallelAsyncHook("modifySearchIndexData", pages);
@@ -1360,34 +1401,44 @@ var PluginDriver = class {
1360
1401
  return this._runParallelAsyncHook("extendPageData", pageData);
1361
1402
  }
1362
1403
  async addPages() {
1363
- const result = await this._runParallelAsyncHook("addPages", _class_private_field_get2(this, _config) || {}, _class_private_field_get2(this, _isProd));
1404
+ const result = await this._runParallelAsyncHook(
1405
+ "addPages",
1406
+ __privateGet(this, _config) || {},
1407
+ __privateGet(this, _isProd)
1408
+ );
1364
1409
  return result.flat();
1365
1410
  }
1366
1411
  async routeGenerated(routes) {
1367
1412
  return this._runParallelAsyncHook("routeGenerated", routes);
1368
1413
  }
1369
1414
  async addSSGRoutes() {
1370
- const result = await this._runParallelAsyncHook("addSSGRoutes", _class_private_field_get2(this, _config) || {}, _class_private_field_get2(this, _isProd));
1415
+ const result = await this._runParallelAsyncHook(
1416
+ "addSSGRoutes",
1417
+ __privateGet(this, _config) || {},
1418
+ __privateGet(this, _isProd)
1419
+ );
1371
1420
  return result.flat();
1372
1421
  }
1373
1422
  globalUIComponents() {
1374
- const result = _class_private_field_get2(this, _plugins).map((plugin) => {
1423
+ const result = __privateGet(this, _plugins).map((plugin) => {
1375
1424
  return plugin.globalUIComponents || [];
1376
1425
  });
1377
1426
  return result.flat();
1378
1427
  }
1379
1428
  globalStyles() {
1380
- return _class_private_field_get2(this, _plugins).filter((plugin) => typeof plugin.globalStyles === "string").map((plugin) => {
1429
+ return __privateGet(this, _plugins).filter((plugin) => typeof plugin.globalStyles === "string").map((plugin) => {
1381
1430
  return plugin.globalStyles;
1382
1431
  });
1383
1432
  }
1384
1433
  _runParallelAsyncHook(hookName, ...args) {
1385
- return Promise.all(_class_private_field_get2(this, _plugins).filter((plugin) => typeof plugin[hookName] === "function").map((plugin) => {
1386
- return plugin[hookName](...args);
1387
- }));
1434
+ return Promise.all(
1435
+ __privateGet(this, _plugins).filter((plugin) => typeof plugin[hookName] === "function").map((plugin) => {
1436
+ return plugin[hookName](...args);
1437
+ })
1438
+ );
1388
1439
  }
1389
1440
  _runSerialAysncHook(hookName, ...args) {
1390
- return _class_private_field_get2(this, _plugins).reduce(async (prev, plugin) => {
1441
+ return __privateGet(this, _plugins).reduce(async (prev, plugin) => {
1391
1442
  if (typeof plugin[hookName] === "function") {
1392
1443
  await prev;
1393
1444
  return plugin[hookName](...args);
@@ -1395,24 +1446,10 @@ var PluginDriver = class {
1395
1446
  return prev;
1396
1447
  }, Promise.resolve());
1397
1448
  }
1398
- constructor(config, isProd) {
1399
- _class_private_field_init2(this, _config, {
1400
- writable: true,
1401
- value: void 0
1402
- });
1403
- _class_private_field_init2(this, _plugins, {
1404
- writable: true,
1405
- value: void 0
1406
- });
1407
- _class_private_field_init2(this, _isProd, {
1408
- writable: true,
1409
- value: void 0
1410
- });
1411
- _class_private_field_set2(this, _config, config);
1412
- _class_private_field_set2(this, _isProd, isProd);
1413
- _class_private_field_set2(this, _plugins, []);
1414
- }
1415
1449
  };
1450
+ _config = new WeakMap();
1451
+ _plugins = new WeakMap();
1452
+ _isProd = new WeakMap();
1416
1453
 
1417
1454
  // src/node/dev.ts
1418
1455
  async function dev(options) {
@@ -1424,7 +1461,13 @@ async function dev(options) {
1424
1461
  try {
1425
1462
  const modifiedConfig = await pluginDriver.modifyConfig();
1426
1463
  await pluginDriver.beforeBuild();
1427
- const builder = await createModernBuilder(docDirectory, modifiedConfig, pluginDriver, false, {});
1464
+ const builder = await createModernBuilder(
1465
+ docDirectory,
1466
+ modifiedConfig,
1467
+ pluginDriver,
1468
+ false,
1469
+ {}
1470
+ );
1428
1471
  const { server } = await builder.startDevServer({
1429
1472
  printURLs: (urls) => {
1430
1473
  return urls.map(({ label, url }) => ({
@@ -1448,7 +1491,11 @@ import { dirname as dirname2, join as join3 } from "path";
1448
1491
  import { pathToFileURL } from "url";
1449
1492
  import chalk2 from "@modern-js/utils/chalk";
1450
1493
  import fs9 from "@modern-js/utils/fs-extra";
1451
- import { APPEARANCE_KEY, normalizeSlash, withBase as withBase3 } from "@rspress/shared";
1494
+ import {
1495
+ APPEARANCE_KEY,
1496
+ normalizeSlash,
1497
+ withBase as withBase3
1498
+ } from "@rspress/shared";
1452
1499
  import { logger as logger4 } from "@rspress/shared/logger";
1453
1500
  var CHECK_DARK_LIGHT_SCRIPT = `
1454
1501
  <script id="check-dark-light">
@@ -1474,10 +1521,7 @@ async function bundle(appDirectory, docDirectory, config, pluginDriver) {
1474
1521
  }
1475
1522
  })
1476
1523
  ]);
1477
- await Promise.all([
1478
- clientBuilder.build(),
1479
- ssrBuilder.build()
1480
- ]);
1524
+ await Promise.all([clientBuilder.build(), ssrBuilder.build()]);
1481
1525
  const publicDir = join3(docDirectory, PUBLIC_DIR);
1482
1526
  if (await fs9.pathExists(publicDir)) {
1483
1527
  await fs9.copy(publicDir, outputDir);
@@ -1499,7 +1543,9 @@ async function renderPages(appDirectory, config, pluginDriver) {
1499
1543
  ({ render } = ssrExports);
1500
1544
  } catch (e) {
1501
1545
  logger4.error(e);
1502
- logger4.warn(`Failed to load SSR bundle: ${ssrBundlePath}, fallback to CSR.`);
1546
+ logger4.warn(
1547
+ `Failed to load SSR bundle: ${ssrBundlePath}, fallback to CSR.`
1548
+ );
1503
1549
  }
1504
1550
  const routes = routeService.getRoutes();
1505
1551
  const base = config?.base ?? "";
@@ -1508,50 +1554,60 @@ async function renderPages(appDirectory, config, pluginDriver) {
1508
1554
  const additionalRoutes = (await pluginDriver.addSSGRoutes()).map((route) => ({
1509
1555
  routePath: withBase3(route.path, base)
1510
1556
  }));
1511
- await Promise.all([
1512
- ...routes,
1513
- ...additionalRoutes
1514
- ].filter((route) => {
1515
- return !route.routePath.includes(":");
1516
- }).map(async (route) => {
1517
- const helmetContext = {
1518
- context: {}
1519
- };
1520
- const { routePath } = route;
1521
- let appHtml = "";
1522
- if (render) {
1523
- try {
1524
- ({ appHtml } = await render(routePath, helmetContext.context));
1525
- } catch (e) {
1526
- logger4.warn(`page "${routePath}" render error: ${e.message}, fallback to CSR.`);
1557
+ await Promise.all(
1558
+ [...routes, ...additionalRoutes].filter((route) => {
1559
+ return !route.routePath.includes(":");
1560
+ }).map(async (route) => {
1561
+ const helmetContext = {
1562
+ context: {}
1563
+ };
1564
+ const { routePath } = route;
1565
+ let appHtml = "";
1566
+ if (render) {
1567
+ try {
1568
+ ({ appHtml } = await render(routePath, helmetContext.context));
1569
+ } catch (e) {
1570
+ logger4.warn(
1571
+ `page "${routePath}" render error: ${e.message}, fallback to CSR.`
1572
+ );
1573
+ }
1527
1574
  }
1528
- }
1529
- const { helmet } = helmetContext.context;
1530
- let html = htmlTemplate.replace(APP_HTML_MARKER, () => appHtml).replace(HEAD_MARKER, (config?.head || []).concat([
1531
- helmet?.title?.toString(),
1532
- helmet?.meta?.toString(),
1533
- helmet?.link?.toString(),
1534
- helmet?.style?.toString(),
1535
- helmet?.script?.toString(),
1536
- CHECK_DARK_LIGHT_SCRIPT
1537
- ]).join(""));
1538
- if (helmet?.htmlAttributes) {
1539
- html = html.replace(HTML_START_TAG, `${HTML_START_TAG} ${helmet?.htmlAttributes?.toString()}`);
1540
- }
1541
- if (helmet?.bodyAttributes) {
1542
- html = html.replace(BODY_START_TAG, `${BODY_START_TAG} ${helmet?.bodyAttributes?.toString()}`);
1543
- }
1544
- const normalizeHtmlFilePath = (path9) => {
1545
- const normalizedBase = normalizeSlash(config?.base || "/");
1546
- if (path9.endsWith("/")) {
1547
- return `${path9}index.html`.replace(normalizedBase, "");
1575
+ const { helmet } = helmetContext.context;
1576
+ let html = htmlTemplate.replace(APP_HTML_MARKER, () => appHtml).replace(
1577
+ HEAD_MARKER,
1578
+ (config?.head || []).concat([
1579
+ helmet?.title?.toString(),
1580
+ helmet?.meta?.toString(),
1581
+ helmet?.link?.toString(),
1582
+ helmet?.style?.toString(),
1583
+ helmet?.script?.toString(),
1584
+ CHECK_DARK_LIGHT_SCRIPT
1585
+ ]).join("")
1586
+ );
1587
+ if (helmet?.htmlAttributes) {
1588
+ html = html.replace(
1589
+ HTML_START_TAG,
1590
+ `${HTML_START_TAG} ${helmet?.htmlAttributes?.toString()}`
1591
+ );
1548
1592
  }
1549
- return `${path9}.html`.replace(normalizedBase, "");
1550
- };
1551
- const fileName = normalizeHtmlFilePath(routePath);
1552
- await fs10.ensureDir(join3(outputPath, dirname2(fileName)));
1553
- await fs10.writeFile(join3(outputPath, fileName), html);
1554
- }));
1593
+ if (helmet?.bodyAttributes) {
1594
+ html = html.replace(
1595
+ BODY_START_TAG,
1596
+ `${BODY_START_TAG} ${helmet?.bodyAttributes?.toString()}`
1597
+ );
1598
+ }
1599
+ const normalizeHtmlFilePath = (path9) => {
1600
+ const normalizedBase = normalizeSlash(config?.base || "/");
1601
+ if (path9.endsWith("/")) {
1602
+ return `${path9}index.html`.replace(normalizedBase, "");
1603
+ }
1604
+ return `${path9}.html`.replace(normalizedBase, "");
1605
+ };
1606
+ const fileName = normalizeHtmlFilePath(routePath);
1607
+ await fs10.ensureDir(join3(outputPath, dirname2(fileName)));
1608
+ await fs10.writeFile(join3(outputPath, fileName), html);
1609
+ })
1610
+ );
1555
1611
  await fs10.remove(join3(outputPath, "ssr"));
1556
1612
  await fs10.remove(join3(outputPath, "html"));
1557
1613
  const totalTime = Date.now() - startTime;
@@ -1595,8 +1651,10 @@ async function serve(options) {
1595
1651
  if (err) {
1596
1652
  throw err;
1597
1653
  }
1598
- console.log(`Preview server running at http://${host}:${port}/${base}/
1599
- `);
1654
+ console.log(
1655
+ `Preview server running at http://${host}:${port}/${base}/
1656
+ `
1657
+ );
1600
1658
  });
1601
1659
  } else {
1602
1660
  polka().use(compress, serve2).listen(port, host, (err) => {