@rspress/core 2.0.10 → 2.0.11
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/0~execa.js +1 -1
- package/dist/3323.js +8 -0
- package/dist/{2240.js → 6162.js} +1 -4
- package/dist/8006.js +1 -1
- package/dist/8857.js +1 -1
- package/dist/common-Qw-RoVFD.js +25 -0
- package/dist/eject-theme/components/Llms/LlmsContainer.tsx +1 -2
- package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +1 -2
- package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +1 -2
- package/dist/eject-theme/components/Prompt/icons.tsx +1 -1
- package/dist/eject-theme/components/Prompt/index.scss +325 -380
- package/dist/eject-theme/components/Search/logic/search.ts +10 -5
- package/dist/eject-theme/components/Search/logic/util.test.ts +20 -1
- package/dist/eject-theme/components/Search/logic/util.ts +4 -1
- package/dist/entry/process.d.ts +1 -0
- package/dist/entry/process.js +65 -0
- package/dist/entry/utils.d.ts +7 -0
- package/dist/entry/utils.js +2 -0
- package/dist/entry/worker.d.ts +1 -0
- package/dist/entry/worker.js +74 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -0
- package/dist/node/PluginDriver.js +1 -1
- 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/index.d.ts +1 -0
- package/dist/node/initRsbuild.js +1 -1
- package/dist/node/mdx/options.js +2 -1
- package/dist/node/mdx/processor.js +1 -1
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +1 -1
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.d.ts +1 -0
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +9 -4
- package/dist/node/mdx/remarkPlugins/image.js +1 -1
- 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/i18n.js +1 -1
- 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.js +1 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.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/remarkSplitMdx.js +1 -1
- package/dist/node/ssg-md/renderPage.js +1 -1
- package/dist/node/ssg-md/renderPages.js +1 -1
- 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 +1 -1
- package/dist/runtime/BrowserOnly.d.ts +7 -0
- package/dist/runtime/BrowserOnly.js +40 -0
- package/dist/runtime/BrowserOnly.test.d.ts +1 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/theme/components/Prompt/icons.js +1 -1
- package/dist/theme/components/Prompt/index.css +11 -37
- package/dist/theme/components/Search/logic/search.js +5 -3
- package/dist/theme/components/Search/logic/util.js +2 -1
- package/dist/theme/layout/DocLayout/index.css +4 -0
- package/dist/theme/layout/DocLayout/index.js +3 -2
- package/dist/theme/logic/useThemeState.d.ts +5 -10
- package/dist/theme/logic/useThemeState.js +15 -20
- package/dist/utils-B--2TaWv.js +34 -0
- package/dist/utils-De75vAgL.js +7 -0
- package/package.json +12 -12
- package/dist/3425.js +0 -6
- package/dist/runtime/getSidebarDataGroup.test.js +0 -68
- package/dist/runtime/hooks/useWindowSize.test.js +0 -36
- package/dist/runtime/route.test.js +0 -154
- package/dist/runtime/utils.test.js +0 -34
- package/dist/theme/components/Search/logic/util.test.js +0 -51
- /package/dist/{2287.js → 5810.js} +0 -0
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, rs } from "@rstest/core";
|
|
2
|
-
import { isActive, matchPath, pathnameToRouteService } from "./route.js";
|
|
3
|
-
rs.mock('virtual-routes', ()=>{
|
|
4
|
-
const element = rs.fn();
|
|
5
|
-
const routes = [
|
|
6
|
-
{
|
|
7
|
-
path: '/api/config',
|
|
8
|
-
element,
|
|
9
|
-
filePath: 'api/config.mdx',
|
|
10
|
-
preload: async ()=>{},
|
|
11
|
-
lang: '',
|
|
12
|
-
version: ''
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
path: '/api/config/',
|
|
16
|
-
element,
|
|
17
|
-
filePath: 'api/config/index.mdx',
|
|
18
|
-
preload: async ()=>{},
|
|
19
|
-
lang: '',
|
|
20
|
-
version: ''
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
path: '/',
|
|
24
|
-
element,
|
|
25
|
-
filePath: 'index.mdx',
|
|
26
|
-
preload: async ()=>{},
|
|
27
|
-
lang: '',
|
|
28
|
-
version: ''
|
|
29
|
-
}
|
|
30
|
-
];
|
|
31
|
-
return {
|
|
32
|
-
routes
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
describe('matchPath', ()=>{
|
|
36
|
-
it('should match exact paths', ()=>{
|
|
37
|
-
expect(matchPath('/api/config', '/api/config')).toEqual({
|
|
38
|
-
path: '/api/config'
|
|
39
|
-
});
|
|
40
|
-
expect(matchPath('/api/config/', '/api/config/')).toEqual({
|
|
41
|
-
path: '/api/config/'
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
it('should normalize trailing slashes', ()=>{
|
|
45
|
-
expect(matchPath('/api/config', '/api/config/')).toEqual({
|
|
46
|
-
path: '/api/config'
|
|
47
|
-
});
|
|
48
|
-
expect(matchPath('/api/config/', '/api/config')).toEqual({
|
|
49
|
-
path: '/api/config/'
|
|
50
|
-
});
|
|
51
|
-
expect(matchPath('/api/config/', '/api/config/index.html')).toEqual({
|
|
52
|
-
path: '/api/config/'
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
it('should return null for non-matching paths', ()=>{
|
|
56
|
-
expect(matchPath('/api/config', '/api/other')).toBeNull();
|
|
57
|
-
expect(matchPath('/api', '/api/config')).toBeNull();
|
|
58
|
-
expect(matchPath('/api', '/api/index.md')).toBeNull();
|
|
59
|
-
});
|
|
60
|
-
it('should handle case-insensitive matching', ()=>{
|
|
61
|
-
expect(matchPath('/api/config', '/API/CONFIG')).toEqual({
|
|
62
|
-
path: '/api/config'
|
|
63
|
-
});
|
|
64
|
-
expect(matchPath('/api/config', '/Api/Config')).toEqual({
|
|
65
|
-
path: '/api/config'
|
|
66
|
-
});
|
|
67
|
-
expect(matchPath('/api/config', '/api/CONFIG.html')).toEqual({
|
|
68
|
-
path: '/api/config'
|
|
69
|
-
});
|
|
70
|
-
expect(matchPath('/api/config/', '/API/CONFIG/')).toEqual({
|
|
71
|
-
path: '/api/config/'
|
|
72
|
-
});
|
|
73
|
-
expect(matchPath('/api/config/', '/API/CONFIG/index.html')).toEqual({
|
|
74
|
-
path: '/api/config/'
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
describe('isActive', ()=>{
|
|
79
|
-
it('should return true for matching normalized paths', ()=>{
|
|
80
|
-
expect(isActive('/api/config', '/api/config')).toBe(true);
|
|
81
|
-
expect(isActive('/api/config', '/api/config.html')).toBe(true);
|
|
82
|
-
expect(isActive('/api/config', '/api/config/')).toBe(true);
|
|
83
|
-
});
|
|
84
|
-
it('should return false for non-matching paths', ()=>{
|
|
85
|
-
expect(isActive('/api/config', '/api/other')).toBe(false);
|
|
86
|
-
});
|
|
87
|
-
it('should handle hash and search parameters correctly', ()=>{
|
|
88
|
-
expect(isActive('/api/config', '/api/config#hash')).toBe(true);
|
|
89
|
-
expect(isActive('/api/config', '/api/config?query=value')).toBe(true);
|
|
90
|
-
expect(isActive('/api/config', '/api/config.html#hash')).toBe(true);
|
|
91
|
-
expect(isActive('/api/config', '/api/config.html?query=value')).toBe(true);
|
|
92
|
-
expect(isActive('/api/config', '/api/config.html?query=value#hash')).toBe(true);
|
|
93
|
-
expect(isActive('/api/config#different', '/api/config#hash')).toBe(true);
|
|
94
|
-
});
|
|
95
|
-
it('should handle case-insensitive matching', ()=>{
|
|
96
|
-
expect(isActive('/api/config', '/API/CONFIG')).toBe(true);
|
|
97
|
-
expect(isActive('/api/config', '/Api/Config')).toBe(true);
|
|
98
|
-
expect(isActive('/api/config', '/api/CONFIG.html')).toBe(true);
|
|
99
|
-
expect(isActive('/api/config', '/API/CONFIG/')).toBe(true);
|
|
100
|
-
expect(isActive('/api/config', '/API/CONFIG/index.html')).toBe(true);
|
|
101
|
-
expect(isActive('/api/config', '/api/CONFIG#hash')).toBe(true);
|
|
102
|
-
expect(isActive('/api/config', '/API/config?query=value')).toBe(true);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
describe('pathnameToRouteService', ()=>{
|
|
106
|
-
it('0. /api/config', ()=>{
|
|
107
|
-
const pathname = '/api/config';
|
|
108
|
-
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
109
|
-
});
|
|
110
|
-
it('1. /api/config.html', ()=>{
|
|
111
|
-
const pathname = '/api/config.html';
|
|
112
|
-
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
113
|
-
});
|
|
114
|
-
it('2. /api/config/', ()=>{
|
|
115
|
-
const pathname = '/api/config/';
|
|
116
|
-
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
117
|
-
});
|
|
118
|
-
it('3. /api/config/index', ()=>{
|
|
119
|
-
const pathname = '/api/config/index';
|
|
120
|
-
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
121
|
-
});
|
|
122
|
-
it('4. /api/config/index.html', ()=>{
|
|
123
|
-
const pathname = '/api/config/index.html';
|
|
124
|
-
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
125
|
-
});
|
|
126
|
-
it('5. /', ()=>{
|
|
127
|
-
expect(pathnameToRouteService('/index.html')?.path).toMatchInlineSnapshot('"/"');
|
|
128
|
-
expect(pathnameToRouteService('/index.md')?.path).toMatchInlineSnapshot("undefined");
|
|
129
|
-
});
|
|
130
|
-
it('6. /api/config.html#hash - should handle hash correctly', ()=>{
|
|
131
|
-
const pathname = '/api/config.html#hash';
|
|
132
|
-
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
133
|
-
});
|
|
134
|
-
it('7. /api/config.html?query=value - should handle query params correctly', ()=>{
|
|
135
|
-
const pathname = '/api/config.html?query=value';
|
|
136
|
-
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
137
|
-
});
|
|
138
|
-
it('8. /api/config.html?query=value#hash - should handle both query and hash', ()=>{
|
|
139
|
-
const pathname = '/api/config.html?query=value#hash';
|
|
140
|
-
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
141
|
-
});
|
|
142
|
-
it('9. /api/config#hash - should handle hash without .html', ()=>{
|
|
143
|
-
const pathname = '/api/config#hash';
|
|
144
|
-
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
145
|
-
});
|
|
146
|
-
it('10. Case-insensitive route matching', ()=>{
|
|
147
|
-
expect(pathnameToRouteService('/API/CONFIG')?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
148
|
-
expect(pathnameToRouteService('/Api/Config')?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
149
|
-
expect(pathnameToRouteService('/API/CONFIG.html')?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
150
|
-
expect(pathnameToRouteService('/API/CONFIG/')?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
151
|
-
expect(pathnameToRouteService('/API/CONFIG/index.html')?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
152
|
-
expect(pathnameToRouteService('/api/CONFIG#hash')?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
153
|
-
});
|
|
154
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, rs } from "@rstest/core";
|
|
2
|
-
import { routePathToMdPath } from "./utils.js";
|
|
3
|
-
rs.mock('virtual-site-data', ()=>({
|
|
4
|
-
default: {
|
|
5
|
-
base: '/'
|
|
6
|
-
}
|
|
7
|
-
}));
|
|
8
|
-
describe('routePathToMdPath', ()=>{
|
|
9
|
-
it('should match snapshot for various paths', ()=>{
|
|
10
|
-
const cases = [
|
|
11
|
-
'/foo/bar.html',
|
|
12
|
-
'/foo/bar.html#hash',
|
|
13
|
-
'/foo/bar.html?q=1',
|
|
14
|
-
'/foo/bar.html?q=1#hash',
|
|
15
|
-
'/foo.html',
|
|
16
|
-
'/simple.html#my-heading',
|
|
17
|
-
'/query.html?foo=bar&baz=qux',
|
|
18
|
-
'/complex.html?id=123#section-2'
|
|
19
|
-
];
|
|
20
|
-
const results = cases.map((path)=>routePathToMdPath(path));
|
|
21
|
-
expect(results).toMatchInlineSnapshot(`
|
|
22
|
-
[
|
|
23
|
-
"/foo/bar.md",
|
|
24
|
-
"/foo/bar.md#hash",
|
|
25
|
-
"/foo/bar.md?q=1",
|
|
26
|
-
"/foo/bar.md?q=1#hash",
|
|
27
|
-
"/foo.md",
|
|
28
|
-
"/simple.md#my-heading",
|
|
29
|
-
"/query.md?foo=bar&baz=qux",
|
|
30
|
-
"/complex.md?id=123#section-2",
|
|
31
|
-
]
|
|
32
|
-
`);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "@rstest/core";
|
|
2
|
-
import { backTrackHeaders } from "./util.js";
|
|
3
|
-
describe('utils logic', ()=>{
|
|
4
|
-
test('back track the headers', ()=>{
|
|
5
|
-
const headers = [
|
|
6
|
-
{
|
|
7
|
-
depth: 1,
|
|
8
|
-
text: '1',
|
|
9
|
-
id: '1'
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
depth: 2,
|
|
13
|
-
text: '2',
|
|
14
|
-
id: '2'
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
depth: 3,
|
|
18
|
-
text: '3',
|
|
19
|
-
id: '3'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
depth: 4,
|
|
23
|
-
text: '4',
|
|
24
|
-
id: '4'
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
depth: 5,
|
|
28
|
-
text: '5',
|
|
29
|
-
id: '5'
|
|
30
|
-
}
|
|
31
|
-
];
|
|
32
|
-
const res = backTrackHeaders(headers, 3);
|
|
33
|
-
expect(res).toEqual([
|
|
34
|
-
{
|
|
35
|
-
depth: 2,
|
|
36
|
-
text: '2',
|
|
37
|
-
id: '2'
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
depth: 3,
|
|
41
|
-
text: '3',
|
|
42
|
-
id: '3'
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
depth: 4,
|
|
46
|
-
text: '4',
|
|
47
|
-
id: '4'
|
|
48
|
-
}
|
|
49
|
-
]);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
File without changes
|