@alauda/doom 0.14.2 → 0.14.3

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 (88) hide show
  1. package/global.d.ts +1 -28
  2. package/lib/cli/export.js +4 -5
  3. package/lib/cli/index.js +3 -2
  4. package/lib/cli/load-config.d.ts +4 -3
  5. package/lib/cli/load-config.js +25 -22
  6. package/lib/cli/new.d.ts +1 -1
  7. package/lib/cli/new.js +1 -2
  8. package/lib/cli/translate.js +1 -2
  9. package/lib/config.d.ts +2 -2
  10. package/lib/global/SiteOverrides/index.d.ts +1 -2
  11. package/lib/global/SiteOverrides/index.js +1 -1
  12. package/lib/global/VersionsNav/NavMenuGroup.d.ts +2 -1
  13. package/lib/global/VersionsNav/NavMenuGroup.js +3 -5
  14. package/lib/global/VersionsNav/NavMenuSingleItem.d.ts +9 -8
  15. package/lib/global/VersionsNav/NavMenuSingleItem.js +7 -5
  16. package/lib/global/VersionsNav/index.d.ts +1 -2
  17. package/lib/global/VersionsNav/index.js +20 -8
  18. package/lib/plugins/api/index.d.ts +2 -1
  19. package/lib/plugins/api/index.js +4 -4
  20. package/lib/plugins/auto-sidebar/index.d.ts +3 -1
  21. package/lib/plugins/auto-sidebar/index.js +2 -1
  22. package/lib/plugins/auto-sidebar/type.d.ts +0 -2
  23. package/lib/plugins/auto-sidebar/walk.d.ts +2 -2
  24. package/lib/plugins/auto-sidebar/walk.js +2 -1
  25. package/lib/plugins/global/index.d.ts +7 -3
  26. package/lib/plugins/global/index.js +7 -5
  27. package/lib/plugins/permission/index.d.ts +2 -1
  28. package/lib/plugins/permission/index.js +3 -3
  29. package/lib/plugins/replace/index.d.ts +4 -5
  30. package/lib/plugins/replace/index.js +22 -19
  31. package/lib/plugins/replace/types.d.ts +1 -1
  32. package/lib/plugins/replace/utils.d.ts +1 -1
  33. package/lib/plugins/replace/utils.js +1 -1
  34. package/lib/runtime/hooks/useTranslation.d.ts +1 -1
  35. package/lib/runtime/index.js +2 -0
  36. package/lib/runtime/translation.d.ts +2 -0
  37. package/lib/runtime/translation.js +2 -0
  38. package/lib/shared/helpers.d.ts +2 -0
  39. package/lib/shared/helpers.js +2 -0
  40. package/lib/types.d.ts +30 -0
  41. package/lib/utils/helpers.d.ts +1 -2
  42. package/lib/utils/helpers.js +2 -3
  43. package/lib/utils/index.d.ts +0 -1
  44. package/lib/utils/index.js +0 -1
  45. package/lib/utils/types.d.ts +14 -13
  46. package/package.json +3 -2
  47. package/lib/cli/export-pdf-core/utils/filterRoute.d.ts +0 -8
  48. package/lib/cli/export-pdf-core/utils/filterRoute.js +0 -11
  49. package/lib/cli/export-pdf-core/utils/timeTransformer.d.ts +0 -8
  50. package/lib/cli/export-pdf-core/utils/timeTransformer.js +0 -22
  51. package/lib/plugins/reference/index.d.ts +0 -10
  52. package/lib/plugins/reference/index.js +0 -60
  53. package/lib/plugins/reference/normalize-img-src.d.ts +0 -10
  54. package/lib/plugins/reference/normalize-img-src.js +0 -59
  55. package/lib/plugins/reference/parse-toc.d.ts +0 -17
  56. package/lib/plugins/reference/parse-toc.js +0 -51
  57. package/lib/plugins/reference/remark-normalize-link.d.ts +0 -12
  58. package/lib/plugins/reference/remark-normalize-link.js +0 -114
  59. package/lib/plugins/reference/remark-replace.d.ts +0 -16
  60. package/lib/plugins/reference/remark-replace.js +0 -172
  61. package/lib/plugins/reference/remark-toc.d.ts +0 -19
  62. package/lib/plugins/reference/remark-toc.js +0 -61
  63. package/lib/plugins/reference/resolve-reference.d.ts +0 -8
  64. package/lib/plugins/reference/resolve-reference.js +0 -134
  65. package/lib/plugins/reference/resolve-release.d.ts +0 -2
  66. package/lib/plugins/reference/resolve-release.js +0 -93
  67. package/lib/plugins/reference/types.d.ts +0 -32
  68. package/lib/plugins/reference/utils.d.ts +0 -14
  69. package/lib/plugins/reference/utils.js +0 -85
  70. package/lib/plugins/replace/remark-jsx-table.d.ts +0 -3
  71. package/lib/plugins/replace/remark-jsx-table.js +0 -10
  72. package/lib/runtime/components/CompanyBrand.d.ts +0 -2
  73. package/lib/runtime/components/CompanyBrand.js +0 -4
  74. package/lib/runtime/components/ProductBrand.d.ts +0 -2
  75. package/lib/runtime/components/ProductBrand.js +0 -4
  76. package/lib/runtime/components/ProductShortBrand.d.ts +0 -2
  77. package/lib/runtime/components/ProductShortBrand.js +0 -4
  78. package/lib/runtime/components/_BrandBase.d.ts +0 -5
  79. package/lib/runtime/components/_BrandBase.js +0 -7
  80. package/lib/runtime/components/_Directive.d.ts +0 -10
  81. package/lib/runtime/components/_Directive.js +0 -16
  82. package/lib/runtime/hooks/use.d.ts +0 -12
  83. package/lib/runtime/hooks/use.js +0 -37
  84. package/lib/runtime/types.d.ts +0 -5
  85. package/lib/runtime/types.js +0 -1
  86. package/lib/shared/constants.d.ts +0 -3
  87. package/lib/shared/constants.js +0 -6
  88. /package/lib/{plugins/reference/types.js → types.js} +0 -0
