@alauda/doom 0.19.5 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,9 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import { glob } from 'tinyglobby';
3
- import { FALSY_VALUES, isDoc } from '../shared/index.js';
3
+ import { FALSY_VALUES } from '../shared/index.js';
4
4
  export const parseBoolean = (value) => !!value && !FALSY_VALUES.has(value);
5
+ const DOC_PATTERN = /\.mdx?$/;
6
+ const isDoc = (filename) => DOC_PATTERN.test(filename);
5
7
  export const getMatchedDocFilePaths = (matched) => Promise.all(matched.map(async (it) => {
6
8
  const stat = await fs.stat(it);
7
9
  if (stat.isDirectory()) {
package/lib/cli/index.js CHANGED
@@ -28,7 +28,7 @@ program
28
28
  showGlobalOptions: true,
29
29
  })
30
30
  .option('-c, --config <config>', 'Specify the path to the config file')
31
- .option('-v <version>', 'Specify the version of the documentation')
31
+ .option('-v <version>', `Specify the version of the documentation, can also be 'unversioned' or 'unversioned-x.y'`)
32
32
  .option('-b, --base <base>', 'Override the base of the documentation')
33
33
  .option('-p, --prefix <prefix>', 'Specify the prefix of the documentation base')
34
34
  .option('-f, --force [boolean]', `Force to
@@ -37,7 +37,9 @@ program
37
37
  .option('-i, --ignore [boolean]', 'Ignore internal routes', parseBoolean, false)
38
38
  .option('-d, --download [boolean]', 'Display download pdf link on nav bar', parseBoolean, false)
39
39
  .option('-e, --export [boolean]', 'Run or build in exporting PDF mode, `apis/**` and `*/apis/**` routes will be ignored automatically', parseBoolean, false)
40
- .option('--no-open [boolean]', 'Do not open the browser after starting the server')
40
+ .option('--il, --include-language <language...>', 'Include **only** the specific language(s), `en ru` for example')
41
+ .option('--el, --exclude-language <language...>', 'Include all languages except the specific language(s), `ru` for example')
42
+ .option('-n, --no-open [boolean]', 'Do not open the browser after starting the server')
41
43
  .command('dev', { isDefault: true })
42
44
  .description('Start the development server')
43
45
  .argument('[root]', 'Root directory of the documentation')
@@ -1,6 +1,6 @@
1
1
  import { type UserConfig } from '@rspress/core';
2
2
  import type { GlobalCliOptions } from '../types.js';
3
- export declare function loadConfig(root?: string, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, }?: GlobalCliOptions): Promise<{
3
+ export declare function loadConfig(root?: string, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, includeLanguage: includeLanguages, excludeLanguage: excludeLanguages, }?: GlobalCliOptions): Promise<{
4
4
  config: UserConfig;
5
5
  filepath?: string;
6
6
  }>;
@@ -1,4 +1,4 @@
1
- import fs from 'node:fs';
1
+ import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { nodeTypes } from '@mdx-js/mdx';
4
4
  import { pluginYaml } from '@rsbuild/plugin-yaml';
@@ -7,34 +7,67 @@ import { logger } from '@rspress/shared/logger';
7
7
  import { transformerMetaHighlight, transformerMetaWordHighlight, transformerNotationDiff, transformerNotationErrorLevel, transformerNotationFocus, transformerNotationHighlight, transformerNotationWordHighlight, transformerRemoveNotationEscape, } from '@shikijs/transformers';
8
8
  import rehypeRaw from 'rehype-raw';
9
9
  import { apiPlugin, autoSidebarPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin, replacePlugin, shikiPlugin, } from '../plugins/index.js';
10
- import {} from '../shared/index.js';
10
+ import { isExplicitlyUnversioned, UNVERSIONED, } from '../shared/index.js';
11
11
  import { pathExists, pkgResolve, resolveStaticConfig } from '../utils/index.js';
12
12
  import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from './constants.js';
13
13
  const DEFAULT_LOGO = '/logo.svg';
14
- const zhLocaleConfig = {
15
- searchPlaceholderText: '搜索文档',
16
- searchNoResultsText: '未搜索到相关结果',
17
- searchSuggestedQueryText: '可更换不同的关键字后重试',
18
- outlineTitle: '本页概览',
19
- prevPageText: '上一页',
20
- nextPageText: '下一页',
14
+ const KNOWN_LOCALE_CONFIGS = {
15
+ en: {
16
+ label: 'English',
17
+ },
18
+ zh: {
19
+ label: '简体中文',
20
+ searchPlaceholderText: '搜索文档',
21
+ searchNoResultsText: '未搜索到相关结果',
22
+ searchSuggestedQueryText: '可更换不同的关键字后重试',
23
+ outlineTitle: '本页概览',
24
+ prevPageText: '上一页',
25
+ nextPageText: '下一页',
26
+ },
27
+ ru: {
28
+ label: 'Русский',
29
+ searchPlaceholderText: 'Поиск документов',
30
+ searchNoResultsText: 'Не найдено соответствующих результатов',
31
+ searchSuggestedQueryText: 'Попробуйте изменить ключевые слова и повторить поиск',
32
+ outlineTitle: 'Обзор страницы',
33
+ prevPageText: 'Предыдущая страница',
34
+ nextPageText: 'Следующая страница',
35
+ },
21
36
  };
22
- const ruLocaleConfig = {
23
- searchPlaceholderText: 'Поиск документов',
24
- searchNoResultsText: 'Не найдено соответствующих результатов',
25
- searchSuggestedQueryText: 'Попробуйте изменить ключевые слова и повторить поиск',
26
- outlineTitle: 'Обзор страницы',
27
- prevPageText: 'Предыдущая страница',
28
- nextPageText: 'Следующая страница',
29
- };
30
- const getCommonConfig = async ({ config, root, configFilePath, base, version, download, export: export_, ignore, force, open, lazy, }) => {
37
+ const getCommonConfig = async ({ config, root, configFilePath, base, version, download, export: export_, ignore, force, open, lazy, includeLanguages, excludeLanguages, }) => {
31
38
  const fallbackToZh = 'lang' in config && !config.lang;
32
39
  root = resolveDocRoot(CWD, root, config.root);
33
40
  const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
34
41
  const userBase = (base = addLeadingSlash(addTrailingSlash(base || config.base || '/')));
35
- if (version && version !== 'unversioned') {
42
+ if (version && !isExplicitlyUnversioned(version)) {
36
43
  base = userBase + `${version}/`;
37
44
  }
45
+ let locales;
46
+ if (!fallbackToZh) {
47
+ const dirents = await fs.readdir(root, { withFileTypes: true });
48
+ for (const dirent of dirents) {
49
+ const { name } = dirent;
50
+ if (!dirent.isDirectory() || ['public', 'shared'].includes(name)) {
51
+ continue;
52
+ }
53
+ if (includeLanguages?.length) {
54
+ if (!includeLanguages.includes(name)) {
55
+ continue;
56
+ }
57
+ }
58
+ else if (excludeLanguages?.length) {
59
+ if (excludeLanguages.includes(name)) {
60
+ continue;
61
+ }
62
+ }
63
+ ;
64
+ (locales ??= []).push({
65
+ lang: name,
66
+ label: name,
67
+ ...KNOWN_LOCALE_CONFIGS[name],
68
+ });
69
+ }
70
+ }
38
71
  return {
39
72
  userBase,
40
73
  root,
@@ -64,19 +97,7 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
64
97
  enableScrollToTop: true,
65
98
  // https://github.com/web-infra-dev/rspress/issues/2011
66
99
  outline: true,
67
- ...(fallbackToZh
68
- ? zhLocaleConfig
69
- : {
70
- locales: [
71
- { lang: 'en', label: 'English' },
72
- { lang: 'zh', label: '简体中文', ...zhLocaleConfig },
73
- (await pathExists(path.resolve(root, 'ru'), 'directory')) && {
74
- lang: 'ru',
75
- label: 'Русский',
76
- ...ruLocaleConfig,
77
- },
78
- ].filter(Boolean),
79
- }),
100
+ ...(fallbackToZh ? KNOWN_LOCALE_CONFIGS.zh : { locales }),
80
101
  },
81
102
  plugins: [
82
103
  apiPlugin({
@@ -144,24 +165,28 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
144
165
  },
145
166
  };
146
167
  };
147
- const findConfig = (basePath) => {
148
- return DEFAULT_EXTENSIONS.map((ext) => basePath + ext).find(fs.existsSync);
168
+ const findConfig = async (basePath) => {
169
+ for (const configFile of DEFAULT_EXTENSIONS.map((ext) => basePath + ext)) {
170
+ if (await pathExists(configFile, 'file')) {
171
+ return configFile;
172
+ }
173
+ }
149
174
  };
150
- export async function loadConfig(root, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, } = {}) {
175
+ export async function loadConfig(root, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, includeLanguage: includeLanguages, excludeLanguage: excludeLanguages, } = {}) {
151
176
  let configFilePath;
152
177
  if (configFile) {
153
178
  configFilePath = path.resolve(configFile);
154
179
  }
155
180
  else {
156
181
  if (root) {
157
- configFilePath = findConfig(path.resolve(root, DEFAULT_CONFIG_NAME));
182
+ configFilePath = await findConfig(path.resolve(root, DEFAULT_CONFIG_NAME));
158
183
  }
159
184
  if (!configFilePath) {
160
- configFilePath = findConfig(path.resolve(DEFAULT_CONFIG_NAME));
185
+ configFilePath = await findConfig(path.resolve(DEFAULT_CONFIG_NAME));
161
186
  }
162
187
  // when root is not specified, try to find config in docs folder
163
188
  if (!root && !configFilePath) {
164
- configFilePath = findConfig(path.resolve('docs', DEFAULT_CONFIG_NAME));
189
+ configFilePath = await findConfig(path.resolve('docs', DEFAULT_CONFIG_NAME));
165
190
  }
166
191
  }
167
192
  let config;
@@ -192,7 +217,7 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
192
217
  }
193
218
  else {
194
219
  const sitesConfigFilePath = path.resolve(SITES_FILE);
195
- if (fs.existsSync(sitesConfigFilePath)) {
220
+ if (await pathExists(sitesConfigFilePath, 'file')) {
196
221
  config.sites = await resolveStaticConfig(sitesConfigFilePath);
197
222
  }
198
223
  }
@@ -209,6 +234,8 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
209
234
  force,
210
235
  open,
211
236
  lazy,
237
+ includeLanguages,
238
+ excludeLanguages,
212
239
  });
213
240
  base = commonConfig.base;
214
241
  const mergedConfig = mergeRsbuildConfig(commonConfig, config, {
@@ -230,10 +257,10 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
230
257
  }
231
258
  if (ensureDefaultLogo) {
232
259
  const publicPath = path.resolve(mergedConfig.root, `public`);
233
- fs.mkdirSync(publicPath, { recursive: true });
260
+ await fs.mkdir(publicPath, { recursive: true });
234
261
  const logoPath = path.resolve(publicPath, removeLeadingSlash(DEFAULT_LOGO));
235
- if (!fs.existsSync(logoPath)) {
236
- fs.copyFileSync(pkgResolve(`assets${DEFAULT_LOGO}`), logoPath);
262
+ if (!(await pathExists(logoPath))) {
263
+ await fs.copyFile(pkgResolve(`assets${DEFAULT_LOGO}`), logoPath);
237
264
  }
238
265
  }
239
266
  if (mergedConfig.i18nSourcePath) {
@@ -248,7 +275,7 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
248
275
  mergedConfig.outDir = addTrailingSlash(mergedConfig.outDir) + version;
249
276
  }
250
277
  else {
251
- mergedConfig.outDir = `dist${version === 'unversioned' ? `${base}unversioned` : base}`;
278
+ mergedConfig.outDir = `dist${isExplicitlyUnversioned(version) ? `${base}${UNVERSIONED}` : base}`;
252
279
  }
253
280
  if (mergedConfig.builderConfig?.server?.open === true) {
254
281
  mergedConfig.builderConfig.server.open = mergedConfig.base;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Tag } from '@rspress/core/theme';
3
3
  import { isExternalUrl, withoutBase, } from '@rspress/shared';
4
- import { useState } from 'react';
4
+ import { useCallback, useState } from 'react';
5
5
  import { SvgDown } from './Down.js';
6
6
  import { NavMenuSingleItem, } from './NavMenuSingleItem.js';
7
7
  import { SvgWrapper } from './SvgWrapper.js';
@@ -18,6 +18,12 @@ function NormalGroupItem({ item }) {
18
18
  export function NavMenuGroup(item) {
19
19
  const { activeValue, items: groupItems, base = '', pathname = '' } = item;
20
20
  const [isOpen, setIsOpen] = useState(false);
21
+ const onOpen = useCallback(() => {
22
+ setIsOpen(true);
23
+ }, []);
24
+ const onClose = useCallback(() => {
25
+ setIsOpen(false);
26
+ }, []);
21
27
  const renderLinkItem = (item) => {
22
28
  const isLinkActive = new RegExp(item.activeMatch || item.link).test(withoutBase(pathname, base));
23
29
  if (activeValue === item.text || (!activeValue && isLinkActive)) {
@@ -28,13 +34,10 @@ export function NavMenuGroup(item) {
28
34
  const renderGroup = (item) => {
29
35
  return (_jsxs("div", { children: ['link' in item ? (renderLinkItem(item)) : (_jsx("p", { className: "font-bold text-gray-400 my-1 not:first:border", children: item.text })), item.items.map(renderLinkItem)] }));
30
36
  };
31
- return (_jsxs("div", { className: "relative flex-center h-14", onMouseLeave: () => {
32
- setIsOpen(false);
33
- }, children: [_jsx("button", { onMouseEnter: () => {
34
- setIsOpen(true);
35
- }, className: "rspress-nav-menu-group-button flex-center items-center font-medium text-sm text-text-1 hover:text-text-2 transition-colors duration-200", children: item.link ? (_jsx(NavMenuSingleItem, { ...item, rightIcon: _jsx(SvgWrapper, { icon: SvgDown }) })) : (_jsxs(_Fragment, { children: [_jsxs("span", { className: "text-sm font-medium flex", style: {
36
- marginRight: '2px',
37
- }, children: [_jsx(Tag, { tag: item.tag }), item.text] }), _jsx(SvgWrapper, { icon: SvgDown })] })) }), _jsx("div", { className: "rspress-nav-menu-group-content absolute mx-0.8 transition-opacity duration-300", style: {
37
+ const hasMultiItems = groupItems.length > 1;
38
+ const Content = hasMultiItems || item.link ? 'button' : 'span';
39
+ const content = (_jsx(Content, { onMouseEnter: hasMultiItems ? onOpen : undefined, className: `${Content === 'button' ? 'rspress-nav-menu-group-button ' : ''}flex-center items-center font-medium text-sm text-text-1${hasMultiItems ? ' hover:text-text-2 transition-colors duration-200' : ''}`, children: item.link ? (_jsx(NavMenuSingleItem, { ...item, rightIcon: _jsx(SvgWrapper, { icon: SvgDown }) })) : (_jsxs(_Fragment, { children: [_jsxs("span", { className: "text-sm font-medium flex", style: hasMultiItems ? { marginRight: '2px' } : undefined, children: [_jsx(Tag, { tag: item.tag }), item.text] }), hasMultiItems && _jsx(SvgWrapper, { icon: SvgDown })] })) }));
40
+ return hasMultiItems ? (_jsxs("div", { className: "relative flex-center h-14", onMouseLeave: onClose, children: [content, _jsx("div", { className: "rspress-nav-menu-group-content absolute mx-0.8 transition-opacity duration-300", style: {
38
41
  opacity: isOpen ? 1 : 0,
39
42
  visibility: isOpen ? 'visible' : 'hidden',
40
43
  right: 0,
@@ -45,5 +48,5 @@ export function NavMenuGroup(item) {
45
48
  border: '1px solid var(--rp-c-divider-light)',
46
49
  borderRadius: 'var(--rp-radius-large)',
47
50
  background: 'var(--rp-c-bg)',
48
- }, children: groupItems.map((item) => (_jsx("div", { children: 'items' in item ? renderGroup(item) : renderLinkItem(item) }, item.text))) }) })] }));
51
+ }, children: groupItems.map((item) => (_jsx("div", { children: 'items' in item ? renderGroup(item) : renderLinkItem(item) }, item.text))) }) })] })) : (content);
49
52
  }
@@ -1,14 +1,14 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { isProduction, NoSSR, removeTrailingSlash, useLang, usePageData, } from '@rspress/core/runtime';
2
+ import { isProduction, NoSSR, removeTrailingSlash, usePageData, } from '@rspress/core/runtime';
3
3
  import virtual from 'doom-@global-virtual';
4
4
  import { noop } from 'es-toolkit';
5
5
  import { useEffect, useMemo, useState } from 'react';
6
6
  import { createPortal } from 'react-dom';
7
7
  import { parse } from 'yaml';
8
- import { ACP_BASE, getPdfName } from '../../shared/index.js';
8
+ import { ACP_BASE, getPdfName, getUnversionedVersion, isExplicitlyUnversioned, } from '../../shared/index.js';
9
9
  import { NavMenuGroup } from './NavMenuGroup.js';
10
10
  import { NavMenuSingleItem } from './NavMenuSingleItem.js';
11
- import { useTranslation } from '@alauda/doom/runtime';
11
+ import { useLang, useTranslation } from '@alauda/doom/runtime';
12
12
  const getNavMenu = () => {
13
13
  if (typeof document === 'undefined') {
14
14
  return null;
@@ -35,38 +35,45 @@ const VersionsNav_ = () => {
35
35
  return siteData.base + getPdfName(lang, virtual.userBase, siteData.title);
36
36
  }, [lang, siteData.base, siteData.title]);
37
37
  const [versionsBase, version] = useMemo(() => {
38
- if (!virtual.version) {
38
+ const unversionedVersion = getUnversionedVersion(virtual.version);
39
+ if (!unversionedVersion) {
39
40
  return [];
40
41
  }
41
42
  return [
42
- removeTrailingSlash(siteData.base).slice(0, -virtual.version.length - 1),
43
- virtual.version,
43
+ isExplicitlyUnversioned(virtual.version)
44
+ ? undefined
45
+ : removeTrailingSlash(siteData.base).slice(0, -unversionedVersion.length - 1),
46
+ unversionedVersion,
44
47
  ];
45
48
  }, [siteData.base]);
46
49
  const [navMenu, setNavMenu] = useState(getNavMenu);
47
- const [versions, setVersions] = useState();
50
+ const [versions, setVersions] = useState(version ? [version] : []);
48
51
  useEffect(() => {
49
52
  const fetchVersions = async () => {
50
53
  if (versionsBase == null) {
51
- return;
54
+ if (!version) {
55
+ return;
56
+ }
52
57
  }
53
- const res = await fetch(`${isProduction() ? versionsBase : ''}/versions.yaml`);
54
- if (!res.ok) {
55
- return;
58
+ else {
59
+ const res = await fetch(`${isProduction() ? versionsBase : ''}/versions.yaml`);
60
+ if (!res.ok) {
61
+ return;
62
+ }
63
+ const text = await res.text();
64
+ const versions = parse(text);
65
+ if (version && !versions.includes(version)) {
66
+ versions.unshift(version);
67
+ }
68
+ setVersions(versions);
56
69
  }
57
- const text = await res.text();
58
- const versions = parse(text);
59
- if (version && !versions.includes(version)) {
60
- versions.unshift(version);
61
- }
62
- setVersions(versions);
63
70
  setNavMenu(getNavMenu);
64
71
  };
65
72
  void fetchVersions().catch(noop);
66
73
  }, []);
67
74
  // hack way to detect nav menu recreation on theme change
68
75
  useEffect(() => {
69
- if (!navMenu) {
76
+ if (!navMenu?.parentNode) {
70
77
  return;
71
78
  }
72
79
  const observer = new MutationObserver((mutations) => {
@@ -74,18 +81,18 @@ const VersionsNav_ = () => {
74
81
  setNavMenu(getNavMenu);
75
82
  }
76
83
  });
77
- observer.observe(navMenu, { childList: true });
84
+ observer.observe(navMenu.parentNode, { childList: true });
78
85
  return () => {
79
86
  observer.disconnect();
80
87
  };
81
88
  }, [navMenu]);
89
+ console.log('versionsBase', versionsBase);
82
90
  const navItems = useMemo(() => {
83
- const versionItems = (versions || []).map((v) => ({
84
- text: v,
85
- link: `${versionsBase}/${v}/`,
86
- activeMatch: v,
87
- }));
88
- if (ALLOW_LEGACY_DOMAINS.includes(location.hostname) &&
91
+ const versionItems = versions.map((v) => versionsBase == null
92
+ ? { text: v, items: [] }
93
+ : { text: v, link: `${versionsBase}/${v}/`, activeMatch: v });
94
+ if (versionsBase != null &&
95
+ ALLOW_LEGACY_DOMAINS.includes(location.hostname) &&
89
96
  virtual.userBase === ACP_BASE) {
90
97
  versionItems.push(...LEGACY_NAV_ITEMS);
91
98
  }
@@ -28,7 +28,7 @@ export const globalPlugin = ({ version, download, }) => {
28
28
  'doom-@global-virtual': `export default ${JSON.stringify({
29
29
  userBase: config.userBase,
30
30
  prefix: config.prefix,
31
- version: version === 'unversioned' ? undefined : version,
31
+ version,
32
32
  download,
33
33
  sites: config.sites?.map((site) => ({
34
34
  ...site,
@@ -6,6 +6,7 @@ import { clsx } from 'clsx';
6
6
  import virtual from 'doom-@global-virtual';
7
7
  import { useMemo } from 'react';
8
8
  import classes from '../../../styles/link.module.scss';
9
+ import { isUnversioned } from '../../shared/helpers.js';
9
10
  import { useIsPrint } from '../hooks/index.js';
10
11
  import { Directive } from './Directive.js';
11
12
  const ExternalSiteLink_ = ({ name, href = '', className, ...props }) => {
@@ -28,9 +29,9 @@ const ExternalSiteLink_ = ({ name, href = '', className, ...props }) => {
28
29
  url = removeLeadingSlash(normalizeHref(url));
29
30
  return (_jsx("a", { href: (isPrint ? 'https://docs.alauda.io' : '') +
30
31
  (virtual.prefix || '') +
31
- (virtual.version
32
- ? addTrailingSlash(site.base + site.version)
33
- : site.base) +
32
+ (isUnversioned(virtual.version)
33
+ ? site.base
34
+ : addTrailingSlash(site.base + site.version)) +
34
35
  (lang ? addTrailingSlash(lang) : '') +
35
36
  (hash ? `${url}#${hash}` : url), target: "_blank", rel: "noopener noreferrer", className: clsx(classes.link, 'cursor-pointer', className), ...props }));
36
37
  };
@@ -1,4 +1,4 @@
1
- import type { Language } from '../../shared/index.js';
1
+ import { type Language } from '../../shared/index.js';
2
2
  import { type NamedTerms, type TermName } from '../../terms.js';
3
3
  export type SiteOverridesTerms = Record<TermName, string>;
4
4
  export interface SiteOverridesItem {
@@ -3,6 +3,7 @@ import virtual from 'doom-@global-virtual';
3
3
  import { merge } from 'es-toolkit/compat';
4
4
  import { useEffect, useMemo, useState } from 'react';
5
5
  import { parse } from 'yaml';
6
+ import { isUnversioned } from '../../shared/index.js';
6
7
  import { namedTerms } from '../../terms.js';
7
8
  import { useLang } from './useTranslation.js';
8
9
  const normalizeOverrides = (origin) => Object.keys(origin).reduce((acc, key_) => {
@@ -23,7 +24,7 @@ const fetchSiteOverrides = async (base, version, acpSite) => {
23
24
  return promise;
24
25
  }
25
26
  const acpSiteOverridesUrl = acpSite && isProduction()
26
- ? `${(virtual.prefix || '') + acpSite.base}${version ? acpSite.version + '/' : ''}overrides.yaml`
27
+ ? `${(virtual.prefix || '') + acpSite.base}${isUnversioned(version) ? '' : acpSite.version + '/'}overrides.yaml`
27
28
  : null;
28
29
  const siteOverridesUrl = `${isProduction() ? base : '/'}overrides.yaml`;
29
30
  const urls = [acpSiteOverridesUrl];
@@ -9,3 +9,5 @@ export declare const Language: {
9
9
  };
10
10
  export type Language = keyof typeof Language;
11
11
  export declare const SUPPORTED_LANGUAGES: Language[];
12
+ export declare const UNVERSIONED = "unversioned";
13
+ export declare const UNVERSIONED_PREFIX = "unversioned-";
@@ -14,3 +14,5 @@ export const Language = {
14
14
  ru: '俄文',
15
15
  };
16
16
  export const SUPPORTED_LANGUAGES = Object.keys(Language);
17
+ export const UNVERSIONED = 'unversioned';
18
+ export const UNVERSIONED_PREFIX = `${UNVERSIONED}-`;
@@ -1,4 +1,6 @@
1
+ import type { UnversionedVersion } from './types.js';
1
2
  export declare const removeBothEndsSlashes: (str?: string) => string;
2
3
  export declare const getPdfName: (lang: string, userBase?: string, title?: string) => string;
3
- export declare const DOC_PATTERN: RegExp;
4
- export declare const isDoc: (filename: string) => boolean;
4
+ export declare const isExplicitlyUnversioned: (version?: string) => version is UnversionedVersion;
5
+ export declare const isUnversioned: (version?: string) => version is undefined | "" | UnversionedVersion;
6
+ export declare const getUnversionedVersion: (version?: string) => string | undefined;
@@ -1,4 +1,13 @@
1
+ import { UNVERSIONED, UNVERSIONED_PREFIX } from './constants.js';
1
2
  export const removeBothEndsSlashes = (str) => str?.replace(/^\/|\/$/g, '') || '';
2
3
  export const getPdfName = (lang, userBase, title) => `${removeBothEndsSlashes(userBase) || title || 'exported'}-${lang}.pdf`;
3
- export const DOC_PATTERN = /\.mdx?$/;
4
- export const isDoc = (filename) => DOC_PATTERN.test(filename);
4
+ export const isExplicitlyUnversioned = (version) => version === UNVERSIONED || !!version?.startsWith(UNVERSIONED_PREFIX);
5
+ export const isUnversioned = (version) => !version || isExplicitlyUnversioned(version);
6
+ export const getUnversionedVersion = (version) => {
7
+ if (!version || version === UNVERSIONED) {
8
+ return;
9
+ }
10
+ return version.startsWith(UNVERSIONED_PREFIX)
11
+ ? version.slice(UNVERSIONED_PREFIX.length)
12
+ : version;
13
+ };
@@ -1,3 +1,4 @@
1
+ import type { UNVERSIONED } from './constants.js';
1
2
  export interface DoomSite {
2
3
  name: string;
3
4
  base: string;
@@ -19,3 +20,4 @@ export interface K8sTypeMeta {
19
20
  export interface K8sTypeList<T extends K8sTypeMeta> extends K8sTypeMeta {
20
21
  items: T[];
21
22
  }
23
+ export type UnversionedVersion = typeof UNVERSIONED | `${typeof UNVERSIONED}-${string}`;
package/lib/types.d.ts CHANGED
@@ -14,6 +14,8 @@ export interface GlobalCliOptions {
14
14
  force?: boolean;
15
15
  open?: boolean;
16
16
  lazy?: boolean;
17
+ includeLanguage?: string[];
18
+ excludeLanguage?: string[];
17
19
  }
18
20
  export interface TranslateOptions {
19
21
  systemPrompt?: string;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "0.19.5",
3
+ "version": "0.20.0",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": "https://gitlab-ce.alauda.cn/idp/Doom.git",
7
- "packageManager": "yarn@4.9.0",
7
+ "packageManager": "yarn@4.9.1",
8
8
  "engines": {
9
9
  "node": ">=18.17.0 <20 || >=20.1.0"
10
10
  },
@@ -43,16 +43,16 @@
43
43
  "dependencies": {
44
44
  "@inquirer/prompts": "^7.4.1",
45
45
  "@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
46
- "@playwright/browser-chromium": "^1.51.1",
46
+ "@playwright/browser-chromium": "^1.52.0",
47
47
  "@rsbuild/plugin-yaml": "^1.0.2",
48
48
  "@rspress/core": "1.43.11",
49
- "@shikijs/transformers": "^3.2.2",
49
+ "@shikijs/transformers": "^3.3.0",
50
50
  "chokidar": "^4.0.3",
51
51
  "cli-progress": "^3.12.0",
52
52
  "clsx": "^2.1.1",
53
53
  "commander": "^13.1.0",
54
54
  "ejs": "^3.1.10",
55
- "es-toolkit": "^1.34.1",
55
+ "es-toolkit": "^1.35.0",
56
56
  "html-tag-names": "^2.1.0",
57
57
  "mermaid": "^11.6.0",
58
58
  "openai": "^5.0.0-beta.0",
@@ -61,23 +61,23 @@
61
61
  "pdf-lib": "^1.17.1",
62
62
  "pdf-merger-js": "^5.1.2",
63
63
  "picomatch": "^4.0.2",
64
- "playwright": "^1.51.1",
64
+ "playwright": "^1.52.0",
65
65
  "react-markdown": "^8.0.7",
66
66
  "rehype-raw": "^6.1.1",
67
67
  "remark-directive": "^2.0.1",
68
68
  "remark-frontmatter": "^4.0.1",
69
69
  "remark-gfm": "^3.0.1",
70
- "shiki": "^3.2.2",
70
+ "shiki": "^3.3.0",
71
71
  "simple-git": "^3.27.0",
72
72
  "swagger2openapi": "^7.0.8",
73
- "tinyglobby": "^0.2.12",
74
- "type-fest": "^4.39.1",
73
+ "tinyglobby": "^0.2.13",
74
+ "type-fest": "^4.40.0",
75
75
  "x-fetch": "^0.2.6",
76
76
  "yaml": "^2.7.1",
77
77
  "yoctocolors": "^2.1.1"
78
78
  },
79
79
  "devDependencies": {
80
- "@eslint/js": "^9.24.0",
80
+ "@eslint/js": "^9.25.1",
81
81
  "@swc-node/register": "^1.10.10",
82
82
  "@swc/core": "1.11.21",
83
83
  "@total-typescript/ts-reset": "^0.6.1",
@@ -89,19 +89,20 @@
89
89
  "@types/react-dom": "^18.3.6",
90
90
  "@types/swagger2openapi": "^7.0.4",
91
91
  "@unts/patch-package": "^8.1.1",
92
- "eslint": "^9.24.0",
93
- "eslint-import-resolver-typescript": "^4.3.2",
94
- "eslint-plugin-import-x": "^4.10.3",
92
+ "eslint": "^9.25.1",
93
+ "eslint-import-resolver-typescript": "^4.3.4",
94
+ "eslint-plugin-import-x": "^4.10.6",
95
95
  "nano-staged": "^0.8.0",
96
96
  "npm-run-all2": "^7.0.2",
97
97
  "prettier": "^3.5.3",
98
98
  "prettier-plugin-pkg": "^0.19.0",
99
99
  "simple-git-hooks": "^2.12.1",
100
100
  "typescript": "^5.8.3",
101
- "typescript-eslint": "^8.29.1",
102
- "yarn-berry-deduplicate": "^6.1.1"
101
+ "typescript-eslint": "^8.31.0",
102
+ "yarn-berry-deduplicate": "^6.1.3"
103
103
  },
104
104
  "publishConfig": {
105
- "access": "public"
105
+ "access": "public",
106
+ "registry": "https://registry.npmjs.org"
106
107
  }
107
108
  }
@@ -1,13 +0,0 @@
1
- export interface QuickNavItem {
2
- icon: string;
3
- title: string;
4
- links: Array<{
5
- title: string;
6
- href: string;
7
- }>;
8
- }
9
- export interface QuickNavProps {
10
- items: QuickNavItem[];
11
- }
12
- export declare const QuickNav: ({ items }: QuickNavProps) => import("react/jsx-runtime").JSX.Element;
13
- export default QuickNav;
@@ -1,8 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { normalizeImagePath } from '@rspress/core/runtime';
3
- import { Link } from '@rspress/core/theme';
4
- import classes from '../../../styles/quick-nav.module.scss';
5
- export const QuickNav = ({ items }) => {
6
- return (_jsx("ul", { className: classes.container, children: items.map((item, index) => (_jsxs("li", { className: classes.item, children: [_jsxs("div", { className: classes.title, title: item.title, children: [_jsx("img", { src: normalizeImagePath(item.icon), alt: item.title }), item.title] }), _jsx("hr", { className: classes.divider }), _jsx("ul", { className: classes.links, children: item.links.map((link, index) => (_jsx("li", { children: _jsx(Link, { href: link.href, title: link.title, children: link.title }) }, index))) })] }, index))) }));
7
- };
8
- export default QuickNav;
@@ -1,32 +0,0 @@
1
- import type { serve } from '@rspress/core';
2
-
3
- import type { ApiPluginOptions, AutoSidebarPluginOptions, PermissionPluginOptions, ReferenceItem, ReleaseNotesOptions } from '../plugins/index.js';
4
- import type { DoomSite } from '../shared/index.js';
5
-
6
- export type BaseServeOptions = Parameters<typeof serve>[0];
7
- export type ServeOptions = Omit<BaseServeOptions, 'config'>;
8
- export interface GlobalCliOptions {
9
- config?: string;
10
- base?: string;
11
- prefix?: string;
12
- v?: string;
13
- download?: boolean;
14
- ignore?: boolean;
15
- force?: boolean;
16
- }
17
- declare module '@rspress/shared' {
18
- interface UserConfig {
19
- userBase?: string;
20
- api?: Omit<ApiPluginOptions, 'localBasePath'>;
21
- sites?: DoomSite[];
22
- permission?: PermissionPluginOptions;
23
- reference?: ReferenceItem[];
24
- sidebar?: Omit<AutoSidebarPluginOptions, 'download' | 'excludeRoutes'>;
25
- releaseNotes?: ReleaseNotesOptions;
26
- internalRoutes?: string[];
27
- }
28
- }
29
- export type ContentProcessor = {
30
- type: 'ejsTemplate';
31
- data?: Record<string, unknown>;
32
- };
@@ -1 +0,0 @@
1
- export {};