@alauda/doom 2.3.0 → 2.4.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/translate.js +1 -1
- package/lib/global/Intelligence/AIAssistant/index.js +44 -14
- package/lib/global/Intelligence/AIAssistant/utils.d.ts +12 -1
- package/lib/global/Intelligence/AIAssistant/utils.js +113 -11
- package/lib/plugins/global/index.js +20 -5
- package/lib/products/index.d.ts +15 -0
- package/lib/products/index.js +25 -0
- package/lib/runtime/components/ExternalSiteLink.js +3 -2
- package/lib/runtime/hooks/useSiteOverrides.js +2 -5
- package/lib/runtime/hooks/useTranslation.d.ts +1 -1
- package/lib/runtime/translation.d.ts +12 -0
- package/lib/runtime/translation.js +9 -0
- package/lib/shared/context.d.ts +5 -0
- package/lib/shared/context.js +2 -0
- package/lib/theme/Breadcrumb/index.d.ts +6 -0
- package/lib/theme/Breadcrumb/index.js +85 -0
- package/lib/theme/Layout.js +6 -3
- package/lib/theme/_X.d.ts +23 -0
- package/lib/theme/_X.js +2 -0
- package/package.json +1 -1
- package/styles/_mixins.scss +19 -0
- package/styles/breadcrumb.scss +42 -0
- package/styles/global.scss +1 -0
- package/styles/login.module.scss +3 -12
- package/styles/products.module.scss +45 -0
package/lib/cli/translate.js
CHANGED
|
@@ -173,7 +173,7 @@ export const translate = async ({ source, sourceContent, target, systemPrompt, u
|
|
|
173
173
|
sourceLang,
|
|
174
174
|
targetLang,
|
|
175
175
|
userPrompt,
|
|
176
|
-
additionalPrompts
|
|
176
|
+
additionalPrompts,
|
|
177
177
|
terms,
|
|
178
178
|
titleTranslationPrompt,
|
|
179
179
|
}, { async: true });
|
|
@@ -9,13 +9,12 @@ import { Chat } from "./Chat/index.js";
|
|
|
9
9
|
import { Preamble } from "./Preamble/index.js";
|
|
10
10
|
import { ResizableUserInput } from "./ResizableUserInput/index.js";
|
|
11
11
|
import { Thinking } from "./Thinking.js";
|
|
12
|
-
import { parseStreamContent } from "./utils.js";
|
|
12
|
+
import { consumeSSEEvents, getAnswerDelta, parseStreamContent, } from "./utils.js";
|
|
13
13
|
import CloseIcon from '@alauda/doom/assets/close.svg?react';
|
|
14
14
|
import LogoutIcon from '@alauda/doom/assets/logout.svg?react';
|
|
15
15
|
import NewChatIcon from '@alauda/doom/assets/new-chat.svg?react';
|
|
16
16
|
import { useMemoizedFn, useTranslation } from '@alauda/doom/runtime';
|
|
17
17
|
import classes from '@alauda/doom/styles/ai-assistant.module.scss';
|
|
18
|
-
let textDecoder;
|
|
19
18
|
export const AIAssistant = ({ open, onOpenChange }) => {
|
|
20
19
|
const t = useTranslation();
|
|
21
20
|
const { authInfo, setAuthBasic } = useCloudAuth();
|
|
@@ -92,7 +91,7 @@ export const AIAssistant = ({ open, onOpenChange }) => {
|
|
|
92
91
|
sessionIdRef.current = session_id;
|
|
93
92
|
}
|
|
94
93
|
const sessionId = sessionIdRef.current;
|
|
95
|
-
const res = await xfetch('/smart/api/
|
|
94
|
+
const res = await xfetch('/smart/api/smart_answer_with_search', {
|
|
96
95
|
type: null,
|
|
97
96
|
method: ApiMethod.POST,
|
|
98
97
|
body: {
|
|
@@ -100,30 +99,61 @@ export const AIAssistant = ({ open, onOpenChange }) => {
|
|
|
100
99
|
session_id: sessionId,
|
|
101
100
|
},
|
|
102
101
|
});
|
|
103
|
-
textDecoder
|
|
102
|
+
const textDecoder = new TextDecoder();
|
|
104
103
|
let text = '';
|
|
104
|
+
let sseBuffer = '';
|
|
105
|
+
let sseEvent;
|
|
105
106
|
for await (const chunk_ of res.body) {
|
|
106
107
|
if (sessionId !== sessionIdRef.current) {
|
|
107
108
|
break;
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
!
|
|
118
|
-
|
|
110
|
+
sseBuffer += textDecoder.decode(chunk_, { stream: true });
|
|
111
|
+
const result = consumeSSEEvents(sseBuffer, sseEvent);
|
|
112
|
+
const { events, remainder } = result;
|
|
113
|
+
sseBuffer = remainder;
|
|
114
|
+
sseEvent = result.event;
|
|
115
|
+
let updated = false;
|
|
116
|
+
for (const event of events) {
|
|
117
|
+
const delta = getAnswerDelta(event);
|
|
118
|
+
if (!delta) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
text += delta;
|
|
122
|
+
updated = true;
|
|
123
|
+
}
|
|
124
|
+
if (!updated) {
|
|
119
125
|
continue;
|
|
120
126
|
}
|
|
127
|
+
const parsed = parseStreamContent(text);
|
|
121
128
|
flushMessages((messages) => [
|
|
122
129
|
...messages.slice(0, index),
|
|
123
130
|
{ ...messages[index], ...parsed },
|
|
124
131
|
...messages.slice(index + 1),
|
|
125
132
|
]);
|
|
126
133
|
}
|
|
134
|
+
if (sessionId !== sessionIdRef.current) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
sseBuffer += textDecoder.decode();
|
|
138
|
+
const { events } = consumeSSEEvents(`${sseBuffer}\n`, sseEvent);
|
|
139
|
+
let updated = false;
|
|
140
|
+
for (const event of events) {
|
|
141
|
+
const delta = getAnswerDelta(event);
|
|
142
|
+
if (!delta) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
text += delta;
|
|
146
|
+
updated = true;
|
|
147
|
+
}
|
|
148
|
+
if (!updated) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const parsed = parseStreamContent(text);
|
|
152
|
+
flushMessages((messages) => [
|
|
153
|
+
...messages.slice(0, index),
|
|
154
|
+
{ ...messages[index], ...parsed },
|
|
155
|
+
...messages.slice(index + 1),
|
|
156
|
+
]);
|
|
127
157
|
};
|
|
128
158
|
const [loading, setLoading] = useState(false);
|
|
129
159
|
const onSend = useMemoizedFn(async (content) => {
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { RefDoc } from './types.js';
|
|
2
|
+
export interface SSEEvent {
|
|
3
|
+
data: string;
|
|
4
|
+
event?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SSEConsumeResult {
|
|
7
|
+
event?: string;
|
|
8
|
+
events: SSEEvent[];
|
|
9
|
+
remainder: string;
|
|
10
|
+
}
|
|
2
11
|
export declare const unicodeToString: (unicodeStr: string) => string;
|
|
3
12
|
export declare const removePrefix: (prefix: string | null | undefined, text: string) => string;
|
|
13
|
+
export declare const consumeSSEEvents: (buffer: string, event?: string) => SSEConsumeResult;
|
|
14
|
+
export declare const getAnswerDelta: ({ event, data }: SSEEvent) => string;
|
|
4
15
|
export declare function parseStreamContent(text: string): {
|
|
5
16
|
refDocs: RefDoc[];
|
|
6
|
-
thinkingProcess: string |
|
|
17
|
+
thinkingProcess: string | undefined;
|
|
7
18
|
content: string;
|
|
8
19
|
};
|
|
@@ -1,11 +1,109 @@
|
|
|
1
1
|
// based on https://gitlab-ce.alauda.cn/aml/smart-doc/-/blob/master/frontend/src/app/utils/unicode.ts
|
|
2
2
|
import { isObject } from 'es-toolkit/compat';
|
|
3
|
+
const IGNORED_SSE_EVENT_TYPES = /(?:^|[._-])(?:metadata|trace|updates?)(?:$|[._-])/i;
|
|
4
|
+
const STREAM_TEXT_KEYS = ['delta', 'text', 'content', 'answer', 'message'];
|
|
3
5
|
export const unicodeToString = (unicodeStr) => unicodeStr.replace(/\\u([0-9a-fA-F]{4})/g, (_match, p1) => String.fromCharCode(Number.parseInt(p1, 16)));
|
|
6
|
+
const isRecord = (value) => isObject(value) && !Array.isArray(value);
|
|
4
7
|
export const removePrefix = (prefix, text) => (prefix && text.startsWith(prefix) ? text.slice(prefix.length) : text);
|
|
8
|
+
const parseSSEFieldValue = (line, field) => {
|
|
9
|
+
const value = line.slice(field.length + 1);
|
|
10
|
+
return value.startsWith(' ') ? value.slice(1) : value;
|
|
11
|
+
};
|
|
12
|
+
const getStringValue = (value) => {
|
|
13
|
+
if (typeof value === 'string') {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(value)) {
|
|
17
|
+
const text = value.map((item) => getStringValue(item) || '').join('');
|
|
18
|
+
return text || undefined;
|
|
19
|
+
}
|
|
20
|
+
if (!isRecord(value)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
for (const key of STREAM_TEXT_KEYS) {
|
|
24
|
+
const text = getStringValue(value[key]);
|
|
25
|
+
if (text) {
|
|
26
|
+
return text;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const getChoicesDelta = (choices) => {
|
|
31
|
+
if (!Array.isArray(choices)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const text = choices.map((choice) => getStringValue(choice) || '').join('');
|
|
35
|
+
return text || undefined;
|
|
36
|
+
};
|
|
37
|
+
export const consumeSSEEvents = (buffer, event) => {
|
|
38
|
+
const events = [];
|
|
39
|
+
let remaining = buffer;
|
|
40
|
+
let currentEvent = event;
|
|
41
|
+
let lineBoundary = remaining.match(/\r?\n/);
|
|
42
|
+
while (lineBoundary?.index != null) {
|
|
43
|
+
const line = remaining.slice(0, lineBoundary.index);
|
|
44
|
+
remaining = remaining.slice(lineBoundary.index + lineBoundary[0].length);
|
|
45
|
+
if (!line) {
|
|
46
|
+
currentEvent = undefined;
|
|
47
|
+
}
|
|
48
|
+
else if (line.startsWith(':')) {
|
|
49
|
+
//
|
|
50
|
+
}
|
|
51
|
+
else if (line.startsWith('event:')) {
|
|
52
|
+
currentEvent = parseSSEFieldValue(line, 'event');
|
|
53
|
+
}
|
|
54
|
+
else if (line.startsWith('data:')) {
|
|
55
|
+
events.push({
|
|
56
|
+
event: currentEvent,
|
|
57
|
+
data: parseSSEFieldValue(line, 'data'),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
lineBoundary = remaining.match(/\r?\n/);
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
event: currentEvent,
|
|
64
|
+
events,
|
|
65
|
+
remainder: remaining,
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
export const getAnswerDelta = ({ event, data }) => {
|
|
69
|
+
if (!data || data === '[DONE]') {
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
if (event && IGNORED_SSE_EVENT_TYPES.test(event)) {
|
|
73
|
+
return '';
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const payload = JSON.parse(data);
|
|
77
|
+
if (typeof payload === 'string') {
|
|
78
|
+
return payload;
|
|
79
|
+
}
|
|
80
|
+
if (!isRecord(payload)) {
|
|
81
|
+
return '';
|
|
82
|
+
}
|
|
83
|
+
const type = typeof payload.type === 'string' ? payload.type : undefined;
|
|
84
|
+
if (type && IGNORED_SSE_EVENT_TYPES.test(type)) {
|
|
85
|
+
return '';
|
|
86
|
+
}
|
|
87
|
+
const choiceDelta = getChoicesDelta(payload.choices);
|
|
88
|
+
if (choiceDelta) {
|
|
89
|
+
return choiceDelta;
|
|
90
|
+
}
|
|
91
|
+
for (const key of STREAM_TEXT_KEYS) {
|
|
92
|
+
const text = getStringValue(payload[key]);
|
|
93
|
+
if (text) {
|
|
94
|
+
return text;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return '';
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return data;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
5
103
|
export function parseStreamContent(text) {
|
|
6
|
-
const
|
|
7
|
-
const docsReferences =
|
|
8
|
-
? unicodeToString(
|
|
104
|
+
const docsMatches = [...text.matchAll(/<docs>([\s\S]*?)<\/docs>/g)];
|
|
105
|
+
const docsReferences = docsMatches.length
|
|
106
|
+
? unicodeToString(docsMatches.at(-1)[1])
|
|
9
107
|
: '[]';
|
|
10
108
|
let refDocs = [];
|
|
11
109
|
try {
|
|
@@ -14,16 +112,20 @@ export function parseStreamContent(text) {
|
|
|
14
112
|
catch {
|
|
15
113
|
//
|
|
16
114
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
115
|
+
const thinkMatches = [...text.matchAll(/<think>([\s\S]*?)<\/think>/g)];
|
|
116
|
+
let thinkingProcess = thinkMatches.at(-1)?.[1];
|
|
117
|
+
if (!thinkingProcess) {
|
|
118
|
+
const openThinkMatch = text.match(/<think>([\s\S]*)$/);
|
|
119
|
+
thinkingProcess = openThinkMatch?.[1];
|
|
22
120
|
}
|
|
23
|
-
const
|
|
121
|
+
const content = text
|
|
122
|
+
.replace(/<docs>[\s\S]*?<\/docs>/g, '')
|
|
123
|
+
.replace(/<think>[\s\S]*?<\/think>/g, '')
|
|
124
|
+
.replace(/<docs>[\s\S]*$/g, '')
|
|
125
|
+
.replace(/<think>[\s\S]*$/g, '');
|
|
24
126
|
return {
|
|
25
127
|
refDocs,
|
|
26
|
-
thinkingProcess,
|
|
27
|
-
content: unicodeToString(
|
|
128
|
+
thinkingProcess: thinkingProcess && unicodeToString(thinkingProcess),
|
|
129
|
+
content: unicodeToString(content),
|
|
28
130
|
};
|
|
29
131
|
}
|
|
@@ -41,9 +41,11 @@ export const globalPlugin = ({ version, download, }) => {
|
|
|
41
41
|
},
|
|
42
42
|
addPages(config) {
|
|
43
43
|
let loginPath;
|
|
44
|
+
let productsPath;
|
|
44
45
|
for (const ext of ['.js', '.tsx']) {
|
|
45
46
|
loginPath = baseResolve(`login/index${ext}`);
|
|
46
|
-
|
|
47
|
+
productsPath = baseResolve(`products/index${ext}`);
|
|
48
|
+
if (fs.existsSync(loginPath) && fs.existsSync(productsPath)) {
|
|
47
49
|
break;
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -53,13 +55,26 @@ export const globalPlugin = ({ version, download, }) => {
|
|
|
53
55
|
routePath: '/login',
|
|
54
56
|
filepath: loginPath,
|
|
55
57
|
},
|
|
58
|
+
{
|
|
59
|
+
routePath: '/products',
|
|
60
|
+
filepath: productsPath,
|
|
61
|
+
},
|
|
56
62
|
];
|
|
57
63
|
}
|
|
58
64
|
const lang = config.lang;
|
|
59
|
-
return config.themeConfig.locales.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
return config.themeConfig.locales.flatMap((l) => {
|
|
66
|
+
const prefix = l.lang && l.lang !== lang ? `/${l.lang}` : '';
|
|
67
|
+
return [
|
|
68
|
+
{
|
|
69
|
+
routePath: `${prefix}/login`,
|
|
70
|
+
filepath: loginPath,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
routePath: `${prefix}/products`,
|
|
74
|
+
filepath: productsPath,
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
});
|
|
63
78
|
},
|
|
64
79
|
};
|
|
65
80
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface BuildInfoItem {
|
|
2
|
+
base: string;
|
|
3
|
+
version: string;
|
|
4
|
+
displayName?: {
|
|
5
|
+
en: string;
|
|
6
|
+
zh?: string;
|
|
7
|
+
ru?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface BuildInfoGroup {
|
|
11
|
+
id: string;
|
|
12
|
+
items: BuildInfoItem[];
|
|
13
|
+
}
|
|
14
|
+
declare const _default: () => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { addLeadingSlash, NoSSR, useSite } from '@rspress/core/runtime';
|
|
3
|
+
import virtual from 'doom-@global-virtual';
|
|
4
|
+
import { use } from 'react';
|
|
5
|
+
import { BuildInfoContext } from "../shared/context.js";
|
|
6
|
+
import { isUnversioned } from '../shared/helpers.js';
|
|
7
|
+
import { useIsPrint, useLang, useTranslation } from '@alauda/doom/runtime';
|
|
8
|
+
import classes from '@alauda/doom/styles/products.module.scss';
|
|
9
|
+
const Products = () => {
|
|
10
|
+
const lang = useLang();
|
|
11
|
+
const isPrint = useIsPrint();
|
|
12
|
+
const { site } = useSite();
|
|
13
|
+
const { groups: buildInfoGroups } = use(BuildInfoContext);
|
|
14
|
+
return (_jsx("div", { className: classes.container, children: buildInfoGroups.map((group) => (_jsxs("div", { className: classes.group, children: [_jsx("h2", { children: group.id.toUpperCase() }), _jsx("ul", { children: group.items.map((item) => (_jsx("li", { children: _jsx("a", { className: "rp-link", href: (isPrint ? 'https://docs.alauda.io' : '') +
|
|
15
|
+
(virtual.prefix || '') +
|
|
16
|
+
addLeadingSlash(item.base) +
|
|
17
|
+
(isUnversioned(virtual.version) ? '' : `/${item.version}`) +
|
|
18
|
+
(lang !== site.lang ? addLeadingSlash(lang) : ''), target: "_blank", rel: "noopener noreferrer", children: item.displayName?.[lang] ||
|
|
19
|
+
item.displayName?.en ||
|
|
20
|
+
item.base }) }, item.base))) })] }, group.id))) }));
|
|
21
|
+
};
|
|
22
|
+
export default () => {
|
|
23
|
+
const t = useTranslation();
|
|
24
|
+
return (_jsxs(_Fragment, { children: [_jsx("h1", { children: t('all_product_documentation') }), _jsx("p", { children: t('explore_doc_all_products') }), _jsx(NoSSR, { children: _jsx(Products, {}) })] }));
|
|
25
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useSite } from '@rspress/core/runtime';
|
|
3
3
|
import { addTrailingSlash, isExternalUrl, normalizeHref, parseUrl, removeLeadingSlash, } from '@rspress/shared';
|
|
4
4
|
import { DEFAULT_PAGE_EXTENSIONS } from '@rspress/shared/constants';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
@@ -7,6 +7,7 @@ import virtual from 'doom-@global-virtual';
|
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
import { isUnversioned } from '../../shared/helpers.js';
|
|
9
9
|
import { useIsPrint } from '../hooks/index.js';
|
|
10
|
+
import { useLang } from '@alauda/doom/runtime';
|
|
10
11
|
const ExternalSiteLink_ = ({ name, href = '', className, ...props }) => {
|
|
11
12
|
const isPrint = useIsPrint();
|
|
12
13
|
const { site: siteData } = useSite();
|
|
@@ -31,7 +32,7 @@ const ExternalSiteLink_ = ({ name, href = '', className, ...props }) => {
|
|
|
31
32
|
(isUnversioned(virtual.version)
|
|
32
33
|
? site.base
|
|
33
34
|
: addTrailingSlash(site.base + site.version)) +
|
|
34
|
-
(lang
|
|
35
|
+
(lang !== siteData.lang ? addTrailingSlash(lang) : '') +
|
|
35
36
|
(hash ? `${url}#${hash}` : url), target: "_blank", rel: "noopener noreferrer", className: clsx('rp-link', className), ...props }));
|
|
36
37
|
};
|
|
37
38
|
export const ExternalSiteLink = (props) => (_jsx(ExternalSiteLink_, { ...props }));
|
|
@@ -2,6 +2,7 @@ import { isProduction, withBase } from '@rspress/core/runtime';
|
|
|
2
2
|
import virtual from 'doom-@global-virtual';
|
|
3
3
|
import { merge } from 'es-toolkit/compat';
|
|
4
4
|
import { useEffect, useMemo, useState } from 'react';
|
|
5
|
+
import { xfetch } from 'x-fetch';
|
|
5
6
|
import { parse } from 'yaml';
|
|
6
7
|
import { isUnversioned } from '../../shared/index.js';
|
|
7
8
|
import { namedTerms } from '../../terms.js';
|
|
@@ -35,12 +36,8 @@ const fetchSiteOverrides = async (version, acpSite) => {
|
|
|
35
36
|
if (!url) {
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
|
-
const res = await fetch(url);
|
|
39
|
-
if (!res.ok) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
39
|
try {
|
|
43
|
-
return parse(await
|
|
40
|
+
return parse(await xfetch(url, { type: 'text' }));
|
|
44
41
|
}
|
|
45
42
|
catch {
|
|
46
43
|
//
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Language } from '../../shared/index.js';
|
|
2
2
|
export declare const useLang: () => Language;
|
|
3
|
-
export declare const useTranslation: () => (key: "function" | "name" | "description" | "delete" | "toc" | "create" | "update" | "password" | "close" | "collapse_all" | "expand_all" | "crd_no_schema" | "action" | "view" | "chinese" | "english" | "chinese_bad_cases" | "english_bad_cases" | "download_pdf" | "view_docs_as_pdf" | "ai_assistant" | "exclamation" | "semicolon" | "period" | "colon" | "user_login" | "user_login_tip1" | "user_login_tip2" | "customer_portal_global" | "customer_portal_china" | "account_id" | "username" | "captcha" | "login" | "current_field" | "field_required" | "ERR_INTERNET_DISCONNECTED" | "AccountDisabledError" | "CaptchaError" | "LoginError" | "NetworkError" | "TenantError" | "TenantNotFoundError" | "logout" | "hi_there" | "ai_assistant_tip" | "ai_assistant_placeholder" | "max_chars_exceeded_tip" | "thinking" | "thinking_process" | "referenced_doc_links" | "view_more_related_docs" | "view_less_related_docs" | "new_chat" | "show_more" | "show_less") => string;
|
|
3
|
+
export declare const useTranslation: () => (key: "function" | "name" | "description" | "delete" | "toc" | "create" | "update" | "password" | "close" | "collapse_all" | "expand_all" | "crd_no_schema" | "action" | "view" | "chinese" | "english" | "chinese_bad_cases" | "english_bad_cases" | "download_pdf" | "view_docs_as_pdf" | "ai_assistant" | "exclamation" | "semicolon" | "period" | "colon" | "user_login" | "user_login_tip1" | "user_login_tip2" | "customer_portal_global" | "customer_portal_china" | "account_id" | "username" | "captcha" | "login" | "current_field" | "field_required" | "ERR_INTERNET_DISCONNECTED" | "AccountDisabledError" | "CaptchaError" | "LoginError" | "NetworkError" | "TenantError" | "TenantNotFoundError" | "logout" | "hi_there" | "ai_assistant_tip" | "ai_assistant_placeholder" | "max_chars_exceeded_tip" | "thinking" | "thinking_process" | "referenced_doc_links" | "view_more_related_docs" | "view_less_related_docs" | "new_chat" | "show_more" | "show_less" | "products" | "all_product_documentation" | "explore_doc_all_products") => string;
|
|
@@ -55,6 +55,9 @@ declare const en: {
|
|
|
55
55
|
new_chat: string;
|
|
56
56
|
show_more: string;
|
|
57
57
|
show_less: string;
|
|
58
|
+
products: string;
|
|
59
|
+
all_product_documentation: string;
|
|
60
|
+
explore_doc_all_products: string;
|
|
58
61
|
};
|
|
59
62
|
export type Translation = typeof en;
|
|
60
63
|
export declare const TRANSLATIONS: {
|
|
@@ -115,6 +118,9 @@ export declare const TRANSLATIONS: {
|
|
|
115
118
|
new_chat: string;
|
|
116
119
|
show_more: string;
|
|
117
120
|
show_less: string;
|
|
121
|
+
products: string;
|
|
122
|
+
all_product_documentation: string;
|
|
123
|
+
explore_doc_all_products: string;
|
|
118
124
|
};
|
|
119
125
|
zh: {
|
|
120
126
|
collapse_all: string;
|
|
@@ -173,6 +179,9 @@ export declare const TRANSLATIONS: {
|
|
|
173
179
|
new_chat: string;
|
|
174
180
|
show_more: string;
|
|
175
181
|
show_less: string;
|
|
182
|
+
products: string;
|
|
183
|
+
all_product_documentation: string;
|
|
184
|
+
explore_doc_all_products: string;
|
|
176
185
|
};
|
|
177
186
|
ru: {
|
|
178
187
|
collapse_all: string;
|
|
@@ -231,6 +240,9 @@ export declare const TRANSLATIONS: {
|
|
|
231
240
|
new_chat: string;
|
|
232
241
|
show_more: string;
|
|
233
242
|
show_less: string;
|
|
243
|
+
products: string;
|
|
244
|
+
all_product_documentation: string;
|
|
245
|
+
explore_doc_all_products: string;
|
|
234
246
|
};
|
|
235
247
|
};
|
|
236
248
|
export {};
|
|
@@ -55,6 +55,9 @@ const en = {
|
|
|
55
55
|
new_chat: 'New Chat',
|
|
56
56
|
show_more: 'Show more',
|
|
57
57
|
show_less: 'Show less',
|
|
58
|
+
products: 'Products',
|
|
59
|
+
all_product_documentation: 'All Product Documentation',
|
|
60
|
+
explore_doc_all_products: 'Explore and find documentation for all products',
|
|
58
61
|
};
|
|
59
62
|
const zh = {
|
|
60
63
|
collapse_all: '全部收起',
|
|
@@ -113,6 +116,9 @@ const zh = {
|
|
|
113
116
|
new_chat: '新会话',
|
|
114
117
|
show_more: '显示更多',
|
|
115
118
|
show_less: '显示更少',
|
|
119
|
+
products: '产品',
|
|
120
|
+
all_product_documentation: '所有产品文档',
|
|
121
|
+
explore_doc_all_products: '探索并查找所有产品的文档',
|
|
116
122
|
};
|
|
117
123
|
const ru = {
|
|
118
124
|
collapse_all: 'Свернуть всё',
|
|
@@ -171,5 +177,8 @@ const ru = {
|
|
|
171
177
|
new_chat: 'Новый чат',
|
|
172
178
|
show_more: 'Показать больше',
|
|
173
179
|
show_less: 'Показать меньше',
|
|
180
|
+
products: 'Продукты',
|
|
181
|
+
all_product_documentation: 'Документация по всем продуктам',
|
|
182
|
+
explore_doc_all_products: 'Исследуйте и найдите документацию для всех продуктов',
|
|
174
183
|
};
|
|
175
184
|
export const TRANSLATIONS = { en, zh, ru };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { addTrailingSlash, isActive, useLocation, useSidebar, useSite, } from '@rspress/core/runtime';
|
|
3
|
+
import { IconArrowRight, SvgWrapper } from '@rspress/core/theme';
|
|
4
|
+
import virtual from 'doom-@global-virtual';
|
|
5
|
+
import { use, useEffect, useMemo } from 'react';
|
|
6
|
+
import { xfetch } from 'x-fetch';
|
|
7
|
+
import { parse } from 'yaml';
|
|
8
|
+
import { BuildInfoContext } from "../../shared/context.js";
|
|
9
|
+
import { X } from "../_X.js";
|
|
10
|
+
import { useLang, useSiteOverrides, useTranslation } from '@alauda/doom/runtime';
|
|
11
|
+
const isBuildInfoItem = (obj) => 'base' in obj && 'version' in obj;
|
|
12
|
+
export const BreadCrumb = () => {
|
|
13
|
+
const lang = useLang();
|
|
14
|
+
const t = useTranslation();
|
|
15
|
+
const { pathname } = useLocation();
|
|
16
|
+
const sidebar = useSidebar();
|
|
17
|
+
const site = useSiteOverrides();
|
|
18
|
+
const { site: siteData } = useSite();
|
|
19
|
+
const breadcrumbItems = useMemo(() => {
|
|
20
|
+
function walk(sidebarItems, parents = []) {
|
|
21
|
+
for (const sidebarItem of sidebarItems) {
|
|
22
|
+
if ('link' in sidebarItem &&
|
|
23
|
+
sidebarItem.link &&
|
|
24
|
+
isActive(sidebarItem.link, pathname)) {
|
|
25
|
+
return [
|
|
26
|
+
...parents.map((p) => ({
|
|
27
|
+
text: p.text,
|
|
28
|
+
link: p.link,
|
|
29
|
+
})),
|
|
30
|
+
{
|
|
31
|
+
text: sidebarItem.text,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
if ('items' in sidebarItem && sidebarItem.items.length) {
|
|
36
|
+
const found = walk(sidebarItem.items, [...parents, sidebarItem]);
|
|
37
|
+
if (found) {
|
|
38
|
+
return found;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return walk(sidebar);
|
|
44
|
+
}, [pathname, sidebar]);
|
|
45
|
+
const prefix = addTrailingSlash(`/${lang === siteData.lang ? '' : lang}`);
|
|
46
|
+
const { groups, setGroups: setBuildInfoGroups } = use(BuildInfoContext);
|
|
47
|
+
const hasGroups = !!groups.length;
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const fetchBuildInfo = async () => {
|
|
50
|
+
let rawBuildInfo;
|
|
51
|
+
try {
|
|
52
|
+
rawBuildInfo = parse(await xfetch((virtual.prefix || '') + '/build-info.yaml', {
|
|
53
|
+
type: 'text',
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const buildInfoGroups = [];
|
|
60
|
+
for (const [base, items] of Object.entries(rawBuildInfo)) {
|
|
61
|
+
const id = base
|
|
62
|
+
.replace('alauda-build-of-', '')
|
|
63
|
+
.replace('alauda-', '')[0];
|
|
64
|
+
let group = buildInfoGroups.find((g) => g.id === id);
|
|
65
|
+
if (!group) {
|
|
66
|
+
group = { id, items: [] };
|
|
67
|
+
buildInfoGroups.push(group);
|
|
68
|
+
}
|
|
69
|
+
if (isBuildInfoItem(items)) {
|
|
70
|
+
group.items.push(items);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const latest = Object.values(items).at(-1);
|
|
74
|
+
if (latest) {
|
|
75
|
+
group.items.push(latest);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
setBuildInfoGroups(buildInfoGroups.sort((a, b) => a.id.localeCompare(b.id)));
|
|
80
|
+
};
|
|
81
|
+
void fetchBuildInfo();
|
|
82
|
+
}, [setBuildInfoGroups]);
|
|
83
|
+
return (_jsx("div", { className: "breadcrumb-container", children: _jsxs("ul", { className: "breadcrumb-content", children: [hasGroups && (_jsx("li", { className: "breadcrumb-item rp-doc", children: _jsx(X.a, { href: prefix + 'products', children: t('products') }) })), _jsxs("li", { className: "breadcrumb-item rp-doc", children: [hasGroups && _jsx(SvgWrapper, { icon: IconArrowRight }), _jsx(X.a, { href: prefix, children: site.title || siteData.title })] }), breadcrumbItems?.map((item, index) => (_jsxs("li", { className: "breadcrumb-item rp-doc", children: [_jsx(SvgWrapper, { icon: IconArrowRight }), item.link ? (_jsx(X.a, { href: item.link, children: item.text })) : (_jsx("span", { className: "breadcrumb-item-text", children: item.text }))] }, index)))] }) }));
|
|
84
|
+
};
|
|
85
|
+
export default BreadCrumb;
|
package/lib/theme/Layout.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useLang, useSite } from '@rspress/core/runtime';
|
|
3
|
-
import { Link, Layout as OriginalLayout
|
|
3
|
+
import { Link, Layout as OriginalLayout } from '@rspress/core/theme-original';
|
|
4
4
|
import virtual from 'doom-@global-virtual';
|
|
5
5
|
import { useCallback, useMemo, useState } from 'react';
|
|
6
6
|
import { useLocation } from 'react-router';
|
|
7
7
|
import { useTranslation } from "../runtime/index.js";
|
|
8
|
+
import { BuildInfoContext } from "../shared/context.js";
|
|
9
|
+
import { BreadCrumb } from "./Breadcrumb/index.js";
|
|
8
10
|
import { ForceRenderContext } from "./VersionsNav/context.js";
|
|
9
11
|
import { VersionsNav } from "./VersionsNav/index.js";
|
|
10
|
-
|
|
12
|
+
import { X } from "./_X.js";
|
|
11
13
|
const cleanupUrlPath = (urlPath) => {
|
|
12
14
|
if (urlPath.endsWith('.html')) {
|
|
13
15
|
urlPath = urlPath.slice(0, -5);
|
|
@@ -85,5 +87,6 @@ export const Layout = () => {
|
|
|
85
87
|
const forceRender = useCallback(() => {
|
|
86
88
|
setRender((v) => !v);
|
|
87
89
|
}, []);
|
|
88
|
-
|
|
90
|
+
const [buildInfoGroups, setBuildInfoGroups] = useState([]);
|
|
91
|
+
return (_jsxs(ForceRenderContext, { value: useMemo(() => ({ value: render, setValue: forceRender }), [forceRender, render]), children: [_jsx(VersionsNav, {}), _jsx(BuildInfoContext, { value: useMemo(() => ({ groups: buildInfoGroups, setGroups: setBuildInfoGroups }), [buildInfoGroups, setBuildInfoGroups]), children: _jsx(OriginalLayout, { afterNav: _jsx(BreadCrumb, {}), beforeOutline: pdfLink && (_jsx(X.p, { className: "rp-doc", style: { marginBottom: 16 }, children: _jsx(Link, { href: pdfLink, target: "_blank", rel: "noopener noreferrer", children: t('view_docs_as_pdf') }) })) }) })] }));
|
|
89
92
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const X: {
|
|
2
|
+
h1: (props: React.ComponentProps<"h1">) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
h2: (props: React.ComponentProps<"h2">) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
h3: (props: React.ComponentProps<"h3">) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
h4: (props: React.ComponentProps<"h4">) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
h5: (props: React.ComponentProps<"h5">) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
h6: (props: React.ComponentProps<"h6">) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
ul: (props: import("react").ComponentProps<"ul">) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
ol: (props: import("react").ComponentProps<"ol">) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
li: (props: import("react").ComponentProps<"li">) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
table: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, "ref"> & import("react").RefAttributes<HTMLTableElement>>;
|
|
12
|
+
td: (props: import("react").ComponentProps<"td">) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
th: (props: import("react").ComponentProps<"th">) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
tr: (props: import("react").ComponentProps<"tr">) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
hr: (props: import("react").ComponentProps<"hr">) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
p: (props: import("react").ComponentProps<"p">) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
blockquote: (props: import("react").ComponentProps<"blockquote">) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
strong: (props: import("react").ComponentProps<"strong">) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
a: (props: import("react").ComponentProps<"a">) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
code: typeof import("@rspress/core/dist/theme/components/DocContent/docComponents/code.js").Code;
|
|
21
|
+
img: (props: import("react").ComponentProps<"img">) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
pre: typeof import("@rspress/core/dist/theme/components/DocContent/docComponents/pre.js").ShikiPre;
|
|
23
|
+
};
|
package/lib/theme/_X.js
ADDED
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@mixin special {
|
|
2
|
+
.rp-search-button,
|
|
3
|
+
.rp-doc-layout__menu,
|
|
4
|
+
.rp-sidebar-menu-container,
|
|
5
|
+
.rp-nav-menu__divider,
|
|
6
|
+
.rp-nav-screen-divider,
|
|
7
|
+
aside,
|
|
8
|
+
.rp-doc-footer {
|
|
9
|
+
display: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.rp-doc-layout__container {
|
|
13
|
+
justify-content: center;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.rp-doc-layout__doc {
|
|
17
|
+
max-width: 1440px;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
:root:has(.breadcrumb-container) {
|
|
2
|
+
--rp-banner-height: 50px;
|
|
3
|
+
|
|
4
|
+
.rp-nav {
|
|
5
|
+
top: 0;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.breadcrumb {
|
|
10
|
+
&-container {
|
|
11
|
+
position: sticky;
|
|
12
|
+
top: var(--rp-nav-height);
|
|
13
|
+
z-index: calc(var(--rp-z-index-nav) - 1);
|
|
14
|
+
height: var(--rp-banner-height);
|
|
15
|
+
border-bottom: 1px solid var(--rp-c-divider-light);
|
|
16
|
+
padding: 0 20px;
|
|
17
|
+
background-color: var(--rp-c-bg);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&-content {
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
overflow-x: auto;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
height: 100%;
|
|
26
|
+
|
|
27
|
+
@media (min-width: 1280px) {
|
|
28
|
+
margin-left: calc(var(--rp-sidebar-margin-left));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&-item {
|
|
33
|
+
display: inline-flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
margin-top: 0;
|
|
36
|
+
|
|
37
|
+
.rp-link,
|
|
38
|
+
&-text {
|
|
39
|
+
margin: 0 8px;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
package/styles/global.scss
CHANGED
package/styles/login.module.scss
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
#search-container,
|
|
3
|
-
.rspress-nav-search-button,
|
|
4
|
-
.rspress-sidebar-menu-container,
|
|
5
|
-
aside,
|
|
6
|
-
.rspress-doc-footer,
|
|
7
|
-
[class^='aside-container'] {
|
|
8
|
-
display: none;
|
|
9
|
-
}
|
|
1
|
+
@use 'mixins';
|
|
10
2
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
3
|
+
body:has(.container) :global {
|
|
4
|
+
@include mixins.special;
|
|
14
5
|
}
|
|
15
6
|
|
|
16
7
|
.container {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
@use 'mixins';
|
|
2
|
+
|
|
3
|
+
body:has(.container) :global {
|
|
4
|
+
@include mixins.special;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.container {
|
|
8
|
+
column-count: 5;
|
|
9
|
+
column-gap: 1lh;
|
|
10
|
+
|
|
11
|
+
@media (max-width: 1366px) {
|
|
12
|
+
column-count: 4;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@media (max-width: 1024px) {
|
|
16
|
+
column-count: 3;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media (max-width: 768px) {
|
|
20
|
+
column-count: 2;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
h2 {
|
|
24
|
+
margin-top: 0;
|
|
25
|
+
|
|
26
|
+
&:before {
|
|
27
|
+
display: none;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
ul {
|
|
32
|
+
margin-top: 0;
|
|
33
|
+
margin-bottom: 0;
|
|
34
|
+
padding-left: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
li {
|
|
38
|
+
list-style: none;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.group {
|
|
43
|
+
margin-bottom: 1lh;
|
|
44
|
+
break-inside: avoid;
|
|
45
|
+
}
|