@rspress/core 2.0.0-rc.3 → 2.0.0-rc.5

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.
Files changed (168) hide show
  1. package/dist/{0~7675.723d12b2.js → 0~7675.4468968d.js} +4 -4
  2. package/dist/1820.985588a0.js +5 -0
  3. package/dist/{3521.56e42d70.js → 5341.9eb6b114.js} +12 -12
  4. package/dist/{5485.077f14ff.js → 5485.b9ce9bdf.js} +5 -5
  5. package/dist/6289.29817fb4.js +4 -0
  6. package/dist/8813.4b28f4bb.js +1 -0
  7. package/dist/_private/react/render.js +1 -1
  8. package/dist/cli/config/loadConfigFile.js +2 -2
  9. package/dist/cli/index.44f3184c.js +2 -0
  10. package/dist/cli/index.js +3 -3
  11. package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
  12. package/dist/eject-theme/components/FallbackHeading/index.tsx +4 -0
  13. package/dist/eject-theme/components/HomeBackground/useNavTransparent.tsx +2 -1
  14. package/dist/eject-theme/components/HomeHero/index.scss +8 -0
  15. package/dist/eject-theme/components/HomeHero/index.tsx +11 -2
  16. package/dist/eject-theme/components/HoverGroup/index.scss +3 -2
  17. package/dist/eject-theme/components/HoverGroup/index.tsx +104 -22
  18. package/dist/eject-theme/components/Nav/NavMenu.scss +1 -1
  19. package/dist/eject-theme/components/Nav/NavMenu.tsx +50 -28
  20. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +26 -11
  21. package/dist/eject-theme/components/Overview/index.tsx +11 -0
  22. package/dist/eject-theme/components/OverviewGroup/index.tsx +46 -0
  23. package/dist/eject-theme/components/Steps/index.scss +1 -0
  24. package/dist/index.js +6 -11
  25. package/dist/node/PluginDriver.js +3 -3
  26. package/dist/node/auto-nav-sidebar/index.js +3 -3
  27. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  28. package/dist/node/auto-nav-sidebar/normalize.js +2 -2
  29. package/dist/node/auto-nav-sidebar/utils.js +2 -2
  30. package/dist/node/auto-nav-sidebar/walk.js +13 -9
  31. package/dist/node/constants.js +2 -2
  32. package/dist/node/eject.js +2 -5
  33. package/dist/node/initRsbuild.js +14 -9
  34. package/dist/node/last-updated/index.js +1 -1
  35. package/dist/node/logger/hint.js +1 -1
  36. package/dist/node/mdx/loader.7c249a26.js +12 -0
  37. package/dist/node/mdx/options.js +3 -3
  38. package/dist/node/mdx/processor.js +2 -2
  39. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  40. package/dist/node/mdx/rehypePlugins/headerAnchor.js +4 -4
  41. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  42. package/dist/node/mdx/rehypePlugins/transformers/index.js +5 -5
  43. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  44. package/dist/node/mdx/remarkPlugins/containerSyntax.js +1 -1
  45. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +3 -3
  46. package/dist/node/mdx/remarkPlugins/image.js +2 -3
  47. package/dist/node/mdx/remarkPlugins/link.js +3 -3
  48. package/dist/node/mdx/remarkPlugins/toc.js +3 -3
  49. package/dist/node/medium-zoom/index.js +1 -1
  50. package/dist/node/route/RoutePage.js +1 -1
  51. package/dist/node/route/RouteService.js +3 -3
  52. package/dist/node/route/extractPageData.js +4 -5
  53. package/dist/node/route/normalizeRoutePath.js +2 -2
  54. package/dist/node/runtimeModule/i18n.js +2 -2
  55. package/dist/node/runtimeModule/pageData/createPageData.js +2 -2
  56. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  57. package/dist/node/runtimeModule/searchHooks.js +1 -1
  58. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  59. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  60. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  61. package/dist/node/serve.js +1 -1
  62. package/dist/node/ssg/renderPage.js +2 -2
  63. package/dist/node/ssg/renderPageWorker.165b5d46.js +1 -0
  64. package/dist/node/ssg/renderPageWorker.js +2 -2
  65. package/dist/node/ssg/renderPages.js +3 -3
  66. package/dist/node/ssg/rsbuildPluginSSG.js +2 -2
  67. package/dist/node/ssg/ssgEnv.js +1 -1
  68. package/dist/node/ssg-md/llms/emitLlmsTxt.js +9 -7
  69. package/dist/node/ssg-md/llms/llmsTxt.js +2 -2
  70. package/dist/node/ssg-md/remarkSplitMdx.js +2 -2
  71. package/dist/node/ssg-md/renderPage.js +2 -2
  72. package/dist/node/ssg-md/renderPages.js +2 -2
  73. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +2 -2
  74. package/dist/node/utils/checkLanguageParity.js +1 -1
  75. package/dist/node/utils/createHash.js +1 -1
  76. package/dist/node/utils/error.js +1 -1
  77. package/dist/node/utils/flattenMdxContent.js +4 -5
  78. package/dist/node/utils/fs.js +1 -1
  79. package/dist/node/utils/getPageKey.js +1 -1
  80. package/dist/node/utils/normalizePath.js +3 -3
  81. package/dist/node/utils/reactAlias.js +2 -2
  82. package/dist/runtime/App.js +4 -2
  83. package/dist/runtime/Content.d.ts +4 -0
  84. package/dist/runtime/Content.js +18 -0
  85. package/dist/runtime/NoSSR.d.ts +3 -0
  86. package/dist/runtime/NoSSR.js +14 -0
  87. package/dist/runtime/getSidebarDataGroup.test.js +68 -0
  88. package/dist/runtime/hooks/useActiveMatcher.d.ts +1 -0
  89. package/dist/runtime/hooks/useActiveMatcher.js +14 -0
  90. package/dist/runtime/hooks/useDark.d.ts +7 -0
  91. package/dist/runtime/hooks/useDark.js +7 -0
  92. package/dist/runtime/hooks/useFrontmatter.d.ts +4 -0
  93. package/dist/runtime/hooks/useFrontmatter.js +9 -0
  94. package/dist/runtime/hooks/useI18n.d.ts +2 -0
  95. package/dist/runtime/hooks/useI18n.js +14 -0
  96. package/dist/runtime/hooks/useLang.d.ts +1 -0
  97. package/dist/runtime/hooks/useLang.js +6 -0
  98. package/dist/runtime/hooks/useLocaleSiteData.d.ts +18 -0
  99. package/dist/runtime/hooks/useLocaleSiteData.js +20 -0
  100. package/dist/runtime/hooks/useNav.d.ts +1 -0
  101. package/dist/runtime/hooks/useNav.js +12 -0
  102. package/dist/runtime/hooks/usePage.d.ts +10 -0
  103. package/dist/runtime/hooks/usePage.js +9 -0
  104. package/dist/runtime/hooks/usePageData.d.ts +5 -0
  105. package/dist/runtime/hooks/usePageData.js +16 -0
  106. package/dist/runtime/hooks/usePages.d.ts +4 -0
  107. package/dist/runtime/hooks/usePages.js +7 -0
  108. package/dist/runtime/hooks/useSidebar.d.ts +16 -0
  109. package/dist/runtime/hooks/useSidebar.js +67 -0
  110. package/dist/runtime/hooks/useSite.d.ts +4 -0
  111. package/dist/runtime/hooks/useSite.js +7 -0
  112. package/dist/runtime/hooks/useVersion.d.ts +1 -0
  113. package/dist/runtime/hooks/useVersion.js +6 -0
  114. package/dist/runtime/hooks/useWindowSize.d.ts +9 -0
  115. package/dist/runtime/hooks/useWindowSize.js +31 -0
  116. package/dist/runtime/hooks/useWindowSize.test.js +36 -0
  117. package/dist/runtime/index.d.ts +21 -0
  118. package/dist/runtime/index.js +22 -0
  119. package/dist/runtime/route.d.ts +36 -0
  120. package/dist/runtime/route.js +53 -0
  121. package/dist/runtime/route.test.js +154 -0
  122. package/dist/runtime/ssrMdServerEntry.js +1 -1
  123. package/dist/runtime/utils.d.ts +12 -0
  124. package/dist/runtime/utils.js +34 -0
  125. package/dist/runtime/utils.test.js +34 -0
  126. package/dist/shiki-transformers.js +2 -2
  127. package/dist/theme/components/CodeBlock/index.js +1 -1
  128. package/dist/theme/components/FallbackHeading/index.js +4 -1
  129. package/dist/theme/components/HomeBackground/useNavTransparent.js +1 -1
  130. package/dist/theme/components/HomeHero/index.css +6 -0
  131. package/dist/theme/components/HomeHero/index.js +10 -3
  132. package/dist/theme/components/HoverGroup/index.css +3 -2
  133. package/dist/theme/components/HoverGroup/index.js +88 -17
  134. package/dist/theme/components/Nav/NavMenu.css +1 -1
  135. package/dist/theme/components/Nav/NavMenu.d.ts +6 -1
  136. package/dist/theme/components/Nav/NavMenu.js +47 -45
  137. package/dist/theme/components/NavScreen/NavScreenMenuItem.d.ts +1 -1
  138. package/dist/theme/components/NavScreen/NavScreenMenuItem.js +21 -11
  139. package/dist/theme/components/Overview/index.js +12 -1
  140. package/dist/theme/components/OverviewGroup/index.js +33 -0
  141. package/dist/theme/components/Steps/index.css +1 -0
  142. package/dist/theme/index.d.ts +1 -1
  143. package/dist/theme/index.js +1 -1
  144. package/dist/theme/layout/DocLayout/index.js +10 -0
  145. package/dist/theme/layout/HomeLayout/index.js +40 -0
  146. package/dist/theme/layout/Layout/index.js +10 -6
  147. package/dist/theme/logic/useScrollAfterNav.js +2 -2
  148. package/dist/theme/logic/useScrollReset.js +2 -2
  149. package/dist/theme/logic/useStorageValue.js +6 -3
  150. package/dist/theme/logic/{useAppearance.d.ts → useThemeState.d.ts} +4 -1
  151. package/dist/theme/logic/useThemeState.js +50 -0
  152. package/dist/theme/styles/scrollbar.css +14 -2
  153. package/dist/theme/styles/vars/base-vars.css +2 -2
  154. package/dist/theme/styles/vars/code-vars.css +2 -2
  155. package/nav-json-schema.json +2 -2
  156. package/package.json +10 -11
  157. package/static/MediumZoom.tsx +1 -1
  158. package/dist/4669.12208c6a.js +0 -2
  159. package/dist/6289.c67fe0d5.js +0 -5
  160. package/dist/8813.9da1f210.js +0 -2
  161. package/dist/9643.f109822d.js +0 -5
  162. package/dist/cli/index.cb89dbd1.js +0 -3
  163. package/dist/node/mdx/loader.e1578c62.js +0 -13
  164. package/dist/node/ssg/renderPageWorker.474f9f73.js +0 -2
  165. package/dist/runtime.72d450ac.js +0 -1
  166. package/dist/runtime.d.ts +0 -2
  167. package/dist/runtime.js +0 -4
  168. package/dist/theme/logic/useAppearance.js +0 -64
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "2.0.0-rc.3",
3
+ "version": "2.0.0-rc.5",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -35,8 +35,8 @@
35
35
  "default": "./dist/theme/index.js"
