@alauda/doom 0.23.5 → 1.0.0-next.1

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/index.js CHANGED
@@ -124,7 +124,6 @@ program
124
124
  const docDirectory = config.root;
125
125
  const runBuild = () => build({
126
126
  config,
127
- appDirectory: CWD,
128
127
  docDirectory,
129
128
  });
130
129
  await runBuild();
@@ -1,6 +1,7 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { nodeTypes } from '@mdx-js/mdx';
4
+ import { pluginSass } from '@rsbuild/plugin-sass';
4
5
  import { pluginYaml } from '@rsbuild/plugin-yaml';
5
6
  import { addLeadingSlash, addTrailingSlash, normalizeSlash, removeLeadingSlash, } from '@rspress/core';
6
7
  import { logger } from '@rspress/shared/logger';
@@ -9,7 +10,7 @@ import { difference } from 'es-toolkit';
9
10
  import rehypeRaw from 'rehype-raw';
10
11
  import { cyan } from 'yoctocolors';
11
12
  import { autoTocPlugin } from '../plugins/auto-toc/index.js';
12
- import { apiPlugin, autoSidebarPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin, replacePlugin, shikiPlugin, } from '../plugins/index.js';
13
+ import { apiPlugin, autoSidebarPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin, replacePlugin, } from '../plugins/index.js';
13
14
  import { isExplicitlyUnversioned, UNVERSIONED, } from '../shared/index.js';
14
15
  import { pathExists, pkgResolve, resolveStaticConfig } from '../utils/index.js';
15
16
  import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from './constants.js';
@@ -125,12 +126,22 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
125
126
  },
126
127
  markdown: {
127
128
  checkDeadLinks: true,
128
- highlightLanguages: [['jsonc', 'json']],
129
- mdxRs: false,
130
129
  rehypePlugins: [[rehypeRaw, { passThrough: nodeTypes }]],
131
- },
132
- ssg: {
133
- strict: true,
130
+ shiki: {
131
+ transformers: [
132
+ // builtin transformers
133
+ transformerMetaHighlight(),
134
+ transformerMetaWordHighlight(),
135
+ transformerNotationDiff(),
136
+ transformerNotationErrorLevel(),
137
+ transformerNotationFocus(),
138
+ transformerNotationHighlight(),
139
+ transformerNotationWordHighlight(),
140
+ transformerRemoveNotationEscape(),
141
+ // custom transformers
142
+ createTransformerCallouts(),
143
+ ],
144
+ },
134
145
  },
135
146
  themeConfig: {
136
147
  enableScrollToTop: true,
@@ -163,41 +174,12 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
163
174
  localBasePath,
164
175
  force,
165
176
  }),
166
- shikiPlugin({
167
- theme: config.shiki?.theme,
168
- langs: [
169
- 'dockerfile',
170
- 'dotenv',
171
- 'html',
172
- 'go',
173
- 'jsonc',
174
- 'mermaid',
175
- 'java',
176
- 'python',
177
- 'toml',
178
- ...(config.shiki?.langs ?? []),
179
- ],
180
- transformers: [
181
- // builtin transformers
182
- transformerMetaHighlight(),
183
- transformerMetaWordHighlight(),
184
- transformerNotationDiff(),
185
- transformerNotationErrorLevel(),
186
- transformerNotationFocus(),
187
- transformerNotationHighlight(),
188
- transformerNotationWordHighlight(),
189
- transformerRemoveNotationEscape(),
190
- // custom transformers
191
- createTransformerCallouts(),
192
- ...(config.shiki?.transformers ?? []),
193
- ],
194
- }),
195
177
  ],
