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
@@ -2,7 +2,7 @@ import 'node:path';
2
2
  import 'node:process';
3
3
  import 'yargs';
4
4
  import 'yargs/helpers';
5
- export { c as createCli, s as desktopRuntimeVersion, u as execBuild, O as registerDevCommand, a1 as run, a3 as startValaxyDev } from '../../shared/valaxy.DstXQBtK.mjs';
5
+ export { c as createCli, s as desktopRuntimeVersion, u as execBuild, O as registerDevCommand, a2 as run, a4 as startValaxyDev } from '../../shared/valaxy.CRodiDWz.mjs';
6
6
  import 'node:os';
7
7
  import 'consola';
8
8
  import 'consola/utils';
@@ -19,6 +19,7 @@ import 'node:crypto';
19
19
  import 'floating-vue';
20
20
  import 'define-config-ts';
21
21
  import 'ora';
22
+ import 'node:buffer';
22
23
  import 'cross-spawn';
23
24
  import 'mlly';
24
25
  import 'resolve-global';
@@ -39,16 +40,9 @@ import 'unplugin';
39
40
  import 'unplugin-utils';
40
41
  import 'obug';
41
42
  import 'magic-string';
42
- import 'node:buffer';
43
43
  import 'p-map';
44
- import '@intlify/shared';
45
- import '@intlify/bundle-utils';
46
- import '@rollup/pluginutils';
47
- import 'vue/compiler-sfc';
48
- import 'picocolors';
49
- import '@eslint-community/eslint-utils';
50
- import '@intlify/vue-i18n-extensions';
51
- import '@typescript-eslint/scope-manager';
44
+ import 'pascalcase';
45
+ import '@intlify/unplugin-vue-i18n/vite';
52
46
  import 'minisearch';
53
47
  import '@shikijs/transformers';
54
48
  import 'lru-cache';
@@ -67,7 +61,6 @@ import 'katex/contrib/mhchem';
67
61
  import 'unplugin-vue-markdown/vite';
68
62
  import 'jiti';
69
63
  import 'unocss';
70
- import 'pascalcase';
71
64
  import 'html-to-text';
72
65
  import 'vue-router/vite';
73
66
  import 'vite-ssg-sitemap';
@@ -1,4 +1,4 @@
1
- import { Plugin, UserConfig, InlineConfig, ViteDevServer, PluginOption } from 'vite';
1
+ import { UserConfig, InlineConfig, ViteDevServer, PluginOption, Plugin } from 'vite';
2
2
  import { SiteConfig, DefaultTheme, RuntimeConfig, RedirectItem, ValaxyConfig, PartialDeep, ValaxyAddon, UserSiteConfig } from '../types/index.mjs';
3
3
  import Vue from '@vitejs/plugin-vue';
4
4
  import { Hookable } from 'hookable';
@@ -26,48 +26,6 @@ import 'vue-router';
26
26
  import '@vueuse/core';
27
27
  import '@unhead/schema-org';
28
28
 
