@alauda/doom 1.19.0 → 1.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.
package/lib/cli/export.js CHANGED
@@ -33,7 +33,7 @@ const collectPages = (sidebarItems, base) => {
33
33
  export const exportCommand = new Command('export')
34
34
  .description('Export the documentation as PDF, `apis/**` and `*/apis/**` routes will be ignored automatically')
35
35
  .argument('[root]', 'Root directory of the documentation')
36
- .option('-H, --host [host]', 'Serve host name')
36
+ .option('-H, --host [host]', 'Serve host name', 'localhost')
37
37
  .option('-P, --port [port]', 'Serve port number', '4173')
38
38
  .action(async function (root) {
39
39
  setNodeEnv('production');
@@ -60,7 +60,7 @@ export const exportCommand = new Command('export')
60
60
  const commonOptions = {
61
61
  tempDir,
62
62
  port: port,
63
- host: host || 'localhost',
63
+ host: host,
64
64
  outDir,
65
65
  pdfOptions: {
66
66
  margin: {
@@ -98,6 +98,40 @@ export const exportCommand = new Command('export')
98
98
  pages,
99
99
  outFile: getPdfName(lang, config.userBase, config.title),
100
100
  cleanupTempDir: false,
101
+ customOutlines: options?.overrideOutlines
102
+ ? (pages) => {
103
+ const pageMap = new Map();
104
+ let pageIndex = 0;
105
+ for (const page of pages) {
106
+ pageMap.set(page.url.split('?')[0], {
107
+ title: page.title,
108
+ pageIndex,
109
+ });
110
+ pageIndex += page.count;
111
+ }
112
+ const generateOutlinesFromSidebar = (sidebarItems) => {
113
+ const result = [];
114
+ for (const item of sidebarItems) {
115
+ let children;
116
+ if ('items' in item) {
117
+ children = generateOutlinesFromSidebar(item.items);
118
+ }
119
+ if ('link' in item && item.link) {
120
+ const page = pageMap.get(`${item.link}.html`);
121
+ if (page != null) {
122
+ result.push({
123
+ title: page.title || item.text,
124
+ to: page.pageIndex,
125
+ children,
126
+ });
127
+ }
128
+ }
129
+ }
130
+ return result;
131
+ };
132
+ return generateOutlinesFromSidebar(sidebarItems);
133
+ }
134
+ : undefined,
101
135
  ...commonOptions,
102
136
  ...options,
103
137
  };
@@ -140,13 +174,17 @@ export const exportCommand = new Command('export')
140
174
  if (themeConfig.locales?.length) {
141
175
  for (const { lang, sidebar } of themeConfig.locales) {
142
176
  const sidebarItems = sidebar[config.lang === lang ? '/' : `/${lang}`];
143
- const { allOutlines } = await exportPdf(sidebarItems, lang);
177
+ const { allOutlines } = await exportPdf(sidebarItems, lang, {
178
+ overrideOutlines: true,
179
+ });
144
180
  await exportEntries(sidebarItems, allOutlines, lang);
145
181
  }
146
182
  }
147
183
  else {
148
184
  const sidebarItems = themeConfig.sidebar['/'];
149
- const { allOutlines } = await exportPdf(sidebarItems);
185
+ const { allOutlines } = await exportPdf(sidebarItems, undefined, {
186
+ overrideOutlines: true,
187
+ });
150
188
  await exportEntries(sidebarItems, allOutlines);
151
189
  }
152
190
  await fs.rm(tempDir, { force: true, recursive: true });
@@ -160,6 +160,7 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
160
160
  themeConfig: {
161
161
  enableScrollToTop: true,
162
162
  localeRedirect: redirect,
163
+ llmsUI: false,
163
164
  ...(editRepoEnabled &&
164
165
  editRepoBaseUrl && {
165
166
  editLink: { docRepoBaseUrl: editRepoBaseUrl },
package/lib/cli/new.js CHANGED
@@ -3,7 +3,7 @@ import path from 'node:path';
3
3
  import * as prompts from '@inquirer/prompts';
4
4
  import { logger } from '@rsbuild/core';
5
5
  import { Command } from 'commander';
6
- import { render } from 'ejs';
6
+ import ejs from 'ejs';
7
7
  import { glob } from 'tinyglobby';
8
8
  import { cyan, magenta } from 'yoctocolors';
9
9
  import { JS_STR_FALSY_VALUES } from '../shared/index.js';
@@ -52,7 +52,7 @@ const handleTemplateFile = async ({ source, target, processors, parameters, writ
52
52
  switch (processor.type) {
53
53
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
54
54
  case 'ejsTemplate': {
55
- content = render(content, { data: processor.data, parameters });
55
+ content = ejs.render(content, { data: processor.data, parameters });
56
56
  break;
57
57
  }
58
58
  default: {
@@ -104,9 +104,9 @@ export const newCommand = new Command('new')
104
104
  }
105
105
  logger.start('Generating scaffolding...');
106
106
  for (const layout of scaffolding.layout || []) {
107
- const source = path.resolve(base, render(layout.source, { parameters }));
108
- const target = path.resolve(render(layout.target, { parameters }));
109
- const when = layout.when && render(layout.when, { parameters });
107
+ const source = path.resolve(base, ejs.render(layout.source, { parameters }));
108
+ const target = path.resolve(ejs.render(layout.target, { parameters }));
109
+ const when = layout.when && ejs.render(layout.when, { parameters });
110
110
  if (when != null && JS_STR_FALSY_VALUES.has(when)) {
111
111
  continue;
112
112
  }
@@ -130,7 +130,7 @@ export const newCommand = new Command('new')
130
130
  .filter((d) => d.isFile())
131
131
  .map((d) => path.relative(source, path.resolve(d.parentPath, d.name))));
132
132
  for (const matcher of layout.matchers || []) {
133
- const matched = await glob(matcher.match.map((m) => render(m, { parameters })), { cwd: source });
133
+ const matched = await glob(matcher.match.map((m) => ejs.render(m, { parameters })), { cwd: source });
134
134
  for (const file of matched) {
135
135
  files.delete(file);
136
136
  await handleTemplateFile({
@@ -6,7 +6,7 @@ import { isDeepStrictEqual } from 'node:util';
6
6
  import { logger } from '@rspress/core';
7
7
  import { removeLeadingSlash } from '@rspress/shared';
8
8
  import { Command } from 'commander';
9
- import { render } from 'ejs';
9
+ import ejs from 'ejs';
10
10
  import matter from 'gray-matter';
11
11
  import { AzureOpenAI, RateLimitError } from 'openai';
12
12
  import { pRateLimit } from 'p-ratelimit';
@@ -224,7 +224,7 @@ export const translate = async ({ source, sourceContent, target, systemPrompt, u
224
224
  }
225
225
  }
226
226
  const { content: contentWithPlaceholders, anchors } = replaceAnchorsWithPlaceholders(sourceContent);
227
- const finalSystemPrompt = await render(systemPrompt?.trim() || DEFAULT_SYSTEM_PROMPT, {
227
+ const finalSystemPrompt = await ejs.render(systemPrompt?.trim() || DEFAULT_SYSTEM_PROMPT, {
228
228
  sourceLang,
229
229
  targetLang,
230
230
  userPrompt,
@@ -21,7 +21,7 @@ const AuthCheck = () => {
21
21
  }
22
22
  void navigate(`${lang === site.lang ? '' : `/${lang}`}/login.html?from=${encodeURIComponent(`${pathname}${search}${hash}`)}`);
23
23
  });
24
- const abortController = useRef(null);
24
+ const abortControllerRef = useRef(null);
25
25
  const authCheck = useMemoizedFn(async () => {
26
26
  if (!siteData.base.startsWith('/russian/')) {
27
27
  return;
@@ -30,9 +30,9 @@ const AuthCheck = () => {
30
30
  login();
31
31
  return;
32
32
  }
33
- abortController.current?.abort();
34
- abortController.current = new AbortController();
35
- const signal = abortController.current.signal;
33
+ abortControllerRef.current?.abort();
34
+ abortControllerRef.current = new AbortController();
35
+ const signal = abortControllerRef.current.signal;
36
36
  try {
37
37
  await xfetch('https://cloud.alauda.io/api/v1/tenant/info', {
38
38
  headers: {
@@ -1,4 +1,4 @@
1
- import { usePageData } from '@rspress/core/runtime';
1
+ import { usePage, useSite } from '@rspress/core/runtime';
2
2
  import { useEffect } from 'react';
3
3
  import { useSiteOverrides } from '@alauda/doom/runtime';
4
4
  const setNavBarSpans = (logoText) => {
@@ -24,7 +24,8 @@ const concatTitle = (title, suffix) => {
24
24
  return `${title} ${suffix}`;
25
25
  };
26
26
  export const SiteOverrides = () => {
27
- const { siteData, page } = usePageData();
27
+ const { page } = usePage();
28
+ const { site } = useSite();
28
29
  const { pageType,
29
30
  // Inject by remark-plugin-toc
30
31
  title: articleTitle,
@@ -35,8 +36,8 @@ export const SiteOverrides = () => {
35
36
  if (!title) {
36
37
  return;
37
38
  }
38
- siteData.originalTitle ??= siteData.title;
39
- siteData.title = title;
39
+ site.originalTitle ??= site.title;
40
+ site.title = title;
40
41
  let newTitle = frontmatter.title || articleTitle;
41
42
  if (newTitle && pageType === 'doc') {
42
43
  // append main title as a suffix
@@ -62,7 +63,7 @@ export const SiteOverrides = () => {
62
63
  frontmatter.title,
63
64
  frontmatter.titleSuffix,
64
65
  pageType,
65
- siteData,
66
+ site,
66
67
  title,
67
68
  ]);
68
69
  useEffect(() => {
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useRef, useState, } from 'react';
2
+ import { useMemo, useRef, useState, } from 'react';
3
3
  import { ApiMethod, ResponseError, xfetch } from 'x-fetch';
4
4
  import { ApiErrorAlert } from "../ApiErrorAlert/index.js";
5
5
  import { Button } from "../Button/index.js";
@@ -19,13 +19,13 @@ export const LoginForm = ({ onSubmit, onLoggedIn, ...props }) => {
19
19
  const { setAuthBasic } = useCloudAuth();
20
20
  const captchaId = error?.data?.extra?.captchaId;
21
21
  const [timestamp, setTimestamp] = useState();
22
+ const origin = useMemo(getCloudOrigin, []);
22
23
  const handleSubmit = useMemoizedFn(async (ev) => {
23
24
  ev.preventDefault();
24
25
  ev.stopPropagation();
25
26
  onSubmit?.(ev);
26
27
  const formData = new FormData(ev.currentTarget);
27
28
  setLoading(true);
28
- const origin = getCloudOrigin();
29
29
  if (pwdPubkeyRef.current == null) {
30
30
  try {
31
31
  pwdPubkeyRef.current = await xfetch(`${origin}/api/v1/pubkey`);
@@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { logger } from '@rspress/core';
4
4
  import { isProduction } from '@rspress/shared';
5
- import { render } from 'ejs';
5
+ import ejs from 'ejs';
6
6
  import { red } from 'yoctocolors';
7
7
  import { resolveRepo } from "../../utils/index.js";
8
8
  import { parseToc } from "./parse-toc.js";
@@ -46,7 +46,7 @@ const resolveReference_ = async (localBasePath, localPublicBase, items, refName,
46
46
  switch (processor.type) {
47
47
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
48
48
  case 'ejsTemplate': {
49
- content = await render(content, { data: processor.data }, { async: true });
49
+ content = await ejs.render(content, { data: processor.data }, { async: true });
50
50
  break;
51
51
  }
52
52
  }
@@ -1,6 +1,6 @@
1
1
  import { logger } from '@rspress/core';
2
2
  import { isProduction } from '@rspress/shared';
3
- import { render } from 'ejs';
3
+ import ejs from 'ejs';
4
4
  import { ResponseError, xfetch } from 'x-fetch';
5
5
  import { cyan, red } from 'yoctocolors';
6
6
  const releaseCache = new Map();
@@ -82,7 +82,7 @@ const resolveRelease_ = async (releaseTemplates, releaseQuery, isMdx) => {
82
82
  }
83
83
  data[key] = value;
84
84
  }
85
- const jql = await render(template, data, { async: true });
85
+ const jql = await ejs.render(template, data, { async: true });
86
86
  logger.info(`Fetching release notes for query \`${cyan(releaseQuery)}\`, JQL: \`${cyan(jql)}\``);
87
87
  let issues;
88
88
  try {
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { isEqualPath, usePageData, useSidebar } from '@rspress/core/runtime';
2
+ import { isEqualPath, usePage, usePages, useSidebar, } from '@rspress/core/runtime';
3
3
  import { FallbackHeading, Link, renderInlineMarkdown, } from '@rspress/core/theme-original';
4
4
  import { Fragment, useCallback, useMemo } from 'react';
5
5
  import classes from '../../../styles/overview.module.scss';
@@ -22,11 +22,11 @@ const masonryOptions = {
22
22
  // In overpage page, we select all the related sidebar groups and show the groups in the page.
23
23
  // In the meantime, some sidebar items also should be shown in the page, we collect them in the group named 'Others' and show them in the page.
24
24
  export function Overview(props) {
25
- const { siteData, page: { routePath, frontmatter, title }, } = usePageData();
25
+ const { pages } = usePages();
26
+ const { page: { routePath, frontmatter, title }, } = usePage();
26
27
  const { content, groups: customGroups, defaultGroupTitle = 'Others' } = props;
27
28
  const subFilter = useCallback((link) => link.startsWith(routePath.replace(/overview$/, '')) &&
28
29
  !isEqualPath(link, routePath), [routePath]);
29
- const { pages } = siteData;
30
30
  const overviewModules = useMemo(() => pages.filter((page) => subFilter(page.routePath)), [pages, subFilter]);
31
31
  let overviewSidebarGroups = useSidebar();
32
32
  if (overviewSidebarGroups[0] &&
@@ -1,7 +1,8 @@
1
- import { useI18n, usePageData } from '@rspress/core/runtime';
1
+ import { useI18n, usePage, useSite } from '@rspress/core/runtime';
2
2
  export function useEditLink() {
3
- const { siteData, page } = usePageData();
4
- const editLink = siteData.themeConfig.editLink;
3
+ const { site } = useSite();
4
+ const { page } = usePage();
5
+ const editLink = site.themeConfig.editLink;
5
6
  const t = useI18n();
6
7
  const text = t('editLinkText');
7
8
  if (!editLink?.docRepoBaseUrl || !text) {
@@ -12,7 +13,7 @@ export function useEditLink() {
12
13
  docRepoBaseUrl += '/';
13
14
  }
14
15
  const lastSegment = docRepoBaseUrl.split('/').at(-2);
15
- const fixedLang = siteData.themeConfig.locales.some(({ lang }) => lang === lastSegment);
16
+ const fixedLang = site.themeConfig.locales.some(({ lang }) => lang === lastSegment);
16
17
  const relativePagePath = page._relativePath.replace(/\\/g, '/');
17
18
  const link = `${docRepoBaseUrl}${fixedLang ? relativePagePath.split('/').slice(1).join('/') : relativePagePath}`;
18
19
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "1.19.0",
3
+ "version": "1.20.0",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": {
@@ -40,31 +40,31 @@
40
40
  "rspress-plugins"
41
41
  ],
42
42
  "dependencies": {
43
- "@alauda/doom-export": "^0.3.1",
44
- "@cspell/eslint-plugin": "^9.4.0",
45
- "@eslint-react/eslint-plugin": "^2.5.5",
43
+ "@alauda/doom-export": "^0.4.0",
44
+ "@cspell/eslint-plugin": "^9.6.3",
45
+ "@eslint-react/eslint-plugin": "^2.9.4",
46
46
  "@inquirer/prompts": "^8.2.0",
47
47
  "@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
48
- "@rsbuild/plugin-react": "^1.4.2",
49
- "@rsbuild/plugin-sass": "^1.4.0",
50
- "@rsbuild/plugin-svgr": "^1.2.3",
51
- "@rsbuild/plugin-yaml": "^1.0.3",
52
- "@rspress/core": "2.0.0-rc.5",
53
- "@rspress/plugin-algolia": "2.0.0-rc.5",
54
- "@rspress/plugin-sitemap": "2.0.0-rc.5",
55
- "@rspress/shared": "2.0.0-rc.5",
56
- "@shikijs/transformers": "^3.21.0",
48
+ "@rsbuild/plugin-react": "^1.4.5",
49
+ "@rsbuild/plugin-sass": "^1.5.0",
50
+ "@rsbuild/plugin-svgr": "^1.3.0",
51
+ "@rsbuild/plugin-yaml": "^1.0.4",
52
+ "@rspress/core": "2.0.2",
53
+ "@rspress/plugin-algolia": "2.0.2",
54
+ "@rspress/plugin-sitemap": "2.0.2",
55
+ "@rspress/shared": "2.0.2",
56
+ "@shikijs/transformers": "^3.22.0",
57
57
  "@total-typescript/ts-reset": "^0.6.1",
58
- "@types/react": "^19.2.8",
58
+ "@types/react": "^19.2.10",
59
59
  "ab64": "^0.1.6",
60
60
  "chokidar": "^5.0.0",
61
61
  "clsx": "^2.1.1",
62
- "commander": "^14.0.2",
63
- "ejs": "^3.1.10",
64
- "es-toolkit": "^1.43.0",
62
+ "commander": "^14.0.3",
63
+ "ejs": "^4.0.1",
64
+ "es-toolkit": "^1.44.0",
65
65
  "eslint": "^9.39.2",
66
66
  "eslint-plugin-mdx": "^3.6.2",
67
- "globals": "^17.0.0",
67
+ "globals": "^17.3.0",
68
68
  "html-tag-names": "^2.1.0",
69
69
  "jsencrypt": "^3.5.4",
70
70
  "masonry-layout": "^4.2.2",
@@ -74,7 +74,7 @@
74
74
  "mdast-util-to-markdown": "^2.1.2",
75
75
  "mdast-util-to-string": "^4.0.0",
76
76
  "mermaid": "^11.12.2",
77
- "openai": "^6.16.0",
77
+ "openai": "^6.17.0",
78
78
  "openapi-types": "^12.1.3",
79
79
  "p-ratelimit": "^1.0.1",
80
80
  "picomatch": "^4.0.3",
@@ -95,14 +95,14 @@
95
95
  "remark-mdx": "^3.1.1",
96
96
  "remark-message-control": "^8.0.0",
97
97
  "remark-stringify": "^11.0.0",
98
- "shiki": "^3.21.0",
98
+ "shiki": "^3.22.0",
99
99
  "simple-git": "^3.30.0",
100
- "string-width": "^8.1.0",
100
+ "string-width": "^8.1.1",
101
101
  "swagger2openapi": "^7.0.8",
102
102
  "tinyglobby": "^0.2.15",
103
- "type-fest": "^5.3.1",
103
+ "type-fest": "^5.4.3",
104
104
  "typescript": "^5.9.3",
105
- "typescript-eslint": "^8.52.0",
105
+ "typescript-eslint": "^8.54.0",
106
106
  "unified": "^11.0.5",
107
107
  "unified-lint-rule": "^3.0.1",
108
108
  "unist-util-position": "^5.0.0",