36
36
  },
37
37
  "./runtime": {
38
- "types": "./dist/runtime.d.ts",
39
- "default": "./dist/runtime.js"
38
+ "types": "./dist/runtime/index.d.ts",
39
+ "default": "./dist/runtime/index.js"
40
40
  },
41
41
  "./shiki-transformers": {
42
42
  "types": "./dist/shiki-transformers.d.ts",
@@ -63,12 +63,12 @@
63
63
  "dependencies": {
64
64
  "@mdx-js/mdx": "^3.1.1",
65
65
  "@mdx-js/react": "^3.1.1",
66
- "@rsbuild/core": "~1.6.15",
66
+ "@rsbuild/core": "~1.7.1",
67
67
  "@rsbuild/plugin-react": "~1.4.2",
68
68
  "@rspress/mdx-rs": "0.6.6",
69
69
  "@shikijs/rehype": "^3.20.0",
70
70
  "@types/unist": "^3.0.3",
71
- "@unhead/react": "^2.0.19",
71
+ "@unhead/react": "^2.1.1",
72
72
  "body-scroll-lock": "4.0.0-beta.0",
73
73
  "cac": "^6.7.14",
74
74
  "chokidar": "^3.6.0",
@@ -102,14 +102,13 @@
102
102
  "unified": "^11.0.5",
103
103
  "unist-util-visit": "^5.0.0",
104
104
  "unist-util-visit-children": "^3.0.0",
105
- "@rspress/runtime": "2.0.0-rc.3",
106
- "@rspress/shared": "2.0.0-rc.3"
105
+ "@rspress/shared": "2.0.0-rc.5"
107
106
  },
108
107
  "devDependencies": {
109
108
  "@microsoft/api-extractor": "^7.55.2",
110
109
  "@rsbuild/plugin-sass": "~1.4.0",
111
110
  "@rsbuild/plugin-svgr": "^1.2.3",
112
- "@rslib/core": "0.18.5",
111
+ "@rslib/core": "0.19.1",
113
112
  "@types/body-scroll-lock": "^3.1.2",
114
113
  "@types/hast": "^3.0.4",
115
114
  "@types/html-to-text": "^9.0.4",
@@ -120,7 +119,7 @@
120
119
  "@types/react": "^19.2.7",
121
120
  "@types/react-dom": "^19.2.3",
122
121
  "@types/react-reconciler": "^0.32.3",
123
- "@types/web": "^0.0.306",
122
+ "@types/web": "^0.0.312",
124
123
  "execa": "8.0.1",
125
124
  "mdast-util-directive": "^3.1.0",
126
125
  "mdast-util-mdx-expression": "^2.0.1",
@@ -137,14 +136,14 @@
137
136
  "@rspress/config": "1.0.0"
138
137
  },
139
138
  "engines": {
140
- "node": ">=18.0.0"
139
+ "node": ">=20.9.0"
141
140
  },
142
141
  "publishConfig": {
143
142
  "access": "public",
144
143
  "registry": "https://registry.npmjs.org/"
145
144
  },
146
145
  "scripts": {
147
- "build": "rslib build",
146
+ "build": "node ./scripts/generateJsonSchema.mjs && rslib build",
148
147
  "dev": "rslib build -w",
149
148
  "reset": "rimraf ./**/node_modules"
150
149
  }
@@ -1,4 +1,4 @@
1
- import { useLocation } from '@rspress/runtime';
1
+ import { useLocation } from '@rspress/core/runtime';
2
2
  import mediumZoom, { type Zoom, type ZoomOptions } from 'medium-zoom';
3
3
  import { useEffect } from 'react';
4
4
  import './MediumZoom.css';
@@ -1,2 +0,0 @@
1
- import { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeHref, parseUrl, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
2
- export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeHref, parseUrl, removeLeadingSlash, removeTrailingSlash, slash, withBase };
@@ -1,5 +0,0 @@
1
- import { logger } from "@rspress/shared/logger";
2
- import node_path, { extname, join, relative } from "node:path";
3
- import promises, { mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
4
- import picocolors from "picocolors";
5
- export { extname, join, logger, mkdir, node_path, picocolors, promises, readFile, readdir, relative, rm, stat, writeFile };
@@ -1,2 +0,0 @@
1
- import { visit } from "unist-util-visit";
2
- export { visit };
@@ -1,5 +0,0 @@
1
- import { extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter } from "@rspress/shared/node-utils";
2
- import node_os, { constants } from "node:os";
3
- import node_process, { cwd } from "node:process";
4
- import { createProcessor, nodeTypes } from "@mdx-js/mdx";
5
- export { constants, createProcessor, cwd, extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter, nodeTypes, node_os, node_process };
@@ -1,3 +0,0 @@
1
- import { cac } from "cac";
2
- import chokidar from "chokidar";
3
- export { cac, chokidar };
@@ -1,13 +0,0 @@
1
- import rehype from "@shikijs/rehype";
2
- import rehype_external_links from "rehype-external-links";
3
- import rehype_raw from "rehype-raw";
4
- import remark_gfm from "remark-gfm";
5
- import remark_mdx from "remark-mdx";
6
- import remark_stringify from "remark-stringify";
7
- import { unified } from "unified";
8
- import github_slugger from "github-slugger";
9
- import { headingRank } from "hast-util-heading-rank";
10
- import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddWrapCode } from "@rspress/core/shiki-transformers";
11
- import { createCssVariablesTheme } from "shiki";
12
- import { visitChildren } from "unist-util-visit-children";
13
- export { createCssVariablesTheme, github_slugger, headingRank, rehype, rehype_external_links, rehype_raw, remark_gfm, remark_mdx, remark_stringify, transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddWrapCode, unified, visitChildren };
@@ -1,2 +0,0 @@
1
- import { workerData } from "node:worker_threads";
2
- export { workerData };
@@ -1 +0,0 @@
1
- import "@rspress/runtime";
package/dist/runtime.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from '@rspress/runtime';
2
- export { isDataUrl, isExternalUrl, matchNavbar, matchSidebar, normalizeHref, } from '@rspress/shared';
package/dist/runtime.js DELETED
@@ -1,4 +0,0 @@
1
- import "./runtime.72d450ac.js";
2
- import "./4669.12208c6a.js";
3
- export * from "@rspress/runtime";
4
- export { isDataUrl, isExternalUrl, matchNavbar, matchSidebar, normalizeHref } from "@rspress/shared";
@@ -1,64 +0,0 @@
1
- import { useSite } from "@rspress/core/runtime";
2
- import { useCallback, useEffect, useState } from "react";
3
- import { useHandler } from "./useHandler.js";
4
- import { useMediaQuery } from "./useMediaQuery.js";
5
- import { useStorageValue } from "./useStorageValue.js";
6
- const APPEARANCE_KEY = 'rspress-theme-appearance';
7
- const sanitize = (value)=>[
8
- 'light',
9
- 'dark',
10
- 'auto'
11
- ].includes(value) ? value : 'auto';
12
- const useThemeState = ()=>{
13
- const matchesDark = useMediaQuery('(prefers-color-scheme: dark)');
14
- const [storedTheme, setStoredTheme] = useStorageValue(APPEARANCE_KEY, 'auto');
15
- const { site } = useSite();
16
- const disableDarkMode = false === site.themeConfig.darkMode;
17
- const getPreferredTheme = useHandler(()=>{
18
- if (disableDarkMode) return 'light';
19
- const sanitized = sanitize(storedTheme);
20
- return 'auto' === sanitized ? matchesDark ? 'dark' : 'light' : sanitized;
21
- });
22
- const [theme, setThemeInternal] = useState(()=>{
23
- if ("u" < typeof window) return 'light';
24
- const defaultTheme = window.RSPRESS_THEME ?? window.MODERN_THEME;
25
- if (defaultTheme) return 'dark' === defaultTheme ? 'dark' : 'light';
26
- return getPreferredTheme();
27
- });
28
- const setTheme = useCallback((value, storeValue = value)=>{
29
- if (disableDarkMode) return;
30
- setThemeInternal(value);
31
- setStoredTheme(storeValue);
32
- setSkipEffect(true);
33
- }, []);
34
- useEffect(()=>{
35
- document.documentElement.classList.toggle('dark', 'dark' === theme);
36
- document.documentElement.classList.toggle('rp-dark', 'dark' === theme);
37
- document.documentElement.style.colorScheme = theme;
38
- }, [
39
- theme
40
- ]);
41
- const [skipEffect, setSkipEffect] = useState(true);
42
- useEffect(()=>{
43
- setSkipEffect(false);
44
- }, [
45
- skipEffect
46
- ]);
47
- useEffect(()=>{
48
- if (skipEffect) return;
49
- setTheme(getPreferredTheme(), sanitize(storedTheme));
50
- }, [
51
- storedTheme
52
- ]);
53
- useEffect(()=>{
54
- if (skipEffect) return;
55
- setTheme(matchesDark ? 'dark' : 'light', 'auto');
56
- }, [
57
- matchesDark
58
- ]);
59
- return [
60
- theme,
61
- setTheme
62
- ];
63
- };
64
- export { useThemeState };