valaxy 1.0.1 → 1.2.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.
Files changed (45) hide show
  1. package/client/components/ValaxyCopyright.vue +2 -1
  2. package/client/components/ValaxyCover.vue +92 -0
  3. package/client/components/ValaxyFootnoteTooltip.vue +6 -14
  4. package/client/components/ValaxySvgExport.vue +71 -0
  5. package/client/components/footnote/FootnotePopover.vue +146 -0
  6. package/client/components/footnote/LegacyFootnoteTooltip.vue +25 -0
  7. package/client/composables/collections.ts +13 -9
  8. package/client/composables/decrypt.ts +8 -1
  9. package/client/composables/outline/anchor.ts +20 -8
  10. package/client/composables/post/filter.ts +38 -0
  11. package/client/composables/post/index.ts +2 -34
  12. package/client/index.d.ts +0 -1
  13. package/client/layouts/README.md +1 -1
  14. package/client/locales/en.yml +2 -0
  15. package/client/locales/zh-CN.yml +2 -0
  16. package/client/main.ts +35 -20
  17. package/client/modules/valaxy.ts +14 -5
  18. package/client/shims.d.ts +27 -0
  19. package/client/utils/index.ts +1 -0
  20. package/client/utils/layouts.ts +359 -0
  21. package/client/utils/path.ts +30 -0
  22. package/client/utils/svg.ts +104 -0
  23. package/dist/node/cli/index.mjs +4 -11
  24. package/dist/node/index.d.mts +71 -46
  25. package/dist/node/index.mjs +4 -11
  26. package/dist/shared/{valaxy.CjaAzLmd.d.mts → valaxy.BGgY-Hwl.d.mts} +28 -3
  27. package/dist/shared/{valaxy.DstXQBtK.mjs → valaxy.CRodiDWz.mjs} +402 -1811
  28. package/dist/types/index.d.mts +2 -2
  29. package/package.json +9 -15
  30. package/types/config.ts +12 -1
  31. package/types/frontmatter/page.ts +9 -2
  32. package/types/vue-router.d.ts +8 -0
  33. package/vendor/README.md +8 -8
  34. package/vendor/sources.json +0 -31
  35. package/vendor/i18n/LICENSE +0 -20
  36. package/vendor/i18n/index.d.mts +0 -7
  37. package/vendor/i18n/index.mjs +0 -1389
  38. package/vendor/i18n/types.d.ts +0 -48
  39. package/vendor/layouts/LICENSE +0 -21
  40. package/vendor/layouts/client.d.ts +0 -11
  41. package/vendor/layouts/index.d.mts +0 -86
  42. package/vendor/layouts/index.mjs +0 -235
  43. package/vendor/layouts/layoutName-DVkP7Qpo.mjs +0 -82
  44. package/vendor/layouts/runtime.d.mts +0 -72
  45. package/vendor/layouts/runtime.mjs +0 -284
@@ -1,5 +1,5 @@
1
- import path, { resolve, basename, dirname, relative as relative$1, join, isAbsolute as isAbsolute$1, parse, posix } from 'node:path';
2
- import process$1 from 'node:process';
1
+ import path, { resolve, basename, dirname, relative as relative$1, join, isAbsolute as isAbsolute$1, parse } from 'node:path';
2
+ import process from 'node:process';
3
3
  import yargs from 'yargs';
4
4
  import { hideBin } from 'yargs/helpers';
5
5
  import os from 'node:os';
@@ -10,20 +10,21 @@ import matter from 'gray-matter';
10
10
  import { glob, globSync } from 'tinyglobby';
11
11
  import * as yaml from 'js-yaml';
12
12
  import { dump, load, CORE_SCHEMA } from 'js-yaml';
13
- import { isFunction, ensurePrefix, slash as slash$2, uniq, ensureSuffix, isObject } from '@antfu/utils';
14
- import createDebug from 'debug';
15
- import path$1, { resolve as resolve$1, relative, isAbsolute, parse as parse$1, dirname as dirname$1, normalize, join as join$1 } from 'pathe';
13
+ import { isFunction, ensurePrefix, slash as slash$1, uniq, ensureSuffix, isObject } from '@antfu/utils';
14
+ import _debug from 'debug';
15
+ import path$1, { resolve as resolve$1, relative, isAbsolute, normalize, join as join$1, basename as basename$1, dirname as dirname$1 } from 'pathe';
16
16
  import defu, { createDefu } from 'defu';
17
17
  import { mergeConfig, loadConfigFromFile as loadConfigFromFile$1, searchForWorkspaceRoot, build as build$3, createServer as createServer$1 } from 'vite';
18
18
  import { webcrypto, createHash } from 'node:crypto';
19
19
  import { options } from 'floating-vue';
20
20
  import { loadConfig } from 'define-config-ts';
21
21
  import ora from 'ora';
22
+ import { Buffer as Buffer$1 } from 'node:buffer';
22
23
  import spawn$1, { spawn } from 'cross-spawn';
23
24
  import { resolvePath } from 'mlly';
24
25
  import { resolveGlobal } from 'resolve-global';
25
26
  import { normalizeRepositoryUrl } from '@valaxyjs/utils';
26
- import { existsSync, readFileSync, promises, realpathSync, statSync } from 'node:fs';
27
+ import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
27
28
  import { readFile, mkdir, writeFile, realpath, rm, stat } from 'node:fs/promises';
28
29
  import dayjs from 'dayjs';
29
30
  import { Feed } from 'feed';
@@ -37,18 +38,11 @@ import picomatch from 'picomatch';
37
38
  import chokidar from 'chokidar';
38
39
  import { createUnplugin } from 'unplugin';
39
40
  import { createFilter } from 'unplugin-utils';
40
- import { createDebug as createDebug$1 } from 'obug';
41
+ import { createDebug } from 'obug';
41
42
  import MagicString from 'magic-string';
42
- import { Buffer as Buffer$1 } from 'node:buffer';
43
43
  import pMap from 'p-map';
44
- import { isArray, isString, isBoolean, assign, isEmptyObject, isNumber, generateCodeFrame } from '@intlify/shared';
45
- import { generateJSON, generateYAML, generateJavaScript, generateTypescript } from '@intlify/bundle-utils';
46
- import { createFilter as createFilter$1 } from '@rollup/pluginutils';
47
- import { parse as parse$2, babelParse } from 'vue/compiler-sfc';
48
- import pc from 'picocolors';
49
- import eslintUitls from '@eslint-community/eslint-utils';
50
- import { transformVTDirective } from '@intlify/vue-i18n-extensions';
51
- import { analyze } from '@typescript-eslint/scope-manager';
44
+ import pascalCase$1 from 'pascalcase';
45
+ import VueI18n from '@intlify/unplugin-vue-i18n/vite';
52
46
  import MiniSearch from 'minisearch';
53
47
  import { transformerNotationDiff, transformerNotationFocus, transformerNotationHighlight, transformerNotationErrorLevel, transformerCompactLineOptions } from '@shikijs/transformers';
54
48
  import { LRUCache } from 'lru-cache';
@@ -67,12 +61,11 @@ import 'katex/contrib/mhchem';
67
61
  import Markdown from 'unplugin-vue-markdown/vite';
68
62
  import { createJiti } from 'jiti';
69
63
  import { transformerDirectives, transformerVariantGroup, presetWind4, presetAttributify, presetIcons, presetTypography } from 'unocss';
70
- import pascalCase$1 from 'pascalcase';
71
64
  import { convert } from 'html-to-text';
72
65
  import VueRouter from 'vue-router/vite';
73
66
  import generateSitemap from 'vite-ssg-sitemap';
74
67
  import { renderSSRHead } from '@unhead/vue/server';
75
- import { createRoutesContext, resolveOptions as resolveOptions$4 } from 'vue-router/unplugin';
68
+ import { createRoutesContext, resolveOptions as resolveOptions$2 } from 'vue-router/unplugin';
76
69
  import { execSync, exec } from 'node:child_process';
77
70
  import { intro, confirm, isCancel, cancel, select, outro } from '@clack/prompts';
78
71
  import net from 'node:net';
@@ -80,7 +73,7 @@ import * as readline from 'node:readline';
80
73
  import qrcode from 'qrcode';
81
74
  import ejs from 'ejs';
82
75
 
83
- const version = "1.0.1";
76
+ const version = "1.2.0";
84
77
 
