@alauda/doom 2.5.1 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/index.js +1 -1
- package/lib/remark-lint/index.d.ts +1 -0
- package/lib/remark-lint/index.js +1 -0
- package/lib/remark-lint/no-legacy-os-names.d.ts +2 -0
- package/lib/remark-lint/no-legacy-os-names.js +51 -0
- package/lib/remarkrc.js +2 -1
- package/lib/theme/CodeBlock.d.ts +1 -0
- package/lib/theme/CodeBlock.js +64 -2
- package/package.json +13 -13
package/lib/cli/index.js
CHANGED
|
@@ -85,7 +85,7 @@ program
|
|
|
85
85
|
cwd: CWD,
|
|
86
86
|
});
|
|
87
87
|
let isRestarting = false;
|
|
88
|
-
cliWatcher.on('all', async (eventName, filepath) => {
|
|
88
|
+
cliWatcher.on('all', async (...[eventName, filepath]) => {
|
|
89
89
|
console.log(eventName, filepath);
|
|
90
90
|
if (eventName === 'add' ||
|
|
91
91
|
eventName === 'unlink' ||
|
|
@@ -13,6 +13,7 @@ export * from './no-empty-table-cell.ts';
|
|
|
13
13
|
export * from './no-heading-punctuation.ts';
|
|
14
14
|
export * from './no-heading-special-characters.ts';
|
|
15
15
|
export * from './no-heading-sup-sub.ts';
|
|
16
|
+
export * from './no-legacy-os-names.ts';
|
|
16
17
|
export * from './no-multi-open-api-paths.ts';
|
|
17
18
|
export * from './no-paragraph-indent.ts';
|
|
18
19
|
export * from './no-unmatched-anchor.ts';
|
package/lib/remark-lint/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export * from "./no-empty-table-cell.js";
|
|
|
12
12
|
export * from "./no-heading-punctuation.js";
|
|
13
13
|
export * from "./no-heading-special-characters.js";
|
|
14
14
|
export * from "./no-heading-sup-sub.js";
|
|
15
|
+
export * from "./no-legacy-os-names.js";
|
|
15
16
|
export * from "./no-multi-open-api-paths.js";
|
|
16
17
|
export * from "./no-paragraph-indent.js";
|
|
17
18
|
export * from "./no-unmatched-anchor.js";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { lintRule } from 'unified-lint-rule';
|
|
2
|
+
import { visitParents } from 'unist-util-visit-parents';
|
|
3
|
+
const LEGACY_OS_NAME_REGEX = /(?<![\p{L}\p{N}])(?:micro\s*os|micros|kube\s*os)(?![\p{L}\p{N}])/giu;
|
|
4
|
+
const isStringValueNode = (node) => !!node &&
|
|
5
|
+
typeof node === 'object' &&
|
|
6
|
+
'value' in node &&
|
|
7
|
+
typeof node.value === 'string';
|
|
8
|
+
const reportLegacyOSNames = (value, report) => {
|
|
9
|
+
for (const { 0: legacyName } of value.matchAll(LEGACY_OS_NAME_REGEX)) {
|
|
10
|
+
report(legacyName);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const createMessage = (legacyName) => `Unexpected legacy OS name "${legacyName}", use "Alauda OS" or "alauda os" instead`;
|
|
14
|
+
const getAttributeStringValue = (value) => {
|
|
15
|
+
if (typeof value === 'string') {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
return value.value;
|
|
19
|
+
};
|
|
20
|
+
export const noLegacyOSNames = lintRule('doom-lint:no-legacy-os-names', (root, vfile) => {
|
|
21
|
+
visitParents(root, (node, parents) => {
|
|
22
|
+
if (!isStringValueNode(node)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
reportLegacyOSNames(node.value, (legacyName) => {
|
|
26
|
+
vfile.message(createMessage(legacyName), {
|
|
27
|
+
ancestors: [...parents, node],
|
|
28
|
+
place: node.position,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
visitParents(root, ['mdxJsxFlowElement', 'mdxJsxTextElement'], (element, parents) => {
|
|
33
|
+
for (const attribute of element.attributes) {
|
|
34
|
+
if (attribute.type !== 'mdxJsxAttribute' ||
|
|
35
|
+
typeof attribute.value === 'boolean' ||
|
|
36
|
+
attribute.value == null) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const value = getAttributeStringValue(attribute.value);
|
|
40
|
+
if (value == null) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
reportLegacyOSNames(value, (legacyName) => {
|
|
44
|
+
vfile.message(createMessage(legacyName), {
|
|
45
|
+
ancestors: [...parents, element],
|
|
46
|
+
place: attribute.position,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
package/lib/remarkrc.js
CHANGED
|
@@ -10,7 +10,7 @@ import remarkLintLintMatchPunctuation from 'remark-lint-match-punctuation';
|
|
|
10
10
|
import remarkLintNoChinesePunctuationInNumber from 'remark-lint-no-chinese-punctuation-in-number';
|
|
11
11
|
import remarkLintNoDuplicateHeadingsInSection from 'remark-lint-no-duplicate-headings-in-section';
|
|
12
12
|
import remarkLintNoHiddenTableCell from 'remark-lint-no-hidden-table-cell';
|
|
13
|
-
import doomLint, { checkDeadLinks, headingAnchorFormat, noDeepHeading, noDeepList, noMultiOpenAPIPaths, noParagraphIndent, noUnmatchedAnchor, site, tableSize, titleRequired, unitCase, } from "./remark-lint/index.js";
|
|
13
|
+
import doomLint, { checkDeadLinks, headingAnchorFormat, noDeepHeading, noDeepList, noLegacyOSNames, noMultiOpenAPIPaths, noParagraphIndent, noUnmatchedAnchor, site, tableSize, titleRequired, unitCase, } from "./remark-lint/index.js";
|
|
14
14
|
export default {
|
|
15
15
|
plugins: [
|
|
16
16
|
remarkDirective,
|
|
@@ -27,6 +27,7 @@ export default {
|
|
|
27
27
|
headingAnchorFormat,
|
|
28
28
|
noDeepHeading,
|
|
29
29
|
noDeepList,
|
|
30
|
+
noLegacyOSNames,
|
|
30
31
|
noMultiOpenAPIPaths,
|
|
31
32
|
noParagraphIndent,
|
|
32
33
|
noUnmatchedAnchor,
|
package/lib/theme/CodeBlock.d.ts
CHANGED
package/lib/theme/CodeBlock.js
CHANGED
|
@@ -1,4 +1,66 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { CodeBlock as OriginalCodeBlock, } from '@rspress/core/theme-original';
|
|
2
|
+
import { CodeBlock as OriginalCodeBlock, copyToClipboard, } from '@rspress/core/theme-original';
|
|
3
|
+
import { useCallback } from 'react';
|
|
3
4
|
import { AutoExpandable } from './AutoExpandable.js';
|
|
4
|
-
|
|
5
|
+
const COPIED_CLASS = 'rp-code-copy-button--copied';
|
|
6
|
+
const COPY_IGNORE_SELECTOR = '.rp-copy-ignore, .linenumber';
|
|
7
|
+
const timeoutIdMap = new WeakMap();
|
|
8
|
+
const getCopySourceElement = (codeBlockElement) => codeBlockElement?.querySelector('pre code') ??
|
|
9
|
+
codeBlockElement?.querySelector('code') ??
|
|
10
|
+
codeBlockElement?.querySelector('pre') ??
|
|
11
|
+
null;
|
|
12
|
+
const removeIgnoredElements = (element) => {
|
|
13
|
+
for (const ignoredElement of element.querySelectorAll(COPY_IGNORE_SELECTOR)) {
|
|
14
|
+
ignoredElement.remove();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export const getCodeBlockCopyText = (codeBlockElement) => {
|
|
18
|
+
const sourceElement = getCopySourceElement(codeBlockElement);
|
|
19
|
+
if (!sourceElement) {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
const clonedSourceElement = sourceElement.cloneNode(true);
|
|
23
|
+
if (!(clonedSourceElement instanceof Element)) {
|
|
24
|
+
return sourceElement.textContent;
|
|
25
|
+
}
|
|
26
|
+
removeIgnoredElements(clonedSourceElement);
|
|
27
|
+
const lines = clonedSourceElement.querySelectorAll('.line');
|
|
28
|
+
if (lines.length) {
|
|
29
|
+
return Array.from(lines, (line) => line.textContent).join('\n');
|
|
30
|
+
}
|
|
31
|
+
return clonedSourceElement.textContent;
|
|
32
|
+
};
|
|
33
|
+
const markCopied = (copyButtonElement) => {
|
|
34
|
+
copyButtonElement.classList.add(COPIED_CLASS);
|
|
35
|
+
const timeoutId = timeoutIdMap.get(copyButtonElement);
|
|
36
|
+
if (timeoutId) {
|
|
37
|
+
clearTimeout(timeoutId);
|
|
38
|
+
}
|
|
39
|
+
timeoutIdMap.set(copyButtonElement, setTimeout(() => {
|
|
40
|
+
copyButtonElement.classList.remove(COPIED_CLASS);
|
|
41
|
+
copyButtonElement.blur();
|
|
42
|
+
timeoutIdMap.delete(copyButtonElement);
|
|
43
|
+
}, 2000));
|
|
44
|
+
};
|
|
45
|
+
const copyCodeBlock = async (codeBlockElement, copyButtonElement) => {
|
|
46
|
+
const text = getCodeBlockCopyText(codeBlockElement);
|
|
47
|
+
const isCopied = await copyToClipboard(text);
|
|
48
|
+
if (isCopied) {
|
|
49
|
+
markCopied(copyButtonElement);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export const CodeBlock = (props) => {
|
|
53
|
+
const onClickCapture = useCallback((event) => {
|
|
54
|
+
if (!(event.target instanceof Element)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const copyButtonElement = event.target.closest('.rp-code-copy-button');
|
|
58
|
+
if (!copyButtonElement) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
event.stopPropagation();
|
|
63
|
+
void copyCodeBlock(copyButtonElement.closest('.rp-codeblock'), copyButtonElement);
|
|
64
|
+
}, []);
|
|
65
|
+
return (_jsx(AutoExpandable, { children: _jsx("div", { onClickCapture: onClickCapture, children: _jsx(OriginalCodeBlock, { ...props }) }) }));
|
|
66
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": {
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@alauda/doc-stream-sdk": "0.1.0",
|
|
47
|
-
"@alauda/doom-export": "^0.4.
|
|
47
|
+
"@alauda/doom-export": "^0.4.2",
|
|
48
48
|
"@cspell/eslint-plugin": "^10.0.0",
|
|
49
|
-
"@eslint-react/eslint-plugin": "^5.
|
|
49
|
+
"@eslint-react/eslint-plugin": "^5.8.3",
|
|
50
50
|
"@eslint/js": "^10.0.1",
|
|
51
51
|
"@inquirer/prompts": "^8.4.3",
|
|
52
52
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
"@rsbuild/plugin-sass": "^1.5.2",
|
|
55
55
|
"@rsbuild/plugin-svgr": "^2.0.2",
|
|
56
56
|
"@rsbuild/plugin-yaml": "^1.0.4",
|
|
57
|
-
"@rspress/core": "2.0.
|
|
58
|
-
"@rspress/plugin-algolia": "2.0.
|
|
59
|
-
"@rspress/plugin-sitemap": "2.0.
|
|
60
|
-
"@rspress/shared": "2.0.
|
|
61
|
-
"@shikijs/transformers": "^4.0
|
|
57
|
+
"@rspress/core": "2.0.12",
|
|
58
|
+
"@rspress/plugin-algolia": "2.0.12",
|
|
59
|
+
"@rspress/plugin-sitemap": "2.0.12",
|
|
60
|
+
"@rspress/shared": "2.0.12",
|
|
61
|
+
"@shikijs/transformers": "^4.1.0",
|
|
62
62
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
63
|
-
"@types/react": "^19.2.
|
|
63
|
+
"@types/react": "^19.2.15",
|
|
64
64
|
"ab64": "^0.1.6",
|
|
65
65
|
"chokidar": "^5.0.0",
|
|
66
66
|
"clsx": "^2.1.1",
|
|
67
67
|
"commander": "^14.0.3",
|
|
68
68
|
"ejs": "^5.0.2",
|
|
69
69
|
"es-toolkit": "^1.46.1",
|
|
70
|
-
"eslint": "^10.
|
|
70
|
+
"eslint": "^10.4.0",
|
|
71
71
|
"eslint-plugin-mdx": "^3.7.0",
|
|
72
72
|
"globals": "^17.6.0",
|
|
73
73
|
"hastscript": "^9.0.1",
|
|
@@ -80,13 +80,13 @@
|
|
|
80
80
|
"mdast-util-to-markdown": "^2.1.2",
|
|
81
81
|
"mdast-util-to-string": "^4.0.0",
|
|
82
82
|
"mermaid": "^11.15.0",
|
|
83
|
-
"openai": "^6.
|
|
83
|
+
"openai": "^6.38.0",
|
|
84
84
|
"openapi-types": "^12.1.3",
|
|
85
85
|
"p-ratelimit": "^1.0.1",
|
|
86
86
|
"picomatch": "^4.0.4",
|
|
87
87
|
"pluralize": "^8.0.0",
|
|
88
88
|
"react-markdown": "^10.1.0",
|
|
89
|
-
"react-tooltip": "^6.0.
|
|
89
|
+
"react-tooltip": "^6.0.3",
|
|
90
90
|
"rehype-raw": "^7.0.0",
|
|
91
91
|
"rehype-sanitize": "^6.0.0",
|
|
92
92
|
"remark-directive": "^4.0.0",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"tinyglobby": "^0.2.16",
|
|
108
108
|
"type-fest": "^5.6.0",
|
|
109
109
|
"typescript": "^6.0.3",
|
|
110
|
-
"typescript-eslint": "^8.59.
|
|
110
|
+
"typescript-eslint": "^8.59.4",
|
|
111
111
|
"unified": "^11.0.5",
|
|
112
112
|
"unified-lint-rule": "^3.0.1",
|
|
113
113
|
"unist-util-position": "^5.0.0",
|