@rspress/core 2.0.9 → 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/{740.js → 5810.js} +127 -139
- package/dist/{2240.js → 6162.js} +1 -4
- package/dist/8006.js +1 -1
- package/dist/8857.js +2 -3
- package/dist/cli/index.js +7 -4
- package/dist/common-Qw-RoVFD.js +25 -0
- package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +17 -21
- package/dist/eject-theme/components/DocContent/doc.scss +14 -41
- package/dist/eject-theme/components/Llms/LlmsContainer.tsx +1 -2
- package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +14 -8
- package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +13 -5
- package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +8 -5
- package/dist/eject-theme/components/Outline/index.scss +1 -1
- package/dist/eject-theme/components/Prompt/icons.tsx +80 -0
- package/dist/eject-theme/components/Prompt/index.scss +423 -0
- package/dist/eject-theme/components/Prompt/index.tsx +335 -0
- 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/eject-theme/components/SidebarMenu/index.tsx +5 -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 +2 -2
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/eject.js +1 -0
- 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/DEFAULT_I18N_TEXT.d.ts +28 -0
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +28 -0
- 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/CodeButtonGroup/CopyCodeButton.js +14 -12
- package/dist/theme/components/DocContent/doc.css +13 -21
- package/dist/theme/components/Llms/LlmsCopyButton.js +5 -6
- package/dist/theme/components/Llms/LlmsCopyRow.js +5 -5
- package/dist/theme/components/Llms/LlmsViewOptions.js +1 -3
- package/dist/theme/components/Outline/index.css +1 -1
- package/dist/theme/components/Prompt/icons.d.ts +10 -0
- package/dist/theme/components/Prompt/icons.js +64 -0
- package/dist/theme/components/Prompt/index.css +326 -0
- package/dist/theme/components/Prompt/index.d.ts +33 -0
- package/dist/theme/components/Prompt/index.js +262 -0
- package/dist/theme/components/Search/logic/search.js +5 -3
- package/dist/theme/components/Search/logic/util.js +2 -1
- package/dist/theme/components/SidebarMenu/index.js +2 -1
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/index.js +3 -0
- package/dist/theme/layout/DocLayout/index.css +9 -1
- package/dist/theme/layout/DocLayout/index.js +11 -6
- package/dist/theme/logic/copyToClipboard.d.ts +1 -0
- package/dist/theme/{components/Llms/copy.js → logic/copyToClipboard.js} +4 -3
- package/dist/theme/logic/getCopyableText.d.ts +5 -0
- package/dist/theme/logic/getCopyableText.js +52 -0
- package/dist/theme/logic/useThemeState.d.ts +5 -10
- package/dist/theme/logic/useThemeState.js +15 -20
- package/dist/theme/styles/vars/base-vars.css +4 -4
- package/dist/utils-B--2TaWv.js +34 -0
- package/dist/utils-De75vAgL.js +7 -0
- package/package.json +16 -16
- package/dist/3425.js +0 -6
- package/dist/eject-theme/components/Llms/copy.ts +0 -12
- 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/Llms/copy.d.ts +0 -1
- package/dist/theme/components/Search/logic/util.test.js +0 -51
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@mdx-js/mdx": "^3.1.1",
|
|
62
62
|
"@mdx-js/react": "^3.1.1",
|
|
63
|
-
"@rsbuild/core": "2.0.
|
|
64
|
-
"@rsbuild/plugin-react": "~
|
|
63
|
+
"@rsbuild/core": "^2.0.5",
|
|
64
|
+
"@rsbuild/plugin-react": "~2.0.0",
|
|
65
65
|
"@shikijs/rehype": "^4.0.2",
|
|
66
66
|
"@types/unist": "^3.0.3",
|
|
67
|
-
"@unhead/react": "^2.1.
|
|
67
|
+
"@unhead/react": "^2.1.15",
|
|
68
68
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
69
69
|
"clsx": "2.1.1",
|
|
70
70
|
"copy-to-clipboard": "^3.3.3",
|
|
@@ -75,12 +75,12 @@
|
|
|
75
75
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
76
76
|
"medium-zoom": "1.1.0",
|
|
77
77
|
"nprogress": "^0.2.0",
|
|
78
|
-
"react": "^19.2.
|
|
79
|
-
"react-dom": "^19.2.
|
|
78
|
+
"react": "^19.2.6",
|
|
79
|
+
"react-dom": "^19.2.6",
|
|
80
80
|
"react-lazy-with-preload": "^2.2.1",
|
|
81
81
|
"react-reconciler": "0.33.0",
|
|
82
82
|
"react-render-to-markdown": "19.0.1",
|
|
83
|
-
"react-router-dom": "^7.
|
|
83
|
+
"react-router-dom": "^7.15.0",
|
|
84
84
|
"rehype-external-links": "^3.0.0",
|
|
85
85
|
"rehype-raw": "^7.0.0",
|
|
86
86
|
"remark-cjk-friendly": "^2.0.1",
|
|
@@ -95,13 +95,13 @@
|
|
|
95
95
|
"unist-util-remove": "^4.0.0",
|
|
96
96
|
"unist-util-visit": "^5.1.0",
|
|
97
97
|
"unist-util-visit-children": "^3.0.0",
|
|
98
|
-
"@rspress/shared": "2.0.
|
|
98
|
+
"@rspress/shared": "2.0.11"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
101
|
"@microsoft/api-extractor": "^7.57.7",
|
|
102
|
-
"@rsbuild/plugin-sass": "~1.5.
|
|
103
|
-
"@rsbuild/plugin-svgr": "^
|
|
104
|
-
"@rslib/core": "0.21.
|
|
102
|
+
"@rsbuild/plugin-sass": "~1.5.2",
|
|
103
|
+
"@rsbuild/plugin-svgr": "^2.0.2",
|
|
104
|
+
"@rslib/core": "0.21.4",
|
|
105
105
|
"@types/body-scroll-lock": "^3.1.2",
|
|
106
106
|
"@types/hast": "^3.0.4",
|
|
107
107
|
"@types/mdast": "^4.0.4",
|
|
@@ -110,21 +110,21 @@
|
|
|
110
110
|
"@types/react": "^19.2.14",
|
|
111
111
|
"@types/react-dom": "^19.2.3",
|
|
112
112
|
"@types/react-reconciler": "^0.33.0",
|
|
113
|
-
"@types/web": "^0.0.
|
|
113
|
+
"@types/web": "^0.0.349",
|
|
114
114
|
"cac": "^7.0.0",
|
|
115
115
|
"chokidar": "^3.6.0",
|
|
116
116
|
"execa": "8.0.1",
|
|
117
117
|
"mdast-util-directive": "^3.1.0",
|
|
118
118
|
"mdast-util-mdx-expression": "^2.0.1",
|
|
119
|
-
"memfs": "^4.57.
|
|
119
|
+
"memfs": "^4.57.2",
|
|
120
120
|
"p-map": "^7.0.4",
|
|
121
121
|
"picocolors": "^1.1.1",
|
|
122
|
-
"postcss": "8.5.
|
|
122
|
+
"postcss": "8.5.14",
|
|
123
123
|
"remark-directive": "^4.0.0",
|
|
124
124
|
"rsbuild-plugin-publint": "^0.3.4",
|
|
125
|
-
"rsbuild-plugin-virtual-module": "0.4.
|
|
125
|
+
"rsbuild-plugin-virtual-module": "0.4.2",
|
|
126
126
|
"tailwindcss": "^3.4.19",
|
|
127
|
-
"tinyglobby": "^0.2.
|
|
127
|
+
"tinyglobby": "^0.2.16",
|
|
128
128
|
"tinypool": "^1.1.1",
|
|
129
129
|
"ts-json-schema-generator": "^2.9.0",
|
|
130
130
|
"typescript": "^5.8.2",
|
package/dist/3425.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { readFile } from "node:fs/promises";
|
|
2
|
-
export { default as node_path } from "node:path";
|
|
3
|
-
export { cwd } from "node:process";
|
|
4
|
-
export { logger } from "@rspress/shared/logger";
|
|
5
|
-
export { visit } from "unist-util-visit";
|
|
6
|
-
export { addLeadingSlash, isExternalUrl, isProduction, normalizeHref, parseUrl, withBase } from "@rspress/shared";
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, rs } from "@rstest/core";
|
|
2
|
-
import { getSidebarDataGroup } from "./hooks/useSidebar.js";
|
|
3
|
-
import { isActive } from "./route.js";
|
|
4
|
-
rs.mock('virtual-i18n-text', ()=>({
|
|
5
|
-
default: {}
|
|
6
|
-
}));
|
|
7
|
-
rs.mock('virtual-site-data', ()=>({
|
|
8
|
-
default: {
|
|
9
|
-
base: '/'
|
|
10
|
-
}
|
|
11
|
-
}));
|
|
12
|
-
rs.mock('virtual-routes', ()=>({
|
|
13
|
-
routes: []
|
|
14
|
-
}));
|
|
15
|
-
describe('getSidebarDataGroup', ()=>{
|
|
16
|
-
it('when using "/"', async ()=>{
|
|
17
|
-
expect(getSidebarDataGroup({
|
|
18
|
-
'/': [],
|
|
19
|
-
'/guide': [
|
|
20
|
-
{
|
|
21
|
-
text: 'Getting Started',
|
|
22
|
-
link: '/guide/getting-started'
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
}, '/guide/getting-started')).toMatchInlineSnapshot(`
|
|
26
|
-
[
|
|
27
|
-
{
|
|
28
|
-
"link": "/guide/getting-started",
|
|
29
|
-
"text": "Getting Started",
|
|
30
|
-
},
|
|
31
|
-
]
|
|
32
|
-
`);
|
|
33
|
-
});
|
|
34
|
-
it('when using api-extractor', async ()=>{
|
|
35
|
-
expect(getSidebarDataGroup({
|
|
36
|
-
'/api/react': [
|
|
37
|
-
{
|
|
38
|
-
link: '/api/react.use',
|
|
39
|
-
text: 'react.use'
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
}, '/api/react.use.html')).toMatchInlineSnapshot(`
|
|
43
|
-
[
|
|
44
|
-
{
|
|
45
|
-
"link": "/api/react.use",
|
|
46
|
-
"text": "react.use",
|
|
47
|
-
},
|
|
48
|
-
]
|
|
49
|
-
`);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
describe('isActive', ()=>{
|
|
53
|
-
it('pass cases', ()=>{
|
|
54
|
-
const routes = [
|
|
55
|
-
'/api/config',
|
|
56
|
-
'/api/config.html',
|
|
57
|
-
'/api/config/',
|
|
58
|
-
'/api/config/index',
|
|
59
|
-
'/api/config/index.html'
|
|
60
|
-
];
|
|
61
|
-
for (const route of routes)for (const route2 of routes)expect(isActive(route, route2)).toBeTruthy();
|
|
62
|
-
});
|
|
63
|
-
it('failed cases', ()=>{
|
|
64
|
-
expect(isActive('/api/config', '/api/config2')).toBeFalsy();
|
|
65
|
-
expect(isActive('/api/config', '/api/config/config2')).toBeFalsy();
|
|
66
|
-
expect(isActive('/api/config/index', '/api/config/config2')).toBeFalsy();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@rstest/core";
|
|
2
|
-
import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
|
|
3
|
-
import * as __rspack_external_node_path_c5b9b54f from "node:path";
|
|
4
|
-
describe('useWindowSize', ()=>{
|
|
5
|
-
it('should have debounce implementation with RESIZE_DEBOUNCE_MS constant', ()=>{
|
|
6
|
-
const filePath = __rspack_external_node_path_c5b9b54f.join(__dirname, 'useWindowSize.ts');
|
|
7
|
-
const fileContent = __rspack_external_node_fs_5ea92f0c.readFileSync(filePath, 'utf-8');
|
|
8
|
-
expect(fileContent).toContain('const RESIZE_DEBOUNCE_MS = 150');
|
|
9
|
-
expect(fileContent).toContain('setTimeout');
|
|
10
|
-
expect(fileContent).toContain('RESIZE_DEBOUNCE_MS');
|
|
11
|
-
});
|
|
12
|
-
it('should clear timeout with conditional check', ()=>{
|
|
13
|
-
const filePath = __rspack_external_node_path_c5b9b54f.join(__dirname, 'useWindowSize.ts');
|
|
14
|
-
const fileContent = __rspack_external_node_fs_5ea92f0c.readFileSync(filePath, 'utf-8');
|
|
15
|
-
expect(fileContent).toContain('if (timeoutId) clearTimeout(timeoutId)');
|
|
16
|
-
expect(fileContent).not.toContain('clearTimeout(timeoutId!)');
|
|
17
|
-
});
|
|
18
|
-
it('should register and cleanup resize event listener', ()=>{
|
|
19
|
-
const filePath = __rspack_external_node_path_c5b9b54f.join(__dirname, 'useWindowSize.ts');
|
|
20
|
-
const fileContent = __rspack_external_node_fs_5ea92f0c.readFileSync(filePath, 'utf-8');
|
|
21
|
-
expect(fileContent).toContain("addEventListener('resize'");
|
|
22
|
-
expect(fileContent).toContain("removeEventListener('resize'");
|
|
23
|
-
});
|
|
24
|
-
it('should set initial size immediately', ()=>{
|
|
25
|
-
const filePath = __rspack_external_node_path_c5b9b54f.join(__dirname, 'useWindowSize.ts');
|
|
26
|
-
const fileContent = __rspack_external_node_fs_5ea92f0c.readFileSync(filePath, 'utf-8');
|
|
27
|
-
const setStateMatch = fileContent.match(/setSize\(\{[^}]+\}\)/g);
|
|
28
|
-
expect(setStateMatch).toBeTruthy();
|
|
29
|
-
expect(setStateMatch?.length).toBeGreaterThanOrEqual(2);
|
|
30
|
-
});
|
|
31
|
-
it('should export useWindowSize function', async ()=>{
|
|
32
|
-
const module = await import("./useWindowSize.js");
|
|
33
|
-
expect(module.useWindowSize).toBeDefined();
|
|
34
|
-
expect(typeof module.useWindowSize).toBe('function');
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -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 +0,0 @@
|
|
|
1
|
-
export declare function copyToClipboard(text: string): Promise<void>;
|
|
@@ -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
|
-
});
|