package/global.d.ts CHANGED
@@ -1,30 +1,3 @@
1
- declare module '*.module.scss' {
2
- const classes: { [key: string]: string }
3
- export default classes
4
- }
1
+ /// <reference types="@alauda/doom/types" />
5
2
 
6
3
  type MDXProvidedComponents = typeof import('@alauda/doom/runtime')
7
-
8
- declare module 'doom-@api-crdsMap' {
9
- export default crdsMap
10
- }
11
-
12
- declare module 'doom-@api-openapisMap' {
13
- export default openapisMap
14
- }
15
-
16
- declare module 'doom-@api-virtual' {
17
- export default virtual
18
- }
19
-
20
- declare module 'doom-@global-virtual' {
21
- export default virtual
22
- }
23
-
24
- declare module 'doom-@permission-functionResourcesMap' {
25
- export default functionResourcesMap
26
- }
27
-
28
- declare module 'doom-@permission-roleTemplatesMap' {
29
- export default roleTemplatesMap
30
- }
package/lib/cli/export.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import path from 'node:path';
2
- import { generatePdf, } from './export-pdf-core/index.js';
3
2
  import { removeLeadingSlash, serve } from '@rspress/core';
4
3
  import { logger } from '@rspress/shared/logger';
5
4
  import { Command } from 'commander';
6
5
  import { autoSidebar } from '../plugins/index.js';
7
- import { pathExists, removeBothEndsSlashes, setNodeEnv, } from '../utils/index.js';
6
+ import { getPdfName } from '../shared/index.js';
7
+ import { pathExists, setNodeEnv } from '../utils/index.js';
8
+ import { generatePdf, } from './export-pdf-core/index.js';
8
9
  import { loadConfig } from './load-config.js';
9
10
  export const exportCommand = new Command('export')
10
11
  .description('Export the documentation as PDF')