196
178
  builderConfig: {
197
179
  dev: {
198
180
  lazyCompilation: lazy,
199
181
  },
200
- plugins: [pluginYaml()],
182
+ plugins: [pluginSass(), pluginYaml()],
201
183
  server: {
202
184
  open,
203
185
  },
@@ -18,7 +18,7 @@ export const remarkAutoToc = function () {
18
18
  {
19
19
  type: 'mdxJsxAttribute',
20
20
  name: 'className',
21
- value: 'doom-auto-toc',
21
+ value: 'doom-auto-toc rspress-toc-exclude',
22
22
  },
23
23
  ],
24
24
  children: [
@@ -2,6 +2,16 @@ import type { RspressPlugin } from '@rspress/core';
2
2
  export * from './normalize-img-src.js';
3
3
  export type * from './types.js';
4
4
  export * from './utils.js';
5
+ declare module 'unified' {
6
+ interface Data {
7
+ pageMeta: Record<string, unknown>;
8
+ }
9
+ }
10
+ declare module 'mdast' {
11
+ interface Data {
12
+ _mdxExplicitJsx?: boolean;
13
+ }
14
+ }
5
15
  export declare const replacePlugin: ({ lang, localBasePath, force, }: {
6
16
  lang: string | null;
7
17
  localBasePath: string;
@@ -1,4 +1,4 @@
1
- import type { Content } from 'mdast';
1
+ import type { RootContent } from 'mdast';
2
2
  import type { NormalizedReferenceSource } from './types.js';
3
3
  export interface NormalizeImgSrcOptions {
4
4
  refSource?: NormalizedReferenceSource;
@@ -13,4 +13,4 @@ export interface NormalizeImgSrcOptions {
13
13
  copy?: boolean;
14
14
  };
15
15
  }
16
- export declare const normalizeImgSrc: (content: Content, { refSource, localPublicBase, publicBase, sourceBase, targetBase, force, translating, }: NormalizeImgSrcOptions) => Content;
16
+ export declare const normalizeImgSrc: (content: RootContent, { refSource, localPublicBase, publicBase, sourceBase, targetBase, force, translating, }: NormalizeImgSrcOptions) => RootContent;
@@ -39,7 +39,7 @@ export const rehypeNormalizeLink = () => {
39
39
  if (node.tagName !== 'img') {
40
40
  return;
41
41
  }
42
- const { alt, src } = node.properties || {};
42
+ const { alt, src } = node.properties;
43
43
  if (typeof src !== 'string') {
44
44
  return;
45
45
  }
@@ -1,8 +1,8 @@
1
- import type { Content } from 'mdast';
1
+ import type { RootContent } from 'mdast';
2
2
  import type { NormalizedReferenceSource } from './types.js';
3
3
  export interface ResolveReferenceResult {
4
4
  publicBase: string;
5
5
  sourceBase: string;
6
- contents: Content[];
6
+ contents: RootContent[];
7
7
  }
8
8
  export declare const resolveReference: (localBasePath: string, localPublicBase: string, items: Record<string, NormalizedReferenceSource>, refName: string, force?: boolean) => Promise<ResolveReferenceResult | undefined>;
@@ -1,2 +1,2 @@
1
- import type { Content } from 'mdast';
2
- export declare const resolveRelease: (releaseTemplates: Record<string, string>, releaseQuery: string, lang: string) => Promise<Content | Content[] | undefined>;
1
+ import type { RootContent } from 'mdast';
2
+ export declare const resolveRelease: (releaseTemplates: Record<string, string>, releaseQuery: string, lang: string) => Promise<RootContent | RootContent[] | undefined>;
@@ -1,4 +1,4 @@
1
- import type { Root, YAML } from 'mdast';
1
+ import type { Root, Yaml } from 'mdast';
2
2
  import { type Options } from 'remark-stringify';
3
3
  import type { NormalizedReferenceSource, ReferenceItem } from './types.js';
4
4
  export declare const RELATIVE_URL_PATTERN: RegExp;
@@ -8,7 +8,7 @@ export declare const RELATIVE_URL_PATTERN: RegExp;
8
8
  export declare const extractTextAndId: (title: string) => string[];
9
9
  export declare const normalizeReferenceItems: (items?: ReferenceItem[]) => Record<string, NormalizedReferenceSource>;
10
10
  export declare const stringifySettings: Options;
11
- export declare const mdProcessor: import("unified").FrozenProcessor<Root, Root, Root, string>;
12
- export declare const mdxProcessor: import("unified").FrozenProcessor<Root, Root, Root, string>;
13
- export declare const getFrontmatterNode: (ast: Root) => YAML | undefined;
11
+ export declare const mdProcessor: import("unified").Processor<Root, undefined, undefined, Root, string>;
12
+ export declare const mdxProcessor: import("unified").Processor<Root, undefined, undefined, Root, string>;
13
+ export declare const getFrontmatterNode: (ast: Root) => Yaml | undefined;
14
14
  export declare const isCI: boolean;
@@ -1,19 +1 @@
1
- import type { RspressPlugin } from '@rspress/shared';
2
- import { type BuiltinLanguage, type BuiltinTheme, type ShikiTransformer, type SpecialLanguage } from 'shiki';
3
- export interface PluginShikiOptions {
4
- /**
5
- * Code highlighting theme, @see https://shiki.style/themes
6
- */
7
- theme?: BuiltinTheme | 'css-variables';
8
- /**
9
- * Code highlighting language, @see https://shiki.style/languages
10
- */
11
- langs?: Array<BuiltinLanguage | SpecialLanguage>;
12
- /**
13
- * Custom shiki transformer, @see https://shiki.style/guide/transformers
14
- */
15
- transformers?: ShikiTransformer[];
16
- }
17
- export declare const SHIKI_DEFAULT_HIGHLIGHT_LANGUAGES: BuiltinLanguage[];
18
- export declare function shikiPlugin({ theme, langs, transformers, }?: PluginShikiOptions): RspressPlugin;
19
1
  export * from './transformers/index.js';
@@ -1,53 +1 @@
1
- import { createCssVariablesTheme, } from 'shiki';
2
- import { getHighlighter } from './highlighter.js';
3
- import { rehypePluginShiki } from './rehypePlugin.js';
4
- import { SHIKI_TRANSFORMER_LINE_NUMBER, createTransformerLineNumber, } from './transformers/line-number.js';
5
- export const SHIKI_DEFAULT_HIGHLIGHT_LANGUAGES = [
6
- 'js',
7
- 'ts',
8
- 'jsx',
9
- 'tsx',
10
- 'json',
11
- 'css',
12
- 'scss',
13
- 'less',
14
- 'xml',
15
- 'diff',
16
- 'yaml',
17
- 'md',
18
- 'mdx',
19
- 'bash',
20
- ];
21
- const cssVariablesTheme = createCssVariablesTheme({
22
- name: 'css-variables',
23
- variablePrefix: '--shiki-',
24
- variableDefaults: {},
25
- fontStyle: true,
26
- });
27
- export function shikiPlugin({ theme = 'css-variables', langs = [], transformers = [], } = {}) {
28
- return {
29
- name: 'doom-shiki',
30
- async config(config) {
31
- config.markdown = config.markdown || {};
32
- // Shiki will be integrated by rehype plugin, so we should use the javascript version markdown compiler.
33
- config.markdown.mdxRs = false;
34
- config.markdown.codeHighlighter = 'shiki';
35
- config.markdown.rehypePlugins = config.markdown.rehypePlugins || [];
36
- if (config.markdown.showLineNumbers &&
37
- !transformers.some((transformerItem) => transformerItem.name === SHIKI_TRANSFORMER_LINE_NUMBER)) {
38
- transformers.push(createTransformerLineNumber());
39
- }
40
- const highlighter = await getHighlighter({
41
- themes: [cssVariablesTheme],
42
- langs: [...SHIKI_DEFAULT_HIGHLIGHT_LANGUAGES, ...langs],
43
- transformers,
44
- });
45
- config.markdown.rehypePlugins.push([
46
- rehypePluginShiki,
47
- { highlighter, theme },
48
- ]);
49
- return config;
50
- },
51
- };
52
- }
53
1
  export * from './transformers/index.js';
@@ -1,9 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { getCustomMDXComponent, Tab, Tabs } from '@rspress/core/theme';
3
- import { useState } from 'react';
2
+ import { CodeBlockRuntime, Tab, Tabs } from '@rspress/core/theme';
4
3
  import { stringify } from 'yaml';
5
4
  export const JsonViewer = ({ value }) => {
6
- const [X] = useState(getCustomMDXComponent);
7
- return (_jsxs(Tabs, { children: [_jsx(Tab, { label: "yaml", children: _jsx(X.pre, { children: _jsx(X.code, { className: "language-yaml", codeHighlighter: "prism", children: stringify(value) }) }) }), _jsx(Tab, { label: "json", children: _jsx(X.pre, { children: _jsx(X.code, { className: "language-json", codeHighlighter: "prism", children: JSON.stringify(value, null, 2) }) }) })] }));
5
+ return (_jsxs(Tabs, { children: [_jsx(Tab, { label: "yaml", children: _jsx(CodeBlockRuntime, { lang: "yaml", code: stringify(value) }) }), _jsx(Tab, { label: "json", children: _jsx(CodeBlockRuntime, { lang: "json", code: JSON.stringify(value, null, 2) }) })] }));
8
6
  };
9
7
  export default JsonViewer;
@@ -2,12 +2,13 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  /**
3
3
  * modified based on @see https://github.com/crdsdev/doc/blob/main/template/doc.html
4
4
  */
5
- import { Badge, Button, getCustomMDXComponent } from '@rspress/core/theme';
5
+ import { Badge, Button } from '@rspress/core/theme';
6
6
  import crdsMap from 'doom-@api-crdsMap';
7
7
  import { useCallback, useEffect, useMemo, useState } from 'react';
8
8
  import { useIsPrint, useTranslation } from '../hooks/index.js';
9
9
  import { Directive } from './Directive.js';
10
10
  import { Markdown } from './_Markdown.js';
11
+ import { X } from './_X.js';
11
12
  export const K8sCrdSchemaPart = ({ name, parent, schema: property, expandAll, }) => {
12
13
  const [open, setOpen] = useState(expandAll);
13
14
  const onToggle = useCallback((open) => {
@@ -52,7 +53,6 @@ export const K8sCrdSchema = ({ schema, version, }) => {
52
53
  return (_jsxs(_Fragment, { children: [_jsx(Markdown, { children: description }), _jsxs("div", { className: "flex items-center", children: [_jsxs("span", { children: [_jsx("code", { children: version }), _jsx(Badge, { children: "version" })] }), !isPrint && properties != null && (_jsx(Button, { className: "ml-auto doom-btn", type: "button", text: _jsxs("span", { onClick: toggleExpandAll, children: [expandAll ? '-' : '+', ' ', t(expandAll ? 'collapse_all' : 'expand_all')] }), size: "medium", theme: "alt" }))] }), properties == null ? (_jsx(Directive, { type: "warning", children: t('crd_no_schema') })) : (_jsx("div", { className: "doom-collapse-group", children: Object.entries(properties).map(([name, subSchema]) => SKIPPED_PROPERTIES.includes(name) || (_jsx(K8sCrdSchemaPart, { name: name, parent: schema, schema: subSchema, expandAll: expandAll }, name))) }))] }));
53
54
  };
54
55
  export const K8sCrd = ({ name, crdPath }) => {
55
- const [X] = useState(getCustomMDXComponent);
56
56
  const [, crd] = useMemo(() => Object.entries(crdsMap).find(([pathname, crd]) => {
57
57
  if (crdPath && pathname !== crdPath) {
58
58
  return false;
@@ -1,11 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useLang } from '@rspress/core/runtime';
3
- import { getCustomMDXComponent } from '@rspress/core/theme';
4
3
  import functionResourcesMap from 'doom-@permission-functionResourcesMap';
5
4
  import roleTemplatesMap from 'doom-@permission-roleTemplatesMap';
6
5
  import { intersection, sortBy } from 'es-toolkit';
7
- import { Fragment, useMemo, useState } from 'react';
6
+ import { Fragment, useMemo } from 'react';
8
7
  import { useTranslation } from '../hooks/index.js';
8
+ import { X } from './_X.js';
9
9
  export const VerbsMap = {
10
10
  view: ['get', 'list', 'watch'],
11
11
  create: ['create'],
@@ -20,7 +20,6 @@ const DISPLAY_NAME_EN = 'cpaas.io/display-name.en';
20
20
  const TEXT_CENTER_STYLE = { textAlign: 'center' };
21
21
  const TEXT_NO_WRAP_STYLE = { whiteSpace: 'nowrap' };
22
22
  const RolesPermission = ({ functionResource, roleTemplates, verb, }) => {
23
- const [X] = useState(getCustomMDXComponent);
24
23
  const functionResourceName = functionResource.metadata.name;
25
24
  const actions = functionResource.metadata.annotations['auth.cpaas.io/actions'];
26
25
  return roleTemplates.map(({ metadata: { name }, spec: { rules } }) => {
@@ -49,7 +48,6 @@ const RolesPermission = ({ functionResource, roleTemplates, verb, }) => {
49
48
  });
50
49
  };
51
50
  export const K8sPermissionTable = ({ functions }) => {
52
- const [X] = useState(getCustomMDXComponent);
53
51
  const allFunctionResources = useMemo(() => Object.values(functionResourcesMap).reduce((acc, curr) => Object.assign(acc, ...curr.map((fr) => ({ [fr.metadata.name]: fr }))), {}), []);
54
52
  const functionResources = useMemo(() => {
55
53
  return functions.flatMap((name) => {
@@ -1,18 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { usePageData } from '@rspress/core/runtime';
3
- import { Badge, getCustomMDXComponent } from '@rspress/core/theme';
3
+ import { Badge } from '@rspress/core/theme';
4
4
  import openapisMap from 'doom-@api-openapisMap';
5
5
  import virtual from 'doom-@api-virtual';
6
6
  import BananaSlug from 'github-slugger';
7
7
  import { OpenAPIV3 } from 'openapi-types';
8
- import { Fragment, useMemo, useState } from 'react';
8
+ import { Fragment, useMemo } from 'react';
9
9
  import { omitRoutePathRefs, resolveRef } from '../utils.js';
10
10
  import { OpenAPIProperties, OpenAPIProperty, OpenAPIRef } from './OpenAPIRef.js';
11
11
  import { HeadingTitle } from './_HeadingTitle.js';
12
12
  import { Markdown } from './_Markdown.js';
13
13
  import { RefLink } from './_RefLink.js';
14
+ import { X } from './_X.js';
14
15
  export const OpenAPIParameters = ({ parameters, openapi, }) => {
15
- const [X] = useState(getCustomMDXComponent);
16
16
  return (_jsx(X.ul, { children: parameters.map((param, index) => {
17
17
  const paramObj = '$ref' in param
18
18
  ? resolveRef(openapi, param.$ref)
@@ -30,7 +30,6 @@ export const OpenAPIParameters = ({ parameters, openapi, }) => {
30
30
  }) }));
31
31
  };
32
32
  export const OpenAPIResponses = ({ responses, openapi, }) => {
33
- const [X] = useState(getCustomMDXComponent);
34
33
  return (_jsx(X.ul, { children: Object.entries(responses).map(([code, response]) => {
35
34
  const responseObj = '$ref' in response
36
35
  ? resolveRef(openapi, response.$ref)
@@ -90,7 +89,6 @@ const getRefsForPath = (openapi, path, knownRefs) => {
90
89
  return Array.from(refs);
91
90
  };
92
91
  export const OpenAPIPath = ({ path, openapiPath: openapiPath_, pathPrefix: pathPrefix_, }) => {
93
- const [X] = useState(getCustomMDXComponent);
94
92
  const { page } = usePageData();
95
93
  const pathPrefix = pathPrefix_ ?? (virtual.pathPrefix || '');
96
94
  const slugger = useMemo(() => new BananaSlug(), []);
@@ -1,12 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { usePageData } from '@rspress/core/runtime';
3
- import { getCustomMDXComponent } from '@rspress/core/theme';
4
3
  import openapisMap from 'doom-@api-openapisMap';
5
- import { useMemo, useState } from 'react';
4
+ import { useMemo } from 'react';
6
5
  import { modelName, omitRoutePathRefs, resolveRef } from '../utils.js';
7
6
  import { HeadingTitle } from './_HeadingTitle.js';
8
7
  import { Markdown } from './_Markdown.js';
9
8
  import { RefLink } from './_RefLink.js';
9
+ import { X } from './_X.js';
10
10
  export const OpenAPIProperty = ({ name, property, openapi, }) => {
11
11
  const propObj = '$ref' in property ? resolveRef(openapi, property.$ref) : property;
12
12
  const type = propObj.type;
@@ -43,7 +43,6 @@ export const OpenAPIProperty = ({ name, property, openapi, }) => {
43
43
  return (_jsxs(_Fragment, { children: [name && (_jsxs(_Fragment, { children: [_jsx("code", { children: name }), ":", ' '] })), typeNode, _jsx(Markdown, { children: propObj.description }), extraNode] }));
44
44
  };
45
45
  export const OpenAPIProperties = ({ properties, openapi, }) => {
46
- const [X] = useState(getCustomMDXComponent);
47
46
  return (_jsx(X.ul, { children: Object.entries(properties).map(([name, property], index) => (_jsx(X.li, { children: _jsx(OpenAPIProperty, { name: name, property: property, openapi: openapi }) }, index))) }));
48
47
  };
49
48
  const getRefsForSchema = (openapi, schema, knownRefs) => {
@@ -1,10 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { getCustomMDXComponent } from '@rspress/core/theme';
3
- import { useState } from 'react';
4
2
  import { namedTermItems } from '../../terms.js';
5
3
  import { useTranslation } from '../hooks/index.js';
4
+ import { X } from './_X.js';
6
5
  export const TermsTable = ({ terms }) => {
7
- const [X] = useState(getCustomMDXComponent);
8
6
  const t = useTranslation();
9
7
  const normalized = terms ?? namedTermItems;
10
8
  const withName = normalized.some(({ name }) => name);
@@ -1,9 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { getCustomMDXComponent } from '@rspress/core/theme';
3
2
  import BananaSlug from 'github-slugger';
4
- import { Children, useMemo, useState } from 'react';
3
+ import { Children, useMemo } from 'react';
4
+ import { X } from './_X.js';
5
5
  export const HeadingTitle = ({ slug, slugger, level, children, }) => {
6
- const [X] = useState(getCustomMDXComponent);
7
6
  const HeadingComponents = useMemo(() => {
8
7
  return [null, X.h1, X.h2, X.h3, X.h4, X.h5, X.h6];
9
8
  }, [X]);
@@ -1,9 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getCustomMDXComponent } from '@rspress/core/theme';
3
- import { useState } from 'react';
2
+ import {} from 'react';
4
3
  import ReactMarkdown from 'react-markdown';
5
4
  import remarkGfm from 'remark-gfm';
5
+ import { X } from './_X.js';
6
6
  export const Markdown = ({ children }) => {
7
- const [components] = useState(getCustomMDXComponent);
8
- return (children && (_jsx(ReactMarkdown, { remarkPlugins: [[remarkGfm]], components: components, skipHtml: true, children: children })));
7
+ return (children && (_jsx(ReactMarkdown, { remarkPlugins: [[remarkGfm]], components: X, skipHtml: true, children: children })));
9
8
  };
@@ -1,9 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getCustomMDXComponent } from '@rspress/core/theme';
3
- import { useState } from 'react';
4
2
  import { COMMON_REFS, modelName } from '../utils.js';
3
+ import { X } from './_X.js';
5
4
  export const RefLink = ({ $ref }) => {
6
- const [X] = useState(getCustomMDXComponent);
7
5
  if (!$ref) {
8
6
  return null;
9
7
  }
@@ -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: (props: import("react").ComponentProps<"table">) => import("react/jsx-runtime").JSX.Element;
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: (props: import("react").HTMLProps<HTMLElement>) => import("react/jsx-runtime").JSX.Element;
21
+ pre: ({ children, className, title, ...otherProps }: import("@rspress/theme-default").PreWithCodeButtonGroupProps) => import("react/jsx-runtime").JSX.Element;
22
+ img: (props: import("react").ComponentProps<"img">) => import("react/jsx-runtime").JSX.Element;
23
+ };
@@ -0,0 +1,2 @@
1
+ import { getCustomMDXComponent } from '@rspress/core/theme';
2
+ export const X = getCustomMDXComponent();
package/lib/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Options } from '@cspell/eslint-plugin';
2
2
  import type { serve } from '@rspress/core';
3
- import type { ApiPluginOptions, AutoSidebarPluginOptions, PermissionPluginOptions, PluginShikiOptions, ReferenceItem, ReleaseNotesOptions } from './plugins/index.js';
3
+ import type { ApiPluginOptions, AutoSidebarPluginOptions, PermissionPluginOptions, ReferenceItem, ReleaseNotesOptions } from './plugins/index.js';
4
4
  import type { DoomSite } from './shared/index.js';
5
5
  export type BaseServeOptions = Parameters<typeof serve>[0];
6
6
  export type ServeOptions = Omit<BaseServeOptions, 'config'>;
@@ -41,7 +41,6 @@ declare module '@rspress/shared' {
41
41
  onlyIncludeRoutes?: string[];
42
42
  internalRoutes?: string[];
43
43
  translate?: TranslateOptions;
44
- shiki?: PluginShikiOptions;
45
44
  editRepoBaseUrl?: string;
46
45
  lint?: LintOptions;
47
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "0.23.5",
3
+ "version": "1.0.0-next.1",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": "git+https://github.com/alauda/doom.git",
@@ -33,25 +33,26 @@
33
33
  "rspress-plugins"
34
34
  ],
35
35
  "dependencies": {
36
- "@cspell/eslint-plugin": "^9.0.1",
37
- "@eslint-react/eslint-plugin": "^1.49.0",
38
- "@inquirer/prompts": "^7.5.1",
36
+ "@cspell/eslint-plugin": "^9.0.2",
37
+ "@eslint-react/eslint-plugin": "^1.50.0",
38
+ "@inquirer/prompts": "^7.5.3",
39
39
  "@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
40
40
  "@playwright/browser-chromium": "^1.52.0",
41
+ "@rsbuild/plugin-sass": "^1.3.1",
41
42
  "@rsbuild/plugin-yaml": "^1.0.2",
42
- "@rspress/core": "1.44.0",
43
+ "@rspress/core": "2.0.0-beta.7",
43
44
  "@shikijs/transformers": "^3.4.2",
44
45
  "chokidar": "^4.0.3",
45
46
  "cli-progress": "^3.12.0",
46
47
  "clsx": "^2.1.1",
47
- "commander": "^13.1.0",
48
+ "commander": "^14.0.0",
48
49
  "ejs": "^3.1.10",
49
- "es-toolkit": "^1.37.2",
50
- "eslint": "^9.26.0",
50
+ "es-toolkit": "^1.38.0",
51
+ "eslint": "^9.27.0",
51
52
  "eslint-plugin-mdx": "^3.4.2",
52
53
  "html-tag-names": "^2.1.0",
53
- "mdast-util-mdx": "^2.0.1",
54
- "mdast-util-mdx-jsx": "^2.1.4",
54
+ "mdast-util-mdx": "^3.0.0",
55
+ "mdast-util-mdx-jsx": "^3.2.0",
55
56
  "mermaid": "^11.6.0",
56
57
  "openai": "^5.0.0-beta.0",
57
58
  "openapi-types": "^12.1.3",
@@ -60,17 +61,17 @@
60
61
  "pdf-merger-js": "^5.1.2",
61
62
  "picomatch": "^4.0.2",
62
63
  "playwright": "^1.52.0",
63
- "react-markdown": "^8.0.7",
64
- "rehype-raw": "^6.1.1",
65
- "remark-directive": "^2.0.1",
66
- "remark-frontmatter": "^4.0.1",
67
- "remark-gfm": "^3.0.1",
68
- "remark-mdx": "^2.3.0",
69
- "remark-stringify": "^10.0.3",
64
+ "react-markdown": "^10.1.0",
65
+ "rehype-raw": "^7.0.0",
66
+ "remark-directive": "^4.0.0",
67
+ "remark-frontmatter": "^5.0.0",
68
+ "remark-gfm": "^4.0.1",
69
+ "remark-mdx": "^3.1.0",
70
+ "remark-stringify": "^11.0.0",
70
71
  "shiki": "^3.4.2",
71
72
  "simple-git": "^3.27.0",
72
73
  "swagger2openapi": "^7.0.8",
73
- "tinyglobby": "^0.2.13",
74
+ "tinyglobby": "^0.2.14",
74
75
  "type-fest": "^4.41.0",
75
76
  "typescript-eslint": "^8.32.1",
76
77
  "x-fetch": "^0.2.6",
@@ -78,7 +79,6 @@
78
79
  "yoctocolors": "^2.1.1"
79
80
  },
80
81
  "publishConfig": {
81
- "access": "public",
82
82
  "registry": "https://registry.npmjs.org"
83
83
  }
84
84
  }
@@ -1,7 +1,5 @@
1
1
  @use 'sass:color';
2
2
 
3
- @import url(./shiki.css);
4
-
5
3
  th,
6
4
  td {
7
5
  img {
@@ -1,5 +0,0 @@
1
- import { type BuiltinLanguage, type BuiltinTheme, type Highlighter, type BundledHighlighterOptions as ShikiHighlighterOptions, type ShikiTransformer } from 'shiki';
2
- export interface HighlighterOptions extends ShikiHighlighterOptions<BuiltinLanguage, BuiltinTheme> {
3
- transformers?: ShikiTransformer[];
4
- }
5
- export declare function getHighlighter(options: HighlighterOptions): Promise<Highlighter>;
@@ -1,15 +0,0 @@
1
- import { createHighlighter as createShikiHighlighter, } from 'shiki';
2
- export async function getHighlighter(options) {
3
- const highlighter = await createShikiHighlighter(options);
4
- const baseTransformers = options.transformers ?? [];
5
- return {
6
- ...highlighter,
7
- codeToHtml: (code, htmlOptions) => {
8
- const transformers = htmlOptions.transformers ?? [];
9
- return highlighter.codeToHtml(code, {
10
- ...htmlOptions,
11
- transformers: [...baseTransformers, ...transformers],
12
- });
13
- },
14
- };
15
- }
@@ -1,9 +0,0 @@
1
- import type { Root } from 'hast';
2
- import type { BuiltinTheme, Highlighter } from 'shiki';
3
- import type { Plugin } from 'unified';
4
- interface Options {
5
- highlighter: Highlighter;
6
- theme: BuiltinTheme;
7
- }
8
- export declare const rehypePluginShiki: Plugin<[Options], Root>;
9
- export {};
@@ -1,59 +0,0 @@
1
- import { logger } from '@rspress/shared/logger';
2
- import { fromHtml } from 'hast-util-from-html';
3
- import { visit } from 'unist-util-visit';
4
- // TODO: migrate to official @shikijs/rehype plugin after upgrading unified/remark/rehype packages
5
- export const rehypePluginShiki = ({ highlighter, theme }) => (tree) => {
6
- visit(tree, 'element', (node, index, parent) => {
7
- // <pre><code>...</code></pre>
8
- if (node.tagName === 'pre' &&
9
- node.children[0]?.type === 'element' &&
10
- node.children[0].tagName === 'code') {
11
- const codeNode = node.children[0];
12
- const codeContent = codeNode.children[0].value;
13
- const codeClassName = codeNode.properties?.className?.toString() || '';
14
- const codeMeta = codeNode.properties?.meta?.toString() || '';
15
- // for example: language-js {1,2,3-5}
16
- const lang = codeClassName.split(' ')[0].split('-')[1];
17
- if (!lang) {
18
- return;
19
- }
20
- let highlightedCode;
21
- try {
22
- highlightedCode = highlighter.codeToHtml(codeContent, {
23
- lang,
24
- theme,
25
- meta: {
26
- __raw: codeMeta,
27
- },
28
- });
29
- }
30
- catch (err) {
31
- logger.error(`render with \`${lang}\` results error`, err);
32
- logger.warn('fallback to `plaintext`');
33
- highlightedCode = highlighter.codeToHtml(codeContent, {
34
- lang: 'plaintext',
35
- theme,
36
- meta: {
37
- __raw: codeMeta,
38
- },
39
- });
40
- }
41
- const fragmentAst = fromHtml(highlightedCode, { fragment: true });
42
- const preElement = fragmentAst.children[0];
43
- const codeElement = preElement.children[0];
44
- codeElement.properties.className = `language-${lang}`;
45
- codeElement.properties.meta = codeMeta;
46
- const codeLines = codeElement.children;
47
- // Strip the final empty span
48
- const lastLine = codeLines[codeLines.length - 1];
49
- if (lastLine.children.length === 0) {
50
- codeLines.pop();
51
- }
52
- parent?.children.splice(index, 1, {
53
- type: 'element',
54
- tagName: 'pre',
55
- children: fragmentAst.children,
56
- });
57
- }
58
- });
59
- };
package/styles/shiki.css DELETED
@@ -1,119 +0,0 @@
1
- /**
2
- * Custom shiki code block theme
3
- * reference: https://github.com/shikijs/shiki/blob/main/docs/themes.md
4
- * -------------------------------------------------------------------------- */
5
-
6
- :root {
7
- --shiki-foreground: #414141;
8
- --shiki-background: transparent;
9
- --shiki-token-constant: #1976d2;
10
- --shiki-token-string: #31a94d;
11
- --shiki-token-comment: rgb(182, 180, 180);
12
- --shiki-token-keyword: #cf2727;
13
- --shiki-token-parameter: #f59403;
14
- --shiki-token-function: #7041c8;
15
- --shiki-token-string-expression: #218438;
16
- --shiki-token-punctuation: #242323;
17
- --shiki-token-link: #22863a;
18
- }
19
-
20
- .dark {
21
- --shiki-foreground: #cac7c7;
22
- --shiki-token-constant: #6fb0fa;
23
- --shiki-token-string: #f9a86e;
24
- --shiki-token-comment: #6a727b;
25
- --shiki-token-keyword: #f47481;
26
- --shiki-token-parameter: #ff9800;
27
- --shiki-token-function: #ae8eeb;
28
- --shiki-token-string-expression: #4fb74d;
29
- --shiki-token-punctuation: #bbbbbb;
30
- --shiki-token-link: #f9a76d;
31
- }
32
-
33
- .rspress-doc span.line {
34
- padding: 0 1.25rem;
35
- }
36
-
37
- .diff,
38
- .code-line-highlighted {
39
- transition: background-color 0.5s;
40
- padding: 0 20px;
41
- width: 100%;
42
- display: inline-block;
43
- position: relative;
44
- }
45
-
46
- .diff.add::after {
47
- content: '+';
48
- position: absolute;
49
- left: 10px;
50
- color: #3dd68c;
51
- }
52
-
53
- .diff.remove::after {
54
- content: '-';
55
- position: absolute;
56
- left: 10px;
57
- color: #cb7676;
58
- }
59
-
60
- .has-diff div[class*='language-'] .diff.add {
61
- background-color: rgba(16, 185, 129, 0.16);
62
- border-left: 1px solid #10b981;
63
- padding: 0 20px 0 19px;
64
- }
65
-
66
- div[class*='language-'] code .diff.remove {
67
- background-color: rgba(244, 63, 94, 0.16);
68
- border-left: 1px solid #f43f5e;
69
- padding: 0 20px 0 19px;
70
- }
71
-
72
- .has-highlight div[class*='language-'] .line.highlighted {
73
- background-color: rgba(101, 117, 133, 0.16);
74
- }
75
-
76
- .has-highlight div[class*='language-'] .line.highlighted.error {
77
- background-color: rgba(244, 63, 94, 0.16);
78
- }
79
-
80
- .has-highlight div[class*='language-'] .line.highlighted.warning {
81
- background-color: rgba(234, 179, 8, 0.16);
82
- }
83
-
84
- .has-focused div[class*='language-'] .line:not(.focused) {
85
- filter: blur(0.095rem);
86
- opacity: 0.4;
87
- transition:
88
- filter 0.35s,
89
- opacity 0.35s;
90
- }
91
-
92
- .has-focused:hover div[class*='language-'] .line:not(.focused) {
93
- filter: blur(0);
94
- opacity: 1;
95
- }
96
-
97
- .has-line-number code {
98
- counter-reset: step;
99
- counter-increment: step 0;
100
- }
101
-
102
- .has-line-number code .line-number::before {
103
- content: counter(step);
104
- counter-increment: step;
105
- width: 15px;
106
- margin-right: 15px;
107
- display: inline-block;
108
- text-align: right;
109
- color: rgba(115, 138, 148, 0.4);
110
- }
111
-
112
- .line .highlighted-word {
113
- background-color: var(--rp-c-text-code-bg);
114
- border: 1px solid var(--rp-c-divider);
115
- color: var(--rp-c-text-code);
116
- padding: 1px 3px;
117
- margin: -1px -3px;
118
- border-radius: 4px;
119
- }