valaxy 1.0.0-rc.14 → 1.0.0-rc.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/modules/unhead.ts +8 -0
- package/client/setups.ts +2 -5
- package/client/styles/css-vars/borders.css +1 -1
- package/client/styles/css-vars/function.css +0 -4
- package/client/styles/css-vars/palette.css +10 -19
- package/client/types/index.ts +0 -6
- package/client/utils/content.ts +5 -0
- package/dist/node/cli/index.mjs +3 -5
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.mjs +3 -5
- package/dist/shared/{valaxy.DzzDX_BR.mjs → valaxy.CwHPv9vx.mjs} +273 -64
- package/package.json +3 -4
- package/client/components/builtin/ValaxyMermaid.vue +0 -86
- package/client/modules/mermaid.ts +0 -26
- package/client/setup/mermaid.ts +0 -22
package/client/modules/unhead.ts
CHANGED
|
@@ -6,6 +6,14 @@ export const install: UserModule = async ({ head, isClient }) => {
|
|
|
6
6
|
if (isClient && import.meta.env.PROD)
|
|
7
7
|
return
|
|
8
8
|
|
|
9
|
+
// Unhead's server entry adds this default, but its client entry does not.
|
|
10
|
+
// Keep mobile development previews at device width, just like SSG pages.
|
|
11
|
+
if (import.meta.env.DEV) {
|
|
12
|
+
head?.push({
|
|
13
|
+
meta: [{ name: 'viewport', content: 'width=device-width, initial-scale=1' }],
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
/**
|
|
10
18
|
* https://unhead.unjs.io/docs/head/guides/plugins/infer-seo-meta-tags
|
|
11
19
|
*/
|
package/client/setups.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Awaitable } from '@antfu/utils'
|
|
2
2
|
import type { App } from 'vue'
|
|
3
3
|
import type { Router, RouteRecordRaw } from 'vue-router'
|
|
4
|
-
import type { MermaidOptions } from './types'
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* @en
|
|
@@ -35,9 +34,6 @@ export type AppContext = ValaxySSGContext
|
|
|
35
34
|
|
|
36
35
|
export type AppSetup = (ctx: AppContext) => Awaitable<void>
|
|
37
36
|
|
|
38
|
-
// client
|
|
39
|
-
export type MermaidSetup = () => Partial<MermaidOptions> | void
|
|
40
|
-
|
|
41
37
|
/**
|
|
42
38
|
* @en
|
|
43
39
|
* Define the setup function for the client application.
|
|
@@ -49,6 +45,7 @@ export function defineAppSetup(fn: AppSetup) {
|
|
|
49
45
|
return fn
|
|
50
46
|
}
|
|
51
47
|
|
|
52
|
-
|
|
48
|
+
/** @deprecated Import defineMermaidSetup from valaxy-addon-mermaid instead. */
|
|
49
|
+
export function defineMermaidSetup<T extends object>(fn: () => T | void) {
|
|
53
50
|
return fn
|
|
54
51
|
}
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
--va-c-default-2: var(--va-c-gray-2);
|
|
26
26
|
--va-c-default-3: var(--va-c-gray-3);
|
|
27
27
|
--va-c-default-soft: var(--va-c-gray-soft);
|
|
28
|
-
|
|
29
28
|
--va-c-brand-1: var(--va-c-indigo-1);
|
|
30
29
|
--va-c-brand-2: var(--va-c-indigo-2);
|
|
31
30
|
--va-c-brand-3: var(--va-c-indigo-3);
|
|
@@ -33,17 +32,14 @@
|
|
|
33
32
|
|
|
34
33
|
/* DEPRECATED: Use `--va-c-brand-1` instead. */
|
|
35
34
|
--va-c-brand: var(--va-c-brand-1);
|
|
36
|
-
|
|
37
35
|
--va-c-tip-1: var(--va-c-brand-1);
|
|
38
36
|
--va-c-tip-2: var(--va-c-brand-2);
|
|
39
37
|
--va-c-tip-3: var(--va-c-brand-3);
|
|
40
38
|
--va-c-tip-soft: var(--va-c-brand-soft);
|
|
41
|
-
|
|
42
39
|
--va-c-warning-1: var(--va-c-yellow-1);
|
|
43
40
|
--va-c-warning-2: var(--va-c-yellow-2);
|
|
44
41
|
--va-c-warning-3: var(--va-c-yellow-3);
|
|
45
42
|
--va-c-warning-soft: var(--va-c-yellow-soft);
|
|
46
|
-
|
|
47
43
|
--va-c-danger-1: var(--va-c-red-1);
|
|
48
44
|
--va-c-danger-2: var(--va-c-red-2);
|
|
49
45
|
--va-c-danger-3: var(--va-c-red-3);
|
|
@@ -30,28 +30,23 @@
|
|
|
30
30
|
--va-c-gray-1: #dddde3;
|
|
31
31
|
--va-c-gray-2: #e4e4e9;
|
|
32
32
|
--va-c-gray-3: #ebebef;
|
|
33
|
-
--va-c-gray-soft:
|
|
34
|
-
|
|
33
|
+
--va-c-gray-soft: rgb(142 150 170 / 0.14);
|
|
35
34
|
--va-c-indigo-1: #3451b2;
|
|
36
35
|
--va-c-indigo-2: #3a5ccc;
|
|
37
36
|
--va-c-indigo-3: #5672cd;
|
|
38
|
-
--va-c-indigo-soft:
|
|
39
|
-
|
|
37
|
+
--va-c-indigo-soft: rgb(100 108 255 / 0.14);
|
|
40
38
|
--va-c-green-1: #18794e;
|
|
41
39
|
--va-c-green-2: #299764;
|
|
42
40
|
--va-c-green-3: #30a46c;
|
|
43
|
-
--va-c-green-soft:
|
|
44
|
-
|
|
41
|
+
--va-c-green-soft: rgb(16 185 129 / 0.14);
|
|
45
42
|
--va-c-yellow-1: #915930;
|
|
46
43
|
--va-c-yellow-2: #946300;
|
|
47
44
|
--va-c-yellow-3: #9f6a00;
|
|
48
|
-
--va-c-yellow-soft:
|
|
49
|
-
|
|
45
|
+
--va-c-yellow-soft: rgb(234 179 8 / 0.14);
|
|
50
46
|
--va-c-red-1: #b8272c;
|
|
51
47
|
--va-c-red-2: #d5393e;
|
|
52
48
|
--va-c-red-3: #e0575b;
|
|
53
|
-
--va-c-red-soft:
|
|
54
|
-
|
|
49
|
+
--va-c-red-soft: rgb(244 63 94 / 0.14);
|
|
55
50
|
--va-c-sponsor: #db2777;
|
|
56
51
|
}
|
|
57
52
|
|
|
@@ -59,25 +54,21 @@
|
|
|
59
54
|
--va-c-gray-1: #515c67;
|
|
60
55
|
--va-c-gray-2: #414853;
|
|
61
56
|
--va-c-gray-3: #32363f;
|
|
62
|
-
--va-c-gray-soft:
|
|
63
|
-
|
|
57
|
+
--va-c-gray-soft: rgb(101 117 133 / 0.16);
|
|
64
58
|
--va-c-indigo-1: #a8b1ff;
|
|
65
59
|
--va-c-indigo-2: #5c73e7;
|
|
66
60
|
--va-c-indigo-3: #3e63dd;
|
|
67
|
-
--va-c-indigo-soft:
|
|
68
|
-
|
|
61
|
+
--va-c-indigo-soft: rgb(100 108 255 / 0.16);
|
|
69
62
|
--va-c-green-1: #3dd68c;
|
|
70
63
|
--va-c-green-2: #30a46c;
|
|
71
64
|
--va-c-green-3: #298459;
|
|
72
|
-
--va-c-green-soft:
|
|
73
|
-
|
|
65
|
+
--va-c-green-soft: rgb(16 185 129 / 0.16);
|
|
74
66
|
--va-c-yellow-1: #f9b44e;
|
|
75
67
|
--va-c-yellow-2: #da8b17;
|
|
76
68
|
--va-c-yellow-3: #a46a0a;
|
|
77
|
-
--va-c-yellow-soft:
|
|
78
|
-
|
|
69
|
+
--va-c-yellow-soft: rgb(234 179 8 / 0.16);
|
|
79
70
|
--va-c-red-1: #f66f81;
|
|
80
71
|
--va-c-red-2: #f14158;
|
|
81
72
|
--va-c-red-3: #b62a3c;
|
|
82
|
-
--va-c-red-soft:
|
|
73
|
+
--va-c-red-soft: rgb(244 63 94 / 0.16);
|
|
83
74
|
}
|
package/client/types/index.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import type mermaid from 'mermaid'
|
|
2
1
|
import type { ValaxySSGContext } from '../setups'
|
|
3
2
|
|
|
4
3
|
export type UserModule = (ctx: ValaxySSGContext) => void
|
|
5
4
|
|
|
6
|
-
/**
|
|
7
|
-
* @see https://mermaid.js.org/config/schema-docs/config.html#mermaid-config-schema
|
|
8
|
-
*/
|
|
9
|
-
export type MermaidOptions = (typeof mermaid.initialize) extends (a: infer A) => any ? A : never
|
|
10
|
-
|
|
11
5
|
export * from './collection'
|
package/client/utils/content.ts
CHANGED
|
@@ -8,6 +8,11 @@ export let contentUpdatedCallbacks: (() => any)[] = []
|
|
|
8
8
|
* in the DOM.
|
|
9
9
|
*/
|
|
10
10
|
export function onContentUpdated(fn: () => any) {
|
|
11
|
+
// SSR never unmounts components, so this module-level array would retain
|
|
12
|
+
// every rendered page and its router. In the browser, register during setup
|
|
13
|
+
// so parent listeners exist when child content first mounts.
|
|
14
|
+
if (import.meta.env.SSR)
|
|
15
|
+
return
|
|
11
16
|
contentUpdatedCallbacks.push(fn)
|
|
12
17
|
onUnmounted(() => {
|
|
13
18
|
contentUpdatedCallbacks = contentUpdatedCallbacks.filter(f => f !== fn)
|
package/dist/node/cli/index.mjs
CHANGED
|
@@ -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.
|
|
5
|
+
export { c as createCli, s as desktopRuntimeVersion, u as execBuild, O as registerDevCommand, a1 as run, a3 as startValaxyDev } from '../../shared/valaxy.CwHPv9vx.mjs';
|
|
6
6
|
import 'node:os';
|
|
7
7
|
import 'consola';
|
|
8
8
|
import 'consola/utils';
|
|
@@ -35,8 +35,8 @@ import '@unhead/bundler/vite';
|
|
|
35
35
|
import 'unplugin-vue-components/vite';
|
|
36
36
|
import 'vite-plugin-vue-layouts-next';
|
|
37
37
|
import 'vitepress-plugin-group-icons';
|
|
38
|
-
import 'p-map';
|
|
39
38
|
import 'node:buffer';
|
|
39
|
+
import 'p-map';
|
|
40
40
|
import 'minisearch';
|
|
41
41
|
import '@shikijs/transformers';
|
|
42
42
|
import 'lru-cache';
|
|
@@ -53,18 +53,16 @@ import 'markdown-it-container';
|
|
|
53
53
|
import 'katex';
|
|
54
54
|
import 'katex/contrib/mhchem';
|
|
55
55
|
import 'unplugin-vue-markdown/vite';
|
|
56
|
-
import 'js-base64';
|
|
57
56
|
import 'jiti';
|
|
58
57
|
import 'unocss';
|
|
59
58
|
import 'pascalcase';
|
|
60
59
|
import 'html-to-text';
|
|
61
60
|
import 'vue-router/vite';
|
|
62
|
-
import 'node:child_process';
|
|
63
|
-
import 'node:v8';
|
|
64
61
|
import 'vite-ssg-sitemap';
|
|
65
62
|
import '@unhead/vue/server';
|
|
66
63
|
import 'vue-router/unplugin';
|
|
67
64
|
import 'vue/compiler-sfc';
|
|
65
|
+
import 'node:child_process';
|
|
68
66
|
import '@clack/prompts';
|
|
69
67
|
import 'node:net';
|
|
70
68
|
import 'node:readline';
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1326,4 +1326,4 @@ declare function resolveImportPath(importName: string, ensure?: true): Promise<s
|
|
|
1326
1326
|
declare function resolveImportPath(importName: string, ensure?: boolean): Promise<string | undefined>;
|
|
1327
1327
|
|
|
1328
1328
|
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 };
|
|
1329
|
-
export type { CdnModule, ContentCheckResult, ContentDiagnostic, ContentItem, ContentLoader, ContentLoaderContext, ContentPageInfo, ContentServiceOptions, GroupIconOptions, GroupIconValue, HookResult, LoadConfigFromFileOptions, 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 };
|
|
1329
|
+
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 };
|
package/dist/node/index.mjs
CHANGED
|
@@ -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.
|
|
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.CwHPv9vx.mjs';
|
|
2
2
|
import 'node:path';
|
|
3
3
|
import 'consola';
|
|
4
4
|
import 'fs-extra';
|
|
@@ -35,8 +35,8 @@ import '@unhead/bundler/vite';
|
|
|
35
35
|
import 'unplugin-vue-components/vite';
|
|
36
36
|
import 'vite-plugin-vue-layouts-next';
|
|
37
37
|
import 'vitepress-plugin-group-icons';
|
|
38
|
-
import 'p-map';
|
|
39
38
|
import 'node:buffer';
|
|
39
|
+
import 'p-map';
|
|
40
40
|
import 'minisearch';
|
|
41
41
|
import '@shikijs/transformers';
|
|
42
42
|
import 'lru-cache';
|
|
@@ -53,18 +53,16 @@ import 'markdown-it-container';
|
|
|
53
53
|
import 'katex';
|
|
54
54
|
import 'katex/contrib/mhchem';
|
|
55
55
|
import 'unplugin-vue-markdown/vite';
|
|
56
|
-
import 'js-base64';
|
|
57
56
|
import 'jiti';
|
|
58
57
|
import 'unocss';
|
|
59
58
|
import 'pascalcase';
|
|
60
59
|
import 'html-to-text';
|
|
61
60
|
import 'vue-router/vite';
|
|
62
|
-
import 'node:child_process';
|
|
63
|
-
import 'node:v8';
|
|
64
61
|
import 'vite-ssg-sitemap';
|
|
65
62
|
import '@unhead/vue/server';
|
|
66
63
|
import 'vue-router/unplugin';
|
|
67
64
|
import 'vue/compiler-sfc';
|
|
65
|
+
import 'node:child_process';
|
|
68
66
|
import '@clack/prompts';
|
|
69
67
|
import 'node:net';
|
|
70
68
|
import 'node:readline';
|
|
@@ -12,19 +12,19 @@ import * as yaml from 'js-yaml';
|
|
|
12
12
|
import { dump, load, CORE_SCHEMA } from 'js-yaml';
|
|
13
13
|
import { ensurePrefix, slash, uniq, isFunction, isObject, ensureSuffix } from '@antfu/utils';
|
|
14
14
|
import _debug from 'debug';
|
|
15
|
-
import path$1, {
|
|
15
|
+
import path$1, { resolve, isAbsolute, relative, join as join$1, dirname as dirname$1, normalize } from 'pathe';
|
|
16
16
|
import defu, { createDefu } from 'defu';
|
|
17
17
|
import { loadConfigFromFile as loadConfigFromFile$1, mergeConfig, searchForWorkspaceRoot, build as build$3, createServer as createServer$1 } from 'vite';
|
|
18
|
-
import {
|
|
18
|
+
import { createHash, webcrypto } 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 { spawn } from 'cross-spawn';
|
|
22
|
+
import spawn$1, { spawn } from 'cross-spawn';
|
|
23
23
|
import { resolvePath } from 'mlly';
|
|
24
24
|
import { resolveGlobal } from 'resolve-global';
|
|
25
25
|
import { normalizeRepositoryUrl } from '@valaxyjs/utils';
|
|
26
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
27
|
-
import { readFile, mkdir, writeFile, rm, stat
|
|
26
|
+
import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
27
|
+
import { realpath, readFile, mkdir, writeFile, rm, stat } from 'node:fs/promises';
|
|
28
28
|
import dayjs from 'dayjs';
|
|
29
29
|
import { Feed } from 'feed';
|
|
30
30
|
import { createMarkdownExit } from 'markdown-exit';
|
|
@@ -35,8 +35,8 @@ import { Unhead } from '@unhead/bundler/vite';
|
|
|
35
35
|
import Components from 'unplugin-vue-components/vite';
|
|
36
36
|
import Layouts from 'vite-plugin-vue-layouts-next';
|
|
37
37
|
import { groupIconMdPlugin, groupIconVitePlugin } from 'vitepress-plugin-group-icons';
|
|
38
|
-
import pMap from 'p-map';
|
|
39
38
|
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
39
|
+
import pMap from 'p-map';
|
|
40
40
|
import MiniSearch from 'minisearch';
|
|
41
41
|
import { transformerNotationDiff, transformerNotationFocus, transformerNotationHighlight, transformerNotationErrorLevel, transformerCompactLineOptions } from '@shikijs/transformers';
|
|
42
42
|
import { LRUCache } from 'lru-cache';
|
|
@@ -53,25 +53,23 @@ import container from 'markdown-it-container';
|
|
|
53
53
|
import katex from 'katex';
|
|
54
54
|
import 'katex/contrib/mhchem';
|
|
55
55
|
import Markdown from 'unplugin-vue-markdown/vite';
|
|
56
|
-
import * as base64 from 'js-base64';
|
|
57
56
|
import { createJiti } from 'jiti';
|
|
58
57
|
import { transformerDirectives, transformerVariantGroup, presetWind4, presetAttributify, presetIcons, presetTypography } from 'unocss';
|
|
59
58
|
import pascalCase from 'pascalcase';
|
|
60
59
|
import { convert } from 'html-to-text';
|
|
61
60
|
import VueRouter from 'vue-router/vite';
|
|
62
|
-
import { execFileSync, execSync, exec } from 'node:child_process';
|
|
63
|
-
import v8 from 'node:v8';
|
|
64
61
|
import generateSitemap from 'vite-ssg-sitemap';
|
|
65
62
|
import { renderSSRHead } from '@unhead/vue/server';
|
|
66
63
|
import { createRoutesContext, resolveOptions as resolveOptions$1 } from 'vue-router/unplugin';
|
|
67
64
|
import { babelParse } from 'vue/compiler-sfc';
|
|
65
|
+
import { execSync, exec } from 'node:child_process';
|
|
68
66
|
import { intro, confirm, isCancel, cancel, select, outro } from '@clack/prompts';
|
|
69
67
|
import net from 'node:net';
|
|
70
68
|
import * as readline from 'node:readline';
|
|
71
69
|
import qrcode from 'qrcode';
|
|
72
70
|
import ejs from 'ejs';
|
|
73
71
|
|
|
74
|
-
const version = "1.0.0-rc.
|
|
72
|
+
const version = "1.0.0-rc.16";
|
|
75
73
|
|
|
76
74
|
const GLOBAL_STATE = {
|
|
77
75
|
valaxyApp: void 0,
|
|
@@ -280,6 +278,169 @@ const customElements = /* @__PURE__ */ new Set([
|
|
|
280
278
|
]);
|
|
281
279
|
const defaultViteConfig = {};
|
|
282
280
|
|
|
281
|
+
function isLoopback(address = "") {
|
|
282
|
+
return address === "::1" || /^(?:::ffff:)?127(?:\.\d{1,3}){3}$/.test(address);
|
|
283
|
+
}
|
|
284
|
+
function allowed(request) {
|
|
285
|
+
if (!isLoopback(request.socket.remoteAddress) || request.headers.origin !== void 0 || request.headers["sec-fetch-site"] !== void 0 || request.headers["x-valaxy-client"] !== "1") {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
try {
|
|
289
|
+
const url = new URL(`http://${request.headers.host}`);
|
|
290
|
+
return ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname) && !url.username && !url.password && url.pathname === "/";
|
|
291
|
+
} catch {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
function json(response, status, body2) {
|
|
296
|
+
for (const name of response.getHeaderNames()) {
|
|
297
|
+
if (name.startsWith("access-control-"))
|
|
298
|
+
response.removeHeader(name);
|
|
299
|
+
}
|
|
300
|
+
response.writeHead(status, {
|
|
301
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
302
|
+
"Cache-Control": "no-store",
|
|
303
|
+
"X-Content-Type-Options": "nosniff"
|
|
304
|
+
});
|
|
305
|
+
response.end(JSON.stringify(body2));
|
|
306
|
+
}
|
|
307
|
+
async function body(request) {
|
|
308
|
+
const chunks = [];
|
|
309
|
+
let size = 0;
|
|
310
|
+
for await (const chunk of request) {
|
|
311
|
+
size += Buffer$1.byteLength(chunk);
|
|
312
|
+
if (size > 8192)
|
|
313
|
+
throw new Error("invalid-request");
|
|
314
|
+
chunks.push(Buffer$1.from(chunk));
|
|
315
|
+
}
|
|
316
|
+
return JSON.parse(Buffer$1.concat(chunks).toString("utf8"));
|
|
317
|
+
}
|
|
318
|
+
function editorPlugin(options, routes) {
|
|
319
|
+
return {
|
|
320
|
+
name: "valaxy:editor",
|
|
321
|
+
apply: "serve",
|
|
322
|
+
async configureServer(server) {
|
|
323
|
+
const projectId = createHash("sha256").update((await realpath(options.userRoot)).replaceAll("\\", "/")).digest("hex");
|
|
324
|
+
const base = new URL(server.config.base, "http://localhost").pathname.replace(/\/?$/, "/");
|
|
325
|
+
const prefix = `${base}__valaxy__/`;
|
|
326
|
+
server.middlewares.use((request, response, next) => {
|
|
327
|
+
const path = request.url?.split("?")[0];
|
|
328
|
+
if (path !== `${prefix}capabilities` && path !== `${prefix}routes`)
|
|
329
|
+
return next();
|
|
330
|
+
if (!allowed(request))
|
|
331
|
+
return json(response, 403, { error: "local-editor-only" });
|
|
332
|
+
if (path === `${prefix}capabilities`) {
|
|
333
|
+
if (request.method !== "GET")
|
|
334
|
+
return json(response, 405, { error: "method-not-allowed" });
|
|
335
|
+
const devtools = server.config.plugins.find((plugin) => plugin.name === "valaxy:devtools");
|
|
336
|
+
const openPath = devtools?.api?.getOpenPath?.();
|
|
337
|
+
return json(response, 200, {
|
|
338
|
+
protocolVersion: 1,
|
|
339
|
+
valaxyVersion: version,
|
|
340
|
+
projectId,
|
|
341
|
+
base,
|
|
342
|
+
capabilities: {
|
|
343
|
+
routes: { version: 1, resolve: `${prefix}routes` },
|
|
344
|
+
devtools: options.config.devtools ? { status: openPath ? "available" : "unavailable", path: openPath, authentication: "browser" } : { status: "disabled" }
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
if (request.method !== "POST")
|
|
349
|
+
return json(response, 405, { error: "method-not-allowed" });
|
|
350
|
+
if (request.headers["content-type"]?.split(";")[0] !== "application/json")
|
|
351
|
+
return json(response, 415, { error: "json-required" });
|
|
352
|
+
void (async () => {
|
|
353
|
+
const data = await body(request);
|
|
354
|
+
if (!data || data.projectId !== projectId)
|
|
355
|
+
return json(response, 409, { error: "workspace-mismatch" });
|
|
356
|
+
const result = await routes.resolve(options.userRoot, data.file);
|
|
357
|
+
json(response, result.status === "pending" ? 503 : 200, result);
|
|
358
|
+
})().catch(() => {
|
|
359
|
+
if (!response.headersSent)
|
|
360
|
+
json(response, 400, { error: "invalid-request" });
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
class EditorRoutes {
|
|
368
|
+
routes;
|
|
369
|
+
sources = /* @__PURE__ */ new Map();
|
|
370
|
+
changed = /* @__PURE__ */ new Map();
|
|
371
|
+
revision = 0;
|
|
372
|
+
snapshotGeneration = 0;
|
|
373
|
+
begin(file) {
|
|
374
|
+
const key = resolve(file);
|
|
375
|
+
const change = { revision: ++this.revision, running: true };
|
|
376
|
+
this.changed.set(key, change);
|
|
377
|
+
return () => {
|
|
378
|
+
change.running = false;
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
async update(tree) {
|
|
382
|
+
const generation = ++this.snapshotGeneration;
|
|
383
|
+
const completed = [...this.changed].filter(([, change]) => !change.running);
|
|
384
|
+
const routes = /* @__PURE__ */ new Map();
|
|
385
|
+
const entries = [];
|
|
386
|
+
for (const route of tree) {
|
|
387
|
+
for (const file of route.components.values())
|
|
388
|
+
entries.push({ file: resolve(file), route: { path: route.fullPath, dynamic: route.params.length > 0 } });
|
|
389
|
+
}
|
|
390
|
+
const sources = /* @__PURE__ */ new Map();
|
|
391
|
+
await Promise.all([...new Set(entries.map((entry) => entry.file))].map(async (file) => {
|
|
392
|
+
try {
|
|
393
|
+
const cached = !this.changed.has(file) && this.sources.get(file);
|
|
394
|
+
sources.set(file, cached || (await realpath(file)).replaceAll("\\", "/"));
|
|
395
|
+
} catch {
|
|
396
|
+
}
|
|
397
|
+
}));
|
|
398
|
+
if (generation !== this.snapshotGeneration)
|
|
399
|
+
return;
|
|
400
|
+
for (const { file, route } of entries) {
|
|
401
|
+
const key = sources.get(file);
|
|
402
|
+
if (!key)
|
|
403
|
+
continue;
|
|
404
|
+
const matches = routes.get(key) || [];
|
|
405
|
+
if (!matches.some((entry) => entry.path === route.path))
|
|
406
|
+
matches.push(route);
|
|
407
|
+
routes.set(key, matches);
|
|
408
|
+
}
|
|
409
|
+
this.routes = routes;
|
|
410
|
+
this.sources = sources;
|
|
411
|
+
for (const [file, change] of completed) {
|
|
412
|
+
if (this.changed.get(file)?.revision === change.revision)
|
|
413
|
+
this.changed.delete(file);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
async resolve(root, file) {
|
|
417
|
+
if (typeof file !== "string" || !file.endsWith(".md") || isAbsolute(file) || file.includes("\\") || file.includes("\0") || file.split("/").some((part) => !part || part === "." || part === "..")) {
|
|
418
|
+
throw new Error("invalid-file");
|
|
419
|
+
}
|
|
420
|
+
const absolute = resolve(root, file);
|
|
421
|
+
let canonical;
|
|
422
|
+
try {
|
|
423
|
+
const [realRoot, realFile] = await Promise.all([realpath(root), realpath(absolute)]);
|
|
424
|
+
const child = relative(realRoot, realFile);
|
|
425
|
+
if (child === ".." || child.startsWith("../") || isAbsolute(child))
|
|
426
|
+
throw new Error("invalid-file");
|
|
427
|
+
canonical = realFile.replaceAll("\\", "/");
|
|
428
|
+
} catch (error) {
|
|
429
|
+
if (["ENOENT", "ENOTDIR"].includes(error.code || ""))
|
|
430
|
+
return { status: "not-found", routes: [] };
|
|
431
|
+
throw error;
|
|
432
|
+
}
|
|
433
|
+
if (!this.routes)
|
|
434
|
+
return { status: "pending", routes: [] };
|
|
435
|
+
for (const source of this.changed.keys()) {
|
|
436
|
+
if (source === absolute || source === canonical || this.sources.get(source) === canonical)
|
|
437
|
+
return { status: "pending", routes: [] };
|
|
438
|
+
}
|
|
439
|
+
const routes = this.routes.get(canonical) || [];
|
|
440
|
+
return { status: routes.length ? "resolved" : "not-found", routes };
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
283
444
|
const logger = consola.create({});
|
|
284
445
|
function setLogLevel(level) {
|
|
285
446
|
consola.level = level;
|
|
@@ -2898,6 +3059,40 @@ function snippetPlugin(md, srcDir = "") {
|
|
|
2898
3059
|
md.block.ruler.before("fence", "snippet", parser);
|
|
2899
3060
|
}
|
|
2900
3061
|
|
|
3062
|
+
const warned = /* @__PURE__ */ new WeakSet();
|
|
3063
|
+
function warnMermaidMigration(options, source) {
|
|
3064
|
+
if (options && warned.has(options))
|
|
3065
|
+
return;
|
|
3066
|
+
if (options)
|
|
3067
|
+
warned.add(options);
|
|
3068
|
+
logger.warn([
|
|
3069
|
+
`[valaxy] Mermaid has moved to valaxy-addon-mermaid${source ? ` (${source})` : ""}.`,
|
|
3070
|
+
"Mermaid \u5DF2\u8FC1\u79FB\u5230\u53EF\u9009\u63D2\u4EF6\u3002\u5B89\u88C5 / Install: pnpm add valaxy-addon-mermaid",
|
|
3071
|
+
"\u5728 valaxy.config.ts \u542F\u7528 / Enable in valaxy.config.ts:",
|
|
3072
|
+
" import { addonMermaid } from 'valaxy-addon-mermaid'",
|
|
3073
|
+
" addons: [addonMermaid()]",
|
|
3074
|
+
"Existing mermaid fences do not need changes. Without the addon, they remain code blocks.",
|
|
3075
|
+
"https://valaxy.site/migration/version"
|
|
3076
|
+
].join("\n"));
|
|
3077
|
+
}
|
|
3078
|
+
|
|
3079
|
+
function mermaidMigrationPlugin(md, options) {
|
|
3080
|
+
const fence = md.renderer.rules.fence;
|
|
3081
|
+
let warned = false;
|
|
3082
|
+
md.renderer.rules.fence = (...args) => {
|
|
3083
|
+
const [tokens, index, , env] = args;
|
|
3084
|
+
const token = tokens[index];
|
|
3085
|
+
if (!/^mermaid(?:\s|\{|$)/.test(token.info.trim()))
|
|
3086
|
+
return fence(...args);
|
|
3087
|
+
if (!warned) {
|
|
3088
|
+
warnMermaidMigration(options, env.id || env.path);
|
|
3089
|
+
warned = true;
|
|
3090
|
+
}
|
|
3091
|
+
return `<pre v-pre><code class="language-mermaid">${md.utils.escapeHtml(token.content)}</code></pre>
|
|
3092
|
+
`;
|
|
3093
|
+
};
|
|
3094
|
+
}
|
|
3095
|
+
|
|
2901
3096
|
const defaultCodeTheme = { light: "github-light", dark: "github-dark" };
|
|
2902
3097
|
const cssI18nContainerCompat = cssI18nContainer;
|
|
2903
3098
|
const attrsPluginCompat = attrsPlugin;
|
|
@@ -3073,6 +3268,7 @@ async function setupMarkdownPlugins(md, options, base = options?.config.vite?.ba
|
|
|
3073
3268
|
}
|
|
3074
3269
|
return fenceBeforeGroupIcon(...args);
|
|
3075
3270
|
});
|
|
3271
|
+
md.use(mermaidMigrationPlugin, options);
|
|
3076
3272
|
if (mdOptions.config)
|
|
3077
3273
|
mdOptions.config(md);
|
|
3078
3274
|
return md;
|
|
@@ -3178,18 +3374,6 @@ function resolveTransformIncludes(code, id, options) {
|
|
|
3178
3374
|
};
|
|
3179
3375
|
}
|
|
3180
3376
|
|
|
3181
|
-
function transformMermaid(md) {
|
|
3182
|
-
md = md.replace(/^````txt\n```mermaid/gm, "````txt\n\\`\\`\\`mermaid");
|
|
3183
|
-
md = md.replace(/^```mermaid\s*?(\{.*?\})?\n([\s\S]+?)\n```/gm, (full, options = "", code = "") => {
|
|
3184
|
-
code = code.trim();
|
|
3185
|
-
options = options.trim() || "{}";
|
|
3186
|
-
const encoded = base64.encode(code, true);
|
|
3187
|
-
return `<ValaxyMermaid :code="'${encoded}'" v-bind="${options}" />`;
|
|
3188
|
-
});
|
|
3189
|
-
md = md.replace(/^````txt\n\\`\\`\\`mermaid/gm, "````txt\n```mermaid");
|
|
3190
|
-
return md;
|
|
3191
|
-
}
|
|
3192
|
-
|
|
3193
3377
|
const HTML_COMMENT_RE = /<!--[\s\S]*?-->/g;
|
|
3194
3378
|
function escapeSfcTagsInComment(comment) {
|
|
3195
3379
|
return comment.replace(/<(\s*(?:script|style)\b)/gi, "<$1").replace(/<(\s*\/\s*(?:script|style)\b)/gi, "<$1");
|
|
@@ -3272,7 +3456,6 @@ async function createMarkdownPlugin(options, base, state = Valaxy.state) {
|
|
|
3272
3456
|
},
|
|
3273
3457
|
transforms: {
|
|
3274
3458
|
before(code, id) {
|
|
3275
|
-
code = transformMermaid(code);
|
|
3276
3459
|
code = transformIncludes(code, id);
|
|
3277
3460
|
return userTransforms?.before?.(code, id) ?? code;
|
|
3278
3461
|
},
|
|
@@ -3999,7 +4182,13 @@ async function createMarkdownToVueRenderFn(options, state = Valaxy.state) {
|
|
|
3999
4182
|
};
|
|
4000
4183
|
}
|
|
4001
4184
|
|
|
4002
|
-
function createClientSetupPlugin(
|
|
4185
|
+
function createClientSetupPlugin(options) {
|
|
4186
|
+
const { clientRoot, themeRoot, userRoot } = options;
|
|
4187
|
+
if (!options.addons.some((addon) => addon.name === "valaxy-addon-mermaid" && addon.enable)) {
|
|
4188
|
+
const legacySetup = [themeRoot, userRoot].map((root) => join(root, "setup/mermaid.ts")).find(existsSync);
|
|
4189
|
+
if (legacySetup)
|
|
4190
|
+
warnMermaidMigration(options, legacySetup);
|
|
4191
|
+
}
|
|
4003
4192
|
const setupEntry = slash(resolve$1(clientRoot, "setup"));
|
|
4004
4193
|
return {
|
|
4005
4194
|
name: "valaxy:setup",
|
|
@@ -4853,8 +5042,23 @@ function generateAutoExcerptMd(content, length) {
|
|
|
4853
5042
|
return "";
|
|
4854
5043
|
return cleaned.length > length ? `${cleaned.slice(0, length)}...` : cleaned;
|
|
4855
5044
|
}
|
|
4856
|
-
async function createRouterPlugin(valaxyApp, base) {
|
|
4857
|
-
|
|
5045
|
+
async function createRouterPlugin(valaxyApp, base, editorRoutes) {
|
|
5046
|
+
const options = await createRouterOptions(valaxyApp, base);
|
|
5047
|
+
return VueRouter({
|
|
5048
|
+
...options,
|
|
5049
|
+
async extendRoute(route) {
|
|
5050
|
+
const finish = [...route.components.values()].map((file) => editorRoutes?.begin(file));
|
|
5051
|
+
try {
|
|
5052
|
+
await options.extendRoute?.(route);
|
|
5053
|
+
} finally {
|
|
5054
|
+
finish.forEach((done) => done?.());
|
|
5055
|
+
}
|
|
5056
|
+
},
|
|
5057
|
+
async beforeWriteFiles(root) {
|
|
5058
|
+
await options.beforeWriteFiles?.(root);
|
|
5059
|
+
await editorRoutes?.update(root);
|
|
5060
|
+
}
|
|
5061
|
+
});
|
|
4858
5062
|
}
|
|
4859
5063
|
async function createRouterOptions(valaxyApp, base, parseMatter = (source) => matter(source, matterOptions), onDispose) {
|
|
4860
5064
|
const { options } = valaxyApp;
|
|
@@ -5014,6 +5218,7 @@ async function createRouterOptions(valaxyApp, base, parseMatter = (source) => ma
|
|
|
5014
5218
|
},
|
|
5015
5219
|
async beforeWriteFiles(root) {
|
|
5016
5220
|
await valaxyApp.hooks.callHook("vue-router:beforeWriteFiles", root);
|
|
5221
|
+
await valaxyConfig.router?.beforeWriteFiles?.(root);
|
|
5017
5222
|
}
|
|
5018
5223
|
};
|
|
5019
5224
|
}
|
|
@@ -5081,6 +5286,7 @@ function createMemoryReleasePlugin(state, releaseThreshold = 1) {
|
|
|
5081
5286
|
async function ViteValaxyPlugins(valaxyApp, serverOptions = {}, viteConfig = {}, expectedBuilds = 1) {
|
|
5082
5287
|
const { options } = valaxyApp;
|
|
5083
5288
|
const state = new StateManager();
|
|
5289
|
+
const editorRoutes = options.mode === "dev" ? new EditorRoutes() : void 0;
|
|
5084
5290
|
const { roots, config: valaxyConfig } = options;
|
|
5085
5291
|
const markdownBase = createMarkdownBaseContext(viteConfig.base || valaxyConfig.vite?.base || "/");
|
|
5086
5292
|
const MarkdownBasePlugin = {
|
|
@@ -5121,6 +5327,17 @@ async function ViteValaxyPlugins(valaxyApp, serverOptions = {}, viteConfig = {},
|
|
|
5121
5327
|
include: /\.(?:vue|md)$/,
|
|
5122
5328
|
exclude: [],
|
|
5123
5329
|
...valaxyConfig.vue,
|
|
5330
|
+
script: {
|
|
5331
|
+
...valaxyConfig.vue?.script,
|
|
5332
|
+
// Imported prop types need filesystem access even when TypeScript
|
|
5333
|
+
// does not expose ts.sys (e.g. TypeScript 7).
|
|
5334
|
+
fs: valaxyConfig.vue?.script?.fs ?? {
|
|
5335
|
+
// Directories must not resolve as files for imports like '../types'.
|
|
5336
|
+
fileExists: (file) => statSync(file, { throwIfNoEntry: false })?.isFile() ?? false,
|
|
5337
|
+
readFile: (file) => readFileSync(file, "utf-8"),
|
|
5338
|
+
realpath: realpathSync
|
|
5339
|
+
}
|
|
5340
|
+
},
|
|
5124
5341
|
template: {
|
|
5125
5342
|
...valaxyConfig.vue?.template,
|
|
5126
5343
|
compilerOptions: {
|
|
@@ -5139,7 +5356,7 @@ async function ViteValaxyPlugins(valaxyApp, serverOptions = {}, viteConfig = {},
|
|
|
5139
5356
|
vLogger.debug(` \u251C\u2500 plugin-vue: ${timers.vue()}`);
|
|
5140
5357
|
return r;
|
|
5141
5358
|
}),
|
|
5142
|
-
createRouterPlugin(valaxyApp, markdownBase).then((r) => {
|
|
5359
|
+
createRouterPlugin(valaxyApp, markdownBase, editorRoutes).then((r) => {
|
|
5143
5360
|
vLogger.debug(` \u251C\u2500 createRouterPlugin: ${timers.router()}`);
|
|
5144
5361
|
return r;
|
|
5145
5362
|
}),
|
|
@@ -5159,6 +5376,7 @@ async function ViteValaxyPlugins(valaxyApp, serverOptions = {}, viteConfig = {},
|
|
|
5159
5376
|
const componentsDirs = [...roots.map((root) => `${root}/components`), ...["src/components", "components"]];
|
|
5160
5377
|
const plugins = [
|
|
5161
5378
|
MarkdownBasePlugin,
|
|
5379
|
+
...editorRoutes ? [editorPlugin(options, editorRoutes)] : [],
|
|
5162
5380
|
createCdnPlugin(options),
|
|
5163
5381
|
createLlmsPlugin(options),
|
|
5164
5382
|
MarkdownPlugin,
|
|
@@ -5359,9 +5577,6 @@ function tryGC() {
|
|
|
5359
5577
|
if (typeof globalThis.gc === "function")
|
|
5360
5578
|
globalThis.gc();
|
|
5361
5579
|
}
|
|
5362
|
-
function getHeapLimitMB() {
|
|
5363
|
-
return v8.getHeapStatistics().heap_size_limit / 1024 / 1024;
|
|
5364
|
-
}
|
|
5365
5580
|
function routesToPaths(routes) {
|
|
5366
5581
|
if (!routes)
|
|
5367
5582
|
return ["/"];
|
|
@@ -5389,40 +5604,6 @@ function getSsgSsrConfig() {
|
|
|
5389
5604
|
}
|
|
5390
5605
|
async function ssgBuild(valaxyApp, viteConfig = {}, userSsgOptions = {}) {
|
|
5391
5606
|
const { options } = valaxyApp;
|
|
5392
|
-
if (!process.env.__VALAXY_SSG_NO_RESPAWN__) {
|
|
5393
|
-
const needGC = typeof globalThis.gc !== "function";
|
|
5394
|
-
const currentHeapMB = getHeapLimitMB();
|
|
5395
|
-
const minRequiredMB = 4096;
|
|
5396
|
-
const needMoreHeap = currentHeapMB < minRequiredMB;
|
|
5397
|
-
const needRespawn = needMoreHeap || needGC && currentHeapMB < minRequiredMB;
|
|
5398
|
-
if (needRespawn) {
|
|
5399
|
-
const extraNodeArgs = [];
|
|
5400
|
-
if (needGC)
|
|
5401
|
-
extraNodeArgs.push("--expose-gc");
|
|
5402
|
-
if (needMoreHeap)
|
|
5403
|
-
extraNodeArgs.push(`--max-old-space-size=${minRequiredMB}`);
|
|
5404
|
-
consola.info(`Restarting SSG build with ${extraNodeArgs.join(" ")} (current heap: ${Math.round(currentHeapMB)} MB)...`);
|
|
5405
|
-
const filteredExecArgv = needMoreHeap ? process.execArgv.filter((arg) => !arg.startsWith("--max-old-space-size") && !arg.startsWith("--max_old_space_size")) : process.execArgv;
|
|
5406
|
-
const nodeArgs = [...extraNodeArgs, ...filteredExecArgv, ...process.argv.slice(1)];
|
|
5407
|
-
try {
|
|
5408
|
-
execFileSync(process.execPath, nodeArgs, {
|
|
5409
|
-
cwd: process.cwd(),
|
|
5410
|
-
stdio: "inherit",
|
|
5411
|
-
env: { ...process.env, __VALAXY_SSG_NO_RESPAWN__: "1" },
|
|
5412
|
-
timeout: 30 * 60 * 1e3
|
|
5413
|
-
});
|
|
5414
|
-
return;
|
|
5415
|
-
} catch (e) {
|
|
5416
|
-
if (e.signal) {
|
|
5417
|
-
throw new Error(`SSG build was killed by signal ${e.signal}${e.signal === "SIGTERM" ? " (possible timeout)" : ""}`, { cause: e });
|
|
5418
|
-
}
|
|
5419
|
-
if (e.status != null && e.status !== 0) {
|
|
5420
|
-
throw new Error(`SSG build failed (exit code: ${e.status})`, { cause: e });
|
|
5421
|
-
}
|
|
5422
|
-
throw e;
|
|
5423
|
-
}
|
|
5424
|
-
}
|
|
5425
|
-
}
|
|
5426
5607
|
const configOutDir = viteConfig.build?.outDir || "dist";
|
|
5427
5608
|
const outDir = isAbsolute$1(configOutDir) ? configOutDir : resolve$1(options.userRoot, configOutDir);
|
|
5428
5609
|
const ssgTemp = resolve$1(outDir, ".vite-ssg-temp");
|
|
@@ -5971,6 +6152,7 @@ const ADDON_PACKAGE_PREFIX = "valaxy-addon-";
|
|
|
5971
6152
|
const ADDON_COMMAND_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
5972
6153
|
const CORE_CLI_COMMANDS = /* @__PURE__ */ new Set([
|
|
5973
6154
|
"addon",
|
|
6155
|
+
"app",
|
|
5974
6156
|
"build",
|
|
5975
6157
|
"check",
|
|
5976
6158
|
"clean",
|
|
@@ -6061,6 +6243,32 @@ function shouldResolveAddonCli(argv) {
|
|
|
6061
6243
|
return command !== "." && !command.startsWith("./") && !command.startsWith("../") && !isAbsolute$1(command);
|
|
6062
6244
|
}
|
|
6063
6245
|
|
|
6246
|
+
async function openDesktopApp(path = ".", appPath) {
|
|
6247
|
+
const args = ["app", resolve$1(path)];
|
|
6248
|
+
if (appPath)
|
|
6249
|
+
args.push("--app", resolve$1(appPath));
|
|
6250
|
+
await new Promise((resolve2, reject) => {
|
|
6251
|
+
const child = spawn$1("yunzhan", args, { stdio: "inherit" });
|
|
6252
|
+
child.once("error", (error) => {
|
|
6253
|
+
reject(error.code === "ENOENT" ? new Error("YunZhan CLI was not found. Install the YunZhan desktop app and @yunlefun/cms-cli first, then retry. Nothing was downloaded or installed automatically.") : error);
|
|
6254
|
+
});
|
|
6255
|
+
child.once("exit", (code, signal) => {
|
|
6256
|
+
if (code === 0)
|
|
6257
|
+
resolve2();
|
|
6258
|
+
else
|
|
6259
|
+
reject(new Error(`YunZhan CLI failed (${signal || code}). Run yunzhan doctor to check the desktop installation.`));
|
|
6260
|
+
});
|
|
6261
|
+
});
|
|
6262
|
+
}
|
|
6263
|
+
function registerAppCommand(cli) {
|
|
6264
|
+
cli.command(
|
|
6265
|
+
"app [path]",
|
|
6266
|
+
"Open a local project in the YunZhan desktop app (requires yunzhan CLI)",
|
|
6267
|
+
(args) => args.positional("path", { type: "string", default: ".", describe: "Local project directory" }).option("app", { type: "string", describe: "Explicit YunZhan .app, .exe or AppImage path" }).strict(),
|
|
6268
|
+
async (args) => openDesktopApp(args.path, args.app)
|
|
6269
|
+
);
|
|
6270
|
+
}
|
|
6271
|
+
|
|
6064
6272
|
async function recoverContentTransaction(directory) {
|
|
6065
6273
|
const journal = resolve(directory, "journal.json");
|
|
6066
6274
|
if (!await fs.pathExists(journal))
|
|
@@ -7517,6 +7725,7 @@ const modules = [
|
|
|
7517
7725
|
function createCoreCli(argv) {
|
|
7518
7726
|
const cli = yargs(argv).scriptName("valaxy").usage("$0 [args]").version(version).showHelpOnFail(false).alias("h", "help").alias("v", "version");
|
|
7519
7727
|
registerDevCommand(cli);
|
|
7728
|
+
registerAppCommand(cli);
|
|
7520
7729
|
registerBuildCommand(cli);
|
|
7521
7730
|
registerNewCommand(cli);
|
|
7522
7731
|
registerCleanCommand(cli);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valaxy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.16",
|
|
5
5
|
"description": "📄 Vite & Vue powered static blog generator.",
|
|
6
6
|
"author": {
|
|
7
7
|
"email": "me@yunyoujun.cn",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"@unhead/bundler": "^3.4.1",
|
|
75
75
|
"@unhead/schema-org": "^3.4.1",
|
|
76
76
|
"@unhead/vue": "^3.4.1",
|
|
77
|
-
"@valaxyjs/devtools": "1.0.0-rc.
|
|
78
|
-
"@valaxyjs/utils": "1.0.0-rc.
|
|
77
|
+
"@valaxyjs/devtools": "1.0.0-rc.16",
|
|
78
|
+
"@valaxyjs/utils": "1.0.0-rc.16",
|
|
79
79
|
"@vitejs/devtools": "0.7.5",
|
|
80
80
|
"@vitejs/plugin-vue": "^6.0.9",
|
|
81
81
|
"@vueuse/core": "^15.0.0",
|
|
@@ -113,7 +113,6 @@
|
|
|
113
113
|
"markdown-it-table-of-contents": "^1.2.0",
|
|
114
114
|
"markdown-it-task-lists": "^2.1.1",
|
|
115
115
|
"medium-zoom": "^1.1.0",
|
|
116
|
-
"mermaid": "^12.0.0",
|
|
117
116
|
"minisearch": "^7.2.0",
|
|
118
117
|
"mlly": "^1.8.2",
|
|
119
118
|
"nprogress": "^0.2.0",
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
Mermaid
|
|
3
|
-
(auto transformed, you don't need to use this component directly)
|
|
4
|
-
|
|
5
|
-
Usage:
|
|
6
|
-
|
|
7
|
-
```mermaid
|
|
8
|
-
pie
|
|
9
|
-
"Dogs" : 386
|
|
10
|
-
"Cats" : 85
|
|
11
|
-
"Rats" : 15
|
|
12
|
-
```
|
|
13
|
-
-->
|
|
14
|
-
|
|
15
|
-
<script setup lang="ts">
|
|
16
|
-
import { isClient } from '@vueuse/core'
|
|
17
|
-
|
|
18
|
-
import { useAppStore } from 'valaxy'
|
|
19
|
-
import { getCurrentInstance, ref, watch, watchEffect } from 'vue'
|
|
20
|
-
import { renderMermaid } from '../../modules/mermaid'
|
|
21
|
-
import ShadowRoot from '../internals/ShadowRoot.vue'
|
|
22
|
-
|
|
23
|
-
const props = defineProps<{
|
|
24
|
-
code: string
|
|
25
|
-
scale?: number
|
|
26
|
-
theme?: string
|
|
27
|
-
}>()
|
|
28
|
-
|
|
29
|
-
const vm = getCurrentInstance()
|
|
30
|
-
const el = ref<ShadowRoot>()
|
|
31
|
-
const html = ref('')
|
|
32
|
-
|
|
33
|
-
const appStore = useAppStore()
|
|
34
|
-
|
|
35
|
-
if (isClient) {
|
|
36
|
-
// dynamic import to reduce initial bundle size
|
|
37
|
-
import('mermaid').then(m => m.default).then((mermaid) => {
|
|
38
|
-
mermaid.startOnLoad = false
|
|
39
|
-
mermaid.initialize({ startOnLoad: false })
|
|
40
|
-
|
|
41
|
-
watchEffect(async (onCleanup) => {
|
|
42
|
-
let disposed = false
|
|
43
|
-
onCleanup(() => {
|
|
44
|
-
disposed = true
|
|
45
|
-
})
|
|
46
|
-
const svg = await renderMermaid(
|
|
47
|
-
mermaid,
|
|
48
|
-
props.code || '',
|
|
49
|
-
{
|
|
50
|
-
theme: props.theme || (appStore.isDark ? 'dark' : undefined),
|
|
51
|
-
...vm!.attrs,
|
|
52
|
-
},
|
|
53
|
-
)
|
|
54
|
-
if (!disposed)
|
|
55
|
-
html.value = svg
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
const actualHeight = ref<number>()
|
|
59
|
-
|
|
60
|
-
watch(html, () => {
|
|
61
|
-
actualHeight.value = undefined
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
watchEffect(() => {
|
|
65
|
-
const svgEl = el.value?.children?.[0] as SVGElement | undefined
|
|
66
|
-
if (svgEl && svgEl.hasAttribute('viewBox') && actualHeight.value == null) {
|
|
67
|
-
const v = Number.parseFloat(svgEl.getAttribute('viewBox')?.split(' ')[3] || '')
|
|
68
|
-
actualHeight.value = Number.isNaN(v) ? undefined : v
|
|
69
|
-
}
|
|
70
|
-
}, { flush: 'post' })
|
|
71
|
-
|
|
72
|
-
watchEffect(() => {
|
|
73
|
-
const svgEl = el.value?.children?.[0] as SVGElement | undefined
|
|
74
|
-
if (svgEl != null && props.scale != null && actualHeight.value != null) {
|
|
75
|
-
svgEl.setAttribute('height', `${actualHeight.value * props.scale}`)
|
|
76
|
-
svgEl.removeAttribute('width')
|
|
77
|
-
svgEl.removeAttribute('style')
|
|
78
|
-
}
|
|
79
|
-
}, { flush: 'post' })
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
</script>
|
|
83
|
-
|
|
84
|
-
<template>
|
|
85
|
-
<ShadowRoot class="mermaid" :inner-html="html" @shadow="el = $event" />
|
|
86
|
-
</template>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Mermaid } from 'mermaid'
|
|
2
|
-
import { clearUndefined } from '@antfu/utils'
|
|
3
|
-
import { decode } from 'js-base64'
|
|
4
|
-
import { customAlphabet } from 'nanoid'
|
|
5
|
-
import setupMermaid from '../setup/mermaid'
|
|
6
|
-
|
|
7
|
-
const nanoid = customAlphabet('abcedfghicklmn', 10)
|
|
8
|
-
const cache = new Map<string, string>()
|
|
9
|
-
|
|
10
|
-
export async function renderMermaid(mermaid: Mermaid, encoded: string, options: any) {
|
|
11
|
-
const key = encoded + JSON.stringify(options)
|
|
12
|
-
const _cache = cache.get(key)
|
|
13
|
-
if (_cache)
|
|
14
|
-
return _cache
|
|
15
|
-
|
|
16
|
-
mermaid.initialize({
|
|
17
|
-
startOnLoad: false,
|
|
18
|
-
...clearUndefined(setupMermaid() || {}),
|
|
19
|
-
...clearUndefined(options),
|
|
20
|
-
})
|
|
21
|
-
const code = decode(encoded)
|
|
22
|
-
const id = nanoid()
|
|
23
|
-
const { svg } = await mermaid.render(id, code)
|
|
24
|
-
cache.set(key, svg)
|
|
25
|
-
return svg
|
|
26
|
-
}
|
package/client/setup/mermaid.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/* __imports__ */
|
|
2
|
-
|
|
3
|
-
import type { MermaidOptions } from '../types'
|
|
4
|
-
import { defineMermaidSetup } from 'valaxy'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @en
|
|
8
|
-
* Extend the Mermaid configuration.
|
|
9
|
-
*
|
|
10
|
-
* @zh
|
|
11
|
-
* 扩展 Mermaid 配置。
|
|
12
|
-
*/
|
|
13
|
-
export default defineMermaidSetup(() => {
|
|
14
|
-
// eslint-disable-next-line prefer-const
|
|
15
|
-
let injection_return: MermaidOptions = {
|
|
16
|
-
theme: 'default',
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/* __injections__ */
|
|
20
|
-
|
|
21
|
-
return injection_return
|
|
22
|
-
})
|