85
78
  const GLOBAL_STATE = {
86
79
  valaxyApp: void 0,
@@ -294,7 +287,7 @@ const replaceArrMerge = createDefu((obj, key, value) => {
294
287
  async function loadConfigFromFile(name, options = {}) {
295
288
  const { config, configFile } = await loadConfig({
296
289
  name,
297
- cwd: options.cwd || process$1.cwd(),
290
+ cwd: options.cwd || process.cwd(),
298
291
  throwOnNotFound: false
299
292
  });
300
293
  let userConfig = config;
@@ -377,6 +370,9 @@ const defaultSiteConfig = {
377
370
  options: {}
378
371
  },
379
372
  floatingVue: options,
373
+ footnote: {
374
+ preview: "reka"
375
+ },
380
376
  statistics: {
381
377
  enable: false,
382
378
  readTime: {
@@ -408,6 +404,13 @@ const defaultSiteConfig = {
408
404
  function defineSiteConfig(config) {
409
405
  return config;
410
406
  }
407
+ function resolveFootnoteConfig(config = {}) {
408
+ const preview = config.footnote?.preview;
409
+ if (config.floatingVue != null) {
410
+ consola.warn(preview === "reka" ? "[Valaxy] siteConfig.floatingVue only configures legacy Floating Vue APIs; Reka footnotes use .va-footnote-popover styles." : "[Valaxy] siteConfig.floatingVue is deprecated for footnotes. Keeping the legacy preview; migrate with footnote: { preview: 'reka' }. See https://valaxy.site/guide/markdown#footnote-preview");
411
+ }
412
+ return { preview: preview ?? (config.floatingVue != null ? "floating-vue" : "reka") };
413
+ }
411
414
  async function resolveSiteConfigFromRoot(root) {
412
415
  return loadConfigFromFile("site", {
413
416
  cwd: root
@@ -534,7 +537,7 @@ const mergeValaxyConfig = createDefu((obj, key, value) => {
534
537
  }
535
538
  });
536
539
  async function resolveValaxyConfig(options) {
537
- const configRoot = options.userRoot || process$1.cwd();
540
+ const configRoot = options.userRoot || process.cwd();
538
541
  const endCount = countPerformanceTime();
539
542
  const { config: userValaxyConfig, configFile } = await resolveValaxyConfigFromRoot(configRoot);
540
543
  const duration = endCount();
@@ -645,13 +648,6 @@ function getCryptoDeriveKey(keyMaterial, salt) {
645
648
  ["encrypt", "decrypt"]
646
649
  );
647
650
  }
648
- function bytesToBinaryString(bytes) {
649
- const CHUNK_SIZE = 32768;
650
- const chunks = [];
651
- for (let i = 0; i < bytes.length; i += CHUNK_SIZE)
652
- chunks.push(String.fromCharCode.apply(null, bytes.subarray(i, i + CHUNK_SIZE)));
653
- return chunks.join("");
654
- }
655
651
  async function encryptContent(content, options) {
656
652
  const { password, iv, salt } = options;
657
653
  const keyMaterial = await getKeyMaterial(password);
@@ -665,7 +661,7 @@ async function encryptContent(content, options) {
665
661
  key,
666
662
  enc.encode(content)
667
663
  );
668
- return bytesToBinaryString(new Uint8Array(ciphertextData));
664
+ return Buffer$1.from(ciphertextData).toString("base64");
669
665
  }
670
666
 
671
667
  function getGitTimestamp(file, type = "updated") {
@@ -709,7 +705,7 @@ async function resolveImportUrl(id) {
709
705
  return toAtFS(await resolveImportPath(id, true));
710
706
  }
711
707
  function toAtFS(path) {
712
- return `/@fs${ensurePrefix("/", slash$2(path))}`;
708
+ return `/@fs${ensurePrefix("/", slash$1(path))}`;
713
709
  }
714
710
  async function resolveImportPath(importName, ensure = false) {
715
711
  try {
@@ -746,7 +742,7 @@ async function getModuleRoot(name, entry) {
746
742
  }
747
743
  }
748
744
 
749
- async function parseAddons(addons, userRoot = process$1.cwd()) {
745
+ async function parseAddons(addons, userRoot = process.cwd()) {
750
746
  const spinner = ora(`Resolve ${colors.cyan("addons")} from ${colors.dim(userRoot)}`).start();
751
747
  const resolvers = {};
752
748
  const mergeResolver = (resolver) => {
@@ -784,7 +780,7 @@ async function parseAddons(addons, userRoot = process$1.cwd()) {
784
780
  return resolvedAddons;
785
781
  }
786
782
  async function readAddonModule(name, options = {}) {
787
- const root = await getAddonRoot(name, options.cwd || process$1.cwd());
783
+ const root = await getAddonRoot(name, options.cwd || process.cwd());
788
784
  const packageJSONPath = resolve$1(root, "./package.json");
789
785
  if (!await fs.exists(packageJSONPath)) {
790
786
  logger.error(`No addon named ${name} found`);
@@ -857,7 +853,7 @@ async function getThemeRoot(name, entry) {
857
853
  return await getModuleRoot(themeModule, entry);
858
854
  }
859
855
 
860
- const debug$8 = createDebug("valaxy:options");
856
+ const debug$6 = _debug("valaxy:options");
861
857
  async function processSiteConfig(options) {
862
858
  const { config, themeRoot, theme } = options;
863
859
  const siteConfig = config.siteConfig;
@@ -899,6 +895,7 @@ async function processValaxyOptions(valaxyOptions, valaxyConfig) {
899
895
  }
900
896
  };
901
897
  const config = replaceArrMerge(valaxyConfig, defaultValaxyConfig);
898
+ config.siteConfig.footnote = resolveFootnoteConfig(valaxyConfig.siteConfig);
902
899
  valaxyOptions.config = {
903
900
  ...config,
904
901
  runtimeConfig: {
@@ -929,10 +926,10 @@ async function processValaxyOptions(valaxyOptions, valaxyConfig) {
929
926
  consola.debug(` \u2514\u2500 processSiteConfig: ${siteConfigTimer()}`);
930
927
  return valaxyOptions;
931
928
  }
932
- async function resolveOptions$3(options = { userRoot: process$1.cwd() }, mode = "dev") {
929
+ async function resolveOptions$1(options = { userRoot: process.cwd() }, mode = "dev") {
933
930
  const pkgRoot = dirname(await resolveImportPath("valaxy/package.json", true));
934
931
  const clientRoot = resolve$1(pkgRoot, "client");
935
- const userRoot = resolve$1(options.userRoot || process$1.cwd());
932
+ const userRoot = resolve$1(options.userRoot || process.cwd());
936
933
  consola.start(`Resolve ${colors.magenta("valaxy")} config ...`);
937
934
  const configTimer = countPerformanceTime();
938
935
  const [resolvedValaxy, resolvedSite, resolvedTheme, pages] = await Promise.all([
@@ -988,7 +985,7 @@ async function resolveOptions$3(options = { userRoot: process$1.cwd() }, mode =
988
985
  links: []
989
986
  }
990
987
  };
991
- debug$8(valaxyOptions);
988
+ debug$6(valaxyOptions);
992
989
  const themeValaxyConfig = await resolveThemeValaxyConfig(valaxyOptions);
993
990
  const valaxyConfig = mergeValaxyConfig(userValaxyConfig, themeValaxyConfig);
994
991
  const processTimer = countPerformanceTime();
@@ -1056,10 +1053,10 @@ const matterOptions = {
1056
1053
  };
1057
1054
 
1058
1055
  function isProd() {
1059
- return process$1.env.NODE_ENV === "production";
1056
+ return process.env.NODE_ENV === "production";
1060
1057
  }
1061
1058
  function setEnv(env = "development") {
1062
- process$1.env.NODE_ENV = env;
1059
+ process.env.NODE_ENV = env;
1063
1060
  consola.level = isProd() ? 2 : 3;
1064
1061
  logger.level = consola.level;
1065
1062
  }
@@ -1067,7 +1064,7 @@ function setEnvProd() {
1067
1064
  return setEnv("production");
1068
1065
  }
1069
1066
  function setTimezone(timezone) {
1070
- process$1.env.TZ = timezone;
1067
+ process.env.TZ = timezone;
1071
1068
  }
1072
1069
  async function isPagesDirExist(root) {
1073
1070
  const exist = await fs.exists(path.resolve(root, "pages"));
@@ -1203,7 +1200,7 @@ function registerFuseCommand(cli) {
1203
1200
  (args) => commonOptions(args).strict().help(),
1204
1201
  async ({ root }) => {
1205
1202
  setEnvProd();
1206
- const options = await resolveOptions$3({ userRoot: root }, "build");
1203
+ const options = await resolveOptions$1({ userRoot: root }, "build");
1207
1204
  await execFuse(options);
1208
1205
  }
1209
1206
  );
@@ -1451,7 +1448,7 @@ const llmsModule = defineValaxyModule({
1451
1448
  (args) => commonOptions(args).strict().help(),
1452
1449
  async ({ root }) => {
1453
1450
  setEnvProd();
1454
- const options = await resolveOptions$3({ userRoot: root }, "build");
1451
+ const options = await resolveOptions$1({ userRoot: root }, "build");
1455
1452
  await build$2(options);
1456
1453
  }
1457
1454
  );
@@ -1464,11 +1461,21 @@ const llmsModule = defineValaxyModule({
1464
1461
  }
1465
1462
  });
1466
1463
 
1464
+ async function statIfExists(file) {
1465
+ try {
1466
+ return await fs.stat(file);
1467
+ } catch (e) {
1468
+ const code = e.code;
1469
+ if (code === "ENOENT" || code === "ENOTDIR")
1470
+ return void 0;
1471
+ throw e;
1472
+ }
1473
+ }
1467
1474
  async function getCreatedTime(file) {
1468
- return await getGitTimestamp(file, "created") || (await fs.stat(file)).ctime;
1475
+ return await getGitTimestamp(file, "created") || (await statIfExists(file))?.ctime || Date.now();
1469
1476
  }
1470
1477
  async function getUpdatedTime(file) {
1471
- return await getGitTimestamp(file, "updated") || (await fs.stat(file)).mtime;
1478
+ return await getGitTimestamp(file, "updated") || (await statIfExists(file))?.mtime || Date.now();
1472
1479
  }
1473
1480
 
1474
1481
  const markdown = createMarkdownExit({
@@ -1731,7 +1738,7 @@ const rssModule = defineValaxyModule({
1731
1738
  (args) => commonOptions(args).strict().help(),
1732
1739
  async ({ root }) => {
1733
1740
  setEnvProd();
1734
- const options = await resolveOptions$3({ userRoot: root }, "build");
1741
+ const options = await resolveOptions$1({ userRoot: root }, "build");
1735
1742
  await build$1(options);
1736
1743
  }
1737
1744
  );
@@ -2036,7 +2043,7 @@ function toArray(array) {
2036
2043
  function notNullish(v) {
2037
2044
  return v != null;
2038
2045
  }
2039
- function slash$1(str) {
2046
+ function slash(str) {
2040
2047
  return str.replace(/\\/g, "/");
2041
2048
  }
2042
2049
  function throttle$1(delay, callback, options) {
@@ -2079,7 +2086,7 @@ function throttle(...args) {
2079
2086
  return throttle$1(...args);
2080
2087
  }
2081
2088
  const DISABLE_COMMENT = "/* unplugin-vue-components disabled */";
2082
- Boolean(process$1.env.SSR || process$1.env.SSG || process$1.env.VITE_SSR || process$1.env.VITE_SSG);
2089
+ Boolean(process.env.SSR || process.env.SSG || process.env.VITE_SSR || process.env.VITE_SSG);
2083
2090
  function pascalCase(str) {
2084
2091
  return capitalize(camelCase(str));
2085
2092
  }
@@ -2110,7 +2117,7 @@ function isEmpty(value) {
2110
2117
  function matchGlobs(filepath, globs) {
2111
2118
  for (const glob of globs) {
2112
2119
  const isNegated = glob[0] === "!";
2113
- if (picomatch(isNegated ? glob.slice(1) : glob)(slash$1(filepath))) return !isNegated;
2120
+ if (picomatch(isNegated ? glob.slice(1) : glob)(slash(filepath))) return !isNegated;
2114
2121
  }
2115
2122
  return false;
2116
2123
  }
@@ -2148,7 +2155,7 @@ function stringifyComponentImport({ as: name, from: path, name: importName, side
2148
2155
  }
2149
2156
  function getNameFromFilePath(filePath, options) {
2150
2157
  const { resolvedDirs, directoryAsNamespace, globalNamespaces, collapseSamePrefixes, root } = options;
2151
- const parsedFilePath = parse(slash$1(filePath));
2158
+ const parsedFilePath = parse(slash(filePath));
2152
2159
  let strippedPath = "";
2153
2160
  for (const dir of resolvedDirs) if (parsedFilePath.dir.startsWith(dir)) {
2154
2161
  strippedPath = parsedFilePath.dir.slice(dir.length);
@@ -2253,7 +2260,7 @@ function parseDeclaration(code) {
2253
2260
  function stringifyComponentInfo(filepath, { from: path, as: name, name: importName }, importPathTransform) {
2254
2261
  if (!name) return void 0;
2255
2262
  path = getTransformedPath(path, importPathTransform);
2256
- return [name, `typeof import('${slash$1(isAbsolute$1(path) ? `./${relative$1(dirname(filepath), path)}` : path)}')['${importName || "default"}']`];
2263
+ return [name, `typeof import('${slash(isAbsolute$1(path) ? `./${relative$1(dirname(filepath), path)}` : path)}')['${importName || "default"}']`];
2257
2264
  }
2258
2265
  function stringifyComponentsInfo(filepath, components, importPathTransform) {
2259
2266
  return Object.fromEntries(components.map((info) => stringifyComponentInfo(filepath, info, importPathTransform)).filter(notNullish));
@@ -2342,9 +2349,9 @@ async function writeComponentsJson(ctx, _removeUnused = false) {
2342
2349
  })), ...resolveTypeImports(ctx.options.types)];
2343
2350
  await writeFile$1(ctx.dumpComponentsInfoPath, JSON.stringify(components, null, 2));
2344
2351
  }
2345
- const debug$4$1 = createDebug$1("unplugin-vue-components:glob");
2352
+ const debug$4 = createDebug("unplugin-vue-components:glob");
2346
2353
  function searchComponents(ctx) {
2347
- debug$4$1(`started with: [${ctx.options.globs.join(", ")}]`);
2354
+ debug$4(`started with: [${ctx.options.globs.join(", ")}]`);
2348
2355
  const root = ctx.root;
2349
2356
  const files = globSync(ctx.options.globs, {
2350
2357
  ignore: ctx.options.globsExclude,
@@ -2354,7 +2361,7 @@ function searchComponents(ctx) {
2354
2361
  expandDirectories: false
2355
2362
  });
2356
2363
  if (!files.length && !ctx.options.resolvers?.length) console.warn("[unplugin-vue-components] no components found");
2357
- debug$4$1(`${files.length} components found.`);
2364
+ debug$4(`${files.length} components found.`);
2358
2365
  ctx.addComponents(files);
2359
2366
  }
2360
2367
  const defaultOptions = {
@@ -2383,9 +2390,9 @@ function normalizeResolvers(resolvers) {
2383
2390
  }
2384
2391
  function resolveGlobsExclude(root, glob2) {
2385
2392
  const excludeReg = /^!/;
2386
- return slash$1(`${excludeReg.test(glob2) ? "!" : ""}${resolve(root, glob2.replace(excludeReg, ""))}`);
2393
+ return slash(`${excludeReg.test(glob2) ? "!" : ""}${resolve(root, glob2.replace(excludeReg, ""))}`);
2387
2394
  }
2388
- function resolveOptions$2(options, root) {
2395
+ function resolveOptions(options, root) {
2389
2396
  const resolved = Object.assign({}, defaultOptions, options);
2390
2397
  resolved.resolvers = normalizeResolvers(resolved.resolvers);
2391
2398
  resolved.extensions = toArray(resolved.extensions);
@@ -2403,7 +2410,7 @@ function resolveOptions$2(options, root) {
2403
2410
  prefix = "!";
2404
2411
  i = i.slice(1);
2405
2412
  }
2406
- return resolved.deep ? prefix + escapeSpecialChars(slash$1(join(i, `**/*.${extsGlob}`))) : prefix + escapeSpecialChars(slash$1(join(i, `*.${extsGlob}`)));
2413
+ return resolved.deep ? prefix + escapeSpecialChars(slash(join(i, `**/*.${extsGlob}`))) : prefix + escapeSpecialChars(slash(join(i, `*.${extsGlob}`)));
2407
2414
  });
2408
2415
  if (!resolved.extensions.length) throw new Error("[unplugin-vue-components] `extensions` option is required to search for components");
2409
2416
  }
@@ -2420,7 +2427,7 @@ function resolveOptions$2(options, root) {
2420
2427
  resolved.directives ??= resolved.resolvers.some((i) => i.type === "directive");
2421
2428
  return resolved;
2422
2429
  }
2423
- const debug$3$1 = createDebug$1("unplugin-vue-components:transform:component");
2430
+ const debug$3 = createDebug("unplugin-vue-components:transform:component");
2424
2431
  function resolveVue3$1(code, s, transformerUserResolveFunctions) {
2425
2432
  const results = [];
2426
2433
  for (const match of code.matchAll(/_?resolveComponent\d*\("(.+?)"\)/g)) {
@@ -2441,7 +2448,7 @@ async function transformComponent(code, s, ctx, sfcPath) {
2441
2448
  let no = 0;
2442
2449
  const results = resolveVue3$1(code, s, ctx.options.transformerUserResolveFunctions);
2443
2450
  for (const { rawName, replace } of results) {
2444
- debug$3$1(`| ${rawName}`);
2451
+ debug$3(`| ${rawName}`);
2445
2452
  const name = pascalCase(rawName);
2446
2453
  ctx.updateUsageMap(sfcPath, [name]);
2447
2454
  const component = await ctx.findComponent(name, "component", [sfcPath]);
@@ -2456,9 +2463,9 @@ async function transformComponent(code, s, ctx, sfcPath) {
2456
2463
  replace(varName);
2457
2464
  }
2458
2465
  }
2459
- debug$3$1(`^ (${no})`);
2466
+ debug$3(`^ (${no})`);
2460
2467
  }
2461
- const debug$2$1 = createDebug$1("unplugin-vue-components:transform:directive");
2468
+ const debug$2$1 = createDebug("unplugin-vue-components:transform:directive");
2462
2469
  async function transformDirective(code, s, ctx, sfcPath) {
2463
2470
  let no = 0;
2464
2471
  const results = resolveVue3(code, s, ctx.options.transformerUserResolveFunctions);
@@ -2495,12 +2502,12 @@ function resolveVue3(code, s, transformerUserResolveFunctions) {
2495
2502
  }
2496
2503
  return results;
2497
2504
  }
2498
- const debug$1$2 = createDebug$1("unplugin-vue-components:transformer");
2505
+ const debug$1$1 = createDebug("unplugin-vue-components:transformer");
2499
2506
  function transformer(ctx) {
2500
2507
  return async (code, id, path) => {
2501
2508
  ctx.searchGlob();
2502
2509
  const sfcPath = ctx.normalizePath(path);
2503
- debug$1$2(sfcPath);
2510
+ debug$1$1(sfcPath);
2504
2511
  const s = new MagicString(code);
2505
2512
  await transformComponent(code, s, ctx, sfcPath);
2506
2513
  if (ctx.options.directives) await transformDirective(code, s, ctx, sfcPath);
@@ -2514,12 +2521,12 @@ function transformer(ctx) {
2514
2521
  return result;
2515
2522
  };
2516
2523
  }
2517
- const debug$7 = {
2518
- components: createDebug$1("unplugin-vue-components:context:components"),
2519
- search: createDebug$1("unplugin-vue-components:context:search"),
2520
- hmr: createDebug$1("unplugin-vue-components:context:hmr"),
2521
- declaration: createDebug$1("unplugin-vue-components:declaration"),
2522
- env: createDebug$1("unplugin-vue-components:env")
2524
+ const debug$5 = {
2525
+ components: createDebug("unplugin-vue-components:context:components"),
2526
+ search: createDebug("unplugin-vue-components:context:search"),
2527
+ hmr: createDebug("unplugin-vue-components:context:hmr"),
2528
+ declaration: createDebug("unplugin-vue-components:declaration"),
2529
+ env: createDebug("unplugin-vue-components:env")
2523
2530
  };
2524
2531
  var Context = class {
2525
2532
  rawOptions;
@@ -2532,13 +2539,13 @@ var Context = class {
2532
2539
  _directiveCustomMap = {};
2533
2540
  _removeUnused = false;
2534
2541
  _server;
2535
- root = process$1.cwd();
2542
+ root = process.cwd();
2536
2543
  sourcemap = true;
2537
2544
  alias = {};
2538
2545
  dumpComponentsInfoPath;
2539
2546
  constructor(rawOptions) {
2540
2547
  this.rawOptions = rawOptions;
2541
- this.options = resolveOptions$2(rawOptions, this.root);
2548
+ this.options = resolveOptions(rawOptions, this.root);
2542
2549
  this.sourcemap = rawOptions.sourcemap ?? true;
2543
2550
  this.generateDeclaration = throttle(500, this._generateDeclaration.bind(this), { noLeading: false });
2544
2551
  this._removeUnused = this.options.syncMode !== "append";
@@ -2551,9 +2558,9 @@ var Context = class {
2551
2558
  }
2552
2559
  setRoot(root) {
2553
2560
  if (this.root === root) return;
2554
- debug$7.env("root", root);
2561
+ debug$5.env("root", root);
2555
2562
  this.root = root;
2556
- this.options = resolveOptions$2(this.rawOptions, this.root);
2563
+ this.options = resolveOptions(this.rawOptions, this.root);
2557
2564
  }
2558
2565
  transform(code, id) {
2559
2566
  const { path, query } = parseId(id);
@@ -2570,13 +2577,13 @@ var Context = class {
2570
2577
  this._removeUnused = this.options.syncMode === "overwrite";
2571
2578
  watcher.on("unlink", (path) => {
2572
2579
  if (!matchGlobs(path, globs)) return;
2573
- path = slash$1(path);
2580
+ path = slash(path);
2574
2581
  this.removeComponents(path);
2575
2582
  this.onUpdate(path);
2576
2583
  });
2577
2584
  watcher.on("add", (path) => {
2578
2585
  if (!matchGlobs(path, globs)) return;
2579
- path = slash$1(path);
2586
+ path = slash(path);
2580
2587
  this.addComponents(path);
2581
2588
  this.onUpdate(path);
2582
2589
  });
@@ -2589,13 +2596,13 @@ var Context = class {
2589
2596
  this._removeUnused = this.options.syncMode === "overwrite";
2590
2597
  watcher.on("unlink", (path) => {
2591
2598
  if (!matchGlobs(path, globs)) return;
2592
- path = slash$1(path);
2599
+ path = slash(path);
2593
2600
  this.removeComponents(path);
2594
2601
  emitUpdate(path, "unlink");
2595
2602
  });
2596
2603
  watcher.on("add", (path) => {
2597
2604
  if (!matchGlobs(path, globs)) return;
2598
- path = slash$1(path);
2605
+ path = slash(path);
2599
2606
  this.addComponents(path);
2600
2607
  emitUpdate(path, "add");
2601
2608
  });
@@ -2612,7 +2619,7 @@ var Context = class {
2612
2619
  });
2613
2620
  }
2614
2621
  addComponents(paths) {
2615
- debug$7.components("add", paths);
2622
+ debug$5.components("add", paths);
2616
2623
  const size = this._componentPaths.size;
2617
2624
  toArray(paths).forEach((p) => this._componentPaths.add(p));
2618
2625
  if (this._componentPaths.size !== size) {
@@ -2628,7 +2635,7 @@ var Context = class {
2628
2635
  if (info.as) this._directiveCustomMap[info.as] = info;
2629
2636
  }
2630
2637
  removeComponents(paths) {
2631
- debug$7.components("remove", paths);
2638
+ debug$5.components("remove", paths);
2632
2639
  const size = this._componentPaths.size;
2633
2640
  toArray(paths).forEach((p) => this._componentPaths.delete(p));
2634
2641
  if (this._componentPaths.size !== size) {
@@ -2649,7 +2656,7 @@ var Context = class {
2649
2656
  const name = pascalCase(getNameFromFilePath(path, this.options));
2650
2657
  Object.entries(this._componentUsageMap).forEach(([key, values]) => {
2651
2658
  if (values.has(name)) {
2652
- const r = `/${slash$1(relative$1(this.root, key))}`;
2659
+ const r = `/${slash(relative$1(this.root, key))}`;
2653
2660
  payload.updates.push({
2654
2661
  acceptedPath: r,
2655
2662
  path: r,
@@ -2668,7 +2675,7 @@ var Context = class {
2668
2675
  const fileName = getNameFromFilePath(path, this.options);
2669
2676
  const name = this.options.prefix ? `${pascalCase(this.options.prefix)}${pascalCase(fileName)}` : pascalCase(fileName);
2670
2677
  if (isExclude(name, this.options.excludeNames)) {
2671
- debug$7.components("exclude", name);
2678
+ debug$5.components("exclude", name);
2672
2679
  return;
2673
2680
  }
2674
2681
  if (this._componentNameMap[name] && !this.options.allowOverrides) {
@@ -2705,8 +2712,8 @@ var Context = class {
2705
2712
  return resolveAlias(path, this.viteConfig?.resolve?.alias || this.viteConfig?.alias || []);
2706
2713
  }
2707
2714
  relative(path) {
2708
- if (path.startsWith("/") && !path.startsWith(this.root)) return slash$1(path.slice(1));
2709
- return slash$1(relative$1(this.root, path));
2715
+ if (path.startsWith("/") && !path.startsWith(this.root)) return slash(path.slice(1));
2716
+ return slash(relative$1(this.root, path));
2710
2717
  }
2711
2718
  _searched = false;
2712
2719
  /**
@@ -2717,12 +2724,12 @@ var Context = class {
2717
2724
  searchGlob() {
2718
2725
  if (this._searched) return;
2719
2726
  searchComponents(this);
2720
- debug$7.search(this._componentNameMap);
2727
+ debug$5.search(this._componentNameMap);
2721
2728
  this._searched = true;
2722
2729
  }
2723
2730
  _generateDeclaration(removeUnused = this._removeUnused) {
2724
2731
  if (!this.options.dts) return;
2725
- debug$7.declaration("generating dts");
2732
+ debug$5.declaration("generating dts");
2726
2733
  return writeDeclaration(this, this.options.dts, removeUnused);
2727
2734
  }
2728
2735
  generateDeclaration(removeUnused = this._removeUnused) {
@@ -2730,7 +2737,7 @@ var Context = class {
2730
2737
  }
2731
2738
  _generateComponentsJson(removeUnused = this._removeUnused) {
2732
2739
  if (!Object.keys(this._componentNameMap).length) return;
2733
- debug$7.components("generating components-info");
2740
+ debug$5.components("generating components-info");
2734
2741
  return writeComponentsJson(this, removeUnused);
2735
2742
  }
2736
2743
  generateComponentsJson(removeUnused = this._removeUnused) {
@@ -2812,7 +2819,7 @@ var unplugin_default = createUnplugin((options = {}) => {
2812
2819
  path,
2813
2820
  type
2814
2821
  });
2815
- process$1.nextTick(() => {
2822
+ process.nextTick(() => {
2816
2823
  watcher.invalidate();
2817
2824
  });
2818
2825
  });
@@ -2833,300 +2840,6 @@ var unplugin_default = createUnplugin((options = {}) => {
2833
2840
 
2834
2841
  const Components = unplugin_default.vite;
2835
2842
 
2836
- const REGEX_BACKSLASH$1 = /\\/g;
2837
- const REGEX_SEPARATORS = /[-_/.\s]+/g;
2838
- const REGEX_NON_ALPHANUMERIC = /[^a-z0-9-]+/gi;
2839
- const REGEX_REPEATED_DASH = /-+/g;
2840
- const REGEX_EDGE_DASH = /^-|-$/g;
2841
- const REGEX_NUMBER = /\d/;
2842
- function isUppercase(char = "") {
2843
- if (REGEX_NUMBER.test(char)) return void 0;
2844
- return char !== char.toLowerCase();
2845
- }
2846
- function caseBoundary(previousUpper, isUpper, buffer) {
2847
- if (previousUpper === false && isUpper === true) return "before";
2848
- if (previousUpper === true && isUpper === false && buffer.length > 1) return "after";
2849
- }
2850
- function splitByCase(value) {
2851
- const parts = [];
2852
- let buffer = "";
2853
- let previousUpper;
2854
- let previousSplitter;
2855
- const flush = () => {
2856
- if (buffer) parts.push(buffer);
2857
- };
2858
- for (const char of value) {
2859
- const isSplitter = REGEX_SEPARATORS.test(char);
2860
- REGEX_SEPARATORS.lastIndex = 0;
2861
- if (isSplitter) {
2862
- flush();
2863
- buffer = "";
2864
- previousUpper = void 0;
2865
- previousSplitter = true;
2866
- continue;
2867
- }
2868
- const isUpper = isUppercase(char);
2869
- const boundary = previousSplitter === false ? caseBoundary(previousUpper, isUpper, buffer) : void 0;
2870
- if (boundary === "before") {
2871
- flush();
2872
- buffer = char;
2873
- } else if (boundary === "after") {
2874
- parts.push(buffer.slice(0, -1));
2875
- buffer = buffer.at(-1) + char;
2876
- } else buffer += char;
2877
- previousUpper = isUpper;
2878
- previousSplitter = false;
2879
- }
2880
- flush();
2881
- return parts;
2882
- }
2883
- function kebabCaseSegments(segments) {
2884
- return segments.map((segment) => segment.toLowerCase()).join("-").replace(REGEX_NON_ALPHANUMERIC, "-").replace(REGEX_REPEATED_DASH, "-").replace(REGEX_EDGE_DASH, "");
2885
- }
2886
- function resolveLayoutNameSegments(fileName, prefixParts) {
2887
- const fileNameParts = splitByCase(fileName);
2888
- const fileNamePartsContent = fileNameParts.join("/").toLowerCase();
2889
- const layoutNameParts = prefixParts.flatMap((part) => splitByCase(part));
2890
- const matchedSuffix = [];
2891
- let index = prefixParts.length - 1;
2892
- while (index >= 0) {
2893
- const prefixPart = prefixParts[index];
2894
- matchedSuffix.unshift(...splitByCase(prefixPart).map((part) => part.toLowerCase()));
2895
- const matchedSuffixContent = matchedSuffix.join("/");
2896
- if (fileNamePartsContent === matchedSuffixContent || fileNamePartsContent.startsWith(`${matchedSuffixContent}/`) || prefixPart.toLowerCase() === fileNamePartsContent && prefixParts[index + 1] && prefixParts[index] === prefixParts[index + 1]) layoutNameParts.length = index;
2897
- index -= 1;
2898
- }
2899
- return [...layoutNameParts, ...fileNameParts];
2900
- }
2901
- function normalizeLayoutName(file) {
2902
- const normalizedFile = file.replace(REGEX_BACKSLASH$1, "/");
2903
- const slashIndex = normalizedFile.lastIndexOf("/");
2904
- const dir = slashIndex === -1 ? "" : normalizedFile.slice(0, slashIndex);
2905
- const basename = slashIndex === -1 ? normalizedFile : normalizedFile.slice(slashIndex + 1);
2906
- const dotIndex = basename.lastIndexOf(".");
2907
- const name = dotIndex <= 0 ? basename : basename.slice(0, dotIndex);
2908
- const prefixParts = splitByCase(dir);
2909
- return kebabCaseSegments(resolveLayoutNameSegments(dir && name.toLowerCase() === "index" ? "" : name, prefixParts).filter(Boolean));
2910
- }
2911
-
2912
- const RUNTIME_ID = "valaxy/vendor/layouts/runtime.mjs";
2913
- function getClientCode(importCode, options) {
2914
- const inheritDefaultLayout = options.inheritDefaultLayout ?? true;
2915
- const fallbackArg = options.fallbackLayout ? `, '${options.fallbackLayout}'` : "";
2916
- return `
2917
- import { createGetRoutes, createLayoutWrapper, createSetupLayouts, lazyLayout, setPageLayout, useLayout } from '${RUNTIME_ID}'
2918
- export { createGetRoutes, setPageLayout, useLayout }
2919
- ${importCode}
2920
- const LayoutWrapper = createLayoutWrapper(layouts, '${options.defaultLayout}'${fallbackArg})
2921
- export const setupLayouts = createSetupLayouts(LayoutWrapper, { inheritDefaultLayout: ${inheritDefaultLayout} })
2922
- `;
2923
- }
2924
- function normalizePath$1(path) {
2925
- path = path.startsWith("/") ? path : `/${path}`;
2926
- return posix.normalize(path);
2927
- }
2928
- async function createVirtualModuleCode(options) {
2929
- const { layoutDir, defaultLayout, fallbackLayout, importMode, inheritDefaultLayout = true } = options;
2930
- const normalizedTarget = normalizePath$1(layoutDir);
2931
- const isSync = importMode === "sync";
2932
- const fallbackArg = fallbackLayout ? `, '${fallbackLayout}'` : "";
2933
- return `
2934
- import { createGetRoutes, createLayoutWrapper, createSetupLayouts, lazyLayout, normalizeLayoutName, setPageLayout, useLayout } from '${RUNTIME_ID}'
2935
- export { createGetRoutes, setPageLayout, useLayout }
2936
-
2937
- const modules = import.meta.glob("${normalizedTarget}/**/*.vue", { eager: ${isSync} })
2938
-
2939
- export const layouts = {}
2940
- Object.entries(modules).forEach(([name, module]) => {
2941
- const key = normalizeLayoutName(name.replace("${normalizedTarget}/", ''))
2942
- layouts[key] = ${isSync ? "module.default" : "lazyLayout(module)"}
2943
- })
2944
-
2945
- const LayoutWrapper = createLayoutWrapper(layouts, '${defaultLayout}'${fallbackArg})
2946
- export const setupLayouts = createSetupLayouts(LayoutWrapper, { inheritDefaultLayout: ${inheritDefaultLayout} })
2947
- `;
2948
- }
2949
- const REGEX_BACKSLASH = /\\/g;
2950
- function extensionsToGlob(extensions) {
2951
- return extensions.length > 1 ? `{${extensions.join(",")}}` : extensions[0] || "";
2952
- }
2953
- function normalizePath$2(str) {
2954
- return str.replace(REGEX_BACKSLASH, "/");
2955
- }
2956
- const debug$6 = createDebug("vite-plugin-layouts-next");
2957
- function resolveDirs(dirs, root) {
2958
- if (dirs === null) return [];
2959
- const dirsArray = Array.isArray(dirs) ? dirs : [dirs];
2960
- const dirsResolved = [];
2961
- for (const dir of dirsArray) if (dir.includes("**")) {
2962
- const matches = globSync(dir, { cwd: root, onlyDirectories: true });
2963
- for (const match of matches) dirsResolved.push(normalizePath$2(resolve(root, match)));
2964
- } else dirsResolved.push(normalizePath$2(resolve(root, dir)));
2965
- return dirsResolved;
2966
- }
2967
- async function getFilesFromPath(path, options) {
2968
- const { exclude, extensions } = options;
2969
- const ext = extensionsToGlob(extensions);
2970
- debug$6(extensions);
2971
- return await glob(`**/*.${ext}`, {
2972
- ignore: [
2973
- "node_modules",
2974
- ".git",
2975
- "**/__*__/*",
2976
- ...exclude
2977
- ],
2978
- onlyFiles: true,
2979
- cwd: path
2980
- });
2981
- }
2982
- function getImportCode(files, options) {
2983
- const imports = [];
2984
- const head = [];
2985
- let id = 0;
2986
- for (const __ of files) for (const file of __.files) {
2987
- const path = __.path.startsWith("/") ? `${__.path}/${file}` : `/${__.path}/${file}`;
2988
- const name = normalizeLayoutName(file);
2989
- if (options.importMode(name) === "sync") {
2990
- const variable = `__layout_${id}`;
2991
- head.push(`import ${variable} from '${path}'`);
2992
- imports.push(`'${name}': ${variable},`);
2993
- id += 1;
2994
- } else imports.push(`'${name}': lazyLayout(() => import('${path}')),`);
2995
- }
2996
- return `
2997
- ${head.join("\n")}
2998
- export const layouts = {
2999
- ${imports.join("\n")}
3000
- }`;
3001
- }
3002
- const MODULE_ID = "virtual:generated-layouts";
3003
- const MODULE_ID_VIRTUAL = "/@vite-plugin-vue-layouts-next/generated-layouts";
3004
- function defaultImportMode(name) {
3005
- if (process$1.env.VITE_SSG) return "sync";
3006
- return name === "default" ? "sync" : "async";
3007
- }
3008
- function resolveOptions$1(userOptions) {
3009
- return {
3010
- defaultLayout: "default",
3011
- layoutsDirs: "src/layouts",
3012
- extensions: ["vue"],
3013
- exclude: [],
3014
- importMode: defaultImportMode,
3015
- inheritDefaultLayout: true,
3016
- ...userOptions
3017
- };
3018
- }
3019
- function Layout(userOptions = {}) {
3020
- if (canEnableClientLayout(userOptions)) return ClientSideLayout({
3021
- defaultLayout: userOptions.defaultLayout,
3022
- fallbackLayout: userOptions.fallbackLayout,
3023
- layoutsDirs: userOptions.layoutsDirs,
3024
- inheritDefaultLayout: userOptions.inheritDefaultLayout
3025
- });
3026
- let config;
3027
- const options = resolveOptions$1(userOptions);
3028
- let layoutsDirs;
3029
- return {
3030
- name: "vite-plugin-vue-layouts-next",
3031
- enforce: "pre",
3032
- config() {
3033
- return { optimizeDeps: { include: [RUNTIME_ID] } };
3034
- },
3035
- configResolved(_config) {
3036
- config = _config;
3037
- layoutsDirs = resolveDirs(options.layoutsDirs, config.root);
3038
- },
3039
- configureServer({ moduleGraph, watcher, ws }) {
3040
- watcher.add(options.layoutsDirs);
3041
- const reloadModule = (module, path = "*") => {
3042
- if (module) {
3043
- moduleGraph.invalidateModule(module);
3044
- if (ws) ws.send({
3045
- path,
3046
- type: "full-reload"
3047
- });
3048
- }
3049
- };
3050
- const updateVirtualModule = (path) => {
3051
- path = normalizePath$2(path);
3052
- if (layoutsDirs.some((dir) => path.startsWith(dir))) {
3053
- debug$6("reload", path);
3054
- const module = moduleGraph.getModuleById(MODULE_ID_VIRTUAL);
3055
- reloadModule(module);
3056
- }
3057
- };
3058
- watcher.on("add", (path) => {
3059
- updateVirtualModule(path);
3060
- });
3061
- watcher.on("unlink", (path) => {
3062
- updateVirtualModule(path);
3063
- });
3064
- watcher.on("change", async (path) => {
3065
- updateVirtualModule(path);
3066
- });
3067
- },
3068
- resolveId(id) {
3069
- return id === MODULE_ID || id.startsWith(MODULE_ID) ? MODULE_ID_VIRTUAL : null;
3070
- },
3071
- async load(id) {
3072
- if (id === MODULE_ID_VIRTUAL) {
3073
- const container = [];
3074
- for (const dir of layoutsDirs) {
3075
- const layoutsDirPath = dir.startsWith("/") ? normalizePath$2(dir) : normalizePath$2(resolve(config.root, dir));
3076
- debug$6("Loading Layout Dir: %O", layoutsDirPath);
3077
- const _f = await getFilesFromPath(layoutsDirPath, options);
3078
- container.push({
3079
- path: layoutsDirPath,
3080
- files: _f
3081
- });
3082
- }
3083
- const clientCode = getClientCode(getImportCode(container, options), options);
3084
- debug$6("Client code: %O", clientCode);
3085
- return {
3086
- code: clientCode,
3087
- moduleType: "js"
3088
- };
3089
- }
3090
- }
3091
- };
3092
- }
3093
- function ClientSideLayout(options) {
3094
- const { layoutsDirs, layoutDir: legacyLayoutDir, defaultLayout = "default", fallbackLayout, importMode = process$1.env.VITE_SSG ? "sync" : "async", inheritDefaultLayout = true } = options || {};
3095
- const layoutDir = layoutsDirs ?? legacyLayoutDir ?? "src/layouts";
3096
- return {
3097
- name: "vite-plugin-vue-layouts-next",
3098
- config() {
3099
- return { optimizeDeps: { include: [RUNTIME_ID] } };
3100
- },
3101
- resolveId(id) {
3102
- if (id === MODULE_ID) return `\0${MODULE_ID}`;
3103
- },
3104
- async load(id) {
3105
- if (id === `\0${MODULE_ID}`) return {
3106
- code: await createVirtualModuleCode({
3107
- layoutDir,
3108
- importMode,
3109
- defaultLayout,
3110
- fallbackLayout,
3111
- inheritDefaultLayout
3112
- }),
3113
- moduleType: "js"
3114
- };
3115
- }
3116
- };
3117
- }
3118
- function canEnableClientLayout(options) {
3119
- const keys = Object.keys(options);
3120
- if (keys.length > 4 || keys.some((key) => ![
3121
- "layoutsDirs",
3122
- "defaultLayout",
3123
- "fallbackLayout",
3124
- "inheritDefaultLayout"
3125
- ].includes(key))) return false;
3126
- if (options.layoutsDirs && (Array.isArray(options.layoutsDirs) || options.layoutsDirs.includes("*"))) return false;
3127
- return true;
3128
- }
3129
-
3130
2843
  function isLoopback(address = "") {
3131
2844
  return address === "::1" || /^(?:::ffff:)?127(?:\.\d{1,3}){3}$/.test(address);
3132
2845
  }
@@ -3290,7 +3003,7 @@ class EditorRoutes {
3290
3003
  }
3291
3004
  }
3292
3005
 
3293
- const debug$5 = createDebug("valaxy:group-icons");
3006
+ const debug$2 = _debug("valaxy:group-icons");
3294
3007
  const codeBlockTitleRE = /^[ \t]{0,3}`{3}[^\n[]*\[((?:[^[\]]|\[[^[\]]*\])*)\]/gm;
3295
3008
  async function scanCodeBlockTitles(options) {
3296
3009
  const titles = /* @__PURE__ */ new Set();
@@ -3304,7 +3017,7 @@ async function scanCodeBlockTitles(options) {
3304
3017
  const content = await readFile(file, "utf-8");
3305
3018
  extractCodeBlockTitles(content, titles);
3306
3019
  } catch (error) {
3307
- debug$5("Failed to read %s: %O", page, error);
3020
+ debug$2("Failed to read %s: %O", page, error);
3308
3021
  }
3309
3022
  },
3310
3023
  { concurrency: 64 }
@@ -3451,6 +3164,65 @@ function createCdnPlugin(options) {
3451
3164
  };
3452
3165
  }
3453
3166
 
3167
+ const publicId = "virtual:valaxy-cover-components";
3168
+ const resolvedId = `\0${publicId}`;
3169
+ async function scanCoverComponents(componentDirs) {
3170
+ const components = /* @__PURE__ */ new Map();
3171
+ for (const dir of componentDirs) {
3172
+ const root = join$1(dir, "covers");
3173
+ const files = await glob("**/*.vue", { cwd: root, absolute: true, ignore: ["**/.*/**"] });
3174
+ const names = /* @__PURE__ */ new Set();
3175
+ for (const file of files.sort()) {
3176
+ const name = pascalCase$1(basename$1(file, ".vue"));
3177
+ if (names.has(name))
3178
+ throw new Error(`Duplicate cover component ${name} in ${root}; use unique filenames`);
3179
+ names.add(name);
3180
+ components.set(name, file);
3181
+ }
3182
+ }
3183
+ return components;
3184
+ }
3185
+ function createCoverComponentsPlugin(componentDirs) {
3186
+ const roots = componentDirs.map((dir) => `${normalize(join$1(dir, "covers"))}/`);
3187
+ return {
3188
+ name: "valaxy:cover-components",
3189
+ resolveId(id) {
3190
+ if (id === publicId)
3191
+ return resolvedId;
3192
+ },
3193
+ async load(id) {
3194
+ if (id !== resolvedId)
3195
+ return;
3196
+ const components = await scanCoverComponents(componentDirs);
3197
+ const entries = [...components].map(
3198
+ ([name, file]) => `[${JSON.stringify(name)}, defineAsyncComponent(() => import(${JSON.stringify(toAtFS(file))}))]`
3199
+ );
3200
+ return `import { defineAsyncComponent } from 'vue'
3201
+ export default new Map([${entries.join(",\n")}])`;
3202
+ },
3203
+ configureServer(server) {
3204
+ server.watcher.add(componentDirs.map((dir) => join$1(dir, "covers")));
3205
+ const invalidate = (file) => {
3206
+ const path = normalize(file);
3207
+ if (!path.endsWith(".vue") || !roots.some((root) => path.startsWith(root)))
3208
+ return;
3209
+ for (const environment of Object.values(server.environments)) {
3210
+ const module = environment.moduleGraph.getModuleById(resolvedId);
3211
+ if (module)
3212
+ environment.moduleGraph.invalidateModule(module);
3213
+ }
3214
+ server.ws.send({ type: "full-reload" });
3215
+ };
3216
+ server.watcher.on("add", invalidate);
3217
+ server.watcher.on("unlink", invalidate);
3218
+ server.httpServer?.once("close", () => {
3219
+ server.watcher.off("add", invalidate);
3220
+ server.watcher.off("unlink", invalidate);
3221
+ });
3222
+ }
3223
+ };
3224
+ }
3225
+
3454
3226
  function foucGuardHtml(maxDuration) {
3455
3227
  return [
3456
3228
  `<style id="valaxy-fouc">body{opacity:0!important}</style>`,
@@ -3747,1371 +3519,218 @@ async function getAlias(options) {
3747
3519
  find: /^valaxy-addon-(.*)$/,
3748
3520
  replacement: toAtFS(resolve(options.clientRoot, "./addons/index.ts"))
3749
3521
  });
3750
- return alias;
3751
- }
3752
-
3753
- function normalizeGlobOption(val) {
3754
- if (!val) return void 0;
3755
- return isString(val) ? [normalize(val)] : val.map(normalize);
3756
- }
3757
- function resolveOptions(options) {
3758
- const moduleType = options.module || "vue-i18n";
3759
- let onlyLocales = [];
3760
- if (options.onlyLocales) {
3761
- onlyLocales = isArray(options.onlyLocales) ? options.onlyLocales : [options.onlyLocales];
3762
- }
3763
- const forceStringify = !!options.forceStringify;
3764
- const defaultSFCLang = isString(options.defaultSFCLang) ? options.defaultSFCLang : "json";
3765
- const globalSFCScope = !!options.globalSFCScope;
3766
- const runtimeOnly = isBoolean(options.runtimeOnly) ? options.runtimeOnly : true;
3767
- const dropMessageCompiler = !!options.dropMessageCompiler;
3768
- const compositionOnly = moduleType === "vue-i18n" ? isBoolean(options.compositionOnly) ? options.compositionOnly : true : true;
3769
- const fullInstall = moduleType === "vue-i18n" ? isBoolean(options.fullInstall) ? options.fullInstall : true : false;
3770
- const ssrBuild = !!options.ssr;
3771
- const allowDynamic = !!options.allowDynamic;
3772
- const strictMessage = isBoolean(options.strictMessage) ? options.strictMessage : true;
3773
- const escapeHtml = !!options.escapeHtml;
3774
- const optimizeTranslationDirective = isString(options.optimizeTranslationDirective) || isArray(options.optimizeTranslationDirective) ? options.optimizeTranslationDirective : !!options.optimizeTranslationDirective;
3775
- const translationIdentifiers = /* @__PURE__ */ new Map();
3776
- const transformI18nBlock = typeof options.transformI18nBlock === "function" ? options.transformI18nBlock : null;
3777
- const treeShaking = options.treeShaking ? typeof options.treeShaking === "object" ? {
3778
- safelist: options.treeShaking.safelist || [],
3779
- dynamicKeyStrategy: options.treeShaking.dynamicKeyStrategy || "keep-all",
3780
- scanPatterns: options.treeShaking.scanPatterns
3781
- } : { safelist: [], dynamicKeyStrategy: "keep-all" } : null;
3782
- return {
3783
- include: normalizeGlobOption(options.include || []),
3784
- exclude: normalizeGlobOption(options.exclude),
3785
- module: moduleType,
3786
- onlyLocales,
3787
- forceStringify,
3788
- defaultSFCLang,
3789
- globalSFCScope,
3790
- runtimeOnly,
3791
- dropMessageCompiler,
3792
- compositionOnly,
3793
- fullInstall,
3794
- ssrBuild,
3795
- allowDynamic,
3796
- strictMessage,
3797
- escapeHtml,
3798
- optimizeTranslationDirective,
3799
- translationIdentifiers,
3800
- transformI18nBlock,
3801
- treeShaking
3802
- };
3803
- }
3804
- const PKG_NAME = "unplugin-vue-i18n";
3805
- function warn(...args) {
3806
- console.warn(pc.yellow(pc.bold(`[${PKG_NAME}] `)), ...args);
3807
- }
3808
- function error(...args) {
3809
- console.error(pc.red(pc.bold(`[${PKG_NAME}] `)), ...args);
3810
- }
3811
- function raiseError(message) {
3812
- throw new Error(`[${PKG_NAME}] ${message}`);
3813
- }
3814
- function resolveNamespace(name) {
3815
- return `${PKG_NAME}:${name}`;
3816
- }
3817
- function getVitePlugin(config, name) {
3818
- return config.plugins.find((p) => p.name === name);
3819
- }
3820
- function checkVuePlugin(vuePlugin) {
3821
- if (vuePlugin == null || !vuePlugin.api) {
3822
- error(
3823
- "`@vitejs/plugin-vue` plugin is not found or invalid version. Please install `@vitejs/plugin-vue` v4.3.4 or later version."
3824
- );
3825
- return false;
3826
- }
3827
- return true;
3828
- }
3829
- const isWindows = typeof process !== "undefined" && process.platform === "win32";
3830
- const windowsSlashRE = /\\/g;
3831
- function slash(p) {
3832
- return p.replace(windowsSlashRE, "/");
3833
- }
3834
- function normalizePath(id) {
3835
- return path.posix.normalize(isWindows ? slash(id) : id);
3836
- }
3837
- function parseVueRequest(id) {
3838
- const [filename, rawQuery] = id.split(`?`, 2);
3839
- const params = new URLSearchParams(rawQuery);
3840
- const ret = {};
3841
- const langPart = Object.keys(Object.fromEntries(params)).find((key) => /lang\./i.test(key));
3842
- ret.vue = params.has("vue");
3843
- ret.global = params.has("global");
3844
- ret.src = params.has("src");
3845
- ret.raw = params.has("raw");
3846
- if (params.has("type")) {
3847
- ret.type = params.get("type");
3848
- }
3849
- if (params.has("blockType")) {
3850
- ret.blockType = params.get("blockType");
3851
- }
3852
- if (params.has("index")) {
3853
- ret.index = Number(params.get("index"));
3854
- }
3855
- if (params.has("locale")) {
3856
- ret.locale = params.get("locale");
3857
- }
3858
- if (langPart) {
3859
- const [, lang] = langPart.split(".");
3860
- ret.lang = lang;
3861
- } else if (params.has("lang")) {
3862
- ret.lang = params.get("lang");
3863
- }
3864
- if (params.has("issuerPath")) {
3865
- ret.issuerPath = params.get("issuerPath");
3866
- }
3867
- return {
3868
- filename,
3869
- query: ret
3870
- };
3871
- }
3872
- function getVueCompiler(vuePlugin) {
3873
- return vuePlugin?.api?.options.compiler;
3874
- }
3875
- function getVuePluginOptions(vuePlugin) {
3876
- return {
3877
- isProduction: vuePlugin?.api?.options.isProduction,
3878
- root: vuePlugin?.api?.options.root,
3879
- template: vuePlugin?.api?.options.template,
3880
- compiler: vuePlugin?.api?.options.compiler
3881
- };
3882
- }
3883
- function createDescriptor(filename, source, { template, compiler }) {
3884
- const { descriptor, errors } = compiler.parse(source, {
3885
- filename,
3886
- templateParseOptions: template?.compilerOptions
3887
- });
3888
- return { descriptor, errors };
3889
- }
3890
- function getDescriptor(filename, code, options) {
3891
- const { descriptor, errors } = createDescriptor(filename, code, options);
3892
- if (errors.length) {
3893
- throw errors[0];
3894
- }
3895
- return descriptor;
3896
- }
3897
- const INTLIFY_BUNDLE_IMPORT_ID = "@intlify/unplugin-vue-i18n/messages";
3898
- const VIRTUAL_PREFIX = "virtual:";
3899
- const RE_RESOURCE_FORMAT = /\.(json5?|ya?ml|[c|m]?[j|t]s)$/;
3900
- const RE_SFC_I18N_CUSTOM_BLOCK = /\?vue&type=i18n/;
3901
- const RE_SFC_I18N_WEBPACK_CUSTOM_BLOCK = /blockType=i18n/;
3902
- const VITE_VIRTUAL_PREFIX = "virtual:intlify-i18n-";
3903
- const debug$3 = createDebug(resolveNamespace("resource"));
3904
- function resourcePlugin({
3905
- onlyLocales,
3906
- include,
3907
- exclude,
3908
- module,
3909
- forceStringify,
3910
- defaultSFCLang,
3911
- globalSFCScope,
3912
- runtimeOnly,
3913
- dropMessageCompiler,
3914
- compositionOnly,
3915
- fullInstall,
3916
- ssrBuild,
3917
- strictMessage,
3918
- allowDynamic,
3919
- escapeHtml,
3920
- transformI18nBlock
3921
- }, meta, collector) {
3922
- function resolveIncludeExclude() {
3923
- const customBlockInclude = meta.framework === "vite" ? RE_SFC_I18N_CUSTOM_BLOCK : RE_SFC_I18N_WEBPACK_CUSTOM_BLOCK;
3924
- return include ? [[...include, customBlockInclude], exclude] : [[RE_RESOURCE_FORMAT, customBlockInclude], exclude];
3925
- }
3926
- function resolveIncludeExcludeForLegacy() {
3927
- const customBlockInclude = meta.framework === "vite" ? RE_SFC_I18N_CUSTOM_BLOCK : RE_SFC_I18N_WEBPACK_CUSTOM_BLOCK;
3928
- return include ? [[...include, customBlockInclude], void 0] : [void 0, ["**/**"]];
3929
- }
3930
- let _filter = null;
3931
- async function getFilter() {
3932
- if (_filter != null) {
3933
- return _filter;
3934
- }
3935
- if (meta.framework == "webpack") {
3936
- debug$3("Using filter for webpack");
3937
- _filter = createFilter$1(...resolveIncludeExclude());
3938
- } else if (hasViteJsonPlugin) {
3939
- debug$3("Using filter for rollup-vite");
3940
- _filter = createFilter$1(...resolveIncludeExcludeForLegacy());
3941
- } else {
3942
- debug$3("Using filter for rolldown-vite");
3943
- _filter = createFilter$1(...resolveIncludeExclude());
3944
- }
3945
- return _filter;
3946
- }
3947
- const getVueI18nAliasPath = ({ ssr = false, runtimeOnly: runtimeOnly2 = false }) => {
3948
- return `${module}/dist/${module}${runtimeOnly2 ? ".runtime" : ""}.${!ssr ? "esm-bundler.js" : "node.mjs"}`;
3949
- };
3950
- let isProduction = false;
3951
- let sourceMap = false;
3952
- let hasViteJsonPlugin = false;
3953
- const vueI18nAliasName = module;
3954
- debug$3(`vue-i18n alias name: ${vueI18nAliasName}`);
3955
- let vuePlugin = null;
3956
- const getSfcParser = () => {
3957
- return vuePlugin ? getVueCompiler(vuePlugin).parse : parse$2;
3958
- };
3959
- const virtualIdToRealPath = /* @__PURE__ */ new Map();
3960
- const realPathToVirtualId = /* @__PURE__ */ new Map();
3961
- let virtualCounter = 0;
3962
- function intlifyVirtualize(realPath) {
3963
- const normalized = normalize(realPath);
3964
- let virtualId = realPathToVirtualId.get(normalized);
3965
- if (!virtualId) {
3966
- virtualId = `${VITE_VIRTUAL_PREFIX}${virtualCounter++}`;
3967
- virtualIdToRealPath.set(virtualId, normalized);
3968
- realPathToVirtualId.set(normalized, virtualId);
3969
- }
3970
- return virtualId;
3971
- }
3972
- function isIntlifyVirtualId(id) {
3973
- return virtualIdToRealPath.has(id);
3974
- }
3975
- return {
3976
- name: resolveNamespace("resource"),
3977
- /**
3978
- * NOTE:
3979
- *
3980
- * For vite, If we have json (including SFC's custom block),
3981
- * transform it first because it will be transformed into javascript code by `vite:json` plugin.
3982
- *
3983
- * For webpack, This plugin will handle with 'post', because vue-loader generate the request query.
3984
- */
3985
- enforce: meta.framework === "vite" ? "pre" : "post",
3986
- vite: {
3987
- config() {
3988
- const defineConfig = {
3989
- define: {
3990
- __VUE_I18N_LEGACY_API__: !compositionOnly,
3991
- __VUE_I18N_FULL_INSTALL__: fullInstall,
3992
- __INTLIFY_DROP_MESSAGE_COMPILER__: dropMessageCompiler,
3993
- __VUE_I18N_PROD_DEVTOOLS__: false
3994
- }
3995
- };
3996
- debug$3("define Config:", defineConfig);
3997
- const aliasConfig = {
3998
- resolve: {
3999
- alias: {
4000
- [vueI18nAliasName]: getVueI18nAliasPath({
4001
- ssr: ssrBuild,
4002
- runtimeOnly
4003
- })
4004
- }
4005
- }
4006
- };
4007
- debug$3("alias Config:", aliasConfig);
4008
- return assign(defineConfig, aliasConfig);
4009
- },
4010
- async configResolved(config) {
4011
- vuePlugin = getVitePlugin(config, "vite:vue");
4012
- if (!checkVuePlugin(vuePlugin)) {
4013
- return;
4014
- }
4015
- isProduction = config.isProduction;
4016
- sourceMap = config.command === "build" ? !!config.build.sourcemap : false;
4017
- debug$3(`configResolved: isProduction = ${isProduction}, sourceMap = ${sourceMap}`);
4018
- const jsonPlugin = getVitePlugin(config, "vite:json");
4019
- hasViteJsonPlugin = !!jsonPlugin;
4020
- if (jsonPlugin && jsonPlugin.transform) {
4021
- const transform = jsonPlugin.transform;
4022
- const isObjectHook = typeof transform !== "function" && "handler" in transform;
4023
- const orgTransform = isObjectHook ? transform.handler : transform;
4024
- async function overrideJson(code, id) {
4025
- const filter = await getFilter();
4026
- if (!/\.json$/.test(id) || filter(id)) {
4027
- return;
4028
- }
4029
- const { query } = parseVueRequest(id);
4030
- if (query.vue) {
4031
- return;
4032
- }
4033
- debug$3("org json plugin");
4034
- return orgTransform.apply(this, [code, id]);
4035
- }
4036
- if (isObjectHook) {
4037
- transform.handler = overrideJson;
4038
- } else {
4039
- jsonPlugin.transform = overrideJson;
4040
- }
4041
- }
4042
- },
4043
- handleHotUpdate({ file, modules, server }) {
4044
- const key = normalize(file);
4045
- const virtualId = realPathToVirtualId.get(key);
4046
- const inBundle = !!(include && createFilter$1(include, exclude)(key));
4047
- if (!virtualId && !inBundle) return;
4048
- const affected = new Set(modules);
4049
- const addById = (id) => {
4050
- const mod = id && server.moduleGraph.getModuleById(id);
4051
- if (mod) affected.add(mod);
4052
- };
4053
- addById(virtualId);
4054
- if (inBundle) {
4055
- addById(asVirtualId(INTLIFY_BUNDLE_IMPORT_ID, meta.framework));
4056
- }
4057
- if (affected.size === modules.length) return;
4058
- return [...affected];
4059
- }
4060
- },
4061
- webpack(compiler) {
4062
- isProduction = compiler.options.mode !== "development";
4063
- sourceMap = !!compiler.options.devtool;
4064
- debug$3(`webpack: isProduction = ${isProduction}, sourceMap = ${sourceMap}`);
4065
- compiler.options.resolve = normalizeConfigResolveAlias(
4066
- compiler.options.resolve,
4067
- meta.framework
4068
- );
4069
- compiler.options.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath({
4070
- ssr: ssrBuild,
4071
- runtimeOnly
4072
- });
4073
- debug$3(
4074
- `set ${vueI18nAliasName}: ${getVueI18nAliasPath({
4075
- ssr: ssrBuild,
4076
- runtimeOnly
4077
- })}`
4078
- );
4079
- compiler.options.plugins.push(
4080
- new compiler.webpack.DefinePlugin({
4081
- __VUE_I18N_LEGACY_API__: JSON.stringify(compositionOnly),
4082
- __VUE_I18N_FULL_INSTALL__: JSON.stringify(fullInstall),
4083
- __INTLIFY_PROD_DEVTOOLS__: "false"
4084
- })
4085
- );
4086
- debug$3(`set __VUE_I18N_LEGACY_API__ is '${compositionOnly}'`);
4087
- debug$3(`set __VUE_I18N_FULL_INSTALL__ is '${fullInstall}'`);
4088
- const filter = createFilter$1(...resolveIncludeExclude());
4089
- if (compiler.options.module) {
4090
- compiler.options.module.rules.push({
4091
- test: RE_RESOURCE_FORMAT,
4092
- type: "javascript/auto",
4093
- include(resource) {
4094
- debug$3("webpack resource include", resource);
4095
- return filter(resource);
4096
- }
4097
- });
4098
- }
4099
- },
4100
- resolveId: {
4101
- async handler(id, importer) {
4102
- if (id === INTLIFY_BUNDLE_IMPORT_ID) {
4103
- return asVirtualId(id, meta.framework);
4104
- }
4105
- if (meta.framework === "vite" && !hasViteJsonPlugin) {
4106
- if (id.includes("?vue&type=i18n") && /[?&]lang\.(?:json|json5)(?:$|&)/.test(id)) {
4107
- const { filename, query } = parseVueRequest(id);
4108
- let virtualKey = id;
4109
- if (query.src && importer) {
4110
- const importerPath = (isIntlifyVirtualId(importer) ? virtualIdToRealPath.get(importer) : importer).split("?")[0];
4111
- if (importerPath.endsWith(".vue")) {
4112
- const resolvedSidecar = resolve$1(dirname$1(importerPath), filename);
4113
- virtualKey = id.replace(filename, resolvedSidecar);
4114
- }
4115
- }
4116
- return intlifyVirtualize(virtualKey);
4117
- }
4118
- const idPath = id.split("?")[0];
4119
- if (!RE_RESOURCE_FORMAT.test(idPath)) return;
4120
- let resolvedPath;
4121
- if (idPath.startsWith(".")) {
4122
- const realImporter = importer && isIntlifyVirtualId(importer) ? virtualIdToRealPath.get(importer) : importer;
4123
- if (!realImporter) return;
4124
- resolvedPath = resolve$1(dirname$1(realImporter), idPath);
4125
- } else if (idPath.startsWith("/") || /^[a-z]:[/\\]/i.test(idPath)) {
4126
- resolvedPath = idPath;
4127
- } else {
4128
- return;
4129
- }
4130
- const filter = await getFilter();
4131
- if (!filter(resolvedPath)) return;
4132
- return intlifyVirtualize(resolvedPath);
4133
- }
4134
- }
4135
- },
4136
- load: {
4137
- async handler(id) {
4138
- debug$3("load", id);
4139
- if (INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework) && include) {
4140
- let resourcePaths = [];
4141
- for (const inc of include) {
4142
- resourcePaths = [...resourcePaths, ...await glob(inc, { absolute: true })];
4143
- }
4144
- resourcePaths = resourcePaths.filter((el, pos) => resourcePaths.indexOf(el) === pos);
4145
- const code = await generateBundleResources(resourcePaths, isProduction, {
4146
- forceStringify,
4147
- strictMessage,
4148
- escapeHtml,
4149
- usedKeyFilter: collector ? (keyPath) => collector.shouldKeepKey(keyPath) : void 0
4150
- });
4151
- return {
4152
- moduleType: "js",
4153
- code,
4154
- map: { mappings: "" }
4155
- };
4156
- }
4157
- if (isIntlifyVirtualId(id)) {
4158
- const realId = virtualIdToRealPath.get(id);
4159
- if (realId.includes("?vue&type=i18n")) {
4160
- const { filename, query } = parseVueRequest(realId);
4161
- let source;
4162
- if (query.src) {
4163
- this.addWatchFile(filename);
4164
- source = await promises.readFile(filename, "utf-8");
4165
- } else {
4166
- this.addWatchFile(filename);
4167
- const sfcSource = await promises.readFile(filename, "utf-8");
4168
- const { descriptor } = getSfcParser()(sfcSource, {
4169
- sourceMap,
4170
- filename
4171
- });
4172
- const block = descriptor.customBlocks[query.index];
4173
- if (!block) return;
4174
- source = block.content;
4175
- }
4176
- if (typeof transformI18nBlock === "function") {
4177
- const modifiedSource = transformI18nBlock(source);
4178
- if (modifiedSource && typeof modifiedSource === "string") {
4179
- source = modifiedSource;
4180
- } else {
4181
- warn("transformI18nBlock should return a string");
4182
- }
4183
- }
4184
- let langInfo2 = defaultSFCLang;
4185
- if (isString(query.lang)) {
4186
- langInfo2 = query.src ? query.lang === "i18n" ? defaultSFCLang : query.lang : query.lang;
4187
- }
4188
- if (/\.?[cm]?[jt]s$/.test(langInfo2)) {
4189
- source = `export default ${source.replace(/^[\s;]+/, "")}`;
4190
- }
4191
- const generate2 = getGenerator(langInfo2, generateYAML);
4192
- const isGlobalBlock = globalSFCScope || !!query.global;
4193
- const parseOptions2 = getOptions(
4194
- filename,
4195
- isProduction,
4196
- query,
4197
- sourceMap,
4198
- {
4199
- isGlobal: globalSFCScope,
4200
- allowDynamic,
4201
- jit: true,
4202
- strictMessage,
4203
- escapeHtml,
4204
- onlyLocales,
4205
- forceStringify,
4206
- usedKeyFilter: collector && isGlobalBlock ? (keyPath) => collector.shouldKeepKey(keyPath) : void 0
4207
- }
4208
- );
4209
- const { code: generatedCode2 } = await generate2(source, parseOptions2);
4210
- return {
4211
- moduleType: "js",
4212
- code: generatedCode2,
4213
- map: { mappings: "" }
4214
- };
4215
- }
4216
- this.addWatchFile(realId);
4217
- const code = await promises.readFile(realId, "utf-8");
4218
- const langInfo = parse$1(realId).ext;
4219
- const generate = getGenerator(langInfo);
4220
- const parseOptions = getOptions(
4221
- realId,
4222
- isProduction,
4223
- {},
4224
- sourceMap,
4225
- {
4226
- isGlobal: globalSFCScope,
4227
- allowDynamic,
4228
- strictMessage,
4229
- escapeHtml,
4230
- jit: true,
4231
- onlyLocales,
4232
- forceStringify,
4233
- usedKeyFilter: collector ? (keyPath) => collector.shouldKeepKey(keyPath) : void 0
4234
- }
4235
- );
4236
- const { code: generatedCode } = await generate(code, parseOptions);
4237
- return {
4238
- moduleType: "js",
4239
- code: generatedCode,
4240
- map: { mappings: "" }
4241
- };
4242
- }
4243
- }
4244
- },
4245
- transform: {
4246
- async handler(code, id) {
4247
- if (isIntlifyVirtualId(id)) return;
4248
- const filter = await getFilter();
4249
- if (!filter(id)) {
4250
- return;
4251
- }
4252
- const { filename, query } = parseVueRequest(id);
4253
- debug$3("transform", id, JSON.stringify(query), filename);
4254
- let langInfo = defaultSFCLang;
4255
- let inSourceMap;
4256
- if (!query.vue) {
4257
- langInfo = parse$1(filename).ext;
4258
- const generate = getGenerator(langInfo);
4259
- const parseOptions = getOptions(
4260
- filename,
4261
- isProduction,
4262
- query,
4263
- sourceMap,
4264
- {
4265
- inSourceMap,
4266
- isGlobal: globalSFCScope,
4267
- allowDynamic,
4268
- strictMessage,
4269
- escapeHtml,
4270
- jit: true,
4271
- onlyLocales,
4272
- forceStringify,
4273
- usedKeyFilter: collector ? (keyPath) => collector.shouldKeepKey(keyPath) : void 0
4274
- }
4275
- );
4276
- debug$3("parseOptions", parseOptions);
4277
- const { code: generatedCode, map } = await generate(code, parseOptions);
4278
- debug$3("generated code", generatedCode);
4279
- debug$3("sourcemap", map, sourceMap);
4280
- if (code === generatedCode) return;
4281
- return {
4282
- moduleType: "js",
4283
- code: generatedCode,
4284
- // prettier-ignore
4285
- map: { mappings: "" }
4286
- };
4287
- } else {
4288
- if (isCustomBlock(query)) {
4289
- if (isString(query.lang)) {
4290
- langInfo = query.src ? query.lang === "i18n" ? defaultSFCLang : query.lang : query.lang;
4291
- } else if (defaultSFCLang) {
4292
- langInfo = defaultSFCLang;
4293
- }
4294
- debug$3("langInfo", langInfo);
4295
- const generate = getGenerator(langInfo, generateYAML);
4296
- const isGlobalBlock = globalSFCScope || !!query.global;
4297
- const parseOptions = getOptions(
4298
- filename,
4299
- isProduction,
4300
- query,
4301
- sourceMap,
4302
- {
4303
- inSourceMap,
4304
- isGlobal: globalSFCScope,
4305
- allowDynamic,
4306
- jit: true,
4307
- strictMessage,
4308
- escapeHtml,
4309
- onlyLocales,
4310
- forceStringify,
4311
- usedKeyFilter: collector && isGlobalBlock ? (keyPath) => collector.shouldKeepKey(keyPath) : void 0
4312
- }
4313
- );
4314
- debug$3("parseOptions", parseOptions);
4315
- let source = await getCode(
4316
- code,
4317
- filename,
4318
- sourceMap,
4319
- query,
4320
- getSfcParser(),
4321
- meta.framework
4322
- );
4323
- if (typeof transformI18nBlock === "function") {
4324
- const modifiedSource = transformI18nBlock(source);
4325
- if (modifiedSource && typeof modifiedSource === "string") {
4326
- source = modifiedSource;
4327
- } else {
4328
- warn("transformI18nBlock should return a string");
4329
- }
4330
- }
4331
- if (/\.?[cm]?[jt]s$/.test(langInfo)) {
4332
- source = `export default ${source.replace(/^[\s;]+/, "")}`;
4333
- }
4334
- const { code: generatedCode, map } = await generate(source, parseOptions);
4335
- debug$3("generated code", generatedCode);
4336
- debug$3("sourcemap", map, sourceMap);
4337
- if (code === generatedCode) return;
4338
- return {
4339
- moduleType: "js",
4340
- code: generatedCode,
4341
- // prettier-ignore
4342
- map: { mappings: "" }
4343
- };
4344
- }
4345
- }
4346
- }
4347
- }
4348
- };
4349
- }
4350
- function getGenerator(ext, fallback = generateJSON) {
4351
- if (/\.?json5?$/.test(ext)) {
4352
- return generateJSON;
4353
- }
4354
- if (/\.?ya?ml$/.test(ext)) {
4355
- return generateYAML;
4356
- }
4357
- if (/\.?[cm]?js$/.test(ext)) {
4358
- return generateJavaScript;
4359
- }
4360
- if (/\.?[cm]?ts$/.test(ext)) {
4361
- return generateTypescript;
4362
- }
4363
- return fallback;
4364
- }
4365
- function normalizeConfigResolveAlias(resolve2, framework) {
4366
- if (resolve2 && resolve2.alias) {
4367
- return resolve2;
4368
- }
4369
- if (!resolve2) {
4370
- if (framework === "vite") {
4371
- return { alias: [] };
4372
- } else if (framework === "webpack") {
4373
- return { alias: {} };
4374
- }
4375
- } else if (!resolve2.alias) {
4376
- if (framework === "vite") {
4377
- resolve2.alias = [];
4378
- return resolve2;
4379
- } else if (framework === "webpack") {
4380
- resolve2.alias = {};
4381
- return resolve2;
4382
- }
4383
- }
4384
- }
4385
- async function generateBundleResources(resources, isProduction, {
4386
- forceStringify = false,
4387
- isGlobal = false,
4388
- onlyLocales = [],
4389
- strictMessage = true,
4390
- escapeHtml = false,
4391
- jit = true,
4392
- transformI18nBlock = void 0,
4393
- usedKeyFilter = void 0
4394
- }) {
4395
- const codes = [];
4396
- for (const res of resources) {
4397
- debug$3(`${res} bundle loading ...`);
4398
- if (/\.(json5?|ya?ml)$/.test(res)) {
4399
- const { ext, name } = parse$1(res);
4400
- const source = await getRaw(res);
4401
- const generate = /json5?/.test(ext) ? generateJSON : generateYAML;
4402
- const parseOptions = getOptions(res, isProduction, {}, false, {
4403
- isGlobal,
4404
- jit,
4405
- onlyLocales,
4406
- strictMessage,
4407
- escapeHtml,
4408
- forceStringify,
4409
- transformI18nBlock,
4410
- usedKeyFilter
4411
- });
4412
- parseOptions.type = "bare";
4413
- const { code } = generate(source, parseOptions);
4414
- debug$3("generated code", code);
4415
- codes.push(`${JSON.stringify(name)}: ${code}`);
4416
- }
4417
- }
4418
- return `const isObject = (item) => item && typeof item === 'object' && !Array.isArray(item);
4419
-
4420
- const mergeDeep = (target, ...sources) => {
4421
- if (!sources.length) return target;
4422
- const source = sources.shift();
4423
-
4424
- if (isObject(target) && isObject(source)) {
4425
- for (const key in source) {
4426
- if (isObject(source[key])) {
4427
- if (!target[key]) Object.assign(target, { [key]: {} });
4428
- mergeDeep(target[key], source[key]);
4429
- } else {
4430
- Object.assign(target, { [key]: source[key] });
4431
- }
4432
- }
4433
- }
4434
-
4435
- return mergeDeep(target, ...sources);
4436
- }
4437
-
4438
- export default mergeDeep({},
4439
- ${codes.map((code) => `{${code}}`).join(",\n")}
4440
- );`;
4441
- }
4442
- async function getCode(source, filename, sourceMap, query, parser, framework = "vite") {
4443
- const { index, issuerPath } = query;
4444
- if (!isNumber(index)) {
4445
- raiseError(`unexpected index: ${index}`);
4446
- }
4447
- if (framework === "webpack") {
4448
- if (issuerPath) {
4449
- debug$3(`getCode (webpack) ${index} via issuerPath`, issuerPath);
4450
- return await getRaw(filename);
4451
- } else {
4452
- const result = parser(await getRaw(filename), {
4453
- sourceMap,
4454
- filename
4455
- });
4456
- const block = result.descriptor.customBlocks[index];
4457
- if (block) {
4458
- const code = block.src ? await getRaw(resolveBlockSrc(block.src, filename)) : block.content;
4459
- debug$3(`getCode (webpack) ${index} from SFC`, code);
4460
- return code;
4461
- } else {
4462
- return source;
4463
- }
4464
- }
4465
- } else {
4466
- return source;
4467
- }
4468
- }
4469
- function isCustomBlock(query) {
4470
- return !isEmptyObject(query) && "vue" in query && (query["type"] === "custom" || // for webpack (vue-loader)
4471
- query["type"] === "i18n" || // for vite (@vite/plugin-vue)
4472
- query["blockType"] === "i18n");
4473
- }
4474
- function getOptions(filename, isProduction, query, sourceMap, {
4475
- inSourceMap = void 0,
4476
- forceStringify = false,
4477
- isGlobal = false,
4478
- onlyLocales = [],
4479
- allowDynamic = false,
4480
- strictMessage = true,
4481
- escapeHtml = false,
4482
- jit = true,
4483
- transformI18nBlock = null,
4484
- usedKeyFilter = void 0
4485
- }) {
4486
- const mode = isProduction ? "production" : "development";
4487
- const baseOptions = {
4488
- filename,
4489
- sourceMap,
4490
- inSourceMap,
4491
- forceStringify,
4492
- allowDynamic,
4493
- strictMessage,
4494
- escapeHtml,
4495
- jit,
4496
- onlyLocales,
4497
- usedKeyFilter,
4498
- env: mode,
4499
- transformI18nBlock,
4500
- onWarn: (msg) => {
4501
- warn(`${filename} ${msg}`);
4502
- },
4503
- onError: (msg, extra) => {
4504
- const codeFrame = generateCodeFrame(
4505
- extra?.source || extra?.location?.source || "",
4506
- extra?.location?.start.column,
4507
- extra?.location?.end.column
4508
- );
4509
- const errMssage = `${msg} (error code: ${extra?.code}) in ${filename}
4510
- target message: ${extra?.source}
4511
- target message path: ${extra?.path}
4512
-
4513
- ${codeFrame}
4514
- `;
4515
- error(errMssage);
4516
- throw new Error(errMssage);
4517
- }
4518
- };
4519
- if (isCustomBlock(query)) {
4520
- return assign(baseOptions, {
4521
- type: "sfc",
4522
- locale: isString(query.locale) ? query.locale : "",
4523
- isGlobal: isGlobal || !!query.global
4524
- });
4525
- } else {
4526
- return assign(baseOptions, {
4527
- type: "plain",
4528
- isGlobal: false
4529
- });
4530
- }
4531
- }
4532
- function resolveBlockSrc(src, sfcFilename) {
4533
- if (src.startsWith(".") || !src.startsWith("/") && !/^[a-z]:[/\\]/i.test(src)) {
4534
- return resolve$1(dirname$1(sfcFilename), src);
4535
- }
4536
- return src;
3522
+ return alias;
4537
3523
  }
4538
- function getVirtualId(id, framework = "vite") {
4539
- return framework === "vite" ? id.startsWith(VIRTUAL_PREFIX) ? id.slice(VIRTUAL_PREFIX.length) : "" : id;
3524
+
3525
+ const LAYOUTS_MODULE_ID = "virtual:generated-layouts";
3526
+ const RESOLVED_LAYOUTS_MODULE_ID = `\0${LAYOUTS_MODULE_ID}`;
3527
+ function defaultImportMode(name) {
3528
+ if (process.env.VITE_SSG)
3529
+ return "sync";
3530
+ return name === "default" ? "sync" : "async";
4540
3531
  }
4541
- function asVirtualId(id, framework = "vite") {
4542
- return framework === "vite" ? VIRTUAL_PREFIX + id : id;
3532
+ const REGEX_BACKSLASH = /\\/g;
3533
+ const REGEX_SEPARATORS = /[-_/.\s]/;
3534
+ const REGEX_NON_ALPHANUMERIC = /[^a-z0-9-]+/gi;
3535
+ const REGEX_REPEATED_DASH = /-+/g;
3536
+ const REGEX_EDGE_DASH = /^-|-$/g;
3537
+ const REGEX_NUMBER = /\d/;
3538
+ function isUppercase(char = "") {
3539
+ if (REGEX_NUMBER.test(char))
3540
+ return void 0;
3541
+ return char !== char.toLowerCase();
4543
3542
  }
4544
- async function getRaw(path2) {
4545
- return promises.readFile(path2, { encoding: "utf-8" });
3543
+ function caseBoundary(previousUpper, isUpper, buffer) {
3544
+ if (previousUpper === false && isUpper === true)
3545
+ return "before";
3546
+ if (previousUpper === true && isUpper === false && buffer.length > 1)
3547
+ return "after";
4546
3548
  }
4547
- const debug$2 = createDebug(resolveNamespace("directive"));
4548
- const tsEstree = {
4549
- parse: void 0,
4550
- simpleTraverse: void 0,
4551
- AST_NODE_TYPES: void 0
4552
- };
4553
- function directivePlugin({
4554
- optimizeTranslationDirective,
4555
- translationIdentifiers
4556
- }) {
4557
- let vuePlugin = null;
4558
- let vuePluginOptions = null;
4559
- const excludeLangs = ["pug", "jsx", "tsx"];
4560
- return {
4561
- name: resolveNamespace("directive"),
4562
- enforce: "pre",
4563
- vite: {
4564
- async config(config) {
4565
- await import('@typescript-eslint/typescript-estree').then((r) => {
4566
- tsEstree.parse = r.parse;
4567
- tsEstree.simpleTraverse = r.simpleTraverse;
4568
- tsEstree.AST_NODE_TYPES = r.AST_NODE_TYPES;
4569
- return;
4570
- });
4571
- vuePlugin = getVitePlugin(config, "vite:vue");
4572
- if (!checkVuePlugin(vuePlugin)) {
4573
- return;
4574
- }
4575
- if (optimizeTranslationDirective) {
4576
- vuePlugin.api.options = resolveVueOptions(
4577
- vuePlugin,
4578
- optimizeTranslationDirective,
4579
- translationIdentifiers
4580
- );
4581
- debug$2(`vite:vue options['template']:`, vuePlugin.api.options);
4582
- }
4583
- },
4584
- configResolved(config) {
4585
- vuePlugin = getVitePlugin(config, "vite:vue");
4586
- if (!checkVuePlugin(vuePlugin)) {
4587
- return;
4588
- }
4589
- }
4590
- },
4591
- async transform(code, id) {
4592
- if (id.endsWith(".vue")) {
4593
- const { filename, query } = parseVueRequest(id);
4594
- if (!excludeLangs.includes(query.lang ?? "")) {
4595
- if (vuePluginOptions == null) {
4596
- vuePluginOptions = getVuePluginOptions(vuePlugin);
4597
- }
4598
- if (vuePluginOptions?.compiler) {
4599
- analyzeIdentifiers(
4600
- getDescriptor(filename, code, vuePluginOptions),
4601
- vuePluginOptions,
4602
- translationIdentifiers
4603
- );
4604
- return {
4605
- code,
4606
- map: { version: 3, mappings: "", sources: [] }
4607
- };
4608
- }
4609
- }
4610
- }
4611
- }
3549
+ function splitByCase(value) {
3550
+ const parts = [];
3551
+ let buffer = "";
3552
+ let previousUpper;
3553
+ let previousSplitter;
3554
+ const flush = () => {
3555
+ if (buffer)
3556
+ parts.push(buffer);
4612
3557
  };
4613
- }
4614
- function resolveVueOptions(vuePlugin, optimizeTranslationDirective, translationIdentifiers) {
4615
- const vueOptions = vuePlugin.api.options;
4616
- vueOptions.template ||= {};
4617
- vueOptions.template.compilerOptions ||= {};
4618
- vueOptions.template.compilerOptions.directiveTransforms ||= {};
4619
- const translationSignatureResolver = (context, baseResolver) => {
4620
- const { filename } = context;
4621
- const vuePluginOptions = getVuePluginOptions(vuePlugin);
4622
- const normalizedFilename = normalizePath(path.relative(vuePluginOptions.root, filename));
4623
- const resolveIdentifier2 = translationIdentifiers.get(normalizedFilename);
4624
- debug$2("resolved vue-i18n Identifier", resolveIdentifier2);
4625
- if (resolveIdentifier2 == null) {
4626
- return void 0;
3558
+ for (const char of value) {
3559
+ if (REGEX_SEPARATORS.test(char)) {
3560
+ flush();
3561
+ buffer = "";
3562
+ previousUpper = void 0;
3563
+ previousSplitter = true;
3564
+ continue;
4627
3565
  }
4628
- if (resolveIdentifier2.type === "identifier") {
4629
- return baseResolver(context, resolveIdentifier2.key);
3566
+ const isUpper = isUppercase(char);
3567
+ const boundary = previousSplitter === false ? caseBoundary(previousUpper, isUpper, buffer) : void 0;
3568
+ if (boundary === "before") {
3569
+ flush();
3570
+ buffer = char;
3571
+ } else if (boundary === "after") {
3572
+ parts.push(buffer.slice(0, -1));
3573
+ buffer = buffer.at(-1) + char;
4630
3574
  } else {
4631
- const resolvedSignature = baseResolver(context, resolveIdentifier2.key);
4632
- return resolveIdentifier2?.style === "script-setup" ? `${resolvedSignature}.t` : resolvedSignature;
4633
- }
4634
- };
4635
- vueOptions.template.compilerOptions.directiveTransforms.t = transformVTDirective({
4636
- translationSignatures: isBoolean(optimizeTranslationDirective) ? translationSignatureResolver : optimizeTranslationDirective
4637
- });
4638
- return vueOptions;
4639
- }
4640
- function analyzeIdentifiers(descriptor, { root }, translationIdentifiers) {
4641
- const source = descriptor.scriptSetup?.content || descriptor.script?.content;
4642
- debug$2("getDescriptor content", source);
4643
- if (!source) {
4644
- return;
4645
- }
4646
- const ast = tsEstree.parse(source, { range: true });
4647
- tsEstree.simpleTraverse(ast, {
4648
- enter(node, parent) {
4649
- if (parent) {
4650
- node.parent = parent;
4651
- }
3575
+ buffer += char;
4652
3576
  }
4653
- });
4654
- const scopeManager = analyze(ast, { sourceType: "module" });
4655
- const scope = getScope(scopeManager, ast);
4656
- const importLocalName = getImportLocalName(scope, "vue-i18n", "useI18n");
4657
- if (importLocalName == null) {
4658
- return;
4659
- }
4660
- debug$2("importLocalName", importLocalName);
4661
- const resolvedIdentifier = getVueI18nIdentifier(scope, importLocalName);
4662
- if (resolvedIdentifier) {
4663
- const normalizedFilename = normalizePath(path.relative(root, descriptor.filename));
4664
- debug$2("set vue-i18n resolved identifier: ", resolvedIdentifier);
4665
- translationIdentifiers.set(normalizedFilename, resolvedIdentifier);
4666
- }
4667
- }
4668
- function getScope(manager, node) {
4669
- const scope = manager.acquire(node, true);
4670
- if (scope) {
4671
- if (scope.type === "function-expression-name") {
4672
- return scope.childScopes[0];
4673
- }
4674
- return scope;
3577
+ previousUpper = isUpper;
3578
+ previousSplitter = false;
4675
3579
  }
4676
- return manager.scopes[0];
3580
+ flush();
3581
+ return parts;
4677
3582
  }
4678
- function getImportLocalName(scope, source, imported) {
4679
- const importDecl = getImportDeclaration(scope, source);
4680
- if (importDecl) {
4681
- const specifierNode = importDecl.specifiers.find(
4682
- (specifierNode2) => isImportedIdentifierInImportClause(specifierNode2) && specifierNode2.imported.name === imported
4683
- );
4684
- return specifierNode ? specifierNode.local.name : null;
4685
- }
4686
- return null;
3583
+ function kebabCaseSegments(segments) {
3584
+ return segments.map((segment) => segment.toLowerCase()).join("-").replace(REGEX_NON_ALPHANUMERIC, "-").replace(REGEX_REPEATED_DASH, "-").replace(REGEX_EDGE_DASH, "");
4687
3585
  }
4688
- function getImportDeclaration(scope, source) {
4689
- const tracker = new eslintUitls.ReferenceTracker(scope);
4690
- const traceMap = {
4691
- [source]: {
4692
- [eslintUitls.ReferenceTracker.ESM]: true,
4693
- [eslintUitls.ReferenceTracker.READ]: true
3586
+ function resolveLayoutNameSegments(fileName, prefixParts) {
3587
+ const fileNameParts = splitByCase(fileName);
3588
+ const fileNamePartsContent = fileNameParts.join("/").toLowerCase();
3589
+ const layoutNameParts = prefixParts.flatMap((part) => splitByCase(part));
3590
+ const matchedSuffix = [];
3591
+ let index = prefixParts.length - 1;
3592
+ while (index >= 0) {
3593
+ const prefixPart = prefixParts[index];
3594
+ matchedSuffix.unshift(...splitByCase(prefixPart).map((part) => part.toLowerCase()));
3595
+ const matchedSuffixContent = matchedSuffix.join("/");
3596
+ if (fileNamePartsContent === matchedSuffixContent || fileNamePartsContent.startsWith(`${matchedSuffixContent}/`) || prefixPart.toLowerCase() === fileNamePartsContent && prefixParts[index + 1] && prefixParts[index] === prefixParts[index + 1]) {
3597
+ layoutNameParts.length = index;
4694
3598
  }
4695
- };
4696
- const refs = Array.from(tracker.iterateEsmReferences(traceMap));
4697
- return refs.length ? refs[0].node : null;
4698
- }
4699
- function isImportedIdentifierInImportClause(node) {
4700
- return "imported" in node;
4701
- }
4702
- function getVueI18nIdentifier(scope, local) {
4703
- const { callExpression, returnStatement } = getCallExpressionAndReturnStatement(scope, local);
4704
- if (callExpression == null) {
4705
- return null;
4706
- }
4707
- const id = getVariableDeclarationIdFrom(callExpression);
4708
- if (id == null) {
4709
- return null;
4710
- }
4711
- const variableIdPairs = parseVariableId(id);
4712
- debug$2("variableIdPairs:", variableIdPairs);
4713
- const returnVariableIdPairs = parseReturnStatement(returnStatement);
4714
- debug$2("returnVariableIdPairs:", returnVariableIdPairs);
4715
- return resolveIdentifier(variableIdPairs, returnVariableIdPairs);
4716
- }
4717
- const EMPTY_NODE_RETURN = {
4718
- callExpression: null,
4719
- returnStatement: null
4720
- };
4721
- function getCallExpressionAndReturnStatement(scope, local) {
4722
- const variable = eslintUitls.findVariable(scope, local);
4723
- if (variable == null) {
4724
- return EMPTY_NODE_RETURN;
4725
- }
4726
- const callExpressionRef = variable.references.find((ref) => {
4727
- return ref.identifier.parent?.type === tsEstree.AST_NODE_TYPES.CallExpression;
4728
- });
4729
- if (callExpressionRef == null) {
4730
- return EMPTY_NODE_RETURN;
4731
- }
4732
- let returnStatement = null;
4733
- if (callExpressionRef.from.type === "function" && callExpressionRef.from.block.type === tsEstree.AST_NODE_TYPES.FunctionExpression && // @ts-expect-error -- FIXME: type error
4734
- callExpressionRef.from.block.parent.type === tsEstree.AST_NODE_TYPES.Property && // @ts-expect-error -- FIXME: type error
4735
- callExpressionRef.from.block.parent.key.type === tsEstree.AST_NODE_TYPES.Identifier && // @ts-expect-error -- FIXME: type error
4736
- callExpressionRef.from.block.parent.key.name === "setup") {
4737
- returnStatement = callExpressionRef.from.block.body.body.find((statement) => {
4738
- return statement.type === tsEstree.AST_NODE_TYPES.ReturnStatement;
4739
- });
3599
+ index -= 1;
4740
3600
  }
4741
- return {
4742
- // @ts-expect-error -- FIXME: type error
4743
- callExpression: callExpressionRef.identifier.parent,
4744
- returnStatement
4745
- };
3601
+ return [...layoutNameParts, ...fileNameParts];
4746
3602
  }
4747
- function getVariableDeclarationIdFrom(node) {
4748
- if (node.parent?.type !== tsEstree.AST_NODE_TYPES.VariableDeclarator) {
4749
- return null;
4750
- }
4751
- return node.parent.id;
3603
+ function normalizeLayoutName(file) {
3604
+ const normalizedFile = file.replace(REGEX_BACKSLASH, "/");
3605
+ const slashIndex = normalizedFile.lastIndexOf("/");
3606
+ const dir = slashIndex === -1 ? "" : normalizedFile.slice(0, slashIndex);
3607
+ const basename = slashIndex === -1 ? normalizedFile : normalizedFile.slice(slashIndex + 1);
3608
+ const dotIndex = basename.lastIndexOf(".");
3609
+ const name = dotIndex <= 0 ? basename : basename.slice(0, dotIndex);
3610
+ const prefixParts = splitByCase(dir);
3611
+ return kebabCaseSegments(
3612
+ resolveLayoutNameSegments(dir && name.toLowerCase() === "index" ? "" : name, prefixParts).filter(Boolean)
3613
+ );
4752
3614
  }
4753
- function parseVariableId(node) {
4754
- if (node.type === tsEstree.AST_NODE_TYPES.Identifier) {
4755
- return [{ key: node.name, value: null }];
4756
- } else {
4757
- const props = node.properties.filter(
4758
- // ignore RestElement
4759
- (prop) => prop.type === tsEstree.AST_NODE_TYPES.Property
4760
- );
4761
- const pairs = [];
4762
- for (const prop of props) {
4763
- if (prop?.key.type === tsEstree.AST_NODE_TYPES.Identifier && prop?.value.type === tsEstree.AST_NODE_TYPES.Identifier) {
4764
- pairs.push({ key: prop.key.name, value: prop.value.name });
4765
- }
3615
+ function resolveLayoutsDirs(layoutsDirs, root) {
3616
+ const dirs = [];
3617
+ for (const dir of Array.isArray(layoutsDirs) ? layoutsDirs : [layoutsDirs]) {
3618
+ if (dir.includes("**")) {
3619
+ const matches = globSync(dir, { cwd: root, onlyDirectories: true, absolute: true, expandDirectories: false });
3620
+ dirs.push(...matches.sort().map((match) => normalize(match).replace(/\/$/, "")));
3621
+ } else {
3622
+ dirs.push(normalize(resolve$1(root, dir)));
4766
3623
  }
4767
- return pairs;
4768
3624
  }
3625
+ return dirs;
4769
3626
  }
4770
- function parseReturnStatement(node) {
4771
- const pairs = [];
4772
- if (node == null || node.argument == null) {
4773
- return pairs;
4774
- }
4775
- if (node.argument.type === tsEstree.AST_NODE_TYPES.ObjectExpression) {
4776
- for (const prop of node.argument.properties) {
4777
- if (prop.type === tsEstree.AST_NODE_TYPES.Property) {
4778
- if (prop.key.type === tsEstree.AST_NODE_TYPES.Identifier && prop.value.type === tsEstree.AST_NODE_TYPES.Identifier) {
4779
- pairs.push({ key: prop.key.name, value: prop.value.name });
4780
- } else if (prop.key.type === tsEstree.AST_NODE_TYPES.Identifier && prop.value.type === tsEstree.AST_NODE_TYPES.MemberExpression && prop.value.object.type === tsEstree.AST_NODE_TYPES.Identifier && prop.value.property.type === tsEstree.AST_NODE_TYPES.Identifier) {
4781
- pairs.push({
4782
- key: prop.key.name,
4783
- value: `${prop.value.object.name}.${prop.value.property.name}`
4784
- });
4785
- }
4786
- }
3627
+ function resolveLayoutsOptions(options, userOptions = {}) {
3628
+ const resolved = {
3629
+ layoutsDirs: options.roots.map((root) => `${root}/layouts`),
3630
+ extensions: ["vue"],
3631
+ exclude: [],
3632
+ defaultLayout: "default",
3633
+ // In SSG builds, layout components must be imported synchronously so that
3634
+ // the client-side hydration tree matches the server-rendered HTML. Lazy
3635
+ // non-default layouts (post, home, etc.) would not have resolved when
3636
+ // hydration starts, causing a mismatch.
3637
+ importMode: options.mode === "build" ? () => "sync" : defaultImportMode,
3638
+ inheritDefaultLayout: true
3639
+ };
3640
+ for (const [key, value] of Object.entries(userOptions)) {
3641
+ if (value !== void 0)
3642
+ resolved[key] = value;
3643
+ }
3644
+ return { ...resolved, dirs: resolveLayoutsDirs(resolved.layoutsDirs, options.userRoot) };
3645
+ }
3646
+ async function scanLayouts(options) {
3647
+ const pattern = options.extensions.length > 1 ? `**/*.{${options.extensions.join(",")}}` : `**/*.${options.extensions[0] || ""}`;
3648
+ const layouts = /* @__PURE__ */ new Map();
3649
+ const dirFiles = await Promise.all(options.dirs.map((dir) => glob(pattern, {
3650
+ cwd: dir,
3651
+ ignore: ["**/node_modules/**", "**/.git/**", "**/__*__/*", ...options.exclude],
3652
+ onlyFiles: true,
3653
+ expandDirectories: false
3654
+ })));
3655
+ options.dirs.forEach((dir, index) => {
3656
+ for (const file of dirFiles[index].sort()) {
3657
+ const name = normalizeLayoutName(file);
3658
+ layouts.delete(name);
3659
+ layouts.set(name, normalize(resolve$1(dir, file)));
4787
3660
  }
4788
- return pairs;
4789
- } else if (node.argument.type === tsEstree.AST_NODE_TYPES.Identifier) {
4790
- return pairs;
4791
- } else {
4792
- return pairs;
4793
- }
3661
+ });
3662
+ return layouts;
4794
3663
  }
4795
- function resolveIdentifier(localVariables, returnVariable) {
4796
- if (returnVariable.length === 0) {
4797
- const variable = localVariables.find((pair) => pair.key === "t");
4798
- if (variable && variable.value) {
4799
- return { type: "identifier", key: variable.value };
4800
- }
4801
- const identifierOnly = localVariables.find((pair) => pair.value === null);
4802
- if (identifierOnly && identifierOnly.key) {
4803
- return { type: "object", key: identifierOnly.key, style: "script-setup" };
4804
- }
4805
- return null;
4806
- } else {
4807
- const variable = localVariables.find((pair) => pair.key === "t");
4808
- if (variable && variable.value) {
4809
- const returnVar = returnVariable.find((pair) => pair.value === variable.value);
4810
- if (returnVar && returnVar.key) {
4811
- return { type: "identifier", key: returnVar.key };
4812
- }
4813
- }
4814
- const identifierOnly = localVariables.find((pair) => pair.value === null);
4815
- if (identifierOnly && identifierOnly.key) {
4816
- const targetKey = identifierOnly.key;
4817
- const returnVar = returnVariable.find((pair) => pair.value?.startsWith(targetKey));
4818
- if (returnVar && returnVar.key) {
4819
- return { type: "object", key: returnVar.key, style: "setup-hook" };
4820
- }
3664
+ function generateLayoutsCode(layouts, options, runtime) {
3665
+ const head = [];
3666
+ const entries = [];
3667
+ for (const [name, file] of layouts) {
3668
+ const id = JSON.stringify(toAtFS(file));
3669
+ if (options.importMode(name) === "sync") {
3670
+ const variable = `__layout_${head.length}`;
3671
+ head.push(`import ${variable} from ${id}`);
3672
+ entries.push(` ${JSON.stringify(name)}: ${variable},`);
3673
+ } else {
3674
+ entries.push(` ${JSON.stringify(name)}: lazyLayout(() => import(${id})),`);
4821
3675
  }
4822
- return null;
4823
3676
  }
3677
+ const fallbackArg = options.fallbackLayout ? `, ${JSON.stringify(options.fallbackLayout)}` : "";
3678
+ return `import { createGetRoutes, createLayoutWrapper, createSetupLayouts, lazyLayout, setPageLayout, useLayout } from ${JSON.stringify(toAtFS(runtime))}
3679
+ ${head.join("\n")}
3680
+ export { createGetRoutes, setPageLayout, useLayout }
3681
+ export const layouts = {
3682
+ ${entries.join("\n")}
4824
3683
  }
4825
- function matchSafelistPattern(keyPath, pattern) {
4826
- const regexStr = pattern.replace(/\./g, "\\.").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^.]*").replace(/\{\{GLOBSTAR\}\}/g, ".*");
4827
- return new RegExp(`^${regexStr}$`).test(keyPath);
3684
+ const LayoutWrapper = createLayoutWrapper(layouts, ${JSON.stringify(options.defaultLayout)}${fallbackArg})
3685
+ export const setupLayouts = createSetupLayouts(LayoutWrapper, { inheritDefaultLayout: ${options.inheritDefaultLayout} })
3686
+ `;
4828
3687
  }
4829
- function createUsedKeysCollector(options) {
4830
- const usedKeys = /* @__PURE__ */ new Set();
4831
- const safelistPatterns = options.safelist || [];
4832
- const dynamicKeyStrategy = options.dynamicKeyStrategy || "keep-all";
4833
- const removedKeys = /* @__PURE__ */ new Map();
4834
- let dynamicKeysDetected = false;
3688
+ function createLayoutsPlugin(options) {
3689
+ const runtime = resolve$1(options.clientRoot, "utils/layouts.ts");
3690
+ const resolveOptions = () => resolveLayoutsOptions(options, options.config.layouts);
3691
+ const isLayoutFile = (file, layoutsOptions) => {
3692
+ const path = normalize(file);
3693
+ return layoutsOptions.extensions.some((ext) => path.endsWith(`.${ext}`)) && layoutsOptions.dirs.some((dir) => {
3694
+ const rel = relative(dir, path);
3695
+ return !!rel && !rel.startsWith("..") && !isAbsolute(rel);
3696
+ });
3697
+ };
4835
3698
  return {
4836
- get usedKeys() {
4837
- return usedKeys;
4838
- },
4839
- get dynamicKeysDetected() {
4840
- return dynamicKeysDetected;
4841
- },
4842
- set dynamicKeysDetected(val) {
4843
- dynamicKeysDetected = val;
4844
- },
4845
- safelistPatterns,
4846
- removedKeys,
4847
- addKey(key) {
4848
- usedKeys.add(key);
4849
- },
4850
- markDynamic() {
4851
- dynamicKeysDetected = true;
4852
- },
4853
- shouldKeepKey(keyPath) {
4854
- if (dynamicKeysDetected && dynamicKeyStrategy === "keep-all") {
4855
- return true;
4856
- }
4857
- if (safelistPatterns.some((pattern) => matchSafelistPattern(keyPath, pattern))) {
4858
- return true;
4859
- }
4860
- if (usedKeys.has(keyPath)) {
4861
- return true;
4862
- }
4863
- for (const key of usedKeys) {
4864
- if (key.startsWith(keyPath + ".")) {
4865
- return true;
4866
- }
4867
- }
4868
- return false;
3699
+ name: "valaxy:layouts",
3700
+ resolveId(id) {
3701
+ if (id === LAYOUTS_MODULE_ID)
3702
+ return RESOLVED_LAYOUTS_MODULE_ID;
4869
3703
  },
4870
- reportRemoved(filename, keyPath) {
4871
- const existing = removedKeys.get(filename);
4872
- if (existing) {
4873
- existing.push(keyPath);
4874
- } else {
4875
- removedKeys.set(filename, [keyPath]);
4876
- }
3704
+ async load(id) {
3705
+ if (id !== RESOLVED_LAYOUTS_MODULE_ID)
3706
+ return;
3707
+ const layoutsOptions = resolveOptions();
3708
+ return {
3709
+ code: generateLayoutsCode(await scanLayouts(layoutsOptions), layoutsOptions, runtime),
3710
+ moduleType: "js"
3711
+ };
4877
3712
  },
4878
- getDiagnostics() {
4879
- let totalRemoved = 0;
4880
- for (const keys of removedKeys.values()) {
4881
- totalRemoved += keys.length;
4882
- }
4883
- return { totalRemoved, byFile: removedKeys };
4884
- }
4885
- };
4886
- }
4887
- const I18N_FUNCTIONS = /* @__PURE__ */ new Set(["t", "$t", "tc", "$tc", "te", "$te", "d", "$d", "n", "$n"]);
4888
- const TEMPLATE_T_REGEX = /\$?t\s*\(\s*['"]([^'"]+)['"]/g;
4889
- const VT_DIRECTIVE_STRING_REGEX = /v-t\s*=\s*"'([^']+)'"/g;
4890
- const VT_DIRECTIVE_PATH_REGEX = /v-t\s*=\s*"\{[^}]*path\s*:\s*'([^']+)'/g;
4891
- const TEMPLATE_DYNAMIC_T_REGEX = /\$?t\s*\(\s*[a-zA-Z_$]/g;
4892
- async function extractKeysFromScript(source) {
4893
- const keys = [];
4894
- let hasDynamic = false;
4895
- let tsEstree2;
4896
- try {
4897
- tsEstree2 = await import('@typescript-eslint/typescript-estree');
4898
- } catch {
4899
- return extractKeysFromScriptRegex(source);
4900
- }
4901
- try {
4902
- const ast = tsEstree2.parse(source, {
4903
- range: true,
4904
- jsx: true,
4905
- allowInvalidAST: true,
4906
- suppressDeprecatedPropertyWarnings: true
4907
- });
4908
- tsEstree2.simpleTraverse(ast, {
4909
- enter(node) {
4910
- if (node.type !== tsEstree2.AST_NODE_TYPES.CallExpression) {
4911
- return;
4912
- }
4913
- const calleeName = getCalleeName(node, tsEstree2.AST_NODE_TYPES);
4914
- if (!calleeName || !I18N_FUNCTIONS.has(calleeName)) {
4915
- return;
4916
- }
4917
- const firstArg = node.arguments[0];
4918
- if (!firstArg) {
3713
+ configureServer(server) {
3714
+ server.watcher.add(resolveOptions().dirs);
3715
+ const invalidate = (file) => {
3716
+ if (!isLayoutFile(file, resolveOptions()))
4919
3717
  return;
3718
+ for (const environment of Object.values(server.environments)) {
3719
+ const module = environment.moduleGraph.getModuleById(RESOLVED_LAYOUTS_MODULE_ID);
3720
+ if (module)
3721
+ environment.moduleGraph.invalidateModule(module);
4920
3722
  }
4921
- if (firstArg.type === tsEstree2.AST_NODE_TYPES.Literal && typeof firstArg.value === "string") {
4922
- keys.push(firstArg.value);
4923
- } else if (firstArg.type === tsEstree2.AST_NODE_TYPES.TemplateLiteral && firstArg.expressions.length === 0 && firstArg.quasis.length === 1) {
4924
- const value = firstArg.quasis[0].value.cooked;
4925
- if (value) {
4926
- keys.push(value);
4927
- }
4928
- } else {
4929
- hasDynamic = true;
4930
- }
4931
- }
4932
- });
4933
- } catch {
4934
- return extractKeysFromScriptRegex(source);
4935
- }
4936
- return { keys, hasDynamic };
4937
- }
4938
- function getCalleeName(node, AST_NODE_TYPES) {
4939
- const callee = node.callee;
4940
- if (callee.type === AST_NODE_TYPES.Identifier) {
4941
- return callee.name;
4942
- }
4943
- if (callee.type === AST_NODE_TYPES.MemberExpression && callee.property.type === AST_NODE_TYPES.Identifier) {
4944
- return callee.property.name;
4945
- }
4946
- return null;
4947
- }
4948
- function extractKeysFromScriptRegex(source) {
4949
- const keys = [];
4950
- let match;
4951
- const regex = /\b(?:\$?t|tc|\$tc|te|\$te|d|\$d|n|\$n)\s*\(\s*['"]([^'"]+)['"]/g;
4952
- while ((match = regex.exec(source)) !== null) {
4953
- keys.push(match[1]);
4954
- }
4955
- return { keys, hasDynamic: false };
4956
- }
4957
- function extractKeysFromTemplate(templateContent) {
4958
- const keys = [];
4959
- let hasDynamic = false;
4960
- let match;
4961
- TEMPLATE_T_REGEX.lastIndex = 0;
4962
- VT_DIRECTIVE_STRING_REGEX.lastIndex = 0;
4963
- VT_DIRECTIVE_PATH_REGEX.lastIndex = 0;
4964
- TEMPLATE_DYNAMIC_T_REGEX.lastIndex = 0;
4965
- while ((match = TEMPLATE_T_REGEX.exec(templateContent)) !== null) {
4966
- keys.push(match[1]);
4967
- }
4968
- while ((match = VT_DIRECTIVE_STRING_REGEX.exec(templateContent)) !== null) {
4969
- keys.push(match[1]);
4970
- }
4971
- while ((match = VT_DIRECTIVE_PATH_REGEX.exec(templateContent)) !== null) {
4972
- keys.push(match[1]);
4973
- }
4974
- if (TEMPLATE_DYNAMIC_T_REGEX.test(templateContent)) {
4975
- hasDynamic = true;
4976
- }
4977
- return { keys, hasDynamic };
4978
- }
4979
- async function analyzeVueSFC(content) {
4980
- const keys = [];
4981
- let hasDynamic = false;
4982
- let parse2;
4983
- try {
4984
- const compilerSfc = await import('vue/compiler-sfc');
4985
- parse2 = compilerSfc.parse;
4986
- } catch {
4987
- const templateResult = extractKeysFromTemplate(content);
4988
- const scriptResult = await extractKeysFromScript(content);
4989
- return {
4990
- keys: [...templateResult.keys, ...scriptResult.keys],
4991
- hasDynamic: templateResult.hasDynamic || scriptResult.hasDynamic
4992
- };
4993
- }
4994
- const { descriptor } = parse2(content);
4995
- if (descriptor.template?.content) {
4996
- const templateResult = extractKeysFromTemplate(descriptor.template.content);
4997
- keys.push(...templateResult.keys);
4998
- if (templateResult.hasDynamic) {
4999
- hasDynamic = true;
5000
- }
5001
- }
5002
- const scriptContent = descriptor.scriptSetup?.content || descriptor.script?.content;
5003
- if (scriptContent) {
5004
- const scriptResult = await extractKeysFromScript(scriptContent);
5005
- keys.push(...scriptResult.keys);
5006
- if (scriptResult.hasDynamic) {
5007
- hasDynamic = true;
5008
- }
5009
- }
5010
- return { keys, hasDynamic };
5011
- }
5012
- async function analyzeFile(content, filePath, collector) {
5013
- let result;
5014
- if (filePath.endsWith(".vue")) {
5015
- result = await analyzeVueSFC(content);
5016
- } else {
5017
- result = await extractKeysFromScript(content);
5018
- }
5019
- for (const key of result.keys) {
5020
- collector.addKey(key);
5021
- }
5022
- if (result.hasDynamic) {
5023
- collector.markDynamic();
5024
- }
5025
- }
5026
- const debug$1$1 = createDebug(resolveNamespace("tree-shaking"));
5027
- function treeShakingPlugin(resolvedOptions, collector) {
5028
- let projectRoot = "";
5029
- return {
5030
- name: resolveNamespace("tree-shaking"),
5031
- enforce: "pre",
5032
- vite: {
5033
- configResolved(config) {
5034
- projectRoot = config.root;
5035
- }
5036
- },
5037
- webpack(compiler) {
5038
- projectRoot = compiler.options.context || process.cwd();
5039
- },
5040
- async buildStart() {
5041
- const treeShaking = resolvedOptions.treeShaking;
5042
- const patterns = treeShaking?.scanPatterns || [`${projectRoot}/src/**/*.{vue,ts,js,tsx,jsx}`];
5043
- debug$1$1("scanning patterns:", patterns);
5044
- const files = await glob(patterns, {
5045
- ignore: ["**/node_modules/**"],
5046
- absolute: true
3723
+ server.ws.send({ type: "full-reload" });
3724
+ };
3725
+ server.watcher.on("add", invalidate);
3726
+ server.watcher.on("unlink", invalidate);
3727
+ server.httpServer?.once("close", () => {
3728
+ server.watcher.off("add", invalidate);
3729
+ server.watcher.off("unlink", invalidate);
5047
3730
  });
5048
- debug$1$1(`found ${files.length} source files to scan`);
5049
- for (const file of files) {
5050
- try {
5051
- const content = await promises.readFile(file, "utf-8");
5052
- await analyzeFile(content, file, collector);
5053
- } catch (err) {
5054
- debug$1$1(`failed to analyze file: ${file}`, err);
5055
- }
5056
- }
5057
- debug$1$1(
5058
- `scan complete: ${collector.usedKeys.size} used keys found, dynamic: ${collector.dynamicKeysDetected}`
5059
- );
5060
- if (collector.dynamicKeysDetected) {
5061
- const strategy = treeShaking?.dynamicKeyStrategy || "keep-all";
5062
- if (strategy === "keep-all") {
5063
- warn(
5064
- "Tree-shaking: dynamic key usage detected. All keys will be preserved (dynamicKeyStrategy: keep-all)."
5065
- );
5066
- } else {
5067
- warn(
5068
- "Tree-shaking: dynamic key usage detected. Unused keys will still be removed (dynamicKeyStrategy: ignore)."
5069
- );
5070
- }
5071
- }
5072
- },
5073
- buildEnd() {
5074
- const diagnostics = collector.getDiagnostics();
5075
- if (diagnostics.totalRemoved > 0) {
5076
- debug$1$1(`tree-shaking: removed ${diagnostics.totalRemoved} unused message keys`);
5077
- for (const [file, keys] of diagnostics.byFile) {
5078
- debug$1$1(` ${file}: removed ${keys.length} keys (${keys.join(", ")})`);
5079
- }
5080
- } else {
5081
- debug$1$1("tree-shaking: no keys removed");
5082
- }
5083
3731
  }
5084
3732
  };
5085
3733
  }
5086
- const debug$4 = createDebug(resolveNamespace("root"));
5087
- const unpluginFactory = (options = {}, meta) => {
5088
- debug$4("meta framework", meta.framework);
5089
- if (!["vite", "webpack"].includes(meta.framework)) {
5090
- raiseError(`This plugin is supported 'vite' and 'webpack' only`);
5091
- }
5092
- debug$4("plugin options (resolving):", options);
5093
- const resolvedOptions = resolveOptions(options);
5094
- debug$4("plugin options (resolved):", resolvedOptions);
5095
- const collector = resolvedOptions.treeShaking ? createUsedKeysCollector(resolvedOptions.treeShaking) : null;
5096
- const plugins = [];
5097
- if (resolvedOptions.treeShaking && collector) {
5098
- plugins.push(treeShakingPlugin(resolvedOptions, collector));
5099
- }
5100
- plugins.push(resourcePlugin(resolvedOptions, meta, collector));
5101
- if (resolvedOptions.optimizeTranslationDirective) {
5102
- if (meta.framework === "webpack") {
5103
- raiseError(
5104
- `The 'optimizeTranslationDirective' option still is not supported for webpack.
5105
- We are waiting for your Pull Request \u{1F642}.`
5106
- );
5107
- }
5108
- plugins.push(directivePlugin(resolvedOptions));
5109
- }
5110
- return plugins;
5111
- };
5112
- const unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
5113
-
5114
- const VueI18n = unplugin.vite;
5115
3734
 
5116
3735
  function createLlmsPlugin(options) {
5117
3736
  const llmsConfig = options.config.siteConfig.llms;
@@ -6650,7 +5269,7 @@ function cacheMarkdownRender(md, state, base, fileInfoFor) {
6650
5269
  maxSize: 32 * 1024 * 1024,
6651
5270
  sizeCalculation: (item) => item.bytes
6652
5271
  });
6653
- const log = createDebug("valaxy:md");
5272
+ const log = _debug("valaxy:md");
6654
5273
  const getBase = createMarkdownBaseResolver(base);
6655
5274
  const render = md.renderAsync.bind(md);
6656
5275
  let active = true;
@@ -6685,7 +5304,7 @@ function cacheMarkdownRender(md, state, base, fileInfoFor) {
6685
5304
  const KNOWN_EXTENSIONS = /* @__PURE__ */ new Set();
6686
5305
  function treatAsHtml(filename) {
6687
5306
  if (KNOWN_EXTENSIONS.size === 0) {
6688
- const extraExts = typeof process$1 === "object" && process$1.env.VITE_EXTRA_EXTENSIONS || process$1.env?.VITE_EXTRA_EXTENSIONS || "";
5307
+ const extraExts = typeof process === "object" && process.env.VITE_EXTRA_EXTENSIONS || process.env?.VITE_EXTRA_EXTENSIONS || "";
6689
5308
  `3g2,3gp,aac,ai,apng,au,avif,bin,bmp,cer,class,conf,crl,css,csv,dll,doc,eps,epub,exe,gif,gz,ics,ief,jar,jpe,jpeg,jpg,js,json,jsonld,m4a,man,mid,midi,mjs,mov,mp2,mp3,mp4,mpe,mpeg,mpg,mpp,oga,ogg,ogv,ogx,opus,otf,p10,p7c,p7m,p7s,pdf,png,ps,qt,roff,rtf,rtx,ser,svg,t,tif,tiff,tr,ts,tsv,ttf,txt,vtt,wav,weba,webm,webp,woff,woff2,xhtml,xml,yaml,yml,zip${extraExts && typeof extraExts === "string" ? `,${extraExts}` : ""}`.split(",").forEach((ext2) => KNOWN_EXTENSIONS.add(ext2));
6690
5309
  }
6691
5310
  const ext = filename.split(".").pop();
@@ -6735,7 +5354,7 @@ function resolveTransformIncludes(code, id, options) {
6735
5354
  code = code.replace(includedRE, (m, m1) => {
6736
5355
  const atPresent = m1.startsWith("@");
6737
5356
  const includePath = atPresent ? path$1.resolve(options.userRoot, m1.slice(m1[1] === "/" ? 2 : 1)) : path$1.join(dir, m1);
6738
- includes.push(slash$2(includePath));
5357
+ includes.push(slash$1(includePath));
6739
5358
  return "";
6740
5359
  });
6741
5360
  return {
@@ -6886,7 +5505,7 @@ async function createLightMarkdownRenderer(options, base) {
6886
5505
  return md;
6887
5506
  }
6888
5507
 
6889
- const debug$1 = createDebug("valaxy:local-search");
5508
+ const debug$1 = _debug("valaxy:local-search");
6890
5509
  const LOCAL_SEARCH_INDEX_ID = "@localSearchIndex";
6891
5510
  const LOCAL_SEARCH_INDEX_REQUEST_PATH = `/${LOCAL_SEARCH_INDEX_ID}`;
6892
5511
  async function localSearchPlugin(options, base) {
@@ -6911,7 +5530,7 @@ async function localSearchPlugin(options, base) {
6911
5530
  async function render(file) {
6912
5531
  if (!fs.existsSync(file))
6913
5532
  return { html: "", shared: false };
6914
- const relativePath = getPagePath(file, options.userRoot) || slash$2(path.relative(srcDir, file));
5533
+ const relativePath = getPagePath(file, options.userRoot) || slash$1(path.relative(srcDir, file));
6915
5534
  const env = { path: file, relativePath };
6916
5535
  const mdRaw = await fs.promises.readFile(file, "utf-8");
6917
5536
  const { data: fm, content } = matter(mdRaw, matterOptions);
@@ -6955,8 +5574,8 @@ async function localSearchPlugin(options, base) {
6955
5574
  }
6956
5575
  }
6957
5576
  function getDocId(file) {
6958
- const relFile = getPagePath(file, options.userRoot) || slash$2(path.relative(srcDir, file));
6959
- let id = slash$2(path.join("/", relFile));
5577
+ const relFile = getPagePath(file, options.userRoot) || slash$1(path.relative(srcDir, file));
5578
+ let id = slash$1(path.join("/", relFile));
6960
5579
  id = id.replace(/(^|\/)index\.md$/, "$1");
6961
5580
  id = id.replace(/\.md$/, "");
6962
5581
  return id;
@@ -7082,7 +5701,7 @@ async function localSearchPlugin(options, base) {
7082
5701
  },
7083
5702
  async load(id) {
7084
5703
  if (id === LOCAL_SEARCH_INDEX_REQUEST_PATH) {
7085
- if (process$1.env.NODE_ENV === "production") {
5704
+ if (process.env.NODE_ENV === "production") {
7086
5705
  await scanForBuild();
7087
5706
  }
7088
5707
  const records = [];
@@ -7104,7 +5723,7 @@ async function localSearchPlugin(options, base) {
7104
5723
  },
7105
5724
  async handleHotUpdate({ file }) {
7106
5725
  if (file.endsWith(".md")) {
7107
- const relPath = getPagePath(file, options.userRoot) || slash$2(path.relative(srcDir, file));
5726
+ const relPath = getPagePath(file, options.userRoot) || slash$1(path.relative(srcDir, file));
7108
5727
  if (!relPath.startsWith("..")) {
7109
5728
  changedPages.add(relPath);
7110
5729
  await flushUpdates();
@@ -7213,12 +5832,12 @@ function createScanDeadLinks(options) {
7213
5832
  if (url.endsWith("/"))
7214
5833
  url += `index`;
7215
5834
  const resolved = decodeURIComponent(
7216
- slash$2(
5835
+ slash$1(
7217
5836
  url.startsWith("/") ? url.slice(1) : path$1.normalize(path$1.join(path$1.dirname(logicalFile), url))
7218
5837
  )
7219
5838
  // /index => /
7220
5839
  ).replace(/(^|\/)index$/, "");
7221
- if (!routes.has(resolved) && !fs.existsSync(path$1.resolve(dir, publicDir, `${resolved}.html`)) && !shouldIgnoreDeadLink(url)) {
5840
+ if (!routes.has(resolved) && !resolvePageFile(`${resolved}.vue`, options.userRoot) && !resolvePageFile(path$1.join(resolved, "index.vue"), options.userRoot) && !fs.existsSync(path$1.resolve(dir, publicDir, `${resolved}.html`)) && !shouldIgnoreDeadLink(url)) {
7222
5841
  recordDeadLink(url);
7223
5842
  }
7224
5843
  }
@@ -7240,7 +5859,7 @@ function createTransformEncrypt(options) {
7240
5859
  "</ClientOnly>"
7241
5860
  ].join("");
7242
5861
  };
7243
- const globalPassword = process$1.env.VALAXY_ENCRYPT_PASSWORD;
5862
+ const globalPassword = process.env.VALAXY_ENCRYPT_PASSWORD;
7244
5863
  const password = frontmatter.password || frontmatter.encrypt === true && globalPassword || void 0;
7245
5864
  if (password && !frontmatter.password && globalPassword) {
7246
5865
  if (!globalPasswordLoggedOnce) {
@@ -7450,7 +6069,7 @@ async function generatePageData(code, context, options) {
7450
6069
  return pageData;
7451
6070
  }
7452
6071
 
7453
- const debug = createDebug("valaxy:md");
6072
+ const debug = _debug("valaxy:md");
7454
6073
  const caches = /* @__PURE__ */ new WeakMap();
7455
6074
  function getMarkdownCache(state) {
7456
6075
  let cache = caches.get(state);
@@ -7559,7 +6178,7 @@ function createClientSetupPlugin(options) {
7559
6178
  if (legacySetup)
7560
6179
  warnMermaidMigration(options, legacySetup);
7561
6180
  }
7562
- const setupEntry = slash$2(resolve(clientRoot, "setup"));
6181
+ const setupEntry = slash$1(resolve(clientRoot, "setup"));
7563
6182
  return {
7564
6183
  name: "valaxy:setup",
7565
6184
  enforce: "pre",
@@ -7980,16 +6599,11 @@ async function createValaxyPlugin(options, serverOptions = {}, state = Valaxy.st
7980
6599
  ].filter((item) => !!item);
7981
6600
  return moduleEntries;
7982
6601
  };
7983
- const configFiles = [options.configFile];
6602
+ const configFiles = [options.configFile, options.siteConfigFile, resolve$1(options.themeRoot, "valaxy.config.ts")];
7984
6603
  if (configFiles.includes(file)) {
7985
- const { config } = await resolveOptions$3({ userRoot: options.userRoot });
6604
+ const { config } = await resolveOptions$1({ userRoot: options.userRoot });
7986
6605
  return reloadConfigAndEntries(config);
7987
6606
  }
7988
- if (file === options.siteConfigFile) {
7989
- const { siteConfig } = await resolveSiteConfig(options.userRoot);
7990
- valaxyConfig.siteConfig = replaceArrMerge(siteConfig, defaultSiteConfig);
7991
- return reloadConfigAndEntries(valaxyConfig);
7992
- }
7993
6607
  if (file === options.themeConfigFile) {
7994
6608
  const { themeConfig } = await resolveUserThemeConfig(options);
7995
6609
  const pkg = valaxyConfig.themeConfig.pkg;
@@ -7997,12 +6611,6 @@ async function createValaxyPlugin(options, serverOptions = {}, state = Valaxy.st
7997
6611
  valaxyConfig.themeConfig = themeConfig;
7998
6612
  return reloadConfigAndEntries(valaxyConfig);
7999
6613
  }
8000
- if (file === resolve$1(options.themeRoot, "valaxy.config.ts")) {
8001
- const themeValaxyConfig = await resolveThemeValaxyConfig(options);
8002
- const valaxyConfig2 = mergeValaxyConfig(options.config, themeValaxyConfig);
8003
- const { config } = await processValaxyOptions(options, valaxyConfig2);
8004
- return reloadConfigAndEntries(config);
8005
- }
8006
6614
  if (file.endsWith(".md")) {
8007
6615
  const endCount = countPerformanceTime();
8008
6616
  const content = await read();
@@ -8141,8 +6749,12 @@ async function createRouterOptions(valaxyApp, base, parseMatter = (source) => ma
8141
6749
  }
8142
6750
  }
8143
6751
  const path = route.components.get("default") || "";
8144
- if (path.endsWith(".md")) {
8145
- const md = await fs.readFile(path, "utf-8");
6752
+ const md = path.endsWith(".md") ? await fs.readFile(path, "utf-8").catch((e) => {
6753
+ if (e.code === "ENOENT" || e.code === "ENOTDIR")
6754
+ return void 0;
6755
+ throw e;
6756
+ }) : void 0;
6757
+ if (md !== void 0) {
8146
6758
  const { data, excerpt, content } = parseMatter(md);
8147
6759
  const mdFm = data;
8148
6760
  const lastUpdated = valaxyConfig.siteConfig.lastUpdated;
@@ -8416,20 +7028,11 @@ async function ViteValaxyPlugins(valaxyApp, serverOptions = {}, viteConfig = {},
8416
7028
  vuePlugin,
8417
7029
  createConfigPlugin(options),
8418
7030
  createClientSetupPlugin(options),
7031
+ createCoverComponentsPlugin(componentsDirs),
8419
7032
  Unhead(),
8420
7033
  // https://router.vuejs.org/file-based-routing/
8421
7034
  RouterPlugin,
8422
- // https://github.com/loicduong/vite-plugin-vue-layouts-next
8423
- Layout({
8424
- layoutsDirs: roots.map((root) => `${root}/layouts`),
8425
- // In SSG builds, layout components must be imported synchronously so that
8426
- // the client-side hydration tree matches the server-rendered HTML. Without
8427
- // this, non-default layouts (post, home, etc.) are lazy-loaded and haven't
8428
- // resolved when hydration starts, causing a mismatch. The built-in SSG
8429
- // engine needs an explicit importMode override to force synchronous imports.
8430
- ...options.mode === "build" ? { importMode: () => "sync" } : {},
8431
- ...valaxyConfig.layouts
8432
- }),
7035
+ createLayoutsPlugin(options),
8433
7036
  // https://github.com/antfu/unplugin-vue-components
8434
7037
  Components({
8435
7038
  extensions: ["vue", "md"],
@@ -8508,13 +7111,13 @@ async function ViteValaxyPlugins(valaxyApp, serverOptions = {}, viteConfig = {},
8508
7111
  }
8509
7112
 
8510
7113
  async function profileBuildPhase(phase, run) {
8511
- if (!process$1.env.VALAXY_BUILD_PROFILE)
7114
+ if (!process.env.VALAXY_BUILD_PROFILE)
8512
7115
  return run();
8513
7116
  const started = performance.now();
8514
7117
  try {
8515
7118
  return await run();
8516
7119
  } finally {
8517
- process$1.stdout.write(`[valaxy:build] ${JSON.stringify({ phase, durationMs: performance.now() - started, rssMiB: process$1.memoryUsage().rss / 1024 / 1024 })}
7120
+ process.stdout.write(`[valaxy:build] ${JSON.stringify({ phase, durationMs: performance.now() - started, rssMiB: process.memoryUsage().rss / 1024 / 1024 })}
8518
7121
  `);
8519
7122
  }
8520
7123
  }
@@ -8597,7 +7200,15 @@ function serializeState(state) {
8597
7200
  const serialised = JSON.stringify(state).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/'/g, "\\u0027").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
8598
7201
  return `<script>window.__INITIAL_STATE__='${serialised}'<\/script>`;
8599
7202
  }
7203
+ function decodePathSegment(segment) {
7204
+ try {
7205
+ return decodeURIComponent(segment);
7206
+ } catch {
7207
+ return segment;
7208
+ }
7209
+ }
8600
7210
  function routeToFileName(route) {
7211
+ route = route.split("/").map(decodePathSegment).join("/");
8601
7212
  if (route.endsWith("/"))
8602
7213
  return `${route}index.html`.slice(1);
8603
7214
  if (route.endsWith(".html"))
@@ -9086,7 +7697,7 @@ function getServerInfoText(msg) {
9086
7697
  return `${valaxyPrefix} ${colors.gray(msg)}`;
9087
7698
  }
9088
7699
  async function createServer(valaxyApp, viteConfig = {}, serverOptions = {}) {
9089
- process$1.env.EDITOR = process$1.env.EDITOR || "code";
7700
+ process.env.EDITOR = process.env.EDITOR || "code";
9090
7701
  const { options } = valaxyApp;
9091
7702
  const pluginsTimer = countPerformanceTime();
9092
7703
  const plugins = await ViteValaxyPlugins(valaxyApp, serverOptions, viteConfig);
@@ -9220,7 +7831,7 @@ async function initServer(valaxyApp, viteConfig) {
9220
7831
  } catch (e) {
9221
7832
  consola.error("failed to start server. error:\n");
9222
7833
  console.error(e);
9223
- process$1.exit(1);
7834
+ process.exit(1);
9224
7835
  }
9225
7836
  }
9226
7837
 
@@ -9229,7 +7840,7 @@ async function execBuild({ ssg, root, output, log, siteUrl }) {
9229
7840
  if (!await isPagesDirExist(root))
9230
7841
  throw new Error(`Pages directory not found: ${root}`);
9231
7842
  const userRoot = path.resolve(root);
9232
- const options = await profileBuildPhase("resolve-options", () => resolveOptions$3({ userRoot }, "build"));
7843
+ const options = await profileBuildPhase("resolve-options", () => resolveOptions$1({ userRoot }, "build"));
9233
7844
  if (siteUrl)
9234
7845
  options.config.siteConfig.url = siteUrl;
9235
7846
  setTimezone(options.config.siteConfig.timezone);
@@ -9309,8 +7920,8 @@ function registerBuildCommand(cli) {
9309
7920
  }
9310
7921
 
9311
7922
  async function cleanDist() {
9312
- const distDir = path.join(process$1.cwd(), "dist");
9313
- const cacheDir = path.join(process$1.cwd(), ".valaxy");
7923
+ const distDir = path.join(process.cwd(), "dist");
7924
+ const cacheDir = path.join(process.cwd(), ".valaxy");
9314
7925
  consola.box("\u{1F9F9} Starting clean...");
9315
7926
  if (await fs.exists(distDir)) {
9316
7927
  consola.info("dist directory exists, removing...");
@@ -9350,28 +7961,8 @@ function registerCleanCommand(cli) {
9350
7961
  }
9351
7962
 
9352
7963
  async function resolveContentLayouts(options) {
9353
- const configured = options.config.layouts;
9354
- const dirs = configured?.layoutsDirs ?? options.roots.map((root) => join$1(root, "layouts"));
9355
- const plugin = Layout({
9356
- ...configured,
9357
- // Array form selects the server-side registry generator, including for one directory.
9358
- layoutsDirs: Array.isArray(dirs) ? dirs : [dirs]
9359
- });
9360
- const configure = plugin.configResolved;
9361
- const load = plugin.load;
9362
- configure({ root: options.userRoot });
9363
- const source = await load("/@vite-plugin-vue-layouts-next/generated-layouts");
9364
- const ast = babelParse(source.code, { sourceType: "module" });
9365
- for (const statement of ast.program.body) {
9366
- if (statement.type !== "ExportNamedDeclaration" || statement.declaration?.type !== "VariableDeclaration")
9367
- continue;
9368
- for (const declaration of statement.declaration.declarations) {
9369
- if (declaration.id.type !== "Identifier" || declaration.id.name !== "layouts" || declaration.init?.type !== "ObjectExpression")
9370
- continue;
9371
- return new Set(declaration.init.properties.flatMap((property) => property.type === "ObjectProperty" && property.key.type === "StringLiteral" ? [property.key.value] : []));
9372
- }
9373
- }
9374
- throw new Error("Layout registry was not generated");
7964
+ const layouts = await scanLayouts(resolveLayoutsOptions(options, options.config.layouts));
7965
+ return new Set(layouts.keys());
9375
7966
  }
9376
7967
 
9377
7968
  const safeMatterOptions = {
@@ -9441,7 +8032,7 @@ function createContentService(app, settings = {}) {
9441
8032
  const options = await routerOptions;
9442
8033
  const routes = [];
9443
8034
  routerApp.options.redirects.length = 0;
9444
- const context = createRoutesContext(resolveOptions$4({
8035
+ const context = createRoutesContext(resolveOptions$2({
9445
8036
  ...options,
9446
8037
  root: userRoot,
9447
8038
  dts: false,
@@ -9666,7 +8257,7 @@ function registerContentCommands(cli) {
9666
8257
  setEnv();
9667
8258
  if (json)
9668
8259
  setLogLevel(-999);
9669
- const options = await resolveOptions$3({ userRoot: resolve$1(root) });
8260
+ const options = await resolveOptions$1({ userRoot: resolve$1(root) });
9670
8261
  setTimezone(options.config.siteConfig.timezone);
9671
8262
  const app = createValaxyNode(options);
9672
8263
  if (options.config.loaders?.length) {
@@ -9682,7 +8273,7 @@ function registerContentCommands(cli) {
9682
8273
  });
9683
8274
  const result = command === "inspect" ? await service.inspectPage(file) : await service.checkPage(file);
9684
8275
  if ("ok" in result && !result.ok)
9685
- process$1.exitCode = 1;
8276
+ process.exitCode = 1;
9686
8277
  if (json || !("diagnostics" in result)) {
9687
8278
  console.log(JSON.stringify(result, null, 2));
9688
8279
  } else {
@@ -9692,7 +8283,7 @@ function registerContentCommands(cli) {
9692
8283
  ${diagnostic.hint}`);
9693
8284
  }
9694
8285
  } catch (error) {
9695
- process$1.exitCode = 1;
8286
+ process.exitCode = 1;
9696
8287
  const message = error instanceof Error ? error.message : "Content inspection failed";
9697
8288
  if (json)
9698
8289
  console.log(JSON.stringify({ path: file, ok: false, error: message }));
@@ -9719,12 +8310,12 @@ async function collectDebugInfo() {
9719
8310
  const info = {
9720
8311
  os: os.platform(),
9721
8312
  arch: os.arch(),
9722
- node: process$1.version,
8313
+ node: process.version,
9723
8314
  pnpm: getPnpmVersion(),
9724
8315
  valaxy: version
9725
8316
  };
9726
8317
  try {
9727
- const options = await resolveOptions$3({ userRoot: process$1.cwd() });
8318
+ const options = await resolveOptions$1({ userRoot: process.cwd() });
9728
8319
  info.userRoot = options.userRoot;
9729
8320
  info.theme = options.theme;
9730
8321
  info.themeVersion = options.config.themeConfig?.pkg?.version;
@@ -9832,12 +8423,12 @@ function registerDeployCommand(cli) {
9832
8423
  });
9833
8424
  if (isCancel(shouldBuild)) {
9834
8425
  cancel("Operation cancelled.");
9835
- process$1.exit(0);
8426
+ process.exit(0);
9836
8427
  }
9837
8428
  if (shouldBuild) {
9838
8429
  await execBuild({ ssg: true, root, output, log: "info" });
9839
8430
  }
9840
- const options = await resolveOptions$3({ userRoot: root }, "build");
8431
+ const options = await resolveOptions$1({ userRoot: root }, "build");
9841
8432
  const configDeployType = type ?? options.config.deploy?.type;
9842
8433
  const deployType = configDeployType ?? await select({
9843
8434
  message: "Where do you want to deploy?",
@@ -9848,7 +8439,7 @@ function registerDeployCommand(cli) {
9848
8439
  });
9849
8440
  if (isCancel(deployType)) {
9850
8441
  cancel("Operation cancelled.");
9851
- process$1.exit(0);
8442
+ process.exit(0);
9852
8443
  }
9853
8444
  if (deployType === "gh-pages") {
9854
8445
  let isGhPagesInstalled = false;
@@ -9861,7 +8452,7 @@ function registerDeployCommand(cli) {
9861
8452
  });
9862
8453
  if (isCancel(installGhPages)) {
9863
8454
  cancel("Operation cancelled.");
9864
- process$1.exit(0);
8455
+ process.exit(0);
9865
8456
  }
9866
8457
  if (installGhPages) {
9867
8458
  try {
@@ -9948,7 +8539,7 @@ const SHORTCUTS = [
9948
8539
  key: "e",
9949
8540
  description: "edit",
9950
8541
  action() {
9951
- exec(`code "${process$1.cwd()}"`, (err) => {
8542
+ exec(`code "${process.cwd()}"`, (err) => {
9952
8543
  if (err)
9953
8544
  console.error("Failed to open editor", err);
9954
8545
  });
@@ -9956,15 +8547,15 @@ const SHORTCUTS = [
9956
8547
  }
9957
8548
  ];
9958
8549
  function bindShortcuts(server, createDevServer) {
9959
- if (!server.httpServer || !process$1.stdin.isTTY || process$1.env.CI)
8550
+ if (!server.httpServer || !process.stdin.isTTY || process.env.CI)
9960
8551
  return;
9961
- process$1.stdin.resume();
9962
- process$1.stdin.setEncoding("utf8");
9963
- readline.emitKeypressEvents(process$1.stdin);
9964
- process$1.stdin.setRawMode(true);
8552
+ process.stdin.resume();
8553
+ process.stdin.setEncoding("utf8");
8554
+ readline.emitKeypressEvents(process.stdin);
8555
+ process.stdin.setRawMode(true);
9965
8556
  async function onKeyPress(str, key) {
9966
8557
  if (key.ctrl && key.name === "c") {
9967
- process$1.exit();
8558
+ process.exit();
9968
8559
  } else {
9969
8560
  const shortcut = SHORTCUTS.find((shortcut2) => shortcut2.key === str);
9970
8561
  if (!shortcut)
@@ -9976,14 +8567,14 @@ function bindShortcuts(server, createDevServer) {
9976
8567
  }
9977
8568
  }
9978
8569
  }
9979
- process$1.stdin.on("keypress", onKeyPress);
8570
+ process.stdin.on("keypress", onKeyPress);
9980
8571
  server.httpServer.on("close", () => {
9981
- process$1.stdin.off("keypress", onKeyPress);
8572
+ process.stdin.off("keypress", onKeyPress);
9982
8573
  });
9983
8574
  }
9984
8575
 
9985
8576
  async function startValaxyDev({
9986
- root = process$1.cwd(),
8577
+ root = process.cwd(),
9987
8578
  port,
9988
8579
  remote,
9989
8580
  log,
@@ -9995,10 +8586,10 @@ async function startValaxyDev({
9995
8586
  if (log === "debug")
9996
8587
  setLogLevel(4);
9997
8588
  if (!await isPagesDirExist(root))
9998
- process$1.exit(0);
8589
+ process.exit(0);
9999
8590
  port = port || await findFreePort(4859);
10000
8591
  const resolveTimer = countPerformanceTime();
10001
- const resolvedOptions = await resolveOptions$3({ userRoot: root });
8592
+ const resolvedOptions = await resolveOptions$1({ userRoot: root });
10002
8593
  vLogger.debug(`resolveOptions: ${resolveTimer()}`);
10003
8594
  setTimezone(resolvedOptions.config.siteConfig.timezone);
10004
8595
  const createNodeTimer = countPerformanceTime();
@@ -10108,7 +8699,7 @@ function registerDevCommand(cli) {
10108
8699
  );
10109
8700
  }
10110
8701
 
10111
- const userRoot = process$1.cwd();
8702
+ const userRoot = process.cwd();
10112
8703
  const defaultPostTemplate = `---
10113
8704
  layout: <%=layout%>
10114
8705
  title: <%=title%>
@@ -10117,7 +8708,7 @@ date: <%=date%>
10117
8708
  `;
10118
8709
 
10119
8710
  async function getTemplate(layout) {
10120
- const { clientRoot, themeRoot } = await resolveOptions$3({ userRoot });
8711
+ const { clientRoot, themeRoot } = await resolveOptions$1({ userRoot });
10121
8712
  const roots = [userRoot, themeRoot, clientRoot];
10122
8713
  for (const root of roots) {
10123
8714
  const scaffoldPath = path.resolve(root, "scaffolds", `${layout}.md`);
@@ -10158,7 +8749,7 @@ async function genLayoutTemplate({
10158
8749
  let template = await getTemplate(layout);
10159
8750
  if (!template)
10160
8751
  template = defaultPostTemplate;
10161
- const dateFormat = "YYYY-MM-DD HH:mm:ss";
8752
+ const dateFormat = "YYYY-MM-DDTHH:mm:ssZ";
10162
8753
  return ejs.render(template, { title, layout, date: date ? dayjs().format(dateFormat) : "" });
10163
8754
  }
10164
8755
 
@@ -10223,18 +8814,18 @@ function createCoreCli(argv) {
10223
8814
  });
10224
8815
  return cli.help();
10225
8816
  }
10226
- async function createCli(argv = hideBin(process$1.argv), options = {}) {
8817
+ async function createCli(argv = hideBin(process.argv), options = {}) {
10227
8818
  const cli = createCoreCli(argv);
10228
8819
  if (!shouldResolveAddonCli(argv))
10229
8820
  return cli;
10230
- const userRoot = resolve(options.userRoot || process$1.cwd());
8821
+ const userRoot = resolve(options.userRoot || process.cwd());
10231
8822
  const extensions = await resolveAddonCliExtensions(userRoot);
10232
8823
  registerAddonCliExtensions(cli, extensions, userRoot);
10233
8824
  return cli;
10234
8825
  }
10235
- async function run(argv = hideBin(process$1.argv), options = {}) {
8826
+ async function run(argv = hideBin(process.argv), options = {}) {
10236
8827
  const cli = await createCli(argv, options);
10237
8828
  await cli.parseAsync();
10238
8829
  }
10239
8830
 
10240
- export { resolveValaxyConfig as $, ALL_ROUTE as A, isInstalledGlobally as B, isKatexEnabled as C, isKatexPluginNeeded as D, EXCERPT_SEPARATOR as E, isMathJaxEnabled as F, GLOBAL_STATE as G, isPath as H, loadAllContent as I, loadConfigFromFile as J, mergeValaxyConfig as K, mergeViteConfigs as L, postProcessForSSG as M, processValaxyOptions as N, registerDevCommand as O, PATHNAME_PROTOCOL_RE as P, resolveAddonsConfig as Q, resolveImportPath as R, StateManager as S, resolveImportUrl as T, resolveOptions$3 as U, ViteValaxyPlugins as V, resolveSiteConfig as W, resolveSiteConfigFromRoot as X, resolveThemeConfigFromRoot as Y, resolveThemeValaxyConfig as Z, resolveUserThemeConfig as _, createContentService as a, resolveValaxyConfigFromRoot as a0, run as a1, ssgBuild as a2, startValaxyDev as a3, toAtFS as a4, transformObject as a5, version as a6, build as b, createCli as c, createMemoryReleasePlugin as d, createServer as e, createValaxyNode as f, createValaxyPlugin as g, customElements as h, defaultSiteConfig as i, defaultValaxyConfig as j, defaultViteConfig as k, defineAddon as l, defineConfig as m, defineSiteConfig as n, defineTheme as o, defineValaxyAddon as p, defineValaxyConfig as q, defineValaxyTheme as r, desktopRuntimeVersion as s, encryptContent as t, execBuild as u, generateClientRedirects as v, getGitTimestamp as w, getIndexHtml as x, getServerInfoText as y, isExternal as z };
8831
+ export { resolveUserThemeConfig as $, ALL_ROUTE as A, isInstalledGlobally as B, isKatexEnabled as C, isKatexPluginNeeded as D, EXCERPT_SEPARATOR as E, isMathJaxEnabled as F, GLOBAL_STATE as G, isPath as H, loadAllContent as I, loadConfigFromFile as J, mergeValaxyConfig as K, mergeViteConfigs as L, postProcessForSSG as M, processValaxyOptions as N, registerDevCommand as O, PATHNAME_PROTOCOL_RE as P, resolveAddonsConfig as Q, resolveFootnoteConfig as R, StateManager as S, resolveImportPath as T, resolveImportUrl as U, ViteValaxyPlugins as V, resolveOptions$1 as W, resolveSiteConfig as X, resolveSiteConfigFromRoot as Y, resolveThemeConfigFromRoot as Z, resolveThemeValaxyConfig as _, createContentService as a, resolveValaxyConfig as a0, resolveValaxyConfigFromRoot as a1, run as a2, ssgBuild as a3, startValaxyDev as a4, toAtFS as a5, transformObject as a6, version as a7, build as b, createCli as c, createMemoryReleasePlugin as d, createServer as e, createValaxyNode as f, createValaxyPlugin as g, customElements as h, defaultSiteConfig as i, defaultValaxyConfig as j, defaultViteConfig as k, defineAddon as l, defineConfig as m, defineSiteConfig as n, defineTheme as o, defineValaxyAddon as p, defineValaxyConfig as q, defineValaxyTheme as r, desktopRuntimeVersion as s, encryptContent as t, execBuild as u, generateClientRedirects as v, getGitTimestamp as w, getIndexHtml as x, getServerInfoText as y, isExternal as z };