@rspress/core 2.1.0 → 2.1.2
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/dist/b~0.js +1 -0
- package/dist/eject-theme/components/CodeBlockRuntime/index.tsx +2 -0
- package/dist/eject-theme/components/Llms/LlmsOpenRow.tsx +14 -3
- package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +18 -2
- package/dist/eject-theme/components/Prompt/index.scss +8 -0
- package/dist/eject-theme/components/Search/useSearchPanel.ts +85 -81
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +10 -7
- package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +2 -2
- package/dist/eject-theme/components/SwitchAppearance/global.scss +26 -0
- package/dist/eject-theme/components/SwitchAppearance/index.tsx +46 -35
- package/dist/node/mdx/rehypePlugins/shiki.js +2 -2
- package/dist/node/mdx/rehypePlugins/transformers/meta-highlight.d.ts +1 -1
- package/dist/node/runtimeModule/i18n/DEFAULT_I18N_TEXT.d.ts +463 -0
- package/dist/node/runtimeModule/i18n/DEFAULT_I18N_TEXT.js +497 -34
- package/dist/shiki-transformers.d.ts +4 -0
- package/dist/shiki-transformers.js +18 -0
- package/dist/theme/assets/markdown.js +22 -0
- package/dist/theme/components/CodeBlockRuntime/index.js +3 -1
- package/dist/theme/components/Llms/LlmsOpenRow.js +11 -2
- package/dist/theme/components/Llms/LlmsViewOptions.d.ts +4 -2
- package/dist/theme/components/Llms/LlmsViewOptions.js +14 -2
- package/dist/theme/components/Prompt/index.css +12 -0
- package/dist/theme/components/Search/useSearchPanel.js +66 -65
- package/dist/theme/components/Sidebar/SidebarItem.css +9 -11
- package/dist/theme/components/Sidebar/SidebarItem.js +2 -2
- package/dist/theme/components/SwitchAppearance/global.css +22 -0
- package/dist/theme/components/SwitchAppearance/index.js +35 -27
- package/dist/theme/hooks/useWebMcpNavigation.d.ts +1 -1
- package/dist/theme/hooks/useWebMcpPageList.d.ts +1 -1
- package/dist/theme/hooks/useWebMcpPageReading.d.ts +1 -1
- package/dist/theme/hooks/useWebMcpPageReading.js +2 -2
- package/dist/theme/hooks/useWebMcpSiteInfo.d.ts +1 -1
- package/dist/theme/icons.d.ts +5 -0
- package/dist/theme/icons.js +3 -1
- package/dist/theme/logic/useStorageValue.d.ts +2 -1
- package/dist/theme/logic/useStorageValue.js +50 -34
- package/dist/theme/styles/shiki.css +8 -0
- package/dist/theme/webMcp/tools.js +1 -1
- package/dist/tx~0.js +1 -1
- package/dist/y~0.js +1 -1
- package/package.json +6 -5
package/dist/theme/icons.js
CHANGED
|
@@ -20,6 +20,7 @@ import jsdelivr from "./assets/jsdelivr.js";
|
|
|
20
20
|
import jump from "./assets/jump.js";
|
|
21
21
|
import assets_link from "./assets/link.js";
|
|
22
22
|
import loading from "./assets/loading.js";
|
|
23
|
+
import markdown from "./assets/markdown.js";
|
|
23
24
|
import menu from "./assets/menu.js";
|
|
24
25
|
import moon from "./assets/moon.js";
|
|
25
26
|
import npm from "./assets/npm.js";
|
|
@@ -56,6 +57,7 @@ const IconHeader = header;
|
|
|
56
57
|
const IconJsdelivr = jsdelivr;
|
|
57
58
|
const IconJump = jump;
|
|
58
59
|
const IconLoading = loading;
|
|
60
|
+
const IconMarkdown = markdown;
|
|
59
61
|
const IconMenu = menu;
|
|
60
62
|
const IconMoon = moon;
|
|
61
63
|
const IconNpm = npm;
|
|
@@ -72,4 +74,4 @@ const IconWrap = wrap;
|
|
|
72
74
|
const IconWrapped = wrapped;
|
|
73
75
|
const IconYarn = yarn;
|
|
74
76
|
const IconLink = assets_link;
|
|
75
|
-
export { IconAnthropic, IconArrowDown, IconArrowRight, IconBun, IconClose, IconCopy, IconDeno, IconDeprecated, IconDown, IconEdit, IconEmpty, IconExperimental, IconExternalLink, IconFile, IconGithub, IconGitlab, IconHeader, IconJsdelivr, IconJump, IconLink, IconLoading, IconMenu, IconMoon, IconNpm, IconOpenAI, IconOpenInChat, IconPnpm, IconScrollToTop, IconSearch, IconSmallMenu, IconSuccess, IconSun, IconTitle, IconUnpkg, IconWrap, IconWrapped, IconYarn };
|
|
77
|
+
export { IconAnthropic, IconArrowDown, IconArrowRight, IconBun, IconClose, IconCopy, IconDeno, IconDeprecated, IconDown, IconEdit, IconEmpty, IconExperimental, IconExternalLink, IconFile, IconGithub, IconGitlab, IconHeader, IconJsdelivr, IconJump, IconLink, IconLoading, IconMarkdown, IconMenu, IconMoon, IconNpm, IconOpenAI, IconOpenInChat, IconPnpm, IconScrollToTop, IconSearch, IconSmallMenu, IconSuccess, IconSun, IconTitle, IconUnpkg, IconWrap, IconWrapped, IconYarn };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
export type StorageAction<T> = T | ((prevState: T) => T);
|
|
1
2
|
/**
|
|
2
3
|
* Read/update the value in localStorage, and keeping it in sync with other tabs.
|
|
3
4
|
* @internal
|
|
4
5
|
*/
|
|
5
|
-
export declare const useStorageValue: <T>(key: string, defaultValue: T) => readonly [T, (
|
|
6
|
+
export declare const useStorageValue: <T>(key: string, defaultValue: T) => readonly [T, (action: StorageAction<T>) => void];
|
|
@@ -1,50 +1,66 @@
|
|
|
1
|
-
import { useCallback,
|
|
1
|
+
import { useCallback, useSyncExternalStore } from "react";
|
|
2
2
|
const SYNC_STORAGE_EVENT_NAME = 'RSPRESS_SYNC_STORAGE_EVENT_NAME';
|
|
3
|
+
const getStorageItem = (key)=>{
|
|
4
|
+
if ("u" < typeof window) return null;
|
|
5
|
+
try {
|
|
6
|
+
return window.localStorage.getItem(key);
|
|
7
|
+
} catch {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const setStorageItem = (key, value)=>{
|
|
12
|
+
if ("u" < typeof window) return;
|
|
13
|
+
try {
|
|
14
|
+
if (null == value) window.localStorage.removeItem(key);
|
|
15
|
+
else window.localStorage.setItem(key, value);
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.warn(`[useStorageValue] Failed to set localStorage key "${key}":`, error);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
3
20
|
const useStorageValue = (key, defaultValue)=>{
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
21
|
+
const subscribe = useCallback((onStoreChange)=>{
|
|
22
|
+
const handleStorage = (event)=>{
|
|
23
|
+
if (event.key === key || null === event.key) onStoreChange();
|
|
24
|
+
};
|
|
25
|
+
const handleCustomEvent = (event)=>{
|
|
26
|
+
const customEvent = event;
|
|
27
|
+
if (customEvent.detail?.key === key) onStoreChange();
|
|
28
|
+
};
|
|
29
|
+
window.addEventListener('storage', handleStorage);
|
|
30
|
+
window.addEventListener(SYNC_STORAGE_EVENT_NAME, handleCustomEvent);
|
|
31
|
+
return ()=>{
|
|
32
|
+
window.removeEventListener('storage', handleStorage);
|
|
33
|
+
window.removeEventListener(SYNC_STORAGE_EVENT_NAME, handleCustomEvent);
|
|
34
|
+
};
|
|
9
35
|
}, [
|
|
10
36
|
key
|
|
11
37
|
]);
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
38
|
+
const getSnapshot = useCallback(()=>{
|
|
39
|
+
const raw = getStorageItem(key);
|
|
40
|
+
return null !== raw ? raw : defaultValue;
|
|
41
|
+
}, [
|
|
42
|
+
key,
|
|
43
|
+
defaultValue
|
|
44
|
+
]);
|
|
45
|
+
const getServerSnapshot = useCallback(()=>defaultValue, [
|
|
46
|
+
defaultValue
|
|
47
|
+
]);
|
|
48
|
+
const value = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
49
|
+
const setValue = useCallback((action)=>{
|
|
50
|
+
const currentStored = getStorageItem(key);
|
|
51
|
+
const currentValue = null !== currentStored ? currentStored : defaultValue;
|
|
52
|
+
const nextValue = 'function' == typeof action ? action(currentValue) : action;
|
|
53
|
+
null == nextValue ? setStorageItem(key, null) : setStorageItem(key, String(nextValue));
|
|
54
|
+
if ("u" > typeof window) window.dispatchEvent(new CustomEvent(SYNC_STORAGE_EVENT_NAME, {
|
|
18
55
|
detail: {
|
|
19
56
|
key,
|
|
20
|
-
newValue:
|
|
57
|
+
newValue: nextValue
|
|
21
58
|
}
|
|
22
59
|
}));
|
|
23
|
-
}, [
|
|
24
|
-
key
|
|
25
|
-
]);
|
|
26
|
-
useEffect(()=>{
|
|
27
|
-
const listener = (e)=>{
|
|
28
|
-
if (e.key === key) setValueInternal(localStorage.getItem(key) ?? defaultValue);
|
|
29
|
-
};
|
|
30
|
-
window.addEventListener('storage', listener);
|
|
31
|
-
return ()=>{
|
|
32
|
-
window.removeEventListener('storage', listener);
|
|
33
|
-
};
|
|
34
60
|
}, [
|
|
35
61
|
key,
|
|
36
62
|
defaultValue
|
|
37
63
|
]);
|
|
38
|
-
useEffect(()=>{
|
|
39
|
-
const listener = (e)=>{
|
|
40
|
-
const { key: eventKey, newValue } = e.detail;
|
|
41
|
-
if (eventKey === key) setValueInternal(newValue ?? defaultValue);
|
|
42
|
-
};
|
|
43
|
-
window.addEventListener(SYNC_STORAGE_EVENT_NAME, listener);
|
|
44
|
-
return ()=>{
|
|
45
|
-
window.removeEventListener(SYNC_STORAGE_EVENT_NAME, listener);
|
|
46
|
-
};
|
|
47
|
-
}, []);
|
|
48
64
|
return [
|
|
49
65
|
value,
|
|
50
66
|
setValue
|
package/dist/tx~0.js
CHANGED
|
@@ -13,5 +13,5 @@ export { unified } from "unified";
|
|
|
13
13
|
export { visit } from "unist-util-visit";
|
|
14
14
|
export { default as github_slugger } from "@rspress/shared/github-slugger";
|
|
15
15
|
export { headingRank } from "hast-util-heading-rank";
|
|
16
|
-
export { transformerAddFold, transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddWrapCode } from "@rspress/core/shiki-transformers";
|
|
16
|
+
export { getShikiTransformers, transformerAddFold, transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddWrapCode } from "@rspress/core/shiki-transformers";
|
|
17
17
|
export { createCssVariablesTheme } from "shiki";
|
package/dist/y~0.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -62,8 +62,9 @@
|
|
|
62
62
|
"@mdx-js/react": "^3.1.1",
|
|
63
63
|
"@rsbuild/core": "^2.2.14",
|
|
64
64
|
"@rsbuild/plugin-react": "~2.1.1",
|
|
65
|
-
"@rspress/shared": "2.1.
|
|
65
|
+
"@rspress/shared": "2.1.2",
|
|
66
66
|
"@shikijs/rehype": "^4.2.0",
|
|
67
|
+
"@shikijs/transformers": "^4.2.0",
|
|
67
68
|
"@types/mdast": "^4.0.4",
|
|
68
69
|
"@types/react": "^19.3.0",
|
|
69
70
|
"@unhead/react": "^2.1.17",
|
|
@@ -84,8 +85,8 @@
|
|
|
84
85
|
"react-router-dom": "^7.18.5",
|
|
85
86
|
"rehype-external-links": "^3.0.0",
|
|
86
87
|
"rehype-raw": "^7.0.0",
|
|
87
|
-
"remark-cjk-friendly": "^2.3.
|
|
88
|
-
"remark-cjk-friendly-gfm-strikethrough": "^2.3.
|
|
88
|
+
"remark-cjk-friendly": "^2.3.4",
|
|
89
|
+
"remark-cjk-friendly-gfm-strikethrough": "^2.3.3",
|
|
89
90
|
"remark-gfm": "^4.0.1",
|
|
90
91
|
"remark-mdx": "^3.1.1",
|
|
91
92
|
"remark-parse": "^11.0.0",
|
|
@@ -107,7 +108,7 @@
|
|
|
107
108
|
"@types/node": "^22.8.1",
|
|
108
109
|
"@types/nprogress": "^0.2.3",
|
|
109
110
|
"@types/react-dom": "^19.3.0",
|
|
110
|
-
"@types/web": "^0.0.
|
|
111
|
+
"@types/web": "^0.0.362",
|
|
111
112
|
"cac": "^7.1.0",
|
|
112
113
|
"execa": "8.0.1",
|
|
113
114
|
"mdast-util-directive": "^3.1.1",
|