@alauda/doom 1.15.2 → 1.16.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.
@@ -19,5 +19,5 @@ export declare const parseTerms: () => Promise<{
19
19
  zh?: string[];
20
20
  ru?: string[];
21
21
  } | undefined;
22
- name?: "company" | "product" | "productShort" | undefined;
22
+ name?: "company" | "product" | "productShort" | "alaudaCloudLink" | undefined;
23
23
  }[]>;
@@ -15,7 +15,6 @@ import { transformerMetaHighlight, transformerMetaWordHighlight, transformerNota
15
15
  import { difference } from 'es-toolkit';
16
16
  import { glob } from 'tinyglobby';
17
17
  import { cyan } from 'yoctocolors';
18
- import { attributesPlugin } from "../plugins/attributes/index.js";
19
18
  import { apiPlugin, autoSidebarPlugin, autoTocPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin, replacePlugin, } from "../plugins/index.js";
20
19
  import { isExplicitlyUnversioned, normalizeSlash, UNVERSIONED, } from "../shared/index.js";
21
20
  import { pathExists, pkgResolve, resolveStaticConfig } from "../utils/index.js";
@@ -212,7 +211,6 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
212
211
  apiPlugin({
213
212
  localBasePath,
214
213
  }),
215
- attributesPlugin(),
216
214
  autoSidebarPlugin({ export: export_, ignore }),
217
215
  autoTocPlugin(),
218
216
  directivesPlugin(),
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { NoSSR, useSearchParams } from '@rspress/core/runtime';
2
+ import { NoSSR, useDark, useSearchParams } from '@rspress/core/runtime';
3
3
  import { useCallback } from 'react';
4
4
  import { useNavigate } from 'react-router-dom';
5
5
  import { X } from "../runtime/components/_X.js";
@@ -16,10 +16,10 @@ const Login = () => {
16
16
  const onLoggedIn = useCallback(() => {
17
17
  navigate(from || '/');
18
18
  }, [from, navigate]);
19
+ const dark = useDark();
19
20
  const t = useTranslation();
20
21
  return (_jsx("div", { className: classes.container, style: {
21
- '--login-bg': `url(${bg})`,
22
- '--login-bg-dark': `url(${darkBg})`,
22
+ backgroundImage: `url(${dark ? darkBg : bg})`,
23
23
  }, children: _jsxs("div", { className: classes.loginForm, children: [_jsx("div", { className: classes.title, children: t('user_login') }), _jsxs("div", { className: classes.content, children: [t('user_login_tip1'), _jsx(X.a, { href: getCloudOrigin(), children: t(`customer_portal_${isIoSite() ? 'global' : 'china'}`) }), t('user_login_tip2')] }), _jsx(LoginForm, { onLoggedIn: onLoggedIn })] }) }));
24
24
  };
25
25
  export default () => (_jsx(NoSSR, { children: _jsx(Login, {}) }));
@@ -1,3 +1,4 @@
1
- export declare const Markdown: ({ children }: {
1
+ export declare const Markdown: ({ children, inline, }: {
2
2
  children?: string;
3
+ inline?: boolean;
3
4
  }) => "" | import("react/jsx-runtime").JSX.Element | undefined;
@@ -7,4 +7,14 @@ import remarkGfm from 'remark-gfm';
7
7
  import { X } from './_X.js';
8
8
  const remarkPlugins = [remarkGfm];
9
9
  const rehypePlugins = [rehypeRaw, rehypeSanitize];
10
- export const Markdown = ({ children }) => children && (_jsx(ReactMarkdown, { remarkPlugins: remarkPlugins, rehypePlugins: rehypePlugins, components: X, children: children }));
10
+ const rehypeUnwrap = () => (tree) => {
11
+ if (tree.children.length !== 1) {
12
+ return;
13
+ }
14
+ const child = tree.children[0];
15
+ if (child.type === 'element' && child.tagName === 'p') {
16
+ tree.children = child.children;
17
+ }
18
+ };
19
+ const inlineRehypePlugins = [rehypeRaw, rehypeUnwrap, rehypeSanitize];
20
+ export const Markdown = ({ children, inline, }) => children && (_jsx(ReactMarkdown, { remarkPlugins: remarkPlugins, rehypePlugins: inline ? inlineRehypePlugins : rehypePlugins, components: X, children: children }));
@@ -3,5 +3,5 @@ export interface TermProps {
3
3
  name: TermName;
4
4
  textCase?: 'lower' | 'upper' | 'capitalize';
5
5
  }
6
- export declare const Term: ({ name, textCase }: TermProps) => string;
6
+ export declare const Term: ({ name, textCase }: TermProps) => import("react/jsx-runtime").JSX.Element;
7
7
  export default Term;
@@ -1,7 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import { capitalize } from 'es-toolkit';
2
3
  import { useMemo } from 'react';
3
4
  import { useSiteOverrides } from '../hooks/index.js';
4
5
  import { handleCJKWhitespaces } from '../utils.js';
6
+ import { Markdown } from './Markdown.js';
5
7
  export const Term = ({ name, textCase }) => {
6
8
  const { terms } = useSiteOverrides();
7
9
  const text = useMemo(() => {
@@ -24,6 +26,6 @@ export const Term = ({ name, textCase }) => {
24
26
  }
25
27
  }
26
28
  }, [terms, name, textCase]);
27
- return text;
29
+ return _jsx(Markdown, { inline: true, children: text });
28
30
  };
29
31
  export default Term;
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { namedTermItems } from '../../terms.js';
3
3
  import { useTranslation } from '../hooks/index.js';
4
+ import { Markdown } from './Markdown.js';
4
5
  import { X } from './_X.js';
5
6
  export const TermsTable = ({ terms }) => {
6
7
  const t = useTranslation();
@@ -8,7 +9,7 @@ export const TermsTable = ({ terms }) => {
8
9
  const withName = normalized.some(({ name }) => name);
9
10
  const renderBadCases = (list) => list?.length ? (_jsx(X.ul, { children: list.map((item, index) => (
10
11
  // eslint-disable-next-line @eslint-react/no-array-index-key
11
- _jsx(X.li, { children: item }, index))) })) : ('-');
12
- return (_jsxs(X.table, { children: [_jsx("thead", { children: _jsxs(X.tr, { children: [withName && _jsx(X.th, { children: t('name') }), _jsx(X.th, { children: t('chinese') }), _jsx(X.th, { children: t('chinese_bad_cases') }), _jsx(X.th, { children: t('english') }), _jsx(X.th, { children: t('english_bad_cases') }), _jsx(X.th, { children: t('description') })] }) }), _jsx("tbody", { children: normalized.map((term, index) => (_jsxs(X.tr, { children: [withName && _jsx(X.td, { children: term.name || '-' }), _jsx(X.td, { children: term.zh || term.en }), _jsx(X.td, { children: renderBadCases(term.badCases?.zh) }), _jsx(X.td, { children: term.en }), _jsx(X.td, { children: renderBadCases(term.badCases?.en) }), _jsx(X.td, { children: term.description || '-' })] }, term.name || index))) })] }));
12
+ _jsx(X.li, { children: _jsx(Markdown, { children: item }) }, index))) })) : ('-');
13
+ return (_jsxs(X.table, { children: [_jsx("thead", { children: _jsxs(X.tr, { children: [withName && _jsx(X.th, { children: t('name') }), _jsx(X.th, { children: t('chinese') }), _jsx(X.th, { children: t('chinese_bad_cases') }), _jsx(X.th, { children: t('english') }), _jsx(X.th, { children: t('english_bad_cases') }), _jsx(X.th, { children: t('description') })] }) }), _jsx("tbody", { children: normalized.map((term, index) => (_jsxs(X.tr, { children: [withName && _jsx(X.td, { children: term.name || '-' }), _jsx(X.td, { children: _jsx(Markdown, { children: term.zh || term.en }) }), _jsx(X.td, { children: renderBadCases(term.badCases?.zh) }), _jsx(X.td, { children: _jsx(Markdown, { children: term.en }) }), _jsx(X.td, { children: renderBadCases(term.badCases?.en) }), _jsx(X.td, { children: term.description ? _jsx(Markdown, { children: term.description }) : '-' })] }, term.name || index))) })] }));
13
14
  };