@@ -14,7 +15,6 @@ export const exportCommand = new Command('export')
14
15
  .action(async function (root) {
15
16
  setNodeEnv('production');
16
17
  const { port, host, ...globalOptions } = this.optsWithGlobals();
17
- const { base } = globalOptions;
18
18
  let { config } = await loadConfig(root, globalOptions);
19
19
  const outDir = config.outDir;
20
20
  if (!(await pathExists(path.resolve(outDir, 'index.html'), 'file'))) {
@@ -22,7 +22,6 @@ export const exportCommand = new Command('export')
22
22
  process.exit(1);
23
23
  }
24
24
  config = await autoSidebar(config, {
25
- ...config.sidebar,
26
25
  excludeRoutes: (globalOptions.ignore && config.internalRoutes) || [],
27
26
  });
28
27
  config.builderConfig.server.open = false;
@@ -83,7 +82,7 @@ export const exportCommand = new Command('export')
83
82
  const exportPdf = async (sidebarItems, lang = config.lang) => {
84
83
  await generatePdf({
85
84
  pages: collectPages(sidebarItems),
86
- outFile: `${removeBothEndsSlashes(base || config.base) || config.title}-${lang}.pdf`,
85
+ outFile: getPdfName(lang, config.userBase, config.title),
87
86
  ...commonOptions,
88
87
  });
89
88
  };
package/lib/cli/index.js CHANGED
@@ -9,12 +9,12 @@ import { build, dev, serve } from '@rspress/core';
9
9
  import { watch } from 'chokidar';
10
10
  import { program } from 'commander';
11
11
  import { green } from 'yoctocolors';
12
+ import { setNodeEnv } from '../utils/index.js';
12
13
  import { CWD, DEFAULT_CONFIGS, I18N_FILE, SITES_FILE } from './constants.js';
14
+ import { exportCommand } from './export.js';
13
15
  import { loadConfig } from './load-config.js';
14
16
  import { newCommand } from './new.js';
15
17
  import { translateCommand } from './translate.js';
16
- import { exportCommand } from './export.js';
17
- import { setNodeEnv, } from '../utils/index.js';
18
18
  const META_FILE = '_meta.json';
19
19
  const CONFIG_FILES = [...DEFAULT_CONFIGS, I18N_FILE, SITES_FILE];
20
20
  const cjsRequire = module.createRequire(import.meta.url);
@@ -32,6 +32,7 @@ program
32
32
  .option('-p, --prefix <prefix>', 'Specify the prefix of the documentation base')
33
33
  .option('-f, --force [boolean]', 'Force to fetch latest reference remotes or scaffolding templates, otherwise use local cache', (value) => !!value && value !== 'false', false)
34
34
  .option('-i, --ignore [boolean]', 'Ignore internal routes', (value) => !!value && value !== 'false', false)
35
+ .option('-d, --download [boolean]', 'Display download pdf link on nav bar', (value) => !!value && value !== 'false', false)
35
36
  .command('dev', { isDefault: true })
36
37
  .description('Start the development server')
37
38
  .argument('[root]', 'Root directory of the documentation')
@@ -1,6 +1,7 @@
1
- import { type DoomConfig, type GlobalCliOptions } from '../utils/index.js';
2
- export declare function loadConfig(root?: string, { config: configFile, base, prefix, v: version, ignore, force, }?: GlobalCliOptions): Promise<{
3
- config: DoomConfig;
1
+ import { type UserConfig } from '@rspress/core';
2
+ import type { GlobalCliOptions } from '../types.js';
3
+ export declare function loadConfig(root?: string, { config: configFile, base, prefix, v: version, download, ignore, force, }?: GlobalCliOptions): Promise<{
4
+ config: UserConfig;
4
5
  filepath?: string;
5
6
  }>;
6
7
  export declare function resolveDocRoot(cwd: string, cliRoot?: string, configRoot?: string): string;
@@ -1,13 +1,13 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { nodeTypes } from '@mdx-js/mdx';
4
- import { addLeadingSlash, addTrailingSlash, normalizeSlash, removeLeadingSlash, removeTrailingSlash, } from '@rspress/core';
4
+ import { addLeadingSlash, addTrailingSlash, normalizeSlash, removeLeadingSlash, } from '@rspress/core';
5
5
  import { logger } from '@rspress/shared/logger';
6
6
  import { transformerMetaHighlight, transformerMetaWordHighlight, transformerNotationDiff, transformerNotationErrorLevel, transformerNotationFocus, transformerNotationHighlight, transformerNotationWordHighlight, transformerRemoveNotationEscape, } from '@shikijs/transformers';
7
7
  import rehypeRaw from 'rehype-raw';
8
8
  import { apiPlugin, autoSidebarPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin, replacePlugin, shikiPlugin, } from '../plugins/index.js';
9
9
  import { normalizeVersion } from '../shared/index.js';
10
- import { pkgResolve, resolveStaticConfig, } from '../utils/index.js';
10
+ import { pkgResolve, resolveStaticConfig } from '../utils/index.js';
11
11
  import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from './constants.js';
12
12
  const DEFAULT_LOGO = '/logo.svg';
13
13
  const zhLocaleConfig = {
@@ -18,13 +18,19 @@ const zhLocaleConfig = {
18
18
  prevPageText: '上一页',
19
19
  nextPageText: '下一页',
20
20
  };
21
- const getCommonConfig = (config, cliRoot, configFilePath, version, ignore, force) => {
21
+ const getCommonConfig = ({ config, root, configFilePath, base, version, download, ignore, force, }) => {
22
22
  const fallbackToZh = 'lang' in config && !config.lang;
23
- const root = resolveDocRoot(CWD, cliRoot, config.root);
23
+ root = resolveDocRoot(CWD, root, config.root);
24
24
  const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
25
25
  const excludeRoutes = (ignore && config.internalRoutes) || [];
26
+ const userBase = (base = addLeadingSlash(addTrailingSlash(base || config.base || '/')));
27
+ if (version && version !== 'unversioned') {
28
+ base = userBase + `${version}/`;
29
+ }
26
30
  return {
31
+ userBase,
27
32
  root,
33
+ base: addTrailingSlash(base),
28
34
  lang: fallbackToZh ? 'zh' : config.lang || 'en',
29
35
  title: '',
30
36
  route: {
@@ -60,30 +66,21 @@ const getCommonConfig = (config, cliRoot, configFilePath, version, ignore, force
60
66
  },
61
67
  plugins: [
62
68
  apiPlugin({
63
- ...config.api,
64
69
  localBasePath,
65
70
  }),
66
71
  autoSidebarPlugin({
67
- ...config.sidebar,
68
72
  excludeRoutes,
69
73
  }),
70
74
  directivesPlugin(),
71
- globalPlugin({
72
- sites: config.sites,
73
- version,
74
- }),
75
+ globalPlugin({ version, download }),
75
76
  mermaidPlugin(),
76
77
  permissionPlugin({
77
- ...config.permission,
78
78
  localBasePath,
79
79
  }),
80
80
  replacePlugin({
81
- root,
82
81
  lang: fallbackToZh ? null : (config.lang ?? 'en'),
83
82
  localBasePath,
84
- items: config.reference,
85
83
  force,
86
- releaseNotes: config.releaseNotes,
87
84
  }),
88
85
  shikiPlugin({
89
86
  langs: ['dockerfile', 'dotenv', 'html', 'go', 'jsonc', 'mermaid'],
@@ -121,7 +118,7 @@ const getCommonConfig = (config, cliRoot, configFilePath, version, ignore, force
121
118
  const findConfig = (basePath) => {
122
119
  return DEFAULT_EXTENSIONS.map((ext) => basePath + ext).find(fs.existsSync);
123
120
  };
124
- export async function loadConfig(root, { config: configFile, base, prefix, v: version, ignore, force, } = {}) {
121
+ export async function loadConfig(root, { config: configFile, base, prefix, v: version, download, ignore, force, } = {}) {
125
122
  let configFilePath;
126
123
  if (configFile) {
127
124
  configFilePath = path.resolve(configFile);
@@ -171,17 +168,23 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
171
168
  }
172
169
  }
173
170
  const normalizedVersion = normalizeVersion(version);
174
- const commonConfig = getCommonConfig(config, root, configFilePath, normalizedVersion, ignore, force);
171
+ const commonConfig = getCommonConfig({
172
+ config,
173
+ configFilePath,
174
+ root,
175
+ base,
176
+ version: normalizedVersion,
177
+ download,
178
+ ignore,
179
+ force,
180
+ });
181
+ base = commonConfig.base;
175
182
  const mergedConfig = mergeRsbuildConfig(commonConfig, config, {
183
+ base,
176
184
  lang: commonConfig.lang,
177
185
  root: commonConfig.root,
178
186
  });
179
- base = addLeadingSlash(base || mergedConfig.base || '/');
180
- if (normalizedVersion && normalizedVersion !== 'unversioned') {
181
- base = removeTrailingSlash(base) + `/${normalizedVersion}`;
182
- }
183
- mergedConfig.base = base = addTrailingSlash(base);
184
- if (prefix) {
187
+ if (base && prefix) {
185
188
  mergedConfig.base = normalizeSlash(prefix) + base;
186
189
  }
187
190
  let ensureDefaultLogo = false;
package/lib/cli/new.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as prompts from '@inquirer/prompts';
2
2
  import { Command } from 'commander';
3
- import type { ContentProcessor } from '../utils/types.js';
3
+ import type { ContentProcessor } from '../types.js';
4
4
  export declare const DEFAULT_PATH = "templates/scaffolding.yaml";
5
5
  export interface ScaffoldingTemplate {
6
6
  repo: string;
package/lib/cli/new.js CHANGED
@@ -6,8 +6,7 @@ import { Command } from 'commander';
6
6
  import { render } from 'ejs';
7
7
  import { glob } from 'tinyglobby';
8
8
  import { cyan, magenta } from 'yoctocolors';
9
- import { resolveStaticConfig } from '../utils/helpers.js';
10
- import { resolveRepo } from '../utils/index.js';
9
+ import { resolveRepo, resolveStaticConfig } from '../utils/index.js';
11
10
  export const DEFAULT_PATH = 'templates/scaffolding.yaml';
12
11
  const scaffoldingTemplates = {
13
12
  'product-doc': {
@@ -7,8 +7,7 @@ import matter from 'gray-matter';
7
7
  import { AzureOpenAI } from 'openai';
8
8
  import { pRateLimit } from 'p-ratelimit';
9
9
  import { cyan } from 'yoctocolors';
10
- import { normalizeImgSrc, } from '../plugins/replace/normalize-img-src.js';
11
- import { mdProcessor, mdxProcessor } from '../plugins/replace/utils.js';
10
+ import { mdProcessor, mdxProcessor, normalizeImgSrc, } from '../plugins/index.js';
12
11
  import { pathExists } from '../utils/index.js';
13
12
  import { loadConfig } from './load-config.js';
14
13
  const LANGUAGE_CODES = {
package/lib/config.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import type { DoomConfig } from './utils/index.js';
2
- export declare const defineConfig: (config: DoomConfig) => DoomConfig;
1
+ import type { Config } from '@rspress/core';
2
+ export declare const defineConfig: (config: Config) => Config;
@@ -1,3 +1,2 @@
1
- import { type FC } from 'react';
2
- export declare const SiteOverrides: FC;
1
+ export declare const SiteOverrides: () => null;
3
2
  export default SiteOverrides;
@@ -1,6 +1,6 @@
1
+ import { useSiteOverrides } from '@alauda/doom/runtime';
1
2
  import { usePageData } from '@rspress/core/runtime';
2
3
  import { useEffect } from 'react';
3
- import { useSiteOverrides } from '../../runtime/hooks/index.js';
4
4
  const setNavBarSpans = (logoText) => {
5
5
  const navBarLinks = document.querySelectorAll('[class^=navBarTitle] > a');
6
6
  if (!navBarLinks.length) {
@@ -1,6 +1,7 @@
1
1
  import { type NavItem } from '@rspress/shared';
2
+ import { type ReactNode } from 'react';
2
3
  export interface NavMenuGroupItem {
3
- text?: string | React.ReactElement;
4
+ text?: string | ReactNode;
4
5
  link?: string;
5
6
  items: NavItem[];
6
7
  tag?: string;
@@ -3,7 +3,7 @@ import { Tag } from '@rspress/core/theme';
3
3
  import { withoutBase, } from '@rspress/shared';
4
4
  import { useState } from 'react';
5
5
  import { SvgDown } from './Down.js';
6
- import { NavMenuSingleItem } from './NavMenuSingleItem.js';
6
+ import { NavMenuSingleItem, } from './NavMenuSingleItem.js';
7
7
  import { SvgWrapper } from './SvgWrapper.js';
8
8
  function ActiveGroupItem({ item }) {
9
9
  return (_jsxs("div", { className: "rounded-2xl my-1 flex", style: {
@@ -16,7 +16,7 @@ function NormalGroupItem({ item }) {
16
16
  }, children: _jsxs("div", { className: "flex", children: [item.tag && _jsx(Tag, { tag: item.tag }), _jsx("span", { children: item.text })] }) }) }) }, item.link));
17
17
  }
18
18
  export function NavMenuGroup(item) {
19
- const { activeValue, items: groupItems, base = '', link = '', pathname = '', } = item;
19
+ const { activeValue, items: groupItems, base = '', pathname = '' } = item;
20
20
  const [isOpen, setIsOpen] = useState(false);
21
21
  const renderLinkItem = (item) => {
22
22
  const isLinkActive = new RegExp(item.activeMatch || item.link).test(withoutBase(pathname, base));
@@ -32,9 +32,7 @@ export function NavMenuGroup(item) {
32
32
  setIsOpen(false);
33
33
  }, children: [_jsx("button", { onMouseEnter: () => {
34
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: link ? (
36
- // @ts-expect-error item.text may be ReactElement
37
- _jsx(NavMenuSingleItem, { ...item, rightIcon: _jsx(SvgWrapper, { icon: SvgDown }) })) : (_jsxs(_Fragment, { children: [_jsxs("span", { className: "text-sm font-medium flex", style: {
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: {
38
36
  marginRight: '2px',
39
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: {
40
38
  opacity: isOpen ? 1 : 0,
@@ -1,10 +1,11 @@
1
- import { type NavItemWithLink, type NavItemWithLinkAndChildren } from '@rspress/shared';
2
- interface Props {
3
- pathname: string;
4
- langs?: string[];
5
- base: string;
6
- rightIcon?: React.ReactNode;
1
+ import { type NavItemWithLink } from '@rspress/shared';
2
+ import { type ReactNode } from 'react';
3
+ export interface NavMenuSingleItemProps extends Omit<NavItemWithLink, 'text'> {
4
+ base?: string;
7
5
  compact?: boolean;
6
+ download?: string | boolean;
7
+ pathname?: string;
8
+ rightIcon?: ReactNode;
9
+ text?: ReactNode;
8
10
  }
9
- export declare function NavMenuSingleItem(item: (NavItemWithLink | NavItemWithLinkAndChildren) & Props): import("react/jsx-runtime").JSX.Element;
10
- export {};
11
+ export declare function NavMenuSingleItem({ activeMatch, base, compact, download, link, pathname, rightIcon, text, tag, }: NavMenuSingleItemProps): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Tag } from '@rspress/core/theme';
3
- import { withoutBase, } from '@rspress/shared';
3
+ import { withoutBase } from '@rspress/shared';
4
+ import { useMemo } from 'react';
4
5
  import styles from '../../../styles/versions-nav.module.scss';
5
- export function NavMenuSingleItem(item) {
6
- const { pathname, base } = item;
7
- const isActive = new RegExp(item.activeMatch || item.link).test(withoutBase(pathname, base));
8
- return (_jsx("a", { href: item.link, children: _jsxs("div", { className: `rspress-nav-menu-item ${styles.singleItem} ${isActive ? styles.activeItem : ''} text-sm font-medium ${item.compact ? 'mx-0.5' : 'mx-1.5'} px-3 py-2 flex items-center`, children: [_jsx(Tag, { tag: item.tag }), item.text, item.rightIcon] }, item.text) }));
6
+ export function NavMenuSingleItem({ activeMatch, base, compact, download, link, pathname, rightIcon, text, tag, }) {
7
+ const isActive = useMemo(() => !!base &&
8
+ !!pathname &&
9
+ new RegExp(activeMatch || link).test(withoutBase(pathname, base)), [activeMatch, base, link, pathname]);
10
+ return (_jsx("a", { href: link, download: download, children: _jsxs("div", { className: `rspress-nav-menu-item ${styles.singleItem} ${isActive ? styles.activeItem : ''} text-sm font-medium ${compact ? 'mx-0.5' : 'mx-1.5'} px-3 py-2 flex items-center`, children: [_jsx(Tag, { tag: tag }), text, rightIcon] }) }));
9
11
  }
@@ -1,3 +1,2 @@
1
- import { type FC } from 'react';
2
- export declare const VersionsNav: FC;
1
+ export declare const VersionsNav: () => import("react").ReactPortal | null;
3
2
  export default VersionsNav;
@@ -1,10 +1,13 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { isProduction, removeTrailingSlash, usePageData, } from '@rspress/core/runtime';
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useTranslation } from '@alauda/doom/runtime';
3
+ import { isProduction, removeTrailingSlash, useLang, usePageData, } from '@rspress/core/runtime';
3
4
  import { noop } from 'es-toolkit';
4
5
  import { useEffect, useMemo, useState } from 'react';
5
6
  import { createPortal } from 'react-dom';
6
7
  import { parse } from 'yaml';
8
+ import { getPdfName } from '../../shared/index.js';
7
9
  import { NavMenuGroup } from './NavMenuGroup.js';
10
+ import { NavMenuSingleItem } from './NavMenuSingleItem.js';
8
11
  import virtual from 'doom-@global-virtual';
9
12
  const getNavMenu = () => {
10
13
  if (typeof document === 'undefined') {
@@ -14,6 +17,14 @@ const getNavMenu = () => {
14
17
  };
15
18
  export const VersionsNav = () => {
16
19
  const { siteData } = usePageData();
20
+ const lang = useLang();
21
+ const t = useTranslation();
22
+ const downloadLink = useMemo(() => {
23
+ if (!virtual.download) {
24
+ return;
25
+ }
26
+ return siteData.base + getPdfName(lang, virtual.userBase, siteData.title);
27
+ }, [lang, siteData.base, siteData.title]);
17
28
  const [versionsBase, version] = useMemo(() => {
18
29
  if (!virtual.version) {
19
30
  return [];
@@ -56,13 +67,14 @@ export const VersionsNav = () => {
56
67
  observer.disconnect();
57
68
  };
58
69
  }, [navMenu]);
59
- if (!versions?.length) {
70
+ const versionItems = useMemo(() => versions?.map((v) => ({
71
+ text: v,
72
+ link: `${versionsBase}/${v}/`,
73
+ activeMatch: v,
74
+ })), [versionsBase, versions]);
75
+ if (!versions?.length && !virtual.download) {
60
76
  return null;
61
77
  }
62
- return createPortal(_jsx(NavMenuGroup, { text: version, base: versionsBase, items: versions.map((v) => ({
63
- text: v,
64
- link: `${versionsBase}/${v}/`,
65
- activeMatch: v,
66
- })), pathname: siteData.base }), getNavMenu());
78
+ return createPortal(_jsxs(_Fragment, { children: [downloadLink && (_jsx(NavMenuSingleItem, { text: t('download'), link: downloadLink, download: true })), !versionItems?.length || (_jsx(NavMenuGroup, { text: version, base: versionsBase, items: versionItems, pathname: siteData.base }))] }), getNavMenu());
67
79
  };
68
80
  export default VersionsNav;
@@ -1,3 +1,4 @@
1
1
  import type { RspressPlugin } from '@rspress/core';
2
2
  import type { ApiPluginOptions } from './types.js';
3
- export declare const apiPlugin: ({ localBasePath, crds, openapis, references, pathPrefix, }: ApiPluginOptions) => RspressPlugin;
3
+ export type * from './types.js';
4
+ export declare const apiPlugin: ({ localBasePath, }: ApiPluginOptions) => RspressPlugin;
@@ -1,14 +1,14 @@
1
1
  import { openapiSchemaToJsonSchema } from '@openapi-contrib/openapi-schema-to-json-schema';
2
2
  import { convertObj } from 'swagger2openapi';
3
3
  import { generateRuntimeModule } from '../../utils/index.js';
4
- export const apiPlugin = ({ localBasePath, crds = [], openapis = [], references, pathPrefix, }) => {
4
+ export const apiPlugin = ({ localBasePath, }) => {
5
5
  return {
6
6
  name: 'doom-api',
7
7
  async addRuntimeModules(config, isProd) {
8
8
  return {
9
- 'doom-@api-virtual': `export default ${JSON.stringify({ references, pathPrefix }, null, isProd ? 0 : 2)}`,
10
- ...(await generateRuntimeModule(crds, 'api-crds', config.root, localBasePath, isProd)),
11
- ...(await generateRuntimeModule(openapis, 'api-openapis', config.root, localBasePath, isProd, async (doc) => {
9
+ 'doom-@api-virtual': `export default ${JSON.stringify({ references: config.api?.references, pathPrefix: config.api?.pathPrefix }, null, isProd ? 0 : 2)}`,
10
+ ...(await generateRuntimeModule(config.api?.crds, 'api-crds', config.root, localBasePath, isProd)),
11
+ ...(await generateRuntimeModule(config.api?.openapis, 'api-openapis', config.root, localBasePath, isProd, async (doc) => {
12
12
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
13
13
  doc.info ??= { title: 'Unknown', version: '0.0.0' };
14
14
  if ('swagger' in doc && doc.swagger === '2.0') {
@@ -1,7 +1,9 @@
1
1
  import { type RspressPlugin, type UserConfig } from '@rspress/core';
2
+ export type * from './walk.js';
3
+ export type * from './type.js';
2
4
  export interface AutoSidebarPluginOptions {
3
5
  excludeRoutes?: string[];
4
6
  collapsed?: boolean;
5
7
  }
6
- export declare const autoSidebar: (config: UserConfig, { excludeRoutes, collapsed }: AutoSidebarPluginOptions) => Promise<UserConfig<import("@rspress/shared").DefaultThemeConfig>>;
8
+ export declare const autoSidebar: (config: UserConfig, { excludeRoutes }: AutoSidebarPluginOptions) => Promise<UserConfig<import("@rspress/shared").DefaultThemeConfig>>;
7
9
  export declare const autoSidebarPlugin: (options?: AutoSidebarPluginOptions) => RspressPlugin;
@@ -154,7 +154,7 @@ function processLocales(langs, versions, root, defaultLang, defaultVersion, exte
154
154
  }));
155
155
  }
156
156
  const defaultExtensions = ['.mdx', '.md', '.tsx', '.jsx', '.ts', '.js'];
157
- export const autoSidebar = async (config, { excludeRoutes, collapsed }) => {
157
+ export const autoSidebar = async (config, { excludeRoutes }) => {
158
158
  config.themeConfig = config.themeConfig || {};
159
159
  config.themeConfig.locales =
160
160
  config.themeConfig.locales || config.locales || [];
@@ -165,6 +165,7 @@ export const autoSidebar = async (config, { excludeRoutes, collapsed }) => {
165
165
  const defaultLang = config.lang || '';
166
166
  const { default: defaultVersion = '' } = config.multiVersion || {};
167
167
  const { extensions = defaultExtensions } = config.route || {};
168
+ const collapsed = config.sidebar?.collapsed;
168
169
  if (hasLocales) {
169
170
  const metaInfo = await processLocales(langs, versions, root, defaultLang, defaultVersion, extensions, excludeRoutes, collapsed);
170
171
  config.themeConfig.locales = config.themeConfig.locales.map((item, index) => ({
@@ -1,5 +1,3 @@
1
- import type { Nav } from '@rspress/shared';
2
- export type NavMeta = Nav;
3
1
  export type SideMetaItem = string | {
4
2
  type: 'file' | 'dir' | 'divider' | 'custom-link' | 'section-header';
5
3
  name: string;
@@ -1,4 +1,4 @@
1
- import { type SidebarDivider, type SidebarGroup, type SidebarItem, type SidebarSectionHeader } from '@rspress/shared';
1
+ import { type NavItem, type SidebarDivider, type SidebarGroup, type SidebarItem, type SidebarSectionHeader } from '@rspress/shared';
2
2
  export interface DoomSidebarItem extends SidebarItem {
3
3
  weight?: number;
4
4
  }
@@ -12,7 +12,7 @@ export declare function scanSideMeta(workDir: string, rootDir: string, docsDir:
12
12
  others: DoomSidebar[];
13
13
  }>;
14
14
  export declare function walk(workDir: string, routePrefix: string | undefined, docsDir: string, extensions: string[], excludeRoutes?: string[], collapsed?: boolean): Promise<{
15
- nav: never[];
15
+ nav: NavItem[];
16
16
  sidebar: {
17
17
  [routePrefix]: DoomSidebar[];
18
18
  };
@@ -212,8 +212,9 @@ export async function walk(workDir, routePrefix = '/', docsDir, extensions, excl
212
212
  if (simpleRoutePrefix) {
213
213
  sidebarConfig[simpleRoutePrefix] = sidebars;
214
214
  }
215
+ const nav = [];
215
216
  return {
216
- nav: [],
217
+ nav,
217
218
  sidebar: sidebarConfig,
218
219
  };
219
220
  }
@@ -1,7 +1,11 @@
1
1
  import { type RspressPlugin } from '@rspress/core';
2
- import type { DoomSite } from '../../shared/types.js';
2
+ import { type DoomSite } from '../../shared/index.js';
3
3
  export interface GlobalPluginOptions {
4
- sites?: DoomSite[];
5
4
  version?: string;
5
+ download?: boolean;
6
+ }
7
+ export interface GlobalVirtual extends GlobalPluginOptions {
8
+ userBase?: string;
9
+ sites?: DoomSite[];
6
10
  }
7
- export declare const globalPlugin: ({ sites, version, }?: GlobalPluginOptions) => RspressPlugin;
11
+ export declare const globalPlugin: ({ version, download, }: GlobalPluginOptions) => RspressPlugin;
@@ -2,10 +2,10 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { addTrailingSlash } from '@rspress/core';
4
4
  import { baseResolve, pkgResolve } from '../../utils/index.js';
5
- import { normalizeVersion } from '../../shared/helpers.js';
5
+ import { normalizeVersion } from '../../shared/index.js';
6
6
  const globalComponentsDir = baseResolve('global');
7
7
  const componentsDir = baseResolve('runtime/components');
8
- export const globalPlugin = ({ sites, version, } = {}) => {
8
+ export const globalPlugin = ({ version, download, }) => {
9
9
  return {
10
10
  name: 'doom-global',
11
11
  globalStyles: pkgResolve('styles/global.scss'),
@@ -23,15 +23,17 @@ export const globalPlugin = ({ sites, version, } = {}) => {
23
23
  })
24
24
  .map((file) => path.resolve(componentsDir, file)),
25
25
  },
26
- addRuntimeModules(_, isProd) {
26
+ addRuntimeModules(config, isProd) {
27
27
  return {
28
28
  'doom-@global-virtual': `export default ${JSON.stringify({
29
- sites: sites?.map((site) => ({
29
+ userBase: config.userBase,
30
+ version: version === 'unversioned' ? undefined : version,
31
+ download,
32
+ sites: config.sites?.map((site) => ({
30
33
  ...site,
31
34
  base: addTrailingSlash(site.base || (site.name === 'acp' ? '/container-platform' : '')),
32
35
  version: normalizeVersion(site.version),
33
36
  })),
34
- version: version === 'unversioned' ? undefined : version,
35
37
  }, null, isProd ? 0 : 2)}`,
36
38
  };
37
39
  },
@@ -1,3 +1,4 @@
1
1
  import type { RspressPlugin } from '@rspress/core';
2
2
  import type { PermissionPluginOptions } from './types.js';
3
- export declare const permissionPlugin: ({ localBasePath, functionresources, roletemplates, }: PermissionPluginOptions) => RspressPlugin;
3
+ export type * from './types.js';
4
+ export declare const permissionPlugin: ({ localBasePath, }: PermissionPluginOptions) => RspressPlugin;
@@ -1,11 +1,11 @@
1
1
  import { generateRuntimeModule } from '../../utils/index.js';
2
- export const permissionPlugin = ({ localBasePath, functionresources = [], roletemplates = [], }) => {
2
+ export const permissionPlugin = ({ localBasePath, }) => {
3
3
  return {
4
4
  name: 'doom-permission',
5
5
  async addRuntimeModules(config, isProd) {
6
6
  return {
7
- ...(await generateRuntimeModule(functionresources, 'permission-functionResources', config.root, localBasePath, isProd, ({ items }) => items)),
8
- ...(await generateRuntimeModule(roletemplates, 'permission-roleTemplates', config.root, localBasePath, isProd, ({ items }) => items)),
7
+ ...(await generateRuntimeModule(config.permission?.functionresources, 'permission-functionResources', config.root, localBasePath, isProd, ({ items }) => items)),
8
+ ...(await generateRuntimeModule(config.permission?.roletemplates, 'permission-roleTemplates', config.root, localBasePath, isProd, ({ items }) => items)),
9
9
  };
10
10
  },
11
11
  };
@@ -1,10 +1,9 @@
1
1
  import type { RspressPlugin } from '@rspress/core';
2
- import type { ReferenceItem, ReleaseNotesOptions } from './types.js';
3
- export declare const replacePlugin: ({ root, lang, localBasePath, items, force, releaseNotes, }: {
4
- root: string;
2
+ export * from './normalize-img-src.js';
3
+ export type * from './types.js';
4
+ export * from './utils.js';
5
+ export declare const replacePlugin: ({ lang, localBasePath, force, }: {
5
6
  lang: string | null;
6
7
  localBasePath: string;
7
- items?: ReferenceItem[];
8
8
  force?: boolean;
9
- releaseNotes?: ReleaseNotesOptions;
10
9
  }) => RspressPlugin;