@rspress/core 2.1.0-beta.1 → 2.1.0
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/cli/index.js +2 -2
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/CdnTabs/index.test.tsx +71 -0
- package/dist/eject-theme/components/CdnTabs/index.tsx +175 -0
- package/dist/eject-theme/components/DocContent/index.tsx +0 -3
- package/dist/eject-theme/components/FallbackHeading/index.tsx +6 -1
- package/dist/eject-theme/components/Link/index.tsx +9 -18
- package/dist/eject-theme/components/Link/useLinkNavigate.ts +17 -3
- package/dist/eject-theme/components/NavTitle/index.test.tsx +78 -0
- package/dist/eject-theme/components/NavTitle/index.tsx +9 -5
- package/dist/eject-theme/components/PackageManagerTabs/index.test.tsx +79 -1
- package/dist/eject-theme/components/PackageManagerTabs/index.tsx +25 -12
- package/dist/eject-theme/components/Search/NoSearchResult.scss +1 -2
- package/dist/eject-theme/components/Search/SearchPanel.scss +75 -63
- package/dist/eject-theme/components/Search/SuggestItem.scss +28 -41
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +8 -0
- package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.scss +3 -0
- package/dist/node/PluginDriver.d.ts +5 -0
- package/dist/node/PluginDriver.js +14 -5
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +1 -1
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/constants.js +1 -1
- package/dist/node/eject.js +1 -1
- package/dist/node/initRsbuild.js +12 -4
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -0
- package/dist/node/mdx/remarkPlugins/link.js +1 -1
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +1 -1
- package/dist/node/route/extractPageData.js +1 -1
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/{DEFAULT_I18N_TEXT.d.ts → i18n/DEFAULT_I18N_TEXT.d.ts} +34 -0
- package/dist/node/runtimeModule/{DEFAULT_I18N_TEXT.js → i18n/DEFAULT_I18N_TEXT.js} +68 -34
- package/dist/node/runtimeModule/i18n/getI18nData.d.ts +11 -0
- package/dist/node/runtimeModule/{i18n.js → i18n/getI18nData.js} +35 -22
- package/dist/node/runtimeModule/i18n/rsbuildPlugin.d.ts +5 -0
- package/dist/node/runtimeModule/i18n/rsbuildPlugin.js +21 -0
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.d.ts +2 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +3 -3
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.d.ts +2 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +3 -4
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +2 -2
- package/dist/node/serve.js +1 -1
- package/dist/node/sitemap.d.ts +7 -2
- package/dist/node/sitemap.js +40 -57
- package/dist/node/ssg/alternateLinks.js +1 -1
- package/dist/node/ssg/htmlFile.js +1 -1
- package/dist/node/ssg/renderHtmlTemplate.js +1 -1
- package/dist/node/ssg/renderPage.js +1 -1
- package/dist/node/ssg/renderPageWorker.js +1 -1
- package/dist/node/ssg/renderPages.js +2 -2
- package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
- package/dist/node/ssg-md/renderPage.js +1 -1
- package/dist/node/ssg-md/renderPages.js +2 -2
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/reactAlias.js +2 -2
- package/dist/{h~0.js → p~0.js} +6 -4
- package/dist/runtime/App.js +14 -10
- package/dist/runtime/BrowserOnly.d.ts +1 -1
- package/dist/runtime/BrowserOnly.js +53 -20
- package/dist/runtime/ClientApp.js +4 -0
- package/dist/runtime/NoSSR.d.ts +7 -3
- package/dist/runtime/NoSSR.js +30 -9
- package/dist/runtime/PageRoute.js +20 -8
- package/dist/runtime/index.d.ts +3 -2
- package/dist/runtime/index.js +3 -4
- package/dist/runtime/react.d.ts +5 -0
- package/dist/runtime/react.js +4 -0
- package/dist/runtime/reactDom.d.ts +6 -0
- package/dist/runtime/reactDom.js +2 -1
- package/dist/runtime/socialLinks.d.ts +1 -0
- package/dist/runtime/socialLinks.js +3 -0
- package/dist/theme/assets/bun.js +101 -0
- package/dist/theme/assets/deno.js +15 -0
- package/dist/theme/assets/jsdelivr.js +53 -0
- package/dist/theme/{components/PackageManagerTabs/icons/Npm.js → assets/npm.js} +4 -4
- package/dist/theme/{components/PackageManagerTabs/icons/Pnpm.js → assets/pnpm.js} +4 -4
- package/dist/theme/assets/unpkg.js +15 -0
- package/dist/theme/assets/yarn.js +22 -0
- package/dist/theme/components/CdnTabs/index.d.ts +10 -0
- package/dist/theme/components/CdnTabs/index.js +146 -0
- package/dist/theme/components/DocContent/index.js +1 -2
- package/dist/theme/components/FallbackHeading/index.js +1 -0
- package/dist/theme/components/Link/index.js +4 -13
- package/dist/theme/components/Link/useLinkNavigate.js +12 -4
- package/dist/theme/components/NavTitle/index.js +10 -5
- package/dist/theme/components/PackageManagerTabs/index.d.ts +2 -0
- package/dist/theme/components/PackageManagerTabs/index.js +22 -12
- package/dist/theme/components/Search/NoSearchResult.css +1 -2
- package/dist/theme/components/Search/SearchPanel.css +72 -51
- package/dist/theme/components/Search/SuggestItem.css +21 -34
- package/dist/theme/components/Sidebar/SidebarItem.css +5 -0
- package/dist/theme/components/Sidebar/SidebarSectionHeader.css +1 -0
- package/dist/theme/hooks/useDynamicToc.js +27 -34
- package/dist/theme/icons.d.ts +7 -0
- package/dist/theme/icons.js +15 -1
- package/dist/theme/index.d.ts +1 -2
- package/dist/theme/index.js +1 -2
- package/dist/theme/layout/Layout/index.js +1 -2
- package/dist/y~0.js +168 -0
- package/package.json +17 -17
- package/dist/b~0.js +0 -104
- package/dist/eject-theme/components/PackageManagerTabs/icons/Bun.tsx +0 -101
- package/dist/eject-theme/components/PackageManagerTabs/icons/Deno.tsx +0 -18
- package/dist/eject-theme/components/PackageManagerTabs/icons/Npm.tsx +0 -16
- package/dist/eject-theme/components/PackageManagerTabs/icons/Pnpm.tsx +0 -22
- package/dist/eject-theme/components/PackageManagerTabs/icons/Yarn.tsx +0 -18
- package/dist/node/runtimeModule/i18n.d.ts +0 -8
- package/dist/theme/components/PackageManagerTabs/icons/Bun.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Bun.js +0 -137
- package/dist/theme/components/PackageManagerTabs/icons/Deno.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Deno.js +0 -15
- package/dist/theme/components/PackageManagerTabs/icons/Npm.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Pnpm.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Yarn.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Yarn.js +0 -22
- package/dist/theme/logic/useScrollAfterNav.d.ts +0 -5
- package/dist/theme/logic/useScrollAfterNav.js +0 -35
- package/dist/theme/logic/useScrollReset.d.ts +0 -5
- package/dist/theme/logic/useScrollReset.js +0 -12
- package/dist/tu~0.js +0 -3
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
.rp-search-panel {
|
|
2
2
|
&__mask {
|
|
3
3
|
position: fixed;
|
|
4
|
-
|
|
5
|
-
top: 0;
|
|
6
|
-
right: 0;
|
|
7
|
-
bottom: 0;
|
|
4
|
+
inset: 0;
|
|
8
5
|
background: #3c3c3c66;
|
|
9
6
|
backdrop-filter: blur(5px);
|
|
10
7
|
// Keep the modal above the sticky banner (z-index: 999).
|
|
@@ -12,71 +9,109 @@
|
|
|
12
9
|
}
|
|
13
10
|
|
|
14
11
|
&__modal {
|
|
12
|
+
--rp-search-panel-top: min(80px, 10dvh);
|
|
13
|
+
|
|
15
14
|
position: relative;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
margin:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
height:
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
margin: calc(var(--rp-search-panel-top) + env(safe-area-inset-top, 0px))
|
|
18
|
+
auto auto;
|
|
19
|
+
width: calc(100% - 48px);
|
|
20
|
+
max-width: 640px;
|
|
21
|
+
max-height: calc(
|
|
22
|
+
100dvh - var(--rp-search-panel-top) -
|
|
23
|
+
24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)
|
|
24
|
+
);
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
border: 1px solid var(--rp-c-divider-light);
|
|
27
|
+
border-radius: 16px;
|
|
28
|
+
background-color: var(--rp-c-bg);
|
|
29
|
+
box-shadow: 0 16px 48px #0003;
|
|
23
30
|
animation: rp-search-panel-in 0.18s ease-out;
|
|
24
31
|
|
|
25
32
|
@media (prefers-reduced-motion: reduce) {
|
|
26
33
|
animation: none;
|
|
27
34
|
}
|
|
35
|
+
|
|
36
|
+
@media (max-width: 768px) {
|
|
37
|
+
--rp-search-panel-top: 24px;
|
|
38
|
+
|
|
39
|
+
width: calc(100% - 24px);
|
|
40
|
+
max-width: 560px;
|
|
41
|
+
}
|
|
28
42
|
}
|
|
29
43
|
|
|
30
44
|
&__header {
|
|
31
45
|
display: flex;
|
|
32
46
|
align-items: center;
|
|
47
|
+
flex-shrink: 0;
|
|
48
|
+
gap: 8px;
|
|
49
|
+
padding: 12px 20px;
|
|
50
|
+
|
|
51
|
+
@media (max-width: 768px) {
|
|
52
|
+
padding: 8px 12px;
|
|
53
|
+
}
|
|
33
54
|
}
|
|
34
55
|
|
|
35
56
|
&__cancel {
|
|
57
|
+
display: none;
|
|
36
58
|
color: var(--rp-c-brand);
|
|
37
|
-
margin-left: 0.5rem;
|
|
38
59
|
cursor: pointer;
|
|
39
|
-
// CJK cancel text
|
|
40
|
-
// by the 100%-width input form, keep it on one line.
|
|
60
|
+
// Keep CJK cancel text on one line when the input shrinks.
|
|
41
61
|
white-space: nowrap;
|
|
42
62
|
|
|
43
|
-
@media (
|
|
44
|
-
display:
|
|
63
|
+
@media (max-width: 768px) {
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
flex-shrink: 0;
|
|
67
|
+
min-height: 44px;
|
|
68
|
+
margin: 0;
|
|
69
|
+
padding: 0 4px;
|
|
70
|
+
font-size: 14px;
|
|
71
|
+
font-weight: 500;
|
|
45
72
|
}
|
|
46
73
|
}
|
|
47
74
|
|
|
48
75
|
&__input-form {
|
|
49
|
-
width: 100%;
|
|
50
|
-
height: 55px;
|
|
51
76
|
display: flex;
|
|
52
77
|
align-items: center;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
78
|
+
flex: 1;
|
|
79
|
+
min-width: 0;
|
|
80
|
+
height: 48px;
|
|
81
|
+
|
|
82
|
+
@media (max-width: 768px) {
|
|
83
|
+
height: 44px;
|
|
84
|
+
}
|
|
57
85
|
}
|
|
58
86
|
|
|
59
87
|
&__input {
|
|
60
88
|
flex: 1;
|
|
61
|
-
|
|
89
|
+
min-width: 0;
|
|
90
|
+
padding-left: 10px;
|
|
62
91
|
height: 100%;
|
|
63
|
-
width: 80%;
|
|
64
92
|
outline: none;
|
|
65
93
|
background-color: var(--rp-c-bg);
|
|
66
|
-
|
|
67
|
-
font-
|
|
94
|
+
color: var(--rp-c-text-1);
|
|
95
|
+
font-weight: 400;
|
|
96
|
+
font-size: 18px;
|
|
68
97
|
|
|
69
|
-
|
|
70
|
-
|
|
98
|
+
@media (max-width: 768px) {
|
|
99
|
+
font-size: 16px;
|
|
71
100
|
}
|
|
72
101
|
}
|
|
73
102
|
|
|
103
|
+
&__search-icon,
|
|
74
104
|
&__close {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
105
|
+
display: block;
|
|
106
|
+
width: 20px;
|
|
107
|
+
height: 20px;
|
|
108
|
+
color: var(--rp-c-text-2);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&__close:hover {
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
color: var(--rp-c-brand);
|
|
114
|
+
transition: color 0.3s;
|
|
80
115
|
}
|
|
81
116
|
|
|
82
117
|
&__search-icon--loading {
|
|
@@ -87,15 +122,12 @@
|
|
|
87
122
|
}
|
|
88
123
|
}
|
|
89
124
|
|
|
90
|
-
&__search-icon {
|
|
91
|
-
display: inline-block;
|
|
92
|
-
font-size: 20px;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
125
|
&__results {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
126
|
+
min-height: 0;
|
|
127
|
+
padding: 8px;
|
|
128
|
+
border-top: 1px solid var(--rp-c-divider-light);
|
|
129
|
+
overflow: auto;
|
|
130
|
+
overscroll-behavior: contain;
|
|
99
131
|
}
|
|
100
132
|
|
|
101
133
|
&__error {
|
|
@@ -106,7 +138,7 @@
|
|
|
106
138
|
|
|
107
139
|
&__tabs {
|
|
108
140
|
position: sticky;
|
|
109
|
-
background-color: var(--rp-c-bg
|
|
141
|
+
background-color: var(--rp-c-bg);
|
|
110
142
|
padding-bottom: 6px;
|
|
111
143
|
|
|
112
144
|
&.rp-tabs {
|
|
@@ -118,27 +150,7 @@
|
|
|
118
150
|
}
|
|
119
151
|
|
|
120
152
|
&__group {
|
|
121
|
-
padding-bottom:
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
@media (max-width: 960px) {
|
|
125
|
-
&__modal {
|
|
126
|
-
margin-top: calc(32px + env(safe-area-inset-top, 0px));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
&__input-form {
|
|
130
|
-
height: 40px;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
&__search-icon,
|
|
134
|
-
&__close {
|
|
135
|
-
width: 16px;
|
|
136
|
-
height: 16px;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
&__input {
|
|
140
|
-
font-size: 16px;
|
|
141
|
-
}
|
|
153
|
+
padding-bottom: 4px;
|
|
142
154
|
}
|
|
143
155
|
}
|
|
144
156
|
|
|
@@ -1,53 +1,15 @@
|
|
|
1
1
|
.rp-suggest-item {
|
|
2
2
|
list-style: none;
|
|
3
3
|
box-sizing: border-box;
|
|
4
|
-
margin:
|
|
4
|
+
margin: 4px 0;
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
.dark & .rp-suggest-item__link {
|
|
8
|
-
box-shadow: none;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
& .rp-suggest-item__link {
|
|
6
|
+
&__link {
|
|
12
7
|
color: var(--rp-c-text-1);
|
|
13
8
|
background-color: var(--rp-c-bg);
|
|
14
9
|
border-radius: var(--rp-radius-small);
|
|
15
10
|
padding-left: 12px;
|
|
16
11
|
display: flex;
|
|
17
12
|
width: 100%;
|
|
18
|
-
box-shadow: 0 1px 3px 0 #d4d9e1;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&--current {
|
|
22
|
-
.rp-suggest-item__link {
|
|
23
|
-
background-color: var(--rp-c-brand);
|
|
24
|
-
cursor: pointer;
|
|
25
|
-
color: #ffffff;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.rp-suggest-item__container {
|
|
29
|
-
.rp-suggest-item__icon {
|
|
30
|
-
color: #ffffff;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.rp-suggest-item__action-icon {
|
|
34
|
-
opacity: 1;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.rp-suggest-item__content {
|
|
38
|
-
.rp-suggest-item__statement {
|
|
39
|
-
color: #ffffff;
|
|
40
|
-
}
|
|
41
|
-
.rp-suggest-item__mark {
|
|
42
|
-
color: #ffffff;
|
|
43
|
-
text-decoration: underline;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.rp-suggest-item__title {
|
|
47
|
-
color: #ffffff;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
13
|
}
|
|
52
14
|
|
|
53
15
|
&__container {
|
|
@@ -64,7 +26,9 @@
|
|
|
64
26
|
}
|
|
65
27
|
|
|
66
28
|
&__content {
|
|
67
|
-
|
|
29
|
+
min-width: 0;
|
|
30
|
+
padding: 6px 8px;
|
|
31
|
+
overflow-wrap: anywhere;
|
|
68
32
|
font-size: 14px;
|
|
69
33
|
line-height: 1.5;
|
|
70
34
|
width: 100%;
|
|
@@ -92,4 +56,27 @@
|
|
|
92
56
|
&__action-icon {
|
|
93
57
|
opacity: 0;
|
|
94
58
|
}
|
|
59
|
+
|
|
60
|
+
&--current {
|
|
61
|
+
.rp-suggest-item__link {
|
|
62
|
+
background-color: var(--rp-c-brand);
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.rp-suggest-item__link,
|
|
67
|
+
.rp-suggest-item__icon,
|
|
68
|
+
.rp-suggest-item__statement,
|
|
69
|
+
.rp-suggest-item__mark,
|
|
70
|
+
.rp-suggest-item__title {
|
|
71
|
+
color: #fff;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.rp-suggest-item__mark {
|
|
75
|
+
text-decoration: underline;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.rp-suggest-item__action-icon {
|
|
79
|
+
opacity: 1;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
95
82
|
}
|
|
@@ -74,6 +74,14 @@
|
|
|
74
74
|
display: flex;
|
|
75
75
|
align-items: center;
|
|
76
76
|
gap: 4px;
|
|
77
|
+
// Long unbroken labels can make scrollIntoView on the active entry shift
|
|
78
|
+
// and clip its group: https://github.com/web-infra-dev/rspress/pull/3777
|
|
79
|
+
overflow-wrap: anywhere;
|
|
80
|
+
|
|
81
|
+
> .rp-doc code {
|
|
82
|
+
// Override inline code's own wrapping rule, also when nested in bold text.
|
|
83
|
+
overflow-wrap: anywhere;
|
|
84
|
+
}
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
&__icon {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TransformContext } from '@rsbuild/core';
|
|
1
2
|
import { type PageIndexInfo, type RouteMeta, type RspressPlugin, type UserConfig } from '@rspress/shared';
|
|
2
3
|
import type { RouteService } from './route/RouteService.js';
|
|
3
4
|
type RspressPluginHookKeys = 'beforeBuild' | 'config' | 'afterBuild' | 'addPages' | 'addRuntimeModules' | 'routeGenerated' | 'routeServiceGenerated' | 'extendPageData' | 'modifySearchIndexData' | 'i18nSource';
|
|
@@ -14,6 +15,10 @@ export declare class PluginDriver {
|
|
|
14
15
|
removePlugin(pluginName: string): void;
|
|
15
16
|
private normalizeConfig;
|
|
16
17
|
modifyConfig(): Promise<UserConfig>;
|
|
18
|
+
getI18nData(context?: Pick<TransformContext, 'addDependency' | 'addMissingDependency'>): Promise<{
|
|
19
|
+
[x: string]: Record<string, string>;
|
|
20
|
+
}>;
|
|
21
|
+
invalidateI18nData(): void;
|
|
17
22
|
beforeBuild(): Promise<void[]>;
|
|
18
23
|
afterBuild(): Promise<void[]>;
|
|
19
24
|
modifySearchIndexData(pages: PageIndexInfo[]): Promise<void[]>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { addTrailingSlash, node_path, addLeadingSlash } from "../
|
|
1
|
+
import { addTrailingSlash, node_path, addLeadingSlash } from "../p~0.js";
|
|
2
|
+
import { createI18nDataLoader } from "./runtimeModule/i18n/getI18nData.js";
|
|
2
3
|
import { createError } from "./utils/error.js";
|
|
3
4
|
import { haveNavSidebarConfig as auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
|
|
4
5
|
class PluginDriver {
|
|
5
6
|
#config;
|
|
6
7
|
#plugins;
|
|
7
8
|
#isProd;
|
|
9
|
+
#i18nData;
|
|
8
10
|
haveNavSidebarConfig = false;
|
|
9
11
|
static async create(config, configFilePathOrIsProd, isProd = false) {
|
|
10
12
|
if ('boolean' == typeof configFilePathOrIsProd) isProd = configFilePathOrIsProd;
|
|
@@ -16,6 +18,7 @@ class PluginDriver {
|
|
|
16
18
|
this.#config = config;
|
|
17
19
|
this.#isProd = isProd;
|
|
18
20
|
this.#plugins = [];
|
|
21
|
+
this.#i18nData = createI18nDataLoader(()=>this.#config, this);
|
|
19
22
|
}
|
|
20
23
|
async init() {
|
|
21
24
|
this.clearPlugins();
|
|
@@ -31,10 +34,6 @@ class PluginDriver {
|
|
|
31
34
|
const { pluginMediumZoom } = await import("./medium-zoom/index.js");
|
|
32
35
|
this.addPlugin(pluginMediumZoom('object' == typeof mediumZoomConfig ? mediumZoomConfig : void 0));
|
|
33
36
|
}
|
|
34
|
-
if (this.#isProd) {
|
|
35
|
-
const { pluginSitemap } = await import("./sitemap.js");
|
|
36
|
-
this.addPlugin(pluginSitemap());
|
|
37
|
-
}
|
|
38
37
|
(config.plugins || []).forEach((plugin)=>{
|
|
39
38
|
this.addPlugin(plugin);
|
|
40
39
|
});
|
|
@@ -60,17 +59,21 @@ class PluginDriver {
|
|
|
60
59
|
this.#config.llms ??= true;
|
|
61
60
|
this.#config.webMcp ??= true;
|
|
62
61
|
this.#config.sitemap ??= true;
|
|
62
|
+
this.#config.route ??= {};
|
|
63
|
+
this.#config.route.cleanUrls ??= true;
|
|
63
64
|
this.#config.base = addTrailingSlash(addLeadingSlash(this.#config.base ?? '/'));
|
|
64
65
|
this.#config.lang ??= 'en';
|
|
65
66
|
this.#config.themeDir ??= node_path.join(process.cwd(), 'theme');
|
|
66
67
|
}
|
|
67
68
|
async modifyConfig() {
|
|
69
|
+
this.invalidateI18nData();
|
|
68
70
|
this.normalizeConfig();
|
|
69
71
|
let config = this.#config;
|
|
70
72
|
for(let i = 0; i < this.#plugins.length; i++){
|
|
71
73
|
const plugin = this.#plugins[i];
|
|
72
74
|
if ('function' == typeof plugin.config) config = await plugin.config(config || {}, {
|
|
73
75
|
addPlugin: this.addPlugin.bind(this),
|
|
76
|
+
getI18nData: this.getI18nData.bind(this),
|
|
74
77
|
removePlugin: (pluginName)=>{
|
|
75
78
|
const index = this.#plugins.findIndex((item)=>item.name === pluginName);
|
|
76
79
|
this.removePlugin(pluginName);
|
|
@@ -82,6 +85,12 @@ class PluginDriver {
|
|
|
82
85
|
this.haveNavSidebarConfig = auto_nav_sidebar_haveNavSidebarConfig(config);
|
|
83
86
|
return this.#config;
|
|
84
87
|
}
|
|
88
|
+
getI18nData(context) {
|
|
89
|
+
return this.#i18nData.get(context);
|
|
90
|
+
}
|
|
91
|
+
invalidateI18nData() {
|
|
92
|
+
this.#i18nData.invalidate();
|
|
93
|
+
}
|
|
85
94
|
async beforeBuild() {
|
|
86
95
|
return this._runParallelAsyncHook('beforeBuild', this.#config || {}, this.#isProd);
|
|
87
96
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../
|
|
1
|
+
import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../p~0.js";
|
|
2
2
|
import { processLocales, combineWalkResult } from "./locales.js";
|
|
3
3
|
import { walk } from "./walk.js";
|
|
4
4
|
async function runAutoNavSide(config, metaFileSet, mdFileSet) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../t~0.js";
|
|
3
|
-
import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../
|
|
3
|
+
import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../p~0.js";
|
|
4
4
|
import { createError } from "../utils/error.js";
|
|
5
5
|
import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
|
|
6
6
|
import { absolutePathToRoutePath, addRoutePrefix } from "../route/RoutePage.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isExternalUrl, node_path, promises } from "../../
|
|
1
|
+
import { isExternalUrl, node_path, promises } from "../../p~0.js";
|
|
2
2
|
import { pathExists } from "../utils/fs.js";
|
|
3
3
|
import { readJson } from "./utils.js";
|
|
4
4
|
import { addRoutePrefix } from "../route/RoutePage.js";
|
package/dist/node/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isDarkModeSwitchEnabled, node_path, package_namespaceObject, getDefaultDarkModeValue, createRequire } from "../
|
|
1
|
+
import { isDarkModeSwitchEnabled, node_path, package_namespaceObject, getDefaultDarkModeValue, createRequire } from "../y~0.js";
|
|
2
2
|
const constants_require = createRequire(import.meta.url);
|
|
3
3
|
const RSPRESS_VERSION = package_namespaceObject.rE;
|
|
4
4
|
const APPEARANCE_KEY = 'rspress-theme-appearance';
|
package/dist/node/eject.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../rslib-runtime~0.js";
|
|
2
2
|
import "../t~0.js";
|
|
3
|
-
import { node_path, logger, promises } from "../
|
|
3
|
+
import { node_path, logger, promises } from "../p~0.js";
|
|
4
4
|
import { EJECTED_THEME } from "./constants.js";
|
|
5
5
|
const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
6
6
|
var picocolors_default = /*#__PURE__*/ compatGetDefaultExport(picocolors);
|
package/dist/node/initRsbuild.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../
|
|
1
|
+
import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../p~0.js";
|
|
2
2
|
import { createError } from "./utils/error.js";
|
|
3
3
|
import { CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, NODE_SSG_BUNDLE_FOLDER, getInlineLocaleRedirectScript, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, getInlineThemeScript, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
|
|
4
4
|
import { isLlmsUIEnabled, isLlmsHintEnabled } from "./llms.js";
|
|
5
5
|
import { RouteChunkAssetsPlugin } from "./route/routeChunkAssets.js";
|
|
6
6
|
import { hintBuilderPluginsBreakingChange, hintThemeBreakingChange } from "./logger/hint.js";
|
|
7
7
|
import { resolveReactRouterDomAlias, resolveReactRenderToMarkdownAlias, resolveReactAlias } from "./utils/reactAlias.js";
|
|
8
|
+
import { rsbuildPluginI18n } from "./runtimeModule/i18n/rsbuildPlugin.js";
|
|
8
9
|
import { rsbuildPluginDocVM } from "./runtimeModule/pageData/rsbuildPlugin.js";
|
|
9
10
|
import { socialLinksVMPlugin } from "./runtimeModule/socialLinks.js";
|
|
10
|
-
import { i18nVMPlugin } from "./runtimeModule/i18n.js";
|
|
11
11
|
import { globalUIComponentsVMPlugin } from "./runtimeModule/globalUIComponents.js";
|
|
12
12
|
import { globalStylesVMPlugin } from "./runtimeModule/globalStyles.js";
|
|
13
13
|
import { searchHookVMPlugin } from "./runtimeModule/searchHooks.js";
|
|
14
14
|
import { routeListVMPlugin } from "./runtimeModule/routeList.js";
|
|
15
15
|
import { siteDataVMPlugin } from "./runtimeModule/siteData/rsbuildPlugin.js";
|
|
16
|
+
import { rsbuildPluginSitemap } from "./sitemap.js";
|
|
16
17
|
import { rsbuildPluginSSG } from "./ssg/rsbuildPluginSSG.js";
|
|
17
18
|
import { rsbuildPluginCSR } from "./ssg/rsbuildPluginCSR.js";
|
|
18
19
|
import { rsbuildPluginSSGMD } from "./ssg-md/rsbuildPluginSSGMD.js";
|
|
19
|
-
import { package_namespaceObject } from "../
|
|
20
|
+
import { package_namespaceObject } from "../y~0.js";
|
|
20
21
|
function isPluginIncluded(config, pluginName) {
|
|
21
22
|
return Boolean(config.builderConfig?.plugins?.some((plugin)=>plugin && plugin.name === pluginName));
|
|
22
23
|
}
|
|
@@ -71,6 +72,9 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
71
72
|
...isPluginIncluded(config, PLUGIN_REACT_NAME) ? [] : [
|
|
72
73
|
pluginReact()
|
|
73
74
|
],
|
|
75
|
+
rsbuildPluginI18n({
|
|
76
|
+
pluginDriver
|
|
77
|
+
}),
|
|
74
78
|
rsbuildPluginDocVM({
|
|
75
79
|
config,
|
|
76
80
|
pluginDriver,
|
|
@@ -81,7 +85,6 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
81
85
|
tempDir: '.rspress/runtime',
|
|
82
86
|
virtualModules: {
|
|
83
87
|
...socialLinksVMPlugin(context),
|
|
84
|
-
...i18nVMPlugin(context),
|
|
85
88
|
...globalUIComponentsVMPlugin(context),
|
|
86
89
|
...globalStylesVMPlugin(context),
|
|
87
90
|
...searchHookVMPlugin(context),
|
|
@@ -90,6 +93,10 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
90
93
|
...siteDataVMPlugin(context)
|
|
91
94
|
}
|
|
92
95
|
}),
|
|
96
|
+
config.sitemap ? rsbuildPluginSitemap({
|
|
97
|
+
config,
|
|
98
|
+
routeService
|
|
99
|
+
}) : null,
|
|
93
100
|
enableSSG && config.ssg ? rsbuildPluginSSG({
|
|
94
101
|
routeService,
|
|
95
102
|
config,
|
|
@@ -195,6 +202,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
195
202
|
},
|
|
196
203
|
performance: {
|
|
197
204
|
printFileSize: {
|
|
205
|
+
detail: false,
|
|
198
206
|
compressed: true
|
|
199
207
|
},
|
|
200
208
|
...'false' !== process.env.RSPRESS_PERSISTENT_CACHE ? {
|
|
@@ -156,7 +156,7 @@ function normalizeLink(nodeUrl, routeService, filePath, cleanUrls, autoPrefix, d
|
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
const remarkLink = ({ cleanUrls, routeService, remarkLinkOptions, lint, __base, __siteOrigin })=>(tree, file)=>{
|
|
159
|
-
const { checkAnchors: shouldCheckAnchors =
|
|
159
|
+
const { checkAnchors: shouldCheckAnchors = true, checkDeadLinks: shouldCheckDeadLinks = true, autoPrefix = true } = remarkLinkOptions ?? {};
|
|
160
160
|
const deadLinks = new Map();
|
|
161
161
|
const anchorLinks = new Map();
|
|
162
162
|
visit(tree, 'link', (node)=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../
|
|
1
|
+
import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../p~0.js";
|
|
2
2
|
import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
|
|
3
3
|
import { createError } from "../utils/error.js";
|
|
4
4
|
import { getRouteChunkName } from "./routeChunkAssets.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unified, node_path, promises, loadFrontMatter, extractTextAndId, remark_gfm, remark_parse, MDX_OR_MD_REGEXP } from "../../
|
|
1
|
+
import { unified, node_path, promises, loadFrontMatter, extractTextAndId, remark_gfm, remark_parse, MDX_OR_MD_REGEXP } from "../../p~0.js";
|
|
2
2
|
import { applyReplaceRules } from "../utils/applyReplaceRules.js";
|
|
3
3
|
import { flattenMdxContent } from "../utils/flattenMdxContent.js";
|
|
4
4
|
import { importStatementRegex } from "../constants.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../
|
|
1
|
+
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../p~0.js";
|
|
2
2
|
const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
|
|
3
3
|
const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
|
|
4
4
|
return [
|