29
- //#region src/types.d.ts
30
- interface Options {
31
- /**
32
- * Relative path to the directory to search for layout components.
33
- * @default 'src/layouts'
34
- */
35
- layoutsDirs: string | string[];
36
- /**
37
- * Valid file extensions for layout components.
38
- * @default ['vue']
39
- */
40
- extensions: string[];
41
- /**
42
- * List of path globs to exclude when resolving layouts.
43
- */
44
- exclude: string[];
45
- /**
46
- * Normalized layout name/key to use as the default layout
47
- * (for example, myDefault.vue -> my-default)
48
- * @default 'default'
49
- */
50
- defaultLayout: string;
51
- /**
52
- * Layout name/key to render when a page asks for a layout that does not exist.
53
- * Defaults to `defaultLayout`.
54
- */
55
- fallbackLayout?: string;
56
- /**
57
- * `sync` bundles a layout into the main chunk, `async` lazy-loads it.
58
- * Defaults to `sync` for `default` (and for every layout under `VITE_SSG`), `async` otherwise.
59
- */
60
- importMode: (name: string) => 'sync' | 'async';
61
- /**
62
- * Whether nested routes should inherit the default layout from parent routes.
63
- * When false, if a child route has its own layout, the parent route won't use the default layout.
64
- * @default true
65
- */
66
- inheritDefaultLayout: boolean;
67
- }
68
- type UserOptions = Partial<Options>;
69
- declare function Layout(userOptions?: UserOptions): Plugin;
70
-
71
29
  interface ValaxyFileInfo {
72
30
  /**
73
31
  * file path id
@@ -104,6 +62,58 @@ declare class StateManager {
104
62
  */
105
63
  declare function createValaxyNode(options: ResolvedValaxyOptions): ValaxyNode;
106
64
 
65
+ /**
66
+ * Valaxy's layout system: scans `layouts/` in every root and serves
67
+ * `virtual:generated-layouts`. The client runtime lives in `client/utils/layouts.ts`.
68
+ *
69
+ * Options, layout-name normalization and runtime behavior follow
70
+ * vite-plugin-vue-layouts-next@3.2.0 (MIT, https://github.com/loicduong/vite-plugin-vue-layouts-next),
71
+ * so existing `layouts` configs and `meta.layout` values keep working.
72
+ */
73
+
74
+ type LayoutImportMode = 'sync' | 'async';
75
+ interface LayoutsOptions {
76
+ /**
77
+ * Directories to search for layout components, absolute or relative to the user root.
78
+ * Entries containing `**` are expanded to every matching directory.
79
+ * Later directories override layouts with the same name from earlier ones.
80
+ * @default roots.map(root => `${root}/layouts`) (core → theme → addons → user)
81
+ */
82
+ layoutsDirs: string | string[];
83
+ /**
84
+ * Valid file extensions for layout components.
85
+ * @default ['vue']
86
+ */
87
+ extensions: string[];
88
+ /**
89
+ * List of path globs to exclude when resolving layouts.
90
+ */
91
+ exclude: string[];
92
+ /**
93
+ * Normalized layout name/key to use as the default layout
94
+ * (for example, myDefault.vue -> my-default)
95
+ * @default 'default'
96
+ */
97
+ defaultLayout: string;
98
+ /**
99
+ * Layout name/key to render when a page asks for a layout that does not exist.
100
+ * Defaults to `defaultLayout`.
101
+ */
102
+ fallbackLayout?: string;
103
+ /**
104
+ * `sync` bundles a layout into the main chunk, `async` lazy-loads it.
105
+ * Defaults to `sync` for every layout in builds (SSG hydration needs it),
106
+ * otherwise `sync` for `default` and `async` for the rest.
107
+ */
108
+ importMode: (name: string) => LayoutImportMode;
109
+ /**
110
+ * Whether nested routes should inherit the default layout from parent routes.
111
+ * When false, if a child route has its own layout, the parent route won't use the default layout.
112
+ * @default true
113
+ */
114
+ inheritDefaultLayout: boolean;
115
+ }
116
+
107
117
  interface MarkdownItHeader {
108
118
  /**
109
119
  * The level of the header
@@ -921,9 +931,10 @@ interface ValaxyExtendConfig {
921
931
  */
922
932
  components?: Parameters<typeof Components>[0];
923
933
  /**
924
- * @see https://github.com/loicduong/vite-plugin-vue-layouts-next
934
+ * Layout system options, compatible with vite-plugin-vue-layouts-next.
935
+ * @see https://valaxy.site/guide/custom/extend#automatic-layout-registration
925
936
  */
926
- layouts?: Parameters<typeof Layout>[0];
937
+ layouts?: Partial<LayoutsOptions>;
927
938
  /**
928
939
  * @see https://router.vuejs.org/file-based-routing/
929
940
  */
@@ -1133,6 +1144,8 @@ declare const defaultSiteConfig: SiteConfig;
1133
1144
  * @param config
1134
1145
  */
1135
1146
  declare function defineSiteConfig(config: UserSiteConfig): PartialDeep<SiteConfig>;
1147
+ /** Resolve before merging defaults so explicit legacy settings stay effective. */
1148
+ declare function resolveFootnoteConfig(config?: UserSiteConfig): SiteConfig['footnote'];
1136
1149
  /**
1137
1150
  * resolve valaxy config from special root
1138
1151
  */
@@ -1318,6 +1331,18 @@ declare function getServerInfoText(msg: string): string;
1318
1331
  declare function createServer(valaxyApp: ValaxyNode, viteConfig?: InlineConfig, serverOptions?: ValaxyServerOptions): Promise<ViteDevServer>;
1319
1332
 
1320
1333
  /**
1334
+ * Encrypt content and return the ciphertext as base64.
1335
+ *
1336
+ * The ciphertext is embedded in the compiled page module, which UnoCSS scans
1337
+ * for utilities. A raw binary string (`String.fromCharCode` per byte) carries
1338
+ * quotes, brackets, `$`, `*` and backslashes, so random bytes could form
1339
+ * tokens like `p-["*(.]` that UnoCSS turns into unparsable CSS, failing the
1340
+ * build at random because salt/iv change on every build. Base64 has none of
1341
+ * those characters, and it is smaller once JSON-escaped.
1342
+ *
1343
+ * Breaking change: before this, the return value was a binary string (one char
1344
+ * per byte). Code that decodes it outside `useDecrypt` must now `atob` it first.
1345
+ *
1321
1346
  * @see https://github.com/mdn/dom-examples/blob/main/web-crypto/encrypt-decrypt/aes-cbc.js
1322
1347
  * @param content
1323
1348
  */
@@ -1367,5 +1392,5 @@ declare function toAtFS(path: string): string;
1367
1392
  declare function resolveImportPath(importName: string, ensure?: true): Promise<string>;
1368
1393
  declare function resolveImportPath(importName: string, ensure?: boolean): Promise<string | undefined>;
1369
1394
 
1370
- export { $t, ALL_ROUTE, EXCERPT_SEPARATOR, GLOBAL_STATE, PATHNAME_PROTOCOL_RE, StateManager, ViteValaxyPlugins, build, createContentService, createMemoryReleasePlugin, createServer, createValaxyNode, createValaxyPlugin, customElements, defaultSiteConfig, defaultValaxyConfig, defaultViteConfig, defineAddon, defineConfig, defineContentLoader, defineSiteConfig, defineTheme, defineUnoSetup, defineValaxyAddon, defineValaxyConfig, defineValaxyTheme, encryptContent, generateClientRedirects, getGitTimestamp, getIndexHtml, getServerInfoText, isExternal, isInstalledGlobally, isKatexEnabled, isKatexPluginNeeded, isMathJaxEnabled, isPath, loadAllContent, loadConfigFromFile, mergeValaxyConfig, mergeViteConfigs, postProcessForSSG, processValaxyOptions, resolveAddonsConfig, resolveImportPath, resolveImportUrl, resolveOptions, resolveSiteConfig, resolveSiteConfigFromRoot, resolveThemeConfigFromRoot, resolveThemeValaxyConfig, resolveUserThemeConfig, resolveValaxyConfig, resolveValaxyConfigFromRoot, ssgBuild, toAtFS, transformObject, version };
1395
+ export { $t, ALL_ROUTE, EXCERPT_SEPARATOR, GLOBAL_STATE, PATHNAME_PROTOCOL_RE, StateManager, ViteValaxyPlugins, build, createContentService, createMemoryReleasePlugin, createServer, createValaxyNode, createValaxyPlugin, customElements, defaultSiteConfig, defaultValaxyConfig, defaultViteConfig, defineAddon, defineConfig, defineContentLoader, defineSiteConfig, defineTheme, defineUnoSetup, defineValaxyAddon, defineValaxyConfig, defineValaxyTheme, encryptContent, generateClientRedirects, getGitTimestamp, getIndexHtml, getServerInfoText, isExternal, isInstalledGlobally, isKatexEnabled, isKatexPluginNeeded, isMathJaxEnabled, isPath, loadAllContent, loadConfigFromFile, mergeValaxyConfig, mergeViteConfigs, postProcessForSSG, processValaxyOptions, resolveAddonsConfig, resolveFootnoteConfig, resolveImportPath, resolveImportUrl, resolveOptions, resolveSiteConfig, resolveSiteConfigFromRoot, resolveThemeConfigFromRoot, resolveThemeValaxyConfig, resolveUserThemeConfig, resolveValaxyConfig, resolveValaxyConfigFromRoot, ssgBuild, toAtFS, transformObject, version };
1371
1396
  export type { CdnModule, ContentCheckResult, ContentDiagnostic, ContentItem, ContentLoader, ContentLoaderContext, ContentPageInfo, ContentServiceOptions, GroupIconOptions, GroupIconValue, HookResult, LoadConfigFromFileOptions, MarkdownRenderer, MdAfterRenderContext, ResolvedConfig, ResolvedValaxyOptions, UnoSetup, UserInputConfig, UserValaxyNodeConfig, ValaxyAddonCliContext, ValaxyAddonExport, ValaxyAddonExtendCli, ValaxyAddonFn, ValaxyAddonLike, ValaxyAddonResolver, ValaxyAddons, ValaxyApp, ValaxyConfigExport, ValaxyConfigExtendKey, ValaxyConfigFn, ValaxyEntryOptions, ValaxyExtendConfig, ValaxyFileInfo, ValaxyHooks, ValaxyNode, ValaxyNodeAddon, ValaxyNodeConfig, ValaxyPickConfig, ValaxyServerOptions, ValaxyTheme };
@@ -1,4 +1,4 @@
1
- export { A as ALL_ROUTE, E as EXCERPT_SEPARATOR, G as GLOBAL_STATE, P as PATHNAME_PROTOCOL_RE, S as StateManager, V as ViteValaxyPlugins, b as build, c as createCli, a as createContentService, d as createMemoryReleasePlugin, e as createServer, f as createValaxyNode, g as createValaxyPlugin, h as customElements, i as defaultSiteConfig, j as defaultValaxyConfig, k as defaultViteConfig, l as defineAddon, m as defineConfig, n as defineSiteConfig, o as defineTheme, p as defineValaxyAddon, q as defineValaxyConfig, r as defineValaxyTheme, s as desktopRuntimeVersion, t as encryptContent, u as execBuild, v as generateClientRedirects, w as getGitTimestamp, x as getIndexHtml, y as getServerInfoText, z as isExternal, B as isInstalledGlobally, C as isKatexEnabled, D as isKatexPluginNeeded, F as isMathJaxEnabled, H as isPath, I as loadAllContent, J as loadConfigFromFile, K as mergeValaxyConfig, L as mergeViteConfigs, M as postProcessForSSG, N as processValaxyOptions, O as registerDevCommand, Q as resolveAddonsConfig, R as resolveImportPath, T as resolveImportUrl, U as resolveOptions, W as resolveSiteConfig, X as resolveSiteConfigFromRoot, Y as resolveThemeConfigFromRoot, Z as resolveThemeValaxyConfig, _ as resolveUserThemeConfig, $ as resolveValaxyConfig, a0 as resolveValaxyConfigFromRoot, a1 as run, a2 as ssgBuild, a3 as startValaxyDev, a4 as toAtFS, a5 as transformObject, a6 as version } from '../shared/valaxy.DstXQBtK.mjs';
1
+ export { A as ALL_ROUTE, E as EXCERPT_SEPARATOR, G as GLOBAL_STATE, P as PATHNAME_PROTOCOL_RE, S as StateManager, V as ViteValaxyPlugins, b as build, c as createCli, a as createContentService, d as createMemoryReleasePlugin, e as createServer, f as createValaxyNode, g as createValaxyPlugin, h as customElements, i as defaultSiteConfig, j as defaultValaxyConfig, k as defaultViteConfig, l as defineAddon, m as defineConfig, n as defineSiteConfig, o as defineTheme, p as defineValaxyAddon, q as defineValaxyConfig, r as defineValaxyTheme, s as desktopRuntimeVersion, t as encryptContent, u as execBuild, v as generateClientRedirects, w as getGitTimestamp, x as getIndexHtml, y as getServerInfoText, z as isExternal, B as isInstalledGlobally, C as isKatexEnabled, D as isKatexPluginNeeded, F as isMathJaxEnabled, H as isPath, I as loadAllContent, J as loadConfigFromFile, K as mergeValaxyConfig, L as mergeViteConfigs, M as postProcessForSSG, N as processValaxyOptions, O as registerDevCommand, Q as resolveAddonsConfig, R as resolveFootnoteConfig, T as resolveImportPath, U as resolveImportUrl, W as resolveOptions, X as resolveSiteConfig, Y as resolveSiteConfigFromRoot, Z as resolveThemeConfigFromRoot, _ as resolveThemeValaxyConfig, $ as resolveUserThemeConfig, a0 as resolveValaxyConfig, a1 as resolveValaxyConfigFromRoot, a2 as run, a3 as ssgBuild, a4 as startValaxyDev, a5 as toAtFS, a6 as transformObject, a7 as version } from '../shared/valaxy.CRodiDWz.mjs';
2
2
  import 'node:path';
3
3
  import 'consola';
4
4
  import 'fs-extra';
@@ -19,6 +19,7 @@ import 'vite';
19
19
  import 'node:crypto';
20
20
  import 'floating-vue';
21
21
  import 'ora';
22
+ import 'node:buffer';
22
23
  import 'cross-spawn';
23
24
  import 'mlly';
24
25
  import 'resolve-global';
@@ -39,16 +40,9 @@ import 'unplugin';
39
40
  import 'unplugin-utils';
40
41
  import 'obug';
41
42
  import 'magic-string';
42
- import 'node:buffer';
43
43
  import 'p-map';
44
- import '@intlify/shared';
45
- import '@intlify/bundle-utils';
46
- import '@rollup/pluginutils';
47
- import 'vue/compiler-sfc';
48
- import 'picocolors';
49
- import '@eslint-community/eslint-utils';
50
- import '@intlify/vue-i18n-extensions';
51
- import '@typescript-eslint/scope-manager';
44
+ import 'pascalcase';
45
+ import '@intlify/unplugin-vue-i18n/vite';
52
46
  import 'minisearch';
53
47
  import '@shikijs/transformers';
54
48
  import 'lru-cache';
@@ -67,7 +61,6 @@ import 'katex/contrib/mhchem';
67
61
  import 'unplugin-vue-markdown/vite';
68
62
  import 'jiti';
69
63
  import 'unocss';
70
- import 'pascalcase';
71
64
  import 'html-to-text';
72
65
  import 'vue-router/vite';
73
66
  import 'vite-ssg-sitemap';
@@ -166,9 +166,16 @@ interface PageFrontMatter extends BaseFrontMatter {
166
166
  image: NodeRelations<ImageObject | string>;
167
167
  /**
168
168
  * cover
169
- * @description 封面图片
169
+ * @description 封面图片(使用组件封面时可省略)
170
170
  */
171
- cover: string;
171
+ cover?: string;
172
+ /**
173
+ * @description:en-US Vue component name from components/covers/, rendered by supporting themes. An image cover is optional.
174
+ * @description:zh-CN components/covers/ 下的 Vue 组件名,由支持的主题渲染。图片 cover 可省略。
175
+ */
176
+ coverComponent?: string;
177
+ /** JSON-serializable props passed to the cover component. */
178
+ coverProps?: Record<string, unknown>;
172
179
  /**
173
180
  * @description:en-US Open Graph image for SEO
174
181
  * @description:zh-CN Open Graph 图片,用于 SEO
@@ -426,6 +433,14 @@ declare module 'vue-router' {
426
433
  * Layout name
427
434
  */
428
435
  layout?: string
436
+ /**
437
+ * Props passed to the layout component
438
+ */
439
+ layoutProps?: Record<string, unknown>
440
+ /**
441
+ * Set on the parent routes generated by `setupLayouts`
442
+ */
443
+ isLayout?: boolean
429
444
  }
430
445
  }
431
446
 
@@ -828,7 +843,17 @@ interface SiteConfig {
828
843
  options: ILazyLoadOptions;
829
844
  };
830
845
  /**
831
- * Floating Vue configuration for floating footnote tooltips.
846
+ * Footnote preview implementation. Existing Floating Vue configuration
847
+ * selects the legacy implementation unless preview is explicitly set.
848
+ */
849
+ footnote: {
850
+ /** @default 'reka' */
851
+ preview: 'reka' | 'floating-vue';
852
+ };
853
+ /**
854
+ * Legacy Floating Vue configuration, also used by global v-tooltip.
855
+ * @deprecated For footnotes, migrate to footnote.preview: 'reka' and style
856
+ * .va-footnote-popover. Global Floating Vue APIs remain available during migration.
832
857
  * @see https://floating-vue.starpad.dev/guide/config
833
858
  */
834
859
  floatingVue: any;