14
15
  export default TermsTable;
package/lib/terms.d.ts CHANGED
@@ -25,6 +25,10 @@ declare const terms: {
25
25
  readonly en: "ACP";
26
26
  readonly description: "产品品牌简称";
27
27
  };
28
+ readonly alaudaCloudLink: {
29
+ readonly en: "[Alauda Cloud](https://cloud.alauda.io)";
30
+ readonly zh: "[Alauda Cloud](https://cloud.alauda.cn)";
31
+ };
28
32
  };
29
33
  export type TermName = keyof typeof terms;
30
34
  export type NamedTerms = Record<TermName, TermItem>;
package/lib/terms.js CHANGED
@@ -13,6 +13,10 @@ const terms = {
13
13
  en: 'ACP',
14
14
  description: '产品品牌简称',
15
15
  },
16
+ alaudaCloudLink: {
17
+ en: '[Alauda Cloud](https://cloud.alauda.io)',
18
+ zh: '[Alauda Cloud](https://cloud.alauda.cn)',
19
+ },
16
20
  };
17
21
  export const namedTerms = terms;
18
22
  export const namedTermItems = Object.keys(terms).map((name_) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "1.15.2",
3
+ "version": "1.16.1",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": {
@@ -67,7 +67,6 @@
67
67
  "globals": "^16.4.0",
68
68
  "html-tag-names": "^2.1.0",
69
69
  "jsencrypt": "^3.5.4",
70
- "md-attr-parser": "^1.3.0",
71
70
  "mdast-util-mdx": "^3.0.0",
72
71
  "mdast-util-mdx-jsx": "^3.2.0",
73
72
  "mdast-util-phrasing": "^4.1.0",
@@ -16,32 +16,24 @@ body:has(.container) :global {
16
16
  .container {
17
17
  padding: 100px 0 200px;
18
18
  background: no-repeat 0 100px;
19
- background-image: var(--login-bg);
20
19
  }
21
20
 
22
21
  :root {
23
22
  &:global(.dark) {
24
- .container {
25
- background-image: var(--login-bg-dark);
26
- }
27
-
28
23
  .login-form {
29
- --login-form-bg: #434652;
30
- --login-form-shadow: 0 3px 5px #000;
24
+ background-color: #434652;
25
+ box-shadow: 0 3px 5px #000;
31
26
  }
32
27
  }
33
28
  }
34
29
 
35
30
  .login-form {
36
- --login-form-bg: #fefefe;
37
- --login-form-shadow: 0 0 8px #3c3c3c4a;
38
-
39
31
  margin-left: auto;
40
32
  padding: 40px 60px;
41
33
  width: min(452px, 100%);
42
34
  border-radius: 4px;
43
- box-shadow: var(--login-form-shadow);
44
- background-color: var(--login-form-bg);
35
+ background-color: #fefefe;
36
+ box-shadow: 0 0 8px #3c3c3c4a;
45
37
  }
46
38
 
47
39
  .title {
@@ -1,2 +0,0 @@
1
- import type { RspressPlugin } from '@rspress/core';
2
- export declare const attributesPlugin: () => RspressPlugin;
@@ -1,9 +0,0 @@
1
- import { remarkAttributes } from "./remark-attributes/index.js";
2
- export const attributesPlugin = () => {
3
- return {
4
- name: 'doom-attributes',
5
- markdown: {
6
- remarkPlugins: [remarkAttributes],
7
- },
8
- };
9
- };
@@ -1,14 +0,0 @@
1
- import type { Node, Root } from 'mdast';
2
- export interface Attrs extends Node {
3
- type: 'attrs';
4
- value?: string | null;
5
- }
6
- declare module 'mdast' {
7
- interface PhrasingContentMap {
8
- attrs: Attrs;
9
- }
10
- interface RootContentMap {
11
- attrs: Attrs;
12
- }
13
- }
14
- export declare function attributesTransformer(root: Root): void;
@@ -1,63 +0,0 @@
1
- import parseAttrs from 'md-attr-parser';
2
- import { visit } from 'unist-util-visit';
3
- export function attributesTransformer(root) {
4
- visit(root, 'paragraph', (node, _, parent) => {
5
- if ('children' in node &&
6
- node.children.length === 1 &&
7
- node.children[0].type === 'attrs') {
8
- const children = parent.children;
9
- const index = children.indexOf(node);
10
- children[index] = node.children[0];
11
- }
12
- });
13
- visit(root, (node, _, parent) => node.type === 'paragraph' && parent?.type === 'listItem', (node, _, parent) => {
14
- const { children } = node;
15
- const ids = Object.entries(children)
16
- .filter(([, child]) => child.type === 'attrs')
17
- .map(([id, node]) => [Number.parseInt(id, 10), node]);
18
- if (ids.length === 0) {
19
- return;
20
- }
21
- for (const [index, attrNode] of ids) {
22
- const sibling = children[index - 1];
23
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
24
- if (sibling?.type === 'text' && parent) {
25
- const data = parent.data;
26
- parent.data = {
27
- ...data,
28
- hProperties: {
29
- ...data?.hProperties,
30
- ...parseAttrs(attrNode.value).prop,
31
- },
32
- };
33
- children.splice(index, 1);
34
- }
35
- }
36
- });
37
- visit(root, 'attrs', (node, index, parent) => {
38
- if (index == null || parent == null || parent.children.length <= 1) {
39
- return;
40
- }
41
- const { children } = parent;
42
- const sibling = children.at(index - 1);
43
- if (!sibling || sibling.type === 'text') {
44
- parent.data = {
45
- ...parent.data,
46
- hProperties: {
47
- ...parent.data?.hProperties,
48
- ...parseAttrs(node.value).prop,
49
- },
50
- };
51
- }
52
- else {
53
- sibling.data = {
54
- ...sibling.data,
55
- hProperties: {
56
- ...sibling.data?.hProperties,
57
- ...parseAttrs(node.value).prop,
58
- },
59
- };
60
- }
61
- children.splice(index, 1);
62
- });
63
- }
@@ -1,9 +0,0 @@
1
- import type { Root } from 'mdast';
2
- import type { Extension as FromMarkdownExtension } from 'mdast-util-from-markdown';
3
- import type { Plugin } from 'unified';
4
- import type { AttributesExtension } from './types.ts';
5
- export interface AttributesData {
6
- micromarkExtensions?: AttributesExtension[];
7
- fromMarkdownExtensions?: FromMarkdownExtension[];
8
- }
9
- export declare const remarkAttributes: Plugin<[], Root>;
@@ -1,13 +0,0 @@
1
- import { attributesTransformer } from "./attributes-transformer.js";
2
- import { mdastAttributes } from "./mdast-attributes.js";
3
- import { micromarkAttributes } from "./micromark-attributes.js";
4
- export const remarkAttributes = function () {
5
- const data = this.data();
6
- function add(key, value) {
7
- data[key] ||= [];
8
- data[key].unshift(value);
9
- }
10
- add('micromarkExtensions', micromarkAttributes());
11
- add('fromMarkdownExtensions', mdastAttributes());
12
- return attributesTransformer;
13
- };
@@ -1,5 +0,0 @@
1
- import type { Extension as FromMarkdownExtension } from 'mdast-util-from-markdown';
2
- /**
3
- * Fully-configured extension to add Heading ID nodes to Markdown.
4
- **/
5
- export declare function mdastAttributes(): FromMarkdownExtension;
@@ -1,21 +0,0 @@
1
- /**
2
- * Fully-configured extension to add Heading ID nodes to Markdown.
3
- **/
4
- export function mdastAttributes() {
5
- return {
6
- enter: {
7
- attrs(token) {
8
- this.enter({ type: 'attrs', value: null }, token);
9
- this.buffer();
10
- },
11
- },
12
- exit: {
13
- attrs(token) {
14
- const attrs = this.resume();
15
- const node = this.stack[this.stack.length - 1];
16
- this.exit(token);
17
- node.value = attrs;
18
- },
19
- },
20
- };
21
- }
@@ -1,4 +0,0 @@
1
- import type { AttributesExtension } from './types.js';
2
- export declare function micromarkAttributes(options?: {
3
- escaped: boolean;
4
- }): AttributesExtension;
@@ -1,169 +0,0 @@
1
- import { codes } from 'micromark-util-symbol';
2
- export function micromarkAttributes(options = { escaped: false }) {
3
- const syntaxExtensionEscaped = {
4
- text: {
5
- [codes.backslash]: {
6
- name: 'attributesEscapedMaybeStart',
7
- tokenize(effects, ok, stop) {
8
- return start;
9
- function start(code) {
10
- return effects.attempt({
11
- tokenize(effects, startOk, startNok) {
12
- return attemptStart;
13
- function attemptStart(code) {
14
- if (code !== null) {
15
- effects.consume(code);
16
- return dive;
17
- }
18
- }
19
- function dive(code) {
20
- if (code === codes.backslash) {
21
- effects.consume(code);
22
- effects.enter('chunkString', { contentType: 'string' });
23
- return effects.attempt({
24
- tokenize(effects, diveOk, diveNok) {
25
- return escapedBraces;
26
- function escapedBraces(code) {
27
- if (code === codes.backslash) {
28
- effects.consume(code);
29
- return braces;
30
- }
31
- return diveNok(code);
32
- }
33
- function braces(code) {
34
- if (code === codes.leftCurlyBrace ||
35
- code === codes.rightCurlyBrace) {
36
- effects.consume(code);
37
- effects.exit('chunkString');
38
- return diveOk(code);
39
- }
40
- return diveNok(code);
41
- }
42
- },
43
- }, startOk, dive);
44
- }
45
- if (code === codes.leftCurlyBrace) {
46
- effects.enter('attributes');
47
- effects.consume(code);
48
- effects.enter('attrs');
49
- effects.enter('chunkString', { contentType: 'string' });
50
- return inside;
51
- }
52
- if (code !== null) {
53
- return startNok;
54
- }
55
- }
56
- function continueFurtherInside(code) {
57
- effects.consume(code);
58
- return inside;
59
- }
60
- function inside(code) {
61
- // skip `#` which is used heading id in rspress
62
- if (code === codes.numberSign) {
63
- return startNok(code);
64
- }
65
- if ([
66
- codes.carriageReturn,
67
- codes.lineFeed,
68
- codes.carriageReturnLineFeed,
69
- ].includes(code)) {
70
- effects.consume(code);
71
- return startNok(code);
72
- }
73
- if (code === codes.backslash) {
74
- return effects.attempt({
75
- tokenize(effects, insideOk, insideNok) {
76
- return attemptBackslash;
77
- function attemptBackslash(code) {
78
- if (code === codes.backslash) {
79
- effects.exit('chunkString');
80
- effects.exit('attrs');
81
- effects.consume(code);
82
- return endBrace;
83
- }
84
- }
85
- function endBrace(code) {
86
- if (code === codes.rightCurlyBrace) {
87
- effects.consume(code);
88
- effects.exit('attributes');
89
- return insideOk(code);
90
- }
91
- if (code === codes.backslash) {
92
- effects.consume(code);
93
- return insideNok(code);
94
- }
95
- if (code !== null) {
96
- effects.consume(code);
97
- return insideNok(code);
98
- }
99
- throw new Error(`No closing attribute brace found`);
100
- }
101
- },
102
- }, startOk, continueFurtherInside)(code);
103
- }
104
- if (code !== null) {
105
- effects.consume(code);
106
- return inside;
107
- }
108
- }
109
- },
110
- }, ok, stop)(code);
111
- }
112
- },
113
- },
114
- },
115
- };
116
- const syntaxExtension = {
117
- text: {
118
- [codes.leftCurlyBrace]: {
119
- name: 'attributesMaybeStart',
120
- tokenize(effects, ok, nok) {
121
- return start;
122
- function start(code) {
123
- return effects.attempt({
124
- tokenize(effects, ok, nok) {
125
- return attemptStart;
126
- function attemptStart(code) {
127
- if (code !== null) {
128
- effects.enter('attributes');
129
- effects.consume(code);
130
- effects.enter('attrs');
131
- effects.enter('chunkString', { contentType: 'string' });
132
- return inside;
133
- }
134
- }
135
- function inside(code) {
136
- if (code !== null) {
137
- if ([
138
- codes.carriageReturn,
139
- codes.lineFeed,
140
- codes.carriageReturnLineFeed,
141
- null,
142
- codes.backslash,
143
- codes.leftCurlyBrace,
144
- ].includes(code)) {
145
- effects.consume(code);
146
- return nok(code);
147
- }
148
- if (code === codes.rightCurlyBrace) {
149
- effects.exit('chunkString');
150
- effects.exit('attrs');
151
- effects.consume(code);
152
- effects.exit('attributes');
153
- return ok(code);
154
- }
155
- effects.consume(code);
156
- return inside;
157
- }
158
- return nok(code);
159
- }
160
- },
161
- }, ok, nok)(code);
162
- }
163
- },
164
- previous: (code) => code !== codes.backslash,
165
- },
166
- },
167
- };
168
- return options.escaped ? syntaxExtensionEscaped : syntaxExtension;
169
- }
@@ -1,80 +0,0 @@
1
- import type { Construct, Effects, Extension, State, Token, TokenizeContext, TokenType } from 'micromark-util-types';
2
- export type AttributesTokenType = TokenType | 'attributes' | 'attrs';
3
- /**
4
- * Open a token.
5
- *
6
- * @param type
7
- * Token type.
8
- * @param fields
9
- * Extra fields.
10
- * @returns
11
- * Token.
12
- */
13
- export type AttributesEnter = (type: AttributesTokenType, fields?: Omit<Partial<Token>, 'type'>) => Token;
14
- /**
15
- * Close a token.
16
- *
17
- * @param type
18
- * Token type.
19
- * @returns
20
- * Token.
21
- */
22
- export type AttributesExit = (type: AttributesTokenType) => Token;
23
- /**
24
- * Attempt deals with several values, and tries to parse according to those
25
- * values.
26
- *
27
- * If a value resulted in `ok`, it worked, the tokens that were made are used,
28
- * and `ok` is switched to.
29
- * If the result is `nok`, the attempt failed, so we revert to the original
30
- * state, and `nok` is used.
31
- *
32
- * @param construct
33
- * Construct(s) to try.
34
- * @param ok
35
- * State to move to when successful.
36
- * @param nok
37
- * State to move to when unsuccessful.
38
- * @returns
39
- * Next state.
40
- */
41
- export type AttributesAttempt = (construct: AttributesConstruct[] | AttributesConstruct | AttributesConstructRecord, ok: State, nok?: State) => State;
42
- export type AttributeEffects = {
43
- /**
44
- * Start a new token.
45
- */
46
- enter: AttributesEnter;
47
- /**
48
- * End a started token.
49
- */
50
- exit: AttributesExit;
51
- /**
52
- * Try to tokenize a construct.
53
- */
54
- attempt: AttributesAttempt;
55
- } & Effects;
56
- /**
57
- * A tokenize function sets up a state machine to handle character codes streaming in.
58
- *
59
- * @param this
60
- * Tokenize context.
61
- * @param effects
62
- * Effects.
63
- * @param ok
64
- * State to go to when successful.
65
- * @param nok
66
- * State to go to when unsuccessful.
67
- * @returns
68
- * First state.
69
- */
70
- export type AttributesTokenizer = (this: TokenizeContext, effects: AttributeEffects, ok: State, nok: State) => State;
71
- export interface AttributesExtension extends Omit<Extension, 'text'> {
72
- text?: AttributesConstructRecord;
73
- }
74
- /**
75
- * Several constructs, mapped from their initial codes.
76
- */
77
- export type AttributesConstructRecord = Record<string, AttributesConstruct[] | AttributesConstruct | undefined>;
78
- export interface AttributesConstruct extends Omit<Construct, 'tokenize'> {
79
- tokenize?: AttributesTokenizer;
80
- }
@@ -1 +0,0 @@
1
- export {};