valaxy 0.25.10 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
1
  // node/cli/index.ts
2
- import process15 from "process";
2
+ import process16 from "process";
3
3
  import yargs from "yargs";
4
4
  import { hideBin } from "yargs/helpers";
5
5
 
6
6
  // package.json
7
- var version = "0.25.10";
7
+ var version = "0.26.0";
8
8
 
9
9
  // node/modules/fuse.ts
10
10
  import path4 from "path";
11
- import { consola as consola9 } from "consola";
11
+ import { consola as consola8 } from "consola";
12
12
  import { colors as colors7 } from "consola/utils";
13
13
  import fg2 from "fast-glob";
14
- import fs7 from "fs-extra";
14
+ import fs6 from "fs-extra";
15
15
  import matter from "gray-matter";
16
16
 
17
17
  // node/modules/index.ts
@@ -37,12 +37,12 @@ function commonOptions(args) {
37
37
  import { dirname as dirname2 } from "path";
38
38
  import process4 from "process";
39
39
  import { ensureSuffix, uniq } from "@antfu/utils";
40
- import { consola as consola7 } from "consola";
40
+ import { consola as consola6 } from "consola";
41
41
  import { colors as colors6 } from "consola/utils";
42
42
  import _debug from "debug";
43
43
  import fg from "fast-glob";
44
- import fs5 from "fs-extra";
45
- import { resolve as resolve4 } from "pathe";
44
+ import fs4 from "fs-extra";
45
+ import { resolve as resolve3 } from "pathe";
46
46
 
47
47
  // node/build/bundle.ts
48
48
  import path from "path";
@@ -155,12 +155,12 @@ function getRollupOptions(options) {
155
155
 
156
156
  // node/config/addon.ts
157
157
  import path2 from "path";
158
- import fs2 from "fs-extra";
158
+ import fs from "fs-extra";
159
159
 
160
160
  // node/config/valaxy.ts
161
161
  import process2 from "process";
162
162
  import { isFunction } from "@antfu/utils";
163
- import { consola as consola4 } from "consola";
163
+ import { consola as consola3 } from "consola";
164
164
  import { colors as colors2 } from "consola/utils";
165
165
  import { createDefu } from "defu";
166
166
  import { mergeConfig as mergeViteConfig } from "vite";
@@ -180,43 +180,18 @@ function countPerformanceTime() {
180
180
 
181
181
  // node/config/site.ts
182
182
  import { webcrypto } from "crypto";
183
- import { consola as consola3 } from "consola";
183
+ import { consola as consola2 } from "consola";
184
184
  import { colors } from "consola/utils";
185
185
  import { options as floatingVueOptions } from "floating-vue";
186
186
 
187
187
  // node/config/utils.ts
188
188
  import process from "process";
189
- import { consola as consola2 } from "consola";
190
- import fs from "fs-extra";
191
- import { createJiti } from "jiti";
192
- import { resolve } from "pathe";
193
- var jiti = createJiti(import.meta.url, {
194
- // for hmr
195
- moduleCache: false
196
- });
197
- async function loadConfig(options) {
198
- const { name, cwd } = options;
199
- const filePath = resolve(cwd, `${name}.config.ts`);
200
- let data = {};
201
- if (await fs.exists(filePath)) {
202
- try {
203
- data = await jiti.import(filePath, { default: true });
204
- } catch (e) {
205
- console.error(e);
206
- consola2.error(`Failed to load config file: ${filePath}`);
207
- }
208
- } else {
209
- consola2.debug(`Config file not found: ${filePath}`);
210
- }
211
- return {
212
- config: data,
213
- configFile: filePath
214
- };
215
- }
189
+ import { loadConfig } from "define-config-ts";
216
190
  async function loadConfigFromFile(file, options = {}) {
217
191
  const { config, configFile } = await loadConfig({
218
192
  name: file,
219
- cwd: options.cwd || process.cwd()
193
+ cwd: options.cwd || process.cwd(),
194
+ throwOnNotFound: false
220
195
  });
221
196
  let userConfig = config;
222
197
  if (typeof config === "function")
@@ -327,7 +302,7 @@ async function resolveSiteConfig(root) {
327
302
  const { config: userSiteConfig, configFile: siteConfigFile } = await resolveSiteConfigFromRoot(root);
328
303
  const duration = endCount();
329
304
  if (userSiteConfig && siteConfigFile)
330
- consola3.success(`Resolve ${colors.cyan("siteConfig")} from ${colors.dim(siteConfigFile)} ${colors.yellow(duration)}`);
305
+ consola2.success(`Resolve ${colors.cyan("siteConfig")} from ${colors.dim(siteConfigFile)} ${colors.yellow(duration)}`);
331
306
  return {
332
307
  siteConfig: userSiteConfig,
333
308
  siteConfigFile
@@ -407,7 +382,7 @@ async function resolveValaxyConfig(options) {
407
382
  const { config: userValaxyConfig, configFile } = await resolveValaxyConfigFromRoot(configRoot);
408
383
  const duration = endCount();
409
384
  if (configFile && userValaxyConfig && Object.keys(userValaxyConfig).length !== 0)
410
- consola4.success(`Resolve ${colors2.cyan("userValaxyConfig")} from ${colors2.dim(configFile)} ${colors2.yellow(duration)}`);
385
+ consola3.success(`Resolve ${colors2.cyan("userValaxyConfig")} from ${colors2.dim(configFile)} ${colors2.yellow(duration)}`);
411
386
  const theme = options.theme || userValaxyConfig?.theme || "yun";
412
387
  return {
413
388
  config: userValaxyConfig,
@@ -425,7 +400,7 @@ async function resolveAddonsConfig(addons, options) {
425
400
  let valaxyConfig = {};
426
401
  for (const addon of addons) {
427
402
  const addonConfigPath = path2.resolve(addon.root, "valaxy.config.ts");
428
- if (!await fs2.exists(addonConfigPath))
403
+ if (!await fs.exists(addonConfigPath))
429
404
  continue;
430
405
  const { config, configFile } = await resolveValaxyConfigFromRoot(addon.root, options);
431
406
  if (!config)
@@ -441,10 +416,10 @@ import { colors as colors4 } from "consola/utils";
441
416
  import defu from "defu";
442
417
 
443
418
  // node/logger/index.ts
444
- import { consola as consola5 } from "consola";
419
+ import { consola as consola4 } from "consola";
445
420
  import { colors as colors3 } from "consola/utils";
446
421
  import ora from "ora";
447
- var logger = consola5.create({});
422
+ var logger = consola4.create({});
448
423
  var valaxyPrefix = colors3.magenta("[valaxy]");
449
424
  var vLogger = {
450
425
  success: (...args) => logger.success(valaxyPrefix, ...args),
@@ -499,7 +474,7 @@ var replaceArrMerge = createDefu2((obj, key, value) => {
499
474
  // node/utils/getGitTimestamp.ts
500
475
  import { spawn } from "cross-spawn";
501
476
  function getGitTimestamp(file, type = "updated") {
502
- return new Promise((resolve15, _reject) => {
477
+ return new Promise((resolve14, _reject) => {
503
478
  const params = ["log"];
504
479
  if (type === "updated")
505
480
  params.push("-1");
@@ -510,10 +485,10 @@ function getGitTimestamp(file, type = "updated") {
510
485
  let output = "";
511
486
  child.stdout.on("data", (d) => output += String(d));
512
487
  child.on("close", () => {
513
- resolve15(+new Date(output));
488
+ resolve14(+new Date(output));
514
489
  });
515
490
  child.on("error", () => {
516
- resolve15(0);
491
+ resolve14(0);
517
492
  });
518
493
  });
519
494
  }
@@ -547,7 +522,7 @@ function $t(key) {
547
522
 
548
523
  // node/utils/resolve.ts
549
524
  import { ensurePrefix, slash } from "@antfu/utils";
550
- import { consola as consola6 } from "consola";
525
+ import { consola as consola5 } from "consola";
551
526
  import { resolvePath } from "mlly";
552
527
  import { resolveGlobal } from "resolve-global";
553
528
  var isInstalledGlobally = {};
@@ -563,7 +538,7 @@ async function resolveImportPath(importName, ensure = false) {
563
538
  url: import.meta.url
564
539
  });
565
540
  } catch (error) {
566
- consola6.log(error);
541
+ consola5.log(error);
567
542
  }
568
543
  if (isInstalledGlobally.value) {
569
544
  try {
@@ -574,33 +549,33 @@ async function resolveImportPath(importName, ensure = false) {
574
549
  if (ensure)
575
550
  throw new Error(`Failed to resolve package ${importName}`);
576
551
  else
577
- consola6.warn(`Failed to resolve package ${importName}`);
552
+ consola5.warn(`Failed to resolve package ${importName}`);
578
553
  }
579
554
 
580
555
  // node/utils/addons.ts
581
556
  import process3 from "process";
582
557
  import { colors as colors5 } from "consola/utils";
583
558
  import defu2 from "defu";
584
- import fs4 from "fs-extra";
559
+ import fs3 from "fs-extra";
585
560
  import ora2 from "ora";
586
- import { resolve as resolve3 } from "pathe";
561
+ import { resolve as resolve2 } from "pathe";
587
562
 
588
563
  // node/utils/root.ts
589
564
  import { dirname } from "path";
590
- import fs3 from "fs-extra";
591
- import { resolve as resolve2 } from "pathe";
565
+ import fs2 from "fs-extra";
566
+ import { resolve } from "pathe";
592
567
  async function getModuleRoot(name, entry) {
593
568
  if (!name)
594
569
  return "";
595
570
  if (isPath(name)) {
596
571
  if (entry) {
597
- const isFile = fs3.lstatSync(entry).isFile();
598
- return resolve2(isFile ? dirname(entry) : entry, name);
572
+ const isFile = fs2.lstatSync(entry).isFile();
573
+ return resolve(isFile ? dirname(entry) : entry, name);
599
574
  } else {
600
575
  throw new Error(`entry is required when ${name} is path`);
601
576
  }
602
577
  } else {
603
- return resolve2(dirname(await resolveImportPath(`${name}/package.json`) || ""));
578
+ return resolve(dirname(await resolveImportPath(`${name}/package.json`) || ""));
604
579
  }
605
580
  }
606
581
 
@@ -631,12 +606,12 @@ async function parseAddons(addons, userRoot2 = process3.cwd()) {
631
606
  }
632
607
  async function readAddonModule(name, options = {}) {
633
608
  const root = await getAddonRoot(name, options.cwd || process3.cwd());
634
- const packageJSONPath = resolve3(root, "./package.json");
635
- if (!await fs4.exists(packageJSONPath)) {
609
+ const packageJSONPath = resolve2(root, "./package.json");
610
+ if (!await fs3.exists(packageJSONPath)) {
636
611
  logger.error(`No addon named ${name} found`);
637
612
  return;
638
613
  }
639
- const packageJSON = await fs4.readJSON(packageJSONPath);
614
+ const packageJSON = await fs3.readJSON(packageJSONPath);
640
615
  const resolver = {
641
616
  enable: true,
642
617
  name: packageJSON.name,
@@ -714,9 +689,9 @@ async function processSiteConfig(options) {
714
689
  const siteConfig = config.siteConfig;
715
690
  siteConfig.url = ensureSuffix("/", siteConfig.url || "");
716
691
  siteConfig.cdn.prefix = ensureSuffix("/", siteConfig.cdn.prefix || "");
717
- const themePkgPath = resolve4(themeRoot, "package.json");
692
+ const themePkgPath = resolve3(themeRoot, "package.json");
718
693
  try {
719
- config.themeConfig.pkg = await fs5.readJson(themePkgPath, "utf-8");
694
+ config.themeConfig.pkg = await fs4.readJson(themePkgPath, "utf-8");
720
695
  } catch (e) {
721
696
  console.error(`valaxy-theme-${theme} doesn't have package.json`);
722
697
  }
@@ -754,16 +729,16 @@ async function processValaxyOptions(valaxyOptions, valaxyConfig) {
754
729
  }
755
730
  async function resolveOptions(options = { userRoot: process4.cwd() }, mode = "dev") {
756
731
  const pkgRoot = dirname2(await resolveImportPath("valaxy/package.json", true));
757
- const clientRoot = resolve4(pkgRoot, "client");
758
- const userRoot2 = resolve4(options.userRoot || process4.cwd());
759
- consola7.start(`Resolve ${colors6.magenta("valaxy")} config ...`);
732
+ const clientRoot = resolve3(pkgRoot, "client");
733
+ const userRoot2 = resolve3(options.userRoot || process4.cwd());
734
+ consola6.start(`Resolve ${colors6.magenta("valaxy")} config ...`);
760
735
  const [resolvedValaxy, resolvedSite, resolvedTheme, pages] = await Promise.all([
761
736
  resolveValaxyConfig(options),
762
737
  resolveSiteConfig(options.userRoot),
763
738
  // resolveThemeConfig(options),
764
739
  resolveThemeConfigFromRoot(options.userRoot),
765
740
  fg(["**.md"], {
766
- cwd: resolve4(userRoot2, "pages"),
741
+ cwd: resolve3(userRoot2, "pages"),
767
742
  ignore: ["**/node_modules"]
768
743
  })
769
744
  ]);
@@ -776,7 +751,7 @@ async function resolveOptions(options = { userRoot: process4.cwd() }, mode = "de
776
751
  let valaxyOptions = {
777
752
  mode,
778
753
  pkgRoot,
779
- tempDir: resolve4(userRoot2, ".valaxy"),
754
+ tempDir: resolve3(userRoot2, ".valaxy"),
780
755
  clientRoot,
781
756
  userRoot: userRoot2,
782
757
  themeRoot,
@@ -808,7 +783,7 @@ async function resolveOptions(options = { userRoot: process4.cwd() }, mode = "de
808
783
  const themeValaxyConfig = await resolveThemeValaxyConfig(valaxyOptions);
809
784
  const valaxyConfig = mergeValaxyConfig(userValaxyConfig, themeValaxyConfig);
810
785
  valaxyOptions = await processValaxyOptions(valaxyOptions, valaxyConfig);
811
- fs5.ensureDirSync(valaxyOptions.tempDir);
786
+ fs4.ensureDirSync(valaxyOptions.tempDir);
812
787
  return valaxyOptions;
813
788
  }
814
789
  async function resolveThemeValaxyConfig(options) {
@@ -816,7 +791,7 @@ async function resolveThemeValaxyConfig(options) {
816
791
  const { config: themeValaxyConfig } = await resolveValaxyConfigFromRoot(options.themeRoot, options);
817
792
  const duration = endCount();
818
793
  if (themeValaxyConfig)
819
- consola7.success(`Resolve ${colors6.cyan("valaxy.config.ts")} from ${colors6.blue(`theme(${options.theme})`)} ${colors6.yellow(duration)}`);
794
+ consola6.success(`Resolve ${colors6.cyan("valaxy.config.ts")} from ${colors6.blue(`theme(${options.theme})`)} ${colors6.yellow(duration)}`);
820
795
  return themeValaxyConfig;
821
796
  }
822
797
 
@@ -874,15 +849,15 @@ var matterOptions = {
874
849
  // node/utils/env.ts
875
850
  import path3 from "path";
876
851
  import process5 from "process";
877
- import { consola as consola8 } from "consola";
878
- import fs6 from "fs-extra";
852
+ import { consola as consola7 } from "consola";
853
+ import fs5 from "fs-extra";
879
854
  function isProd() {
880
855
  return process5.env.NODE_ENV === "production";
881
856
  }
882
857
  function setEnv(env = "development") {
883
858
  process5.env.NODE_ENV = env;
884
- consola8.level = isProd() ? 2 : 3;
885
- logger.level = consola8.level;
859
+ consola7.level = isProd() ? 2 : 3;
860
+ logger.level = consola7.level;
886
861
  }
887
862
  function setEnvProd() {
888
863
  return setEnv("production");
@@ -891,7 +866,7 @@ function setTimezone(timezone) {
891
866
  process5.env.TZ = timezone;
892
867
  }
893
868
  async function isPagesDirExist(root) {
894
- const exist = await fs6.exists(path3.resolve(root, "pages"));
869
+ const exist = await fs5.exists(path3.resolve(root, "pages"));
895
870
  if (!exist)
896
871
  logger.error(`No pages directory found in ${root}`);
897
872
  return exist;
@@ -899,16 +874,16 @@ async function isPagesDirExist(root) {
899
874
 
900
875
  // node/modules/fuse.ts
901
876
  async function generateFuseList(options) {
902
- consola9.start(`Generate List for Fuse Search by (${colors7.cyan("fuse.js")}) ...`);
877
+ consola8.start(`Generate List for Fuse Search by (${colors7.cyan("fuse.js")}) ...`);
903
878
  const pattern = options.config.siteConfig.fuse.pattern || path4.join(options.userRoot, "pages/**/*.md");
904
879
  const files = await fg2(pattern);
905
880
  const posts = [];
906
881
  for await (const i of files) {
907
- const raw = fs7.readFileSync(i, "utf-8");
882
+ const raw = fs6.readFileSync(i, "utf-8");
908
883
  const { data, excerpt, content } = matter(raw, matterOptions);
909
884
  const fmData = data;
910
885
  if (fmData.draft) {
911
- consola9.warn(`Ignore draft post: ${colors7.dim(i)}`);
886
+ consola8.warn(`Ignore draft post: ${colors7.dim(i)}`);
912
887
  continue;
913
888
  }
914
889
  if (fmData.hide)
@@ -938,30 +913,30 @@ async function generateFuseList(options) {
938
913
  return posts;
939
914
  }
940
915
  async function execFuse(options) {
941
- consola9.info("Start generate fuse list...");
916
+ consola8.info("Start generate fuse list...");
942
917
  const fuseList = await generateFuseList(options);
943
- await fs7.ensureDir("./dist");
918
+ await fs6.ensureDir("./dist");
944
919
  const publicFolder = path4.resolve(options.userRoot, "public");
945
920
  const publicFuseFile = path4.resolve(publicFolder, options.config.siteConfig.fuse.dataPath);
946
921
  const publicRelativeFile = path4.join("public", options.config.siteConfig.fuse.dataPath);
947
- await fs7.ensureFile(publicFuseFile);
948
- fs7.writeJSONSync(publicFuseFile, fuseList);
949
- consola9.success(`Generate fuse list in ${colors7.dim(publicFolder)}`);
922
+ await fs6.ensureFile(publicFuseFile);
923
+ fs6.writeJSONSync(publicFuseFile, fuseList);
924
+ consola8.success(`Generate fuse list in ${colors7.dim(publicFolder)}`);
950
925
  const distFolder = path4.resolve(options.userRoot, "dist");
951
926
  const distFuseFile = path4.resolve(distFolder, options.config.siteConfig.fuse.dataPath);
952
- await fs7.ensureDir(distFolder);
953
- fs7.writeJSONSync(distFuseFile, fuseList);
954
- consola9.success(`Generate fuse list in ${colors7.dim(distFolder)}`);
927
+ await fs6.ensureDir(distFolder);
928
+ fs6.writeJSONSync(distFuseFile, fuseList);
929
+ consola8.success(`Generate fuse list in ${colors7.dim(distFolder)}`);
955
930
  try {
956
931
  const gitignorePath = path4.resolve(options.userRoot, ".gitignore");
957
- const gitignore = await fs7.readFile(gitignorePath, "utf-8");
932
+ const gitignore = await fs6.readFile(gitignorePath, "utf-8");
958
933
  const ignorePath = publicRelativeFile.replace(/\\/g, "/");
959
934
  if (!gitignore.includes(ignorePath)) {
960
- await fs7.appendFile(gitignorePath, `
935
+ await fs6.appendFile(gitignorePath, `
961
936
  # valaxy fuse
962
937
  ${ignorePath}
963
938
  `);
964
- consola9.success(`Add ${colors7.dim(ignorePath)} to ${colors7.dim(".gitignore")}`);
939
+ consola8.success(`Add ${colors7.dim(ignorePath)} to ${colors7.dim(".gitignore")}`);
965
940
  }
966
941
  } catch {
967
942
  }
@@ -991,26 +966,26 @@ var fuseModule = defineValaxyModule({
991
966
 
992
967
  // node/modules/rss/utils.ts
993
968
  import { readFile } from "fs/promises";
994
- import { dirname as dirname3, join, resolve as resolve5 } from "path";
969
+ import { dirname as dirname3, join, resolve as resolve4 } from "path";
995
970
  import { ensurePrefix as ensurePrefix2 } from "@antfu/utils";
996
- import { consola as consola10 } from "consola";
971
+ import { consola as consola9 } from "consola";
997
972
  import { colors as colors8 } from "consola/utils";
998
973
  import dayjs from "dayjs";
999
974
  import fg3 from "fast-glob";
1000
975
  import { Feed } from "feed";
1001
- import fs9 from "fs-extra";
976
+ import fs8 from "fs-extra";
1002
977
  import matter2 from "gray-matter";
1003
978
  import MarkdownIt from "markdown-it";
1004
979
  import ora3 from "ora";
1005
980
  import { getBorderCharacters, table } from "table";
1006
981
 
1007
982
  // node/utils/date.ts
1008
- import fs8 from "fs-extra";
983
+ import fs7 from "fs-extra";
1009
984
  async function getCreatedTime(file) {
1010
- return await getGitTimestamp(file, "created") || (await fs8.stat(file)).ctime;
985
+ return await getGitTimestamp(file, "created") || (await fs7.stat(file)).ctime;
1011
986
  }
1012
987
  async function getUpdatedTime(file) {
1013
- return await getGitTimestamp(file, "created") || (await fs8.stat(file)).mtime;
988
+ return await getGitTimestamp(file, "created") || (await fs7.stat(file)).mtime;
1014
989
  }
1015
990
 
1016
991
  // node/modules/rss/utils.ts
@@ -1025,7 +1000,7 @@ async function build(options) {
1025
1000
  const siteConfig = config.siteConfig;
1026
1001
  const lang = siteConfig.lang || "en";
1027
1002
  if (!siteConfig.url || siteConfig.url === "/") {
1028
- consola10.error("You must set `url` (like `https://example.com`) in `site.config.ts` to generate rss.");
1003
+ consola9.error("You must set `url` (like `https://example.com`) in `site.config.ts` to generate rss.");
1029
1004
  return;
1030
1005
  }
1031
1006
  const siteUrl = siteConfig.url;
@@ -1128,9 +1103,9 @@ async function getPosts(params, options) {
1128
1103
  async function writeFeed(feedOptions, posts, options, feedNameMap) {
1129
1104
  const feed = new Feed(feedOptions);
1130
1105
  posts.forEach((item) => feed.addItem(item));
1131
- await fs9.ensureDir(dirname3(`./dist/${feedNameMap.atom}`));
1132
- const path18 = resolve5(options.userRoot, "./dist");
1133
- const publicFolder = resolve5(options.userRoot, "public");
1106
+ await fs8.ensureDir(dirname3(`./dist/${feedNameMap.atom}`));
1107
+ const path18 = resolve4(options.userRoot, "./dist");
1108
+ const publicFolder = resolve4(options.userRoot, "public");
1134
1109
  const { config } = options;
1135
1110
  const siteConfig = config.siteConfig;
1136
1111
  const now = dayjs().format("YYYY-MM-DD HH:mm:ss zzz");
@@ -1149,24 +1124,24 @@ async function writeFeed(feedOptions, posts, options, feedNameMap) {
1149
1124
  data = feed.atom1();
1150
1125
  else if (type === "json")
1151
1126
  data = feed.json1();
1152
- await fs9.writeFile(distFeedPath, data, "utf-8");
1153
- consola10.debug(`[${colors8.cyan(type)}] dist: ${colors8.dim(distFeedPath)}`);
1127
+ await fs8.writeFile(distFeedPath, data, "utf-8");
1128
+ consola9.debug(`[${colors8.cyan(type)}] dist: ${colors8.dim(distFeedPath)}`);
1154
1129
  tableData.push([colors8.cyan(type), colors8.yellow("dist"), colors8.dim(distFeedPath)]);
1155
- const publicFeedPath = resolve5(publicFolder, feedNameMap[type]);
1130
+ const publicFeedPath = resolve4(publicFolder, feedNameMap[type]);
1156
1131
  const publicRelativeFile = join("public", feedNameMap[type]);
1157
- await fs9.writeFile(publicFeedPath, data, "utf-8");
1158
- consola10.debug(`[${colors8.cyan(type)}] public: ${colors8.dim(publicFeedPath)}`);
1132
+ await fs8.writeFile(publicFeedPath, data, "utf-8");
1133
+ consola9.debug(`[${colors8.cyan(type)}] public: ${colors8.dim(publicFeedPath)}`);
1159
1134
  tableData.push(["", colors8.green("public"), colors8.dim(publicFeedPath)]);
1160
1135
  try {
1161
- const gitignorePath = resolve5(options.userRoot, ".gitignore");
1162
- const gitignore = await fs9.readFile(gitignorePath, "utf-8");
1136
+ const gitignorePath = resolve4(options.userRoot, ".gitignore");
1137
+ const gitignore = await fs8.readFile(gitignorePath, "utf-8");
1163
1138
  const ignorePath = publicRelativeFile.replace(/\\/g, "/");
1164
1139
  if (!gitignore.includes(ignorePath)) {
1165
- await fs9.appendFile(gitignorePath, `
1140
+ await fs8.appendFile(gitignorePath, `
1166
1141
  # valaxy rss
1167
1142
  ${ignorePath}
1168
1143
  `);
1169
- consola10.success(`Add ${colors8.dim(ignorePath)} to ${colors8.dim(".gitignore")}`);
1144
+ consola9.success(`Add ${colors8.dim(ignorePath)} to ${colors8.dim(".gitignore")}`);
1170
1145
  }
1171
1146
  } catch {
1172
1147
  }
@@ -1217,15 +1192,74 @@ var rssModule = defineValaxyModule({
1217
1192
  // node/cli/build.ts
1218
1193
  import path14 from "path";
1219
1194
  import process9 from "process";
1220
- import { consola as consola16 } from "consola";
1195
+ import { consola as consola15 } from "consola";
1221
1196
  import { colors as colors15 } from "consola/utils";
1222
1197
  import { mergeConfig as mergeConfig4 } from "vite";
1223
1198
 
1199
+ // node/app/index.ts
1200
+ import { createHooks } from "hookable";
1201
+
1202
+ // node/app/state.ts
1203
+ var StateManager = class {
1204
+ /**
1205
+ * @zh 文章 ID 映射
1206
+ */
1207
+ idMap = /* @__PURE__ */ new Map();
1208
+ };
1209
+
1210
+ // node/app/class.ts
1211
+ var Valaxy = class {
1212
+ /**
1213
+ * version
1214
+ */
1215
+ static version = version;
1216
+ /**
1217
+ * file state
1218
+ */
1219
+ static state = new StateManager();
1220
+ constructor() {
1221
+ }
1222
+ };
1223
+
1224
+ // node/app/index.ts
1225
+ var buildHooks = [
1226
+ "build:before",
1227
+ "build:after"
1228
+ ];
1229
+ function createValaxyNode(options) {
1230
+ const hooks = createHooks();
1231
+ if (typeof options.config.hooks === "object") {
1232
+ Object.keys(options.config.hooks).forEach((name) => {
1233
+ const hookName = name;
1234
+ const hook = options.config.hooks[hookName];
1235
+ if (typeof hook !== "function")
1236
+ return;
1237
+ if (buildHooks.includes(hookName)) {
1238
+ if (options.mode === "build")
1239
+ hooks.hook(hookName, hook);
1240
+ } else {
1241
+ hooks.hook(hookName, hook);
1242
+ }
1243
+ });
1244
+ }
1245
+ const valaxyNode = {
1246
+ version,
1247
+ hooks,
1248
+ hook: hooks.hook,
1249
+ options
1250
+ };
1251
+ options.addons.forEach((addon) => {
1252
+ if (typeof addon.setup === "function")
1253
+ addon.setup(valaxyNode);
1254
+ });
1255
+ return valaxyNode;
1256
+ }
1257
+
1224
1258
  // node/build.ts
1225
- import { join as join8, resolve as resolve13 } from "path";
1226
- import { consola as consola14 } from "consola";
1259
+ import { join as join8, resolve as resolve12 } from "path";
1260
+ import { consola as consola13 } from "consola";
1227
1261
  import { colors as colors12 } from "consola/utils";
1228
- import fs22 from "fs-extra";
1262
+ import fs21 from "fs-extra";
1229
1263
  import { mergeConfig as mergeViteConfig2, build as viteBuild } from "vite";
1230
1264
  import generateSitemap from "vite-ssg-sitemap";
1231
1265
  import { build as viteSsgBuild } from "vite-ssg/node";
@@ -1233,21 +1267,21 @@ import { build as viteSsgBuild } from "vite-ssg/node";
1233
1267
  // node/plugins/preset.ts
1234
1268
  import VueI18n from "@intlify/unplugin-vue-i18n/vite";
1235
1269
  import UnheadVite from "@unhead/addons/vite";
1236
- import { consola as consola13 } from "consola";
1237
- import { resolve as resolve12 } from "pathe";
1270
+ import { consola as consola12 } from "consola";
1271
+ import { resolve as resolve11 } from "pathe";
1238
1272
  import Components from "unplugin-vue-components/vite";
1239
1273
  import Layouts from "vite-plugin-vue-layouts";
1240
1274
  import { groupIconVitePlugin } from "vitepress-plugin-group-icons";
1241
1275
 
1242
1276
  // node/plugins/extendConfig.ts
1243
- import { dirname as dirname4, join as join3, resolve as resolve6 } from "path";
1277
+ import { dirname as dirname4, join as join3, resolve as resolve5 } from "path";
1244
1278
  import { uniq as uniq3 } from "@antfu/utils";
1245
1279
  import { mergeConfig as mergeConfig2, searchForWorkspaceRoot } from "vite";
1246
1280
 
1247
1281
  // node/common.ts
1248
1282
  import { join as join2 } from "path";
1249
1283
  import { uniq as uniq2 } from "@antfu/utils";
1250
- import fs10 from "fs-extra";
1284
+ import fs9 from "fs-extra";
1251
1285
  import { loadConfigFromFile as loadConfigFromFile2, mergeConfig } from "vite";
1252
1286
  async function mergeViteConfigs({ userRoot: userRoot2, themeRoot }, command) {
1253
1287
  const configEnv = {
@@ -1257,7 +1291,7 @@ async function mergeViteConfigs({ userRoot: userRoot2, themeRoot }, command) {
1257
1291
  let resolvedConfig = {};
1258
1292
  const files = uniq2([themeRoot, userRoot2]).map((i) => join2(i, "vite.config.ts"));
1259
1293
  const loadViteConfigPromiseArr = files.map(async (file) => {
1260
- if (!await fs10.exists(file))
1294
+ if (!await fs9.exists(file))
1261
1295
  return;
1262
1296
  return loadConfigFromFile2(configEnv, file);
1263
1297
  });
@@ -1305,9 +1339,9 @@ async function getIndexHtml({ clientRoot, themeRoot, userRoot: userRoot2, config
1305
1339
  }
1306
1340
  for (const root of roots) {
1307
1341
  const path18 = join2(root, "index.html");
1308
- if (!fs10.existsSync(path18))
1342
+ if (!fs9.existsSync(path18))
1309
1343
  continue;
1310
- const indexHtml = await fs10.readFile(path18, "utf-8");
1344
+ const indexHtml = await fs9.readFile(path18, "utf-8");
1311
1345
  head += `
1312
1346
  ${(indexHtml.match(/<head>([\s\S]*?)<\/head>/i)?.[1] || "").trim()}`;
1313
1347
  body += `
@@ -1398,7 +1432,7 @@ function createConfigPlugin(options) {
1398
1432
  },
1399
1433
  optimizeDeps: {
1400
1434
  // do not entry node file
1401
- entries: [resolve6(options.clientRoot, "main.ts")],
1435
+ entries: [resolve5(options.clientRoot, "main.ts")],
1402
1436
  // must need it
1403
1437
  include: includedDeps,
1404
1438
  exclude: EXCLUDE
@@ -1445,14 +1479,14 @@ async function getAlias(options) {
1445
1479
  { find: /^#valaxy\/(.*)/, replacement: "/@valaxyjs/$1" },
1446
1480
  { find: "~/", replacement: `${toAtFS(options.userRoot)}/` },
1447
1481
  { find: "valaxy/client/", replacement: `${toAtFS(options.clientRoot)}/` },
1448
- { find: "valaxy/package.json", replacement: toAtFS(resolve6(options.clientRoot, "../package.json")) },
1449
- { find: /^valaxy$/, replacement: toAtFS(resolve6(options.clientRoot, "index.ts")) },
1482
+ { find: "valaxy/package.json", replacement: toAtFS(resolve5(options.clientRoot, "../package.json")) },
1483
+ { find: /^valaxy$/, replacement: toAtFS(resolve5(options.clientRoot, "index.ts")) },
1450
1484
  { find: "@valaxyjs/client/", replacement: `${toAtFS(options.clientRoot)}/` },
1451
1485
  // import theme
1452
1486
  { find: "virtual:valaxy-theme", replacement: `${toAtFS(options.themeRoot)}/client/index.ts` },
1453
- { find: `valaxy-theme-${options.theme}/client`, replacement: `${toAtFS(resolve6(options.themeRoot))}/client/index.ts` },
1454
- { find: `valaxy-theme-${options.theme}/`, replacement: `${toAtFS(resolve6(options.themeRoot))}/` },
1455
- { find: `valaxy-theme-${options.theme}`, replacement: `${toAtFS(resolve6(options.themeRoot))}/client/index.ts` }
1487
+ { find: `valaxy-theme-${options.theme}/client`, replacement: `${toAtFS(resolve5(options.themeRoot))}/client/index.ts` },
1488
+ { find: `valaxy-theme-${options.theme}/`, replacement: `${toAtFS(resolve5(options.themeRoot))}/` },
1489
+ { find: `valaxy-theme-${options.theme}`, replacement: `${toAtFS(resolve5(options.themeRoot))}/client/index.ts` }
1456
1490
  ];
1457
1491
  if (options.config.vue?.browserTemplateCompilation) {
1458
1492
  alias.push(
@@ -1462,20 +1496,20 @@ async function getAlias(options) {
1462
1496
  options.addons.forEach((addon) => {
1463
1497
  alias.push({
1464
1498
  find: `${addon.name}/client/`,
1465
- replacement: `${toAtFS(`${resolve6(addon.root)}`)}/client/`
1499
+ replacement: `${toAtFS(`${resolve5(addon.root)}`)}/client/`
1466
1500
  });
1467
1501
  alias.push({
1468
1502
  find: `${addon.name}/App.vue`,
1469
- replacement: `${toAtFS(resolve6(addon.root))}/App.vue`
1503
+ replacement: `${toAtFS(resolve5(addon.root))}/App.vue`
1470
1504
  });
1471
1505
  alias.push({
1472
1506
  find: addon.name,
1473
- replacement: `${toAtFS(resolve6(addon.root))}/client/index.ts`
1507
+ replacement: `${toAtFS(resolve5(addon.root))}/client/index.ts`
1474
1508
  });
1475
1509
  });
1476
1510
  alias.push({
1477
1511
  find: /^valaxy-addon-(.*)$/,
1478
- replacement: toAtFS(resolve6(options.clientRoot, "./addons/index.ts"))
1512
+ replacement: toAtFS(resolve5(options.clientRoot, "./addons/index.ts"))
1479
1513
  });
1480
1514
  return alias;
1481
1515
  }
@@ -2061,7 +2095,7 @@ function preWrapperPlugin(md3, options) {
2061
2095
  const lang = extractLang(token.info);
2062
2096
  const rawCode = fence(...args);
2063
2097
  const codeHeightLimitClass = getCodeHeightLimitStyle(options, env);
2064
- return `<div class="language-${lang}${active}${codeHeightLimitClass}"><button title="${options.codeCopyButtonTitle || "Copy code"}" class="copy"></button><span class="lang">${lang}</span>${rawCode}<button class="collapse"></button></div>`;
2098
+ return `<div class="language-${lang}${active}${codeHeightLimitClass}"><button title="${options.codeCopyButtonTitle || "Copy code"}" class="copy"></button><span class="lang">${lang}</span>${rawCode}<button class="code-block-unfold-btn"></button></div>`;
2065
2099
  };
2066
2100
  }
2067
2101
 
@@ -2412,7 +2446,7 @@ function lineNumberPlugin(md3, enable = false) {
2412
2446
  }
2413
2447
 
2414
2448
  // node/plugins/markdown/plugins/markdown-it/snippet.ts
2415
- import fs11 from "fs-extra";
2449
+ import fs10 from "fs-extra";
2416
2450
  import path5 from "pathe";
2417
2451
  var rawPathRegexp = /^(.+?(?:\.([a-z0-9]+))?)(#[\w-]+)?(?: ?\{(\d+(?:[,-]\d+)*)? ?(\S+)?\})? ?(?:\[(.+)\])?$/;
2418
2452
  function rawPathToToken(rawPath) {
@@ -2515,13 +2549,13 @@ function snippetPlugin(md3, srcDir) {
2515
2549
  return fence(...args);
2516
2550
  if (includes)
2517
2551
  includes.push(src);
2518
- const isAFile = fs11.statSync(src).isFile();
2519
- if (!fs11.existsSync(src) || !isAFile) {
2552
+ const isAFile = fs10.statSync(src).isFile();
2553
+ if (!fs10.existsSync(src) || !isAFile) {
2520
2554
  token.content = isAFile ? `Code snippet path not found: ${src}` : `Invalid code snippet option`;
2521
2555
  token.info = "";
2522
2556
  return fence(...args);
2523
2557
  }
2524
- let content = fs11.readFileSync(src, "utf8");
2558
+ let content = fs10.readFileSync(src, "utf8");
2525
2559
  if (regionName) {
2526
2560
  const lines = content.split(/\r?\n/);
2527
2561
  const region = findRegion(lines, regionName);
@@ -2644,28 +2678,6 @@ async function setupMarkdownPlugins(md3, options, base = "/") {
2644
2678
  // node/plugins/markdown/transform/index.ts
2645
2679
  import Markdown from "unplugin-vue-markdown/vite";
2646
2680
 
2647
- // node/app/state.ts
2648
- var StateManager = class {
2649
- /**
2650
- * @zh 文章 ID 映射
2651
- */
2652
- idMap = /* @__PURE__ */ new Map();
2653
- };
2654
-
2655
- // node/app/class.ts
2656
- var Valaxy = class {
2657
- /**
2658
- * version
2659
- */
2660
- static version = version;
2661
- /**
2662
- * file state
2663
- */
2664
- static state = new StateManager();
2665
- constructor() {
2666
- }
2667
- };
2668
-
2669
2681
  // node/plugins/markdown/transform/include.ts
2670
2682
  import { slash as slash2 } from "@antfu/utils";
2671
2683
  import path7 from "pathe";
@@ -2684,7 +2696,7 @@ function treatAsHtml(filename) {
2684
2696
 
2685
2697
  // node/plugins/markdown/utils/processInclude.ts
2686
2698
  import path6 from "path";
2687
- import fs12 from "fs-extra";
2699
+ import fs11 from "fs-extra";
2688
2700
  function processIncludes(srcDir, src, file) {
2689
2701
  const includesRE = /<!--\s*@include:\s*(.*?)\s*-->/g;
2690
2702
  const rangeRE = /\{(\d*),(\d*)\}$/;
@@ -2696,7 +2708,7 @@ function processIncludes(srcDir, src, file) {
2696
2708
  const atPresent = m1[0] === "@";
2697
2709
  try {
2698
2710
  const includePath = atPresent ? path6.join(srcDir, m1.slice(m1[1] === "/" ? 2 : 1)) : path6.join(path6.dirname(file), m1);
2699
- let content = fs12.readFileSync(includePath, "utf-8");
2711
+ let content = fs11.readFileSync(includePath, "utf-8");
2700
2712
  if (range) {
2701
2713
  const [, startLine, endLine] = range;
2702
2714
  const lines = content.split(/\r?\n/);
@@ -2847,10 +2859,10 @@ function createFixPlugins(options) {
2847
2859
 
2848
2860
  // node/plugins/setupClient.ts
2849
2861
  import { existsSync } from "fs";
2850
- import { join as join4, resolve as resolve7 } from "path";
2862
+ import { join as join4, resolve as resolve6 } from "path";
2851
2863
  import { slash as slash3, uniq as uniq4 } from "@antfu/utils";
2852
2864
  function createClientSetupPlugin({ clientRoot, themeRoot, userRoot: userRoot2 }) {
2853
- const setupEntry = slash3(resolve7(clientRoot, "setup"));
2865
+ const setupEntry = slash3(resolve6(clientRoot, "setup"));
2854
2866
  return {
2855
2867
  name: "valaxy:setup",
2856
2868
  enforce: "pre",
@@ -2889,25 +2901,25 @@ function createClientSetupPlugin({ clientRoot, themeRoot, userRoot: userRoot2 })
2889
2901
  }
2890
2902
 
2891
2903
  // node/plugins/unocss.ts
2892
- import { resolve as resolve9 } from "path";
2904
+ import { resolve as resolve8 } from "path";
2893
2905
  import defu3 from "defu";
2894
- import fs14 from "fs-extra";
2895
- import { createJiti as createJiti3 } from "jiti";
2906
+ import fs13 from "fs-extra";
2907
+ import { createJiti as createJiti2 } from "jiti";
2896
2908
  import {
2897
2909
  presetAttributify,
2898
2910
  presetIcons,
2899
2911
  presetTypography,
2900
- presetUno,
2912
+ presetWind4,
2901
2913
  transformerDirectives,
2902
2914
  transformerVariantGroup
2903
2915
  } from "unocss";
2904
2916
 
2905
2917
  // node/plugins/setupNode.ts
2906
- import { resolve as resolve8 } from "path";
2918
+ import { resolve as resolve7 } from "path";
2907
2919
  import { isObject } from "@antfu/utils";
2908
- import fs13 from "fs-extra";
2909
- import { createJiti as createJiti2 } from "jiti";
2910
- var jiti2 = createJiti2(import.meta.url);
2920
+ import fs12 from "fs-extra";
2921
+ import { createJiti } from "jiti";
2922
+ var jiti = createJiti(import.meta.url);
2911
2923
  function deepMerge(a, b, rootPath = "") {
2912
2924
  a = { ...a };
2913
2925
  Object.keys(b).forEach((key) => {
@@ -2923,9 +2935,9 @@ function deepMerge(a, b, rootPath = "") {
2923
2935
  async function loadSetups(roots, name, arg, initial, merge = true) {
2924
2936
  let returns = initial;
2925
2937
  for (const root of roots) {
2926
- const path18 = resolve8(root, "setup", name);
2927
- if (fs13.existsSync(path18)) {
2928
- const setup = await jiti2.import(path18, { default: true });
2938
+ const path18 = resolve7(root, "setup", name);
2939
+ if (fs12.existsSync(path18)) {
2940
+ const setup = await jiti.import(path18, { default: true });
2929
2941
  const result = await setup(arg);
2930
2942
  if (result !== null) {
2931
2943
  returns = merge ? deepMerge(returns, result) : result;
@@ -2936,7 +2948,7 @@ async function loadSetups(roots, name, arg, initial, merge = true) {
2936
2948
  }
2937
2949
 
2938
2950
  // node/plugins/unocss.ts
2939
- var jiti3 = createJiti3(import.meta.url);
2951
+ var jiti2 = createJiti2(import.meta.url);
2940
2952
  async function createSafelist(options) {
2941
2953
  const { config } = options;
2942
2954
  const safeIcons = [
@@ -2985,7 +2997,7 @@ async function createUnocssConfig(options) {
2985
2997
  ["va-card", "shadow hover:shadow-lg bg-$va-c-bg-light"]
2986
2998
  ],
2987
2999
  presets: [
2988
- presetUno(pluginOptions.unocssPresets?.uno),
3000
+ presetWind4(pluginOptions.unocssPresets?.wind4),
2989
3001
  presetAttributify(pluginOptions.unocssPresets?.attributify),
2990
3002
  presetIcons({
2991
3003
  scale: 1.2,
@@ -3035,14 +3047,14 @@ async function createUnocssPlugin(options) {
3035
3047
  const dirs = [themeRoot, clientRoot];
3036
3048
  dirs.forEach(
3037
3049
  (dir) => unoConfigFiles.forEach(
3038
- (file) => configFiles.push(resolve9(dir, file))
3050
+ (file) => configFiles.push(resolve8(dir, file))
3039
3051
  )
3040
3052
  );
3041
3053
  let config = {};
3042
3054
  const configDeps = [];
3043
3055
  for (const configFile of configFiles) {
3044
- if (await fs14.exists(configFile)) {
3045
- const uConfig = await jiti3.import(configFile, { default: true });
3056
+ if (await fs13.exists(configFile)) {
3057
+ const uConfig = await jiti2.import(configFile, { default: true });
3046
3058
  config = defu3(config, uConfig);
3047
3059
  configDeps.push(configFile);
3048
3060
  }
@@ -3056,19 +3068,19 @@ async function createUnocssPlugin(options) {
3056
3068
  }
3057
3069
 
3058
3070
  // node/plugins/valaxy/index.ts
3059
- import { consola as consola12 } from "consola";
3071
+ import { consola as consola11 } from "consola";
3060
3072
  import { colors as colors11 } from "consola/utils";
3061
- import fs20 from "fs-extra";
3062
- import { join as join7, relative, resolve as resolve10 } from "pathe";
3073
+ import fs19 from "fs-extra";
3074
+ import { join as join7, relative, resolve as resolve9 } from "pathe";
3063
3075
 
3064
3076
  // node/virtual/addons.ts
3065
- import fs15 from "fs-extra";
3077
+ import fs14 from "fs-extra";
3066
3078
  import pascalCase from "pascalcase";
3067
3079
  import { join as join5 } from "pathe";
3068
3080
  var templateAddons = {
3069
3081
  id: "/@valaxyjs/addons",
3070
3082
  async getContent(options) {
3071
- const globalAddonComponents = options.addons.filter((v) => v.global).filter((v) => fs15.existsSync(join5(v.root, "./App.vue")));
3083
+ const globalAddonComponents = options.addons.filter((v) => v.global).filter((v) => fs14.existsSync(join5(v.root, "./App.vue")));
3072
3084
  const spliceImportName = (str) => `Addon${pascalCase(str)}App`;
3073
3085
  const imports = globalAddonComponents.map((addon) => `import ${spliceImportName(addon.name)} from "${addon.name}/App.vue"`).join("\n");
3074
3086
  const components = globalAddonComponents.map((addon) => `{ component: ${spliceImportName(addon.name)}, props: ${JSON.stringify(addon.props)} }`).join(",");
@@ -3079,17 +3091,17 @@ export default [${components}]`;
3079
3091
 
3080
3092
  // node/virtual/blogs.ts
3081
3093
  import path8 from "path";
3082
- import fs16 from "fs-extra";
3094
+ import fs15 from "fs-extra";
3083
3095
  function createBlogTemplate(name) {
3084
3096
  return {
3085
3097
  id: `/@valaxyjs/blog/${name}s`,
3086
3098
  async getContent({ userRoot: userRoot2 }) {
3087
3099
  const root = path8.resolve(userRoot2, "pages", "collections");
3088
- if (!await fs16.pathExists(root)) {
3100
+ if (!await fs15.pathExists(root)) {
3089
3101
  return `export default []`;
3090
3102
  }
3091
- const isDir = (file) => fs16.statSync(path8.join(root, file)).isDirectory();
3092
- const files = fs16.readdirSync(root).filter((file) => isDir(file)).map((file) => path8.join(root, file, "index.ts"));
3103
+ const isDir = (file) => fs15.statSync(path8.join(root, file)).isDirectory();
3104
+ const files = fs15.readdirSync(root).filter((file) => isDir(file)).map((file) => path8.join(root, file, "index.ts"));
3093
3105
  const imports = [];
3094
3106
  const getImportedName = (idx) => `__valaxy_${name}_${idx + 1}`;
3095
3107
  files.forEach((file, idx) => {
@@ -3125,7 +3137,7 @@ var templateConfig = {
3125
3137
  };
3126
3138
 
3127
3139
  // node/virtual/locales.ts
3128
- import fs17 from "fs-extra";
3140
+ import fs16 from "fs-extra";
3129
3141
  var templateLocales = {
3130
3142
  id: "/@valaxyjs/locales",
3131
3143
  async getContent({ roots, config }) {
@@ -3145,7 +3157,7 @@ var templateLocales = {
3145
3157
  roots.forEach((root, i) => {
3146
3158
  languages.forEach((lang) => {
3147
3159
  const langYml = `${root}/locales/${lang}.yml`;
3148
- if (fs17.existsSync(langYml) && fs17.readFileSync(langYml, "utf-8")) {
3160
+ if (fs16.existsSync(langYml) && fs16.readFileSync(langYml, "utf-8")) {
3149
3161
  const varName = lang.replace("-", "") + i;
3150
3162
  imports.unshift(`import ${varName} from "${toAtFS(langYml)}"`);
3151
3163
  imports.push(`messages['${lang}'] = replaceArrMerge(${varName}, messages['${lang}'])`);
@@ -3203,41 +3215,6 @@ import _debug2 from "debug";
3203
3215
  import { LRUCache } from "lru-cache";
3204
3216
  import path12 from "pathe";
3205
3217
 
3206
- // node/app/index.ts
3207
- import { createHooks } from "hookable";
3208
- var buildHooks = [
3209
- "build:before",
3210
- "build:after"
3211
- ];
3212
- function createValaxyNode(options) {
3213
- const hooks = createHooks();
3214
- if (typeof options.config.hooks === "object") {
3215
- Object.keys(options.config.hooks).forEach((name) => {
3216
- const hookName = name;
3217
- const hook = options.config.hooks[hookName];
3218
- if (typeof hook !== "function")
3219
- return;
3220
- if (buildHooks.includes(hookName)) {
3221
- if (options.mode === "build")
3222
- hooks.hook(hookName, hook);
3223
- } else {
3224
- hooks.hook(hookName, hook);
3225
- }
3226
- });
3227
- }
3228
- const valaxyNode = {
3229
- version,
3230
- hooks,
3231
- hook: hooks.hook,
3232
- options
3233
- };
3234
- options.addons.forEach((addon) => {
3235
- if (typeof addon.setup === "function")
3236
- addon.setup(valaxyNode);
3237
- });
3238
- return valaxyNode;
3239
- }
3240
-
3241
3218
  // node/plugins/markdown/transform/code-block.ts
3242
3219
  function handleCodeHeightLimit(mainContentMd, options, codeHeightLimit) {
3243
3220
  if (typeof codeHeightLimit !== "number" || codeHeightLimit <= 0)
@@ -3260,7 +3237,7 @@ function createTransformCodeBlock(options) {
3260
3237
 
3261
3238
  // node/plugins/markdown/transform/dead-links.ts
3262
3239
  import { slash as slash4 } from "@antfu/utils";
3263
- import fs18 from "fs-extra";
3240
+ import fs17 from "fs-extra";
3264
3241
  import path9 from "pathe";
3265
3242
  function createScanDeadLinks(options) {
3266
3243
  const srcDir = path9.resolve(options.userRoot, "pages");
@@ -3307,7 +3284,7 @@ function createScanDeadLinks(options) {
3307
3284
  )
3308
3285
  // /index => /
3309
3286
  ).replace(/\/index$/, "");
3310
- if (!options.pages.includes(resolved) && !fs18.existsSync(path9.resolve(dir, publicDir, `${resolved}.html`)) && !shouldIgnoreDeadLink(url)) {
3287
+ if (!options.pages.includes(resolved) && !fs17.existsSync(path9.resolve(dir, publicDir, `${resolved}.html`)) && !shouldIgnoreDeadLink(url)) {
3311
3288
  recordDeadLink(url);
3312
3289
  }
3313
3290
  }
@@ -3454,11 +3431,11 @@ function transformFootnoteTooltip(code, _id) {
3454
3431
  }
3455
3432
 
3456
3433
  // node/plugins/markdown/transform/hexo.ts
3457
- import { consola as consola11 } from "consola";
3434
+ import { consola as consola10 } from "consola";
3458
3435
  import { colors as colors10 } from "consola/utils";
3459
3436
  function transformHexoTags(code, id) {
3460
3437
  if (code.includes("{%") && code.includes("%}")) {
3461
- consola11.error(
3438
+ consola10.error(
3462
3439
  `${`${id}
3463
3440
  `} Please ${colors10.red("remove")} ${colors10.cyan("{% %}")}, because it conflicts with ${colors10.yellow("markdown-it-attrs")}.`
3464
3441
  );
@@ -3470,7 +3447,7 @@ function transformHexoTags(code, id) {
3470
3447
 
3471
3448
  // node/plugins/markdown/transform/markdown.ts
3472
3449
  import path10 from "path";
3473
- import fs19 from "fs-extra";
3450
+ import fs18 from "fs-extra";
3474
3451
  function genProvideCode(name, data) {
3475
3452
  return [
3476
3453
  `const $${name} = ${transformObject(data)}`,
@@ -3502,7 +3479,7 @@ function injectPageDataCode(pageData) {
3502
3479
  }
3503
3480
  function createTransformMarkdown(options) {
3504
3481
  const loaderVuePath = path10.resolve(options.clientRoot, "templates", "loader.vue");
3505
- const loaderVue = fs19.readFileSync(loaderVuePath, "utf-8");
3482
+ const loaderVue = fs18.readFileSync(loaderVuePath, "utf-8");
3506
3483
  return (code, id, pageData) => {
3507
3484
  const isDev = options.mode === "dev";
3508
3485
  if (!isDev) {
@@ -3654,7 +3631,7 @@ async function createMarkdownToVueRenderFn(options, _viteConfig) {
3654
3631
  var nullVue = 'import { defineComponent } from "vue"; export default defineComponent({ render: () => null });';
3655
3632
  function generateAppVue(root) {
3656
3633
  const appVue = join7(root, "App.vue");
3657
- if (!fs20.existsSync(appVue))
3634
+ if (!fs19.existsSync(appVue))
3658
3635
  return nullVue;
3659
3636
  const scripts = [
3660
3637
  `import AppVue from "${toAtFS(appVue)}"`,
@@ -3726,8 +3703,8 @@ async function createValaxyPlugin(options, serverOptions = {}) {
3726
3703
  const { code: newCode, deadLinks, includes } = await markdownToVue(code, id);
3727
3704
  if (deadLinks.length) {
3728
3705
  hasDeadLinks = true;
3729
- consola12.error(`Dead links found in ${id}`);
3730
- consola12.error(deadLinks);
3706
+ consola11.error(`Dead links found in ${id}`);
3707
+ consola11.error(deadLinks);
3731
3708
  }
3732
3709
  if (includes.length) {
3733
3710
  includes.forEach((i) => {
@@ -3774,7 +3751,7 @@ async function createValaxyPlugin(options, serverOptions = {}) {
3774
3751
  valaxyConfig.themeConfig = themeConfig;
3775
3752
  return reloadConfigAndEntries(valaxyConfig);
3776
3753
  }
3777
- if (file === resolve10(options.themeRoot, "valaxy.config.ts")) {
3754
+ if (file === resolve9(options.themeRoot, "valaxy.config.ts")) {
3778
3755
  const themeValaxyConfig = await resolveThemeValaxyConfig(options);
3779
3756
  const valaxyConfig2 = mergeValaxyConfig(options.config, themeValaxyConfig);
3780
3757
  const { config } = await processValaxyOptions(options, valaxyConfig2);
@@ -3813,11 +3790,11 @@ async function createValaxyPlugin(options, serverOptions = {}) {
3813
3790
  }
3814
3791
 
3815
3792
  // node/plugins/vueRouter.ts
3816
- import fs21 from "fs-extra";
3793
+ import fs20 from "fs-extra";
3817
3794
  import matter3 from "gray-matter";
3818
3795
  import { convert } from "html-to-text";
3819
3796
  import { MarkdownItAsync } from "markdown-it-async";
3820
- import { resolve as resolve11 } from "pathe";
3797
+ import { resolve as resolve10 } from "pathe";
3821
3798
  import VueRouter from "unplugin-vue-router/vite";
3822
3799
 
3823
3800
  // node/plugins/presets/statistics.ts
@@ -3894,7 +3871,7 @@ async function createRouterPlugin(valaxyApp) {
3894
3871
  return VueRouter({
3895
3872
  extensions: [".vue", ".md"],
3896
3873
  routesFolder: roots.map((root) => `${root}/pages`),
3897
- dts: resolve11(options.tempDir, "typed-router.d.ts"),
3874
+ dts: resolve10(options.tempDir, "typed-router.d.ts"),
3898
3875
  ...valaxyConfig.router,
3899
3876
  /**
3900
3877
  * @experimental See https://github.com/posva/unplugin-vue-router/issues/43
@@ -3933,7 +3910,7 @@ async function createRouterPlugin(valaxyApp) {
3933
3910
  }
3934
3911
  const path18 = route.components.get("default") || "";
3935
3912
  if (path18.endsWith(".md")) {
3936
- const md3 = fs21.readFileSync(path18, "utf-8");
3913
+ const md3 = fs20.readFileSync(path18, "utf-8");
3937
3914
  const { data, excerpt, content } = matter3(md3, matterOptions);
3938
3915
  const mdFm = data;
3939
3916
  const lastUpdated = options.config.siteConfig.lastUpdated;
@@ -3943,10 +3920,10 @@ async function createRouterPlugin(valaxyApp) {
3943
3920
  delete mdFm.photos;
3944
3921
  }
3945
3922
  if (!mdFm.date)
3946
- mdFm.date = (await fs21.stat(path18)).mtime;
3923
+ mdFm.date = (await fs20.stat(path18)).mtime;
3947
3924
  if (lastUpdated) {
3948
3925
  if (!mdFm.updated)
3949
- mdFm.updated = (await fs21.stat(path18)).ctime;
3926
+ mdFm.updated = (await fs20.stat(path18)).ctime;
3950
3927
  }
3951
3928
  if (mdFm.from) {
3952
3929
  if (Array.isArray(mdFm.from)) {
@@ -4075,7 +4052,7 @@ async function ViteValaxyPlugins(valaxyApp, serverOptions = {}) {
4075
4052
  * latter override former
4076
4053
  */
4077
4054
  dirs: componentsDirs,
4078
- dts: resolve12(options.tempDir, "components.d.ts"),
4055
+ dts: resolve11(options.tempDir, "components.d.ts"),
4079
4056
  ...valaxyConfig.components
4080
4057
  }),
4081
4058
  // https://github.com/antfu/unocss
@@ -4103,10 +4080,10 @@ async function ViteValaxyPlugins(valaxyApp, serverOptions = {}) {
4103
4080
  );
4104
4081
  } catch (e) {
4105
4082
  console.error(e);
4106
- consola13.error("Failed to load rollup-plugin-visualizer");
4107
- consola13.error("Please install `rollup-plugin-visualizer` to enable the feature");
4083
+ consola12.error("Failed to load rollup-plugin-visualizer");
4084
+ consola12.error("Please install `rollup-plugin-visualizer` to enable the feature");
4108
4085
  console.log();
4109
- consola13.info("pnpm add -D rollup-plugin-visualizer");
4086
+ consola12.info("pnpm add -D rollup-plugin-visualizer");
4110
4087
  console.log();
4111
4088
  }
4112
4089
  }
@@ -4219,7 +4196,7 @@ async function ssgBuild(valaxyApp, viteConfig = {}) {
4219
4196
  const newPaths = paths;
4220
4197
  const posts = paths.filter((path18) => path18.startsWith("/posts/"));
4221
4198
  const pageNumber = Math.ceil(posts.length / options.config.siteConfig.pageSize);
4222
- consola14.info(`Generate ${colors12.yellow(pageNumber)} pages for pagination.`);
4199
+ consola13.info(`Generate ${colors12.yellow(pageNumber)} pages for pagination.`);
4223
4200
  for (let i = 1; i <= pageNumber; i++)
4224
4201
  newPaths.push(`/page/${i}`);
4225
4202
  if (!options.config.vite?.ssgOptions?.includeAllRoutes)
@@ -4233,28 +4210,28 @@ async function ssgBuild(valaxyApp, viteConfig = {}) {
4233
4210
  }
4234
4211
  async function postProcessForSSG(options) {
4235
4212
  const { userRoot: userRoot2 } = options;
4236
- const indexPath = resolve13(userRoot2, "dist/index.html");
4237
- if (fs22.existsSync(indexPath)) {
4238
- consola14.info("post process for ssg...");
4239
- const indexFile = await fs22.readFile(indexPath, "utf-8");
4213
+ const indexPath = resolve12(userRoot2, "dist/index.html");
4214
+ if (fs21.existsSync(indexPath)) {
4215
+ consola13.info("post process for ssg...");
4216
+ const indexFile = await fs21.readFile(indexPath, "utf-8");
4240
4217
  const htmlTag = "</html>";
4241
4218
  if (!indexFile.endsWith(htmlTag)) {
4242
- consola14.warn("fix incomplete index.html...");
4219
+ consola13.warn("fix incomplete index.html...");
4243
4220
  const htmlTagStart = indexFile.lastIndexOf(htmlTag);
4244
- await fs22.writeFile(indexPath, indexFile.slice(0, htmlTagStart + htmlTag.length), "utf-8");
4221
+ await fs21.writeFile(indexPath, indexFile.slice(0, htmlTagStart + htmlTag.length), "utf-8");
4245
4222
  }
4246
4223
  }
4247
4224
  if (!options.config.siteConfig.redirects?.useVueRouter)
4248
4225
  await generateClientRedirects(options);
4249
4226
  }
4250
4227
  async function generateClientRedirects(options) {
4251
- consola14.info("generate client redirects...");
4252
- const outputPath = resolve13(options.userRoot, "dist");
4228
+ consola13.info("generate client redirects...");
4229
+ const outputPath = resolve12(options.userRoot, "dist");
4253
4230
  const redirectRules = collectRedirects(options.redirects);
4254
4231
  const task = redirectRules.map(async (rule) => {
4255
4232
  const fromPath = join8(outputPath, `${rule.from}.html`);
4256
4233
  const toPath = join8(outputPath, `${rule.to}.html`);
4257
- const routeExist = await fs22.pathExists(toPath);
4234
+ const routeExist = await fs21.pathExists(toPath);
4258
4235
  if (!routeExist)
4259
4236
  throw new Error(`the route of '${rule.to}' not exists`);
4260
4237
  await writeRedirectFiles(rule.to, fromPath);
@@ -4262,6 +4239,21 @@ async function generateClientRedirects(options) {
4262
4239
  await Promise.all(task);
4263
4240
  }
4264
4241
 
4242
+ // node/cli/utils/cli.ts
4243
+ import os from "os";
4244
+ import path13 from "path";
4245
+ import process8 from "process";
4246
+ import { consola as consola14 } from "consola";
4247
+ import { colors as colors14 } from "consola/utils";
4248
+ import ora4 from "ora";
4249
+ import { mergeConfig as mergeConfig3 } from "vite";
4250
+
4251
+ // node/env.ts
4252
+ var GLOBAL_STATE = {
4253
+ valaxyApp: void 0,
4254
+ server: void 0
4255
+ };
4256
+
4265
4257
  // node/server.ts
4266
4258
  import process7 from "process";
4267
4259
  import { colors as colors13 } from "consola/utils";
@@ -4295,21 +4287,6 @@ async function createServer(valaxyApp, viteConfig = {}, serverOptions = {}) {
4295
4287
  return server;
4296
4288
  }
4297
4289
 
4298
- // node/cli/utils/cli.ts
4299
- import os from "os";
4300
- import path13 from "path";
4301
- import process8 from "process";
4302
- import { consola as consola15 } from "consola";
4303
- import { colors as colors14 } from "consola/utils";
4304
- import ora4 from "ora";
4305
- import { mergeConfig as mergeConfig3 } from "vite";
4306
-
4307
- // node/env.ts
4308
- var GLOBAL_STATE = {
4309
- valaxyApp: void 0,
4310
- server: void 0
4311
- };
4312
-
4313
4290
  // node/cli/utils/cli.ts
4314
4291
  function printInfo(options, port, remote) {
4315
4292
  const themeVersion = colors14.blue(`v${options.config.themeConfig?.pkg?.version}`) || "unknown";
@@ -4371,7 +4348,7 @@ async function initServer(valaxyApp, viteConfig) {
4371
4348
  serverSpinner.succeed(`${valaxyPrefix} ${colors14.green("server ready.")}`);
4372
4349
  return server;
4373
4350
  } catch (e) {
4374
- consola15.error("failed to start server. error:\n");
4351
+ consola14.error("failed to start server. error:\n");
4375
4352
  console.error(e);
4376
4353
  process8.exit(1);
4377
4354
  }
@@ -4379,7 +4356,7 @@ async function initServer(valaxyApp, viteConfig) {
4379
4356
  if (import.meta.hot) {
4380
4357
  await import.meta.hot.data.stopping;
4381
4358
  let reload = async () => {
4382
- consola15.info("HMR: Stop Server");
4359
+ consola14.info("HMR: Stop Server");
4383
4360
  await GLOBAL_STATE.server?.close();
4384
4361
  };
4385
4362
  import.meta.hot.on("vite:beforeFullReload", () => {
@@ -4426,19 +4403,19 @@ async function execBuild({ ssg, root, output, log }) {
4426
4403
  );
4427
4404
  await callHookWithLog("config:init", valaxyApp);
4428
4405
  await callHookWithLog("build:before", valaxyApp);
4429
- consola16.box("\u{1F320} Start building...");
4406
+ consola15.box("\u{1F320} Start building...");
4430
4407
  try {
4431
4408
  if (ssg) {
4432
- consola16.info(`use ${colors15.yellow("vite-ssg")} to do ssg build...`);
4409
+ consola15.info(`use ${colors15.yellow("vite-ssg")} to do ssg build...`);
4433
4410
  try {
4434
4411
  await ssgBuild(valaxyApp, viteConfig);
4435
4412
  await postProcessForSSG(options);
4436
4413
  } catch (e) {
4437
- consola16.error("[vite-ssg] An internal error occurred.");
4414
+ consola15.error("[vite-ssg] An internal error occurred.");
4438
4415
  console.log(e);
4439
4416
  }
4440
4417
  } else {
4441
- consola16.info("use vite do spa build...");
4418
+ consola15.info("use vite do spa build...");
4442
4419
  await build2(valaxyApp, viteConfig);
4443
4420
  }
4444
4421
  } catch (e) {
@@ -4478,35 +4455,35 @@ function registerBuildCommand(cli2) {
4478
4455
  // node/cli/clean.ts
4479
4456
  import path15 from "path";
4480
4457
  import process10 from "process";
4481
- import { consola as consola17 } from "consola";
4482
- import fs23 from "fs-extra";
4458
+ import { consola as consola16 } from "consola";
4459
+ import fs22 from "fs-extra";
4483
4460
  async function cleanDist() {
4484
4461
  const distDir = path15.join(process10.cwd(), "dist");
4485
4462
  const cacheDir = path15.join(process10.cwd(), ".valaxy");
4486
- consola17.box("\u{1F9F9} Starting clean...");
4487
- if (await fs23.exists(distDir)) {
4488
- consola17.info("dist directory exists, removing...");
4463
+ consola16.box("\u{1F9F9} Starting clean...");
4464
+ if (await fs22.exists(distDir)) {
4465
+ consola16.info("dist directory exists, removing...");
4489
4466
  try {
4490
- await fs23.rm(distDir, { recursive: true, force: true });
4491
- consola17.success("dist directory has been successfully removed.");
4467
+ await fs22.rm(distDir, { recursive: true, force: true });
4468
+ consola16.success("dist directory has been successfully removed.");
4492
4469
  } catch (error) {
4493
- consola17.error("Failed to remove dist directory.");
4494
- consola17.error(error);
4470
+ consola16.error("Failed to remove dist directory.");
4471
+ consola16.error(error);
4495
4472
  }
4496
4473
  } else {
4497
- consola17.info("No dist directory found, nothing to clean.");
4474
+ consola16.info("No dist directory found, nothing to clean.");
4498
4475
  }
4499
- if (await fs23.exists(cacheDir)) {
4500
- consola17.info(".valaxy cache directory exists, removing...");
4476
+ if (await fs22.exists(cacheDir)) {
4477
+ consola16.info(".valaxy cache directory exists, removing...");
4501
4478
  try {
4502
- await fs23.rm(cacheDir, { recursive: true, force: true });
4503
- consola17.success(".valaxy cache directory has been successfully removed.");
4479
+ await fs22.rm(cacheDir, { recursive: true, force: true });
4480
+ consola16.success(".valaxy cache directory has been successfully removed.");
4504
4481
  } catch (error) {
4505
- consola17.error("Failed to remove .valaxy cache directory.");
4506
- consola17.error(error);
4482
+ consola16.error("Failed to remove .valaxy cache directory.");
4483
+ consola16.error(error);
4507
4484
  }
4508
4485
  } else {
4509
- consola17.info("No .valaxy cache directory found, nothing to clean.");
4486
+ consola16.info("No .valaxy cache directory found, nothing to clean.");
4510
4487
  }
4511
4488
  }
4512
4489
  function registerCleanCommand(cli2) {
@@ -4522,15 +4499,21 @@ function registerCleanCommand(cli2) {
4522
4499
  }
4523
4500
 
4524
4501
  // node/cli/debug.ts
4525
- import { consola as consola18 } from "consola";
4502
+ import os2 from "os";
4503
+ import process11 from "process";
4504
+ import { consola as consola17 } from "consola";
4505
+ import { colors as colors16 } from "consola/utils";
4526
4506
  function registerDebugCommand(cli2) {
4527
4507
  cli2.command("debug", "Debug your blog", async () => {
4528
- consola18.info("\u63D0\u95EE\u524D\u8BF7\u643A\u5E26\u4EE5\u4E0B\u4FE1\u606F\uFF1A");
4508
+ console.log();
4509
+ consola17.log(" Operating System:", colors16.green(os2.platform()));
4510
+ consola17.log(" Node.JS Version:", colors16.green(process11.version));
4511
+ consola17.log(" Valaxy Version:", colors16.cyan(`v${version}`));
4529
4512
  });
4530
4513
  }
4531
4514
 
4532
4515
  // node/cli/deploy.ts
4533
- import process11 from "process";
4516
+ import process12 from "process";
4534
4517
  import { confirm, intro, outro, select } from "@clack/prompts";
4535
4518
  function registerDeployCommand(cli2) {
4536
4519
  cli2.command("deploy", "deploy your blog to the cloud", async () => {
@@ -4539,7 +4522,7 @@ function registerDeployCommand(cli2) {
4539
4522
  message: "Do you want to build your blog before deploying?"
4540
4523
  });
4541
4524
  if (shouldBuild) {
4542
- await execBuild({ ssg: true, root: process11.cwd(), output: "dist", log: "info" });
4525
+ await execBuild({ ssg: true, root: process12.cwd(), output: "dist", log: "info" });
4543
4526
  }
4544
4527
  const deployType = await select({
4545
4528
  message: "Where do you want to deploy?",
@@ -4579,7 +4562,7 @@ function registerDeployCommand(cli2) {
4579
4562
 
4580
4563
  // node/cli/dev.ts
4581
4564
  import path16 from "path";
4582
- import process13 from "process";
4565
+ import process14 from "process";
4583
4566
  import { mergeConfig as mergeConfig5 } from "vite";
4584
4567
 
4585
4568
  // node/utils/net.ts
@@ -4590,28 +4573,28 @@ async function findFreePort(start) {
4590
4573
  return await findFreePort(start + 1);
4591
4574
  }
4592
4575
  function isPortFree(port) {
4593
- return new Promise((resolve15) => {
4576
+ return new Promise((resolve14) => {
4594
4577
  const server = net.createServer((socket) => {
4595
4578
  socket.write("Echo server\r\n");
4596
4579
  socket.pipe(socket);
4597
4580
  });
4598
4581
  server.listen(port, "0.0.0.0");
4599
4582
  server.on("error", () => {
4600
- resolve15(false);
4583
+ resolve14(false);
4601
4584
  });
4602
4585
  server.on("listening", () => {
4603
4586
  server.close();
4604
- resolve15(true);
4587
+ resolve14(true);
4605
4588
  });
4606
4589
  });
4607
4590
  }
4608
4591
 
4609
4592
  // node/cli/utils/shortcuts.ts
4610
4593
  import { exec } from "child_process";
4611
- import os2 from "os";
4612
- import process12 from "process";
4594
+ import os3 from "os";
4595
+ import process13 from "process";
4613
4596
  import * as readline from "readline";
4614
- import { colors as colors16 } from "consola/utils";
4597
+ import { colors as colors17 } from "consola/utils";
4615
4598
  import qrcode from "qrcode";
4616
4599
  var SHORTCUTS = [
4617
4600
  {
@@ -4636,7 +4619,7 @@ var SHORTCUTS = [
4636
4619
  key: "q",
4637
4620
  description: "qr",
4638
4621
  action(server) {
4639
- const addresses = Object.values(os2.networkInterfaces()).flat().filter((details) => details?.family === "IPv4" && !details.address.includes("127.0.0.1"));
4622
+ const addresses = Object.values(os3.networkInterfaces()).flat().filter((details) => details?.family === "IPv4" && !details.address.includes("127.0.0.1"));
4640
4623
  const port = server.config.server.port;
4641
4624
  const remoteUrl = `http://${addresses[0]?.address || "localhost"}:${port}`;
4642
4625
  qrcode.toString(remoteUrl, { type: "terminal" }, (err, qrCode) => {
@@ -4650,7 +4633,7 @@ var SHORTCUTS = [
4650
4633
  key: "e",
4651
4634
  description: "edit",
4652
4635
  action() {
4653
- exec(`code "${process12.cwd()}"`, (err) => {
4636
+ exec(`code "${process13.cwd()}"`, (err) => {
4654
4637
  if (err)
4655
4638
  console.error("Failed to open editor", err);
4656
4639
  });
@@ -4658,18 +4641,18 @@ var SHORTCUTS = [
4658
4641
  }
4659
4642
  ];
4660
4643
  function bindShortcuts(server, createDevServer) {
4661
- if (!server.httpServer || process12.env.CI) {
4662
- console.log("restart server to enable shortcuts", server.httpServer, process12.stdin.isTTY, process12.env.CI);
4644
+ if (!server.httpServer || process13.env.CI) {
4645
+ console.log("restart server to enable shortcuts", server.httpServer, process13.stdin.isTTY, process13.env.CI);
4663
4646
  return;
4664
4647
  }
4665
- process12.stdin.resume();
4666
- process12.stdin.setEncoding("utf8");
4667
- readline.emitKeypressEvents(process12.stdin);
4668
- if (process12.stdin.isTTY)
4669
- process12.stdin.setRawMode(true);
4648
+ process13.stdin.resume();
4649
+ process13.stdin.setEncoding("utf8");
4650
+ readline.emitKeypressEvents(process13.stdin);
4651
+ if (process13.stdin.isTTY)
4652
+ process13.stdin.setRawMode(true);
4670
4653
  async function onKeyPress(str, key) {
4671
4654
  if (key.ctrl && key.name === "c") {
4672
- process12.exit();
4655
+ process13.exit();
4673
4656
  } else {
4674
4657
  const shortcut = SHORTCUTS.find((shortcut2) => shortcut2.key === str);
4675
4658
  if (!shortcut)
@@ -4677,19 +4660,19 @@ function bindShortcuts(server, createDevServer) {
4677
4660
  try {
4678
4661
  await shortcut.action(server, createDevServer);
4679
4662
  } catch (error) {
4680
- console.error(colors16.red("Error executing shortcut:"), key, error);
4663
+ console.error(colors17.red("Error executing shortcut:"), key, error);
4681
4664
  }
4682
4665
  }
4683
4666
  }
4684
- process12.stdin.on("keypress", onKeyPress);
4667
+ process13.stdin.on("keypress", onKeyPress);
4685
4668
  server.httpServer.on("close", () => {
4686
- process12.stdin.off("keypress", onKeyPress);
4669
+ process13.stdin.off("keypress", onKeyPress);
4687
4670
  });
4688
4671
  }
4689
4672
 
4690
4673
  // node/cli/dev.ts
4691
4674
  async function startValaxyDev({
4692
- root = process13.cwd(),
4675
+ root = process14.cwd(),
4693
4676
  port,
4694
4677
  remote,
4695
4678
  log,
@@ -4697,7 +4680,7 @@ async function startValaxyDev({
4697
4680
  }) {
4698
4681
  setEnv();
4699
4682
  if (!isPagesDirExist(root))
4700
- process13.exit(0);
4683
+ process14.exit(0);
4701
4684
  port = port || await findFreePort(4859);
4702
4685
  const resolvedOptions = await resolveOptions({ userRoot: root });
4703
4686
  setTimezone(resolvedOptions.config.siteConfig.timezone);
@@ -4765,16 +4748,16 @@ function registerDevCommand(cli2) {
4765
4748
  }
4766
4749
 
4767
4750
  // node/cli/utils/post.ts
4768
- import { dirname as dirname5, join as join9, resolve as resolve14 } from "path";
4769
- import { consola as consola19 } from "consola";
4770
- import { colors as colors17 } from "consola/utils";
4751
+ import { dirname as dirname5, join as join9, resolve as resolve13 } from "path";
4752
+ import { consola as consola18 } from "consola";
4753
+ import { colors as colors18 } from "consola/utils";
4771
4754
  import dayjs2 from "dayjs";
4772
4755
  import { render } from "ejs";
4773
- import fs25 from "fs-extra";
4756
+ import fs24 from "fs-extra";
4774
4757
 
4775
4758
  // node/cli/utils/constants.ts
4776
- import process14 from "process";
4777
- var userRoot = process14.cwd();
4759
+ import process15 from "process";
4760
+ var userRoot = process15.cwd();
4778
4761
  var defaultPostTemplate = `---
4779
4762
  layout: <%=layout%>
4780
4763
  title: <%=title%>
@@ -4785,13 +4768,13 @@ date: <%=date%>
4785
4768
  // node/cli/utils/scaffold.ts
4786
4769
  import { readFile as readFile2 } from "fs/promises";
4787
4770
  import path17 from "path";
4788
- import fs24 from "fs-extra";
4771
+ import fs23 from "fs-extra";
4789
4772
  async function getTemplate(layout) {
4790
4773
  const { clientRoot, themeRoot } = await resolveOptions({ userRoot });
4791
4774
  const roots = [userRoot, themeRoot, clientRoot];
4792
4775
  for (const root of roots) {
4793
4776
  const scaffoldPath = path17.resolve(root, "scaffolds", `${layout}.md`);
4794
- if (await fs24.exists(scaffoldPath))
4777
+ if (await fs23.exists(scaffoldPath))
4795
4778
  return readFile2(scaffoldPath, "utf-8");
4796
4779
  }
4797
4780
  return false;
@@ -4799,22 +4782,22 @@ async function getTemplate(layout) {
4799
4782
 
4800
4783
  // node/cli/utils/post.ts
4801
4784
  async function create(params) {
4802
- const pagesPath = resolve14(userRoot, params.path || "pages");
4785
+ const pagesPath = resolve13(userRoot, params.path || "pages");
4803
4786
  let counter = 0;
4804
4787
  while (true) {
4805
4788
  const postFileName = `${params.title}${counter ? `-${counter}` : ""}`;
4806
4789
  const postFilePath = params.folder ? join9(postFileName, "index.md") : `${postFileName}.md`;
4807
- const targetPath = resolve14(pagesPath, "posts", postFilePath);
4808
- if (!await fs25.exists(targetPath)) {
4809
- await fs25.ensureDir(dirname5(targetPath));
4790
+ const targetPath = resolve13(pagesPath, "posts", postFilePath);
4791
+ if (!await fs24.exists(targetPath)) {
4792
+ await fs24.ensureDir(dirname5(targetPath));
4810
4793
  const content = await genLayoutTemplate(params);
4811
4794
  try {
4812
- await fs25.writeFile(targetPath, content, "utf-8");
4813
- consola19.success(`[valaxy new]: successfully generated file ${colors17.magenta(targetPath)}`);
4795
+ await fs24.writeFile(targetPath, content, "utf-8");
4796
+ consola18.success(`[valaxy new]: successfully generated file ${colors18.magenta(targetPath)}`);
4814
4797
  } catch (e) {
4815
4798
  console.log(e);
4816
- consola19.error(`[valaxy new]: failed to write file ${targetPath}`);
4817
- consola19.warn(`You should run ${colors17.green("valaxy new")} in your valaxy project root directory.`);
4799
+ consola18.error(`[valaxy new]: failed to write file ${targetPath}`);
4800
+ consola18.warn(`You should run ${colors18.green("valaxy new")} in your valaxy project root directory.`);
4818
4801
  }
4819
4802
  return targetPath;
4820
4803
  }
@@ -4875,7 +4858,7 @@ function registerNewCommand(cli2) {
4875
4858
  }
4876
4859
 
4877
4860
  // node/cli/index.ts
4878
- var cli = yargs(hideBin(process15.argv)).scriptName("valaxy").usage("$0 [args]").version(version).showHelpOnFail(false).alias("h", "help").alias("v", "version");
4861
+ var cli = yargs(hideBin(process16.argv)).scriptName("valaxy").usage("$0 [args]").version(version).showHelpOnFail(false).alias("h", "help").alias("v", "version");
4879
4862
  registerDevCommand(cli);
4880
4863
  registerBuildCommand(cli);
4881
4864
  registerNewCommand(cli);
@@ -4911,7 +4894,6 @@ export {
4911
4894
  resolveImportPath,
4912
4895
  mergeViteConfigs,
4913
4896
  getIndexHtml,
4914
- loadConfig,
4915
4897
  loadConfigFromFile,
4916
4898
  defaultSiteConfig,
4917
4899
  defineSiteConfig,
@@ -4940,6 +4922,7 @@ export {
4940
4922
  ssgBuild,
4941
4923
  postProcessForSSG,
4942
4924
  generateClientRedirects,
4925
+ GLOBAL_STATE,
4943
4926
  getServerInfoText,
4944
4927
  createServer,
4945
4928
  startValaxyDev,