@rspress/core 2.0.0-beta.2 → 2.0.0-beta.21
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/README.md +1 -1
- package/dist/208.js +39 -0
- package/dist/309.js +27 -0
- package/dist/94.js +1787 -0
- package/dist/index.d.ts +105 -19
- package/dist/index.js +1217 -561
- package/dist/loader.d.ts +38 -34
- package/dist/loader.js +30 -525
- package/dist/processor.d.ts +95 -0
- package/dist/processor.js +740 -0
- package/dist/runtime/App.d.ts +1 -4
- package/dist/runtime/App.js +17 -20
- package/dist/runtime/ClientApp.js +24 -13
- package/dist/runtime/csrClientEntry.js +5 -13
- package/dist/runtime/initPageData.d.ts +0 -1
- package/dist/runtime/initPageData.js +18 -18
- package/dist/runtime/ssrClientEntry.js +14 -14
- package/dist/runtime/ssrServerEntry.d.ts +3 -2
- package/dist/runtime/ssrServerEntry.js +41 -17
- package/dist/runtime.d.ts +8 -0
- package/dist/runtime.js +3 -0
- package/dist/shiki-transformers.d.ts +38 -0
- package/dist/shiki-transformers.js +77 -0
- package/dist/shiki-transformers.js.LICENSE.txt +5 -0
- package/dist/theme.d.ts +4 -0
- package/dist/theme.js +1 -0
- package/package.json +40 -33
- package/static/MediumZoom.css +5 -0
- package/static/MediumZoom.tsx +29 -0
- package/dist/runtime/tsconfig.js +0 -4
- package/runtime.ts +0 -1
- package/theme.ts +0 -1
package/dist/runtime/App.d.ts
CHANGED
package/dist/runtime/App.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const { pathname, search } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)();
|
|
12
|
-
(0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DataContext, useLocation } from "@rspress/runtime";
|
|
3
|
+
import { Layout } from "@theme";
|
|
4
|
+
import react, { useContext, useLayoutEffect } from "react";
|
|
5
|
+
import virtual_global_components from "virtual-global-components";
|
|
6
|
+
import { initPageData } from "./initPageData.js";
|
|
7
|
+
function App() {
|
|
8
|
+
const { setData: setPageData, data } = useContext(DataContext);
|
|
9
|
+
const { pathname, search } = useLocation();
|
|
10
|
+
useLayoutEffect(()=>{
|
|
13
11
|
async function refetchData() {
|
|
14
12
|
try {
|
|
15
|
-
const pageData = await
|
|
13
|
+
const pageData = await initPageData(pathname);
|
|
16
14
|
setPageData?.(pageData);
|
|
17
15
|
} catch (e) {
|
|
18
16
|
console.log(e);
|
|
@@ -23,24 +21,23 @@ function App({ helmetContext }) {
|
|
|
23
21
|
pathname,
|
|
24
22
|
setPageData
|
|
25
23
|
]);
|
|
26
|
-
if (!data) return /*#__PURE__*/
|
|
24
|
+
if (!data) return /*#__PURE__*/ jsx(Fragment, {});
|
|
27
25
|
const frontmatter = data.page.frontmatter || {};
|
|
28
26
|
const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
|
|
29
27
|
const query = new URLSearchParams(search);
|
|
30
28
|
const hideGlobalUIComponents = false === frontmatter[GLOBAL_COMPONENTS_KEY] || "0" === query.get(GLOBAL_COMPONENTS_KEY);
|
|
31
|
-
return /*#__PURE__*/
|
|
32
|
-
context: helmetContext,
|
|
29
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
33
30
|
children: [
|
|
34
|
-
/*#__PURE__*/
|
|
35
|
-
!hideGlobalUIComponents &&
|
|
31
|
+
/*#__PURE__*/ jsx(Layout, {}),
|
|
32
|
+
!hideGlobalUIComponents && virtual_global_components.map((componentInfo, index)=>{
|
|
36
33
|
if (Array.isArray(componentInfo)) {
|
|
37
34
|
const [component, props] = componentInfo;
|
|
38
|
-
return /*#__PURE__*/
|
|
35
|
+
return /*#__PURE__*/ react.createElement(component, {
|
|
39
36
|
key: index,
|
|
40
37
|
...props
|
|
41
38
|
});
|
|
42
39
|
}
|
|
43
|
-
return /*#__PURE__*/
|
|
40
|
+
return /*#__PURE__*/ react.createElement(componentInfo, {
|
|
44
41
|
key: index
|
|
45
42
|
});
|
|
46
43
|
})
|
|
@@ -1,29 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BrowserRouter, DataContext, ThemeContext } from "@rspress/runtime";
|
|
3
|
+
import { useThemeState } from "@theme";
|
|
4
|
+
import { UnheadProvider, createHead } from "@unhead/react/client";
|
|
5
|
+
import { useMemo, useState } from "react";
|
|
6
|
+
import { base } from "virtual-runtime-config";
|
|
7
|
+
import { App } from "./App.js";
|
|
8
|
+
const head = createHead();
|
|
6
9
|
function ClientApp({ initialPageData = null }) {
|
|
7
|
-
const [data, setData] =
|
|
8
|
-
const [theme, setTheme] =
|
|
9
|
-
return /*#__PURE__*/
|
|
10
|
-
value:
|
|
10
|
+
const [data, setData] = useState(initialPageData);
|
|
11
|
+
const [theme, setTheme] = useThemeState();
|
|
12
|
+
return /*#__PURE__*/ jsx(ThemeContext.Provider, {
|
|
13
|
+
value: useMemo(()=>({
|
|
11
14
|
theme,
|
|
12
15
|
setTheme
|
|
13
16
|
}), [
|
|
14
17
|
theme,
|
|
15
18
|
setTheme
|
|
16
19
|
]),
|
|
17
|
-
children: /*#__PURE__*/
|
|
18
|
-
value:
|
|
20
|
+
children: /*#__PURE__*/ jsx(DataContext.Provider, {
|
|
21
|
+
value: useMemo(()=>({
|
|
19
22
|
data,
|
|
20
23
|
setData
|
|
21
24
|
}), [
|
|
22
25
|
data,
|
|
23
26
|
setData
|
|
24
27
|
]),
|
|
25
|
-
children: /*#__PURE__*/
|
|
26
|
-
|
|
28
|
+
children: /*#__PURE__*/ jsx(BrowserRouter, {
|
|
29
|
+
future: {
|
|
30
|
+
v7_relativeSplatPath: true,
|
|
31
|
+
v7_startTransition: true
|
|
32
|
+
},
|
|
33
|
+
basename: base,
|
|
34
|
+
children: /*#__PURE__*/ jsx(UnheadProvider, {
|
|
35
|
+
head: head,
|
|
36
|
+
children: /*#__PURE__*/ jsx(App, {})
|
|
37
|
+
})
|
|
27
38
|
})
|
|
28
39
|
})
|
|
29
40
|
});
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { createRoot } = await import("react-dom/client");
|
|
7
|
-
createRoot(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}));
|
|
8
|
-
} else {
|
|
9
|
-
const ReactDOM = await import("react-dom");
|
|
10
|
-
ReactDOM.render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}), container);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
renderInBrowser();
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { ClientApp } from "./ClientApp.js";
|
|
4
|
+
const container = document.getElementById('root');
|
|
5
|
+
createRoot(container).render(/*#__PURE__*/ jsx(ClientApp, {}));
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import "virtual-
|
|
4
|
-
import
|
|
1
|
+
import { isEqualPath, pathnameToRouteService } from "@rspress/runtime";
|
|
2
|
+
import { MDX_OR_MD_REGEXP, cleanUrl } from "@rspress/shared";
|
|
3
|
+
import { base } from "virtual-runtime-config";
|
|
4
|
+
import virtual_site_data from "virtual-site-data";
|
|
5
5
|
async function initPageData(routePath) {
|
|
6
|
-
const matchedRoute =
|
|
6
|
+
const matchedRoute = pathnameToRouteService(routePath);
|
|
7
7
|
if (matchedRoute) {
|
|
8
8
|
const mod = await matchedRoute.preload();
|
|
9
|
-
const pagePath =
|
|
9
|
+
const pagePath = cleanUrl(matchedRoute.filePath);
|
|
10
10
|
const normalize = (p)=>p.replace(/\/$/, '').toLowerCase();
|
|
11
|
-
const extractPageInfo =
|
|
11
|
+
const extractPageInfo = virtual_site_data.pages.find((page)=>isEqualPath(normalize(page.routePath), normalize(matchedRoute.path)));
|
|
12
12
|
const encodedPagePath = encodeURIComponent(pagePath);
|
|
13
13
|
const meta = mod.default.__RSPRESS_PAGE_META?.[encodedPagePath] || {};
|
|
14
|
-
const { toc = [], title = '', frontmatter = {}, ...rest } =
|
|
14
|
+
const { toc = [], title = '', frontmatter = {}, ...rest } = MDX_OR_MD_REGEXP.test(matchedRoute.filePath) ? meta : mod;
|
|
15
15
|
return {
|
|
16
|
-
siteData:
|
|
16
|
+
siteData: virtual_site_data,
|
|
17
17
|
page: {
|
|
18
18
|
...rest,
|
|
19
19
|
pagePath,
|
|
@@ -25,21 +25,21 @@ async function initPageData(routePath) {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
let lang =
|
|
29
|
-
let version =
|
|
30
|
-
if (
|
|
31
|
-
const path = location.pathname.replace(
|
|
32
|
-
if (
|
|
33
|
-
const result =
|
|
28
|
+
let lang = virtual_site_data.lang || '';
|
|
29
|
+
let version = virtual_site_data.multiVersion?.default || '';
|
|
30
|
+
if (virtual_site_data.lang && 'undefined' != typeof window) {
|
|
31
|
+
const path = location.pathname.replace(base, '').split('/').slice(0, 2);
|
|
32
|
+
if (virtual_site_data.locales.length) {
|
|
33
|
+
const result = virtual_site_data.locales.find(({ lang })=>path.includes(lang));
|
|
34
34
|
if (result) lang = result.lang;
|
|
35
35
|
}
|
|
36
|
-
if (
|
|
37
|
-
const result =
|
|
36
|
+
if (virtual_site_data.multiVersion.versions) {
|
|
37
|
+
const result = virtual_site_data.multiVersion.versions.find((version)=>path.includes(version));
|
|
38
38
|
if (result) version = result;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
return {
|
|
42
|
-
siteData:
|
|
42
|
+
siteData: virtual_site_data,
|
|
43
43
|
page: {
|
|
44
44
|
pagePath: '',
|
|
45
45
|
pageType: '404',
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { startTransition } from "react";
|
|
3
|
+
import { hydrateRoot } from "react-dom/client";
|
|
4
|
+
import { ClientApp } from "./ClientApp.js";
|
|
5
|
+
import { initPageData } from "./initPageData.js";
|
|
4
6
|
async function renderInBrowser() {
|
|
5
7
|
const container = document.getElementById('root');
|
|
6
|
-
const initialPageData = await
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
hydrateRoot(container, /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
|
|
8
|
+
const initialPageData = await initPageData(window.location.pathname);
|
|
9
|
+
startTransition(()=>{
|
|
10
|
+
hydrateRoot(container, /*#__PURE__*/ jsx(ClientApp, {
|
|
10
11
|
initialPageData: initialPageData
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
12
|
+
}), {
|
|
13
|
+
onRecoverableError (error, errorInfo) {
|
|
14
|
+
if (error instanceof Error) console.warn('hydrateRoot recoverable error:', error, errorInfo);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
18
|
}
|
|
19
19
|
renderInBrowser();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PageData } from '@rspress/shared';
|
|
2
|
-
|
|
2
|
+
import { type Unhead } from '@unhead/react/server';
|
|
3
|
+
export declare function render(routePath: string, head: Unhead): Promise<{
|
|
3
4
|
appHtml: string;
|
|
4
5
|
pageData: PageData;
|
|
5
6
|
}>;
|
|
6
|
-
export { routes } from 'virtual-routes
|
|
7
|
+
export { routes } from 'virtual-routes';
|
|
@@ -1,25 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DataContext, ThemeContext, pathnameToRouteService, withBase } from "@rspress/runtime";
|
|
3
|
+
import { StaticRouter } from "@rspress/runtime/server";
|
|
4
|
+
import { UnheadProvider } from "@unhead/react/server";
|
|
5
|
+
import { renderToPipeableStream } from "react-dom/server";
|
|
6
|
+
import { PassThrough } from "node:stream";
|
|
7
|
+
import { text as consumers_text } from "node:stream/consumers";
|
|
8
|
+
import { base } from "virtual-runtime-config";
|
|
9
|
+
import { App } from "./App.js";
|
|
10
|
+
import { initPageData } from "./initPageData.js";
|
|
11
|
+
import { routes } from "virtual-routes";
|
|
8
12
|
const DEFAULT_THEME = 'light';
|
|
9
|
-
async function
|
|
10
|
-
const
|
|
11
|
-
|
|
13
|
+
async function preloadRoute(pathname) {
|
|
14
|
+
const route = pathnameToRouteService(pathname);
|
|
15
|
+
await route?.preload();
|
|
16
|
+
}
|
|
17
|
+
function renderToHtml(app) {
|
|
18
|
+
return new Promise((resolve, reject)=>{
|
|
19
|
+
const passThrough = new PassThrough();
|
|
20
|
+
const { pipe } = renderToPipeableStream(app, {
|
|
21
|
+
onError (error) {
|
|
22
|
+
reject(error);
|
|
23
|
+
},
|
|
24
|
+
onAllReady () {
|
|
25
|
+
pipe(passThrough);
|
|
26
|
+
consumers_text(passThrough).then(resolve, reject);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async function render(routePath, head) {
|
|
32
|
+
const initialPageData = await initPageData(routePath);
|
|
33
|
+
await preloadRoute(routePath);
|
|
34
|
+
const appHtml = await renderToHtml(/*#__PURE__*/ jsx(ThemeContext.Provider, {
|
|
12
35
|
value: {
|
|
13
36
|
theme: DEFAULT_THEME
|
|
14
37
|
},
|
|
15
|
-
children: /*#__PURE__*/
|
|
38
|
+
children: /*#__PURE__*/ jsx(DataContext.Provider, {
|
|
16
39
|
value: {
|
|
17
40
|
data: initialPageData
|
|
18
41
|
},
|
|
19
|
-
children: /*#__PURE__*/
|
|
20
|
-
location:
|
|
21
|
-
|
|
22
|
-
|
|
42
|
+
children: /*#__PURE__*/ jsx(StaticRouter, {
|
|
43
|
+
location: withBase(routePath),
|
|
44
|
+
basename: base,
|
|
45
|
+
children: /*#__PURE__*/ jsx(UnheadProvider, {
|
|
46
|
+
value: head,
|
|
47
|
+
children: /*#__PURE__*/ jsx(App, {})
|
|
23
48
|
})
|
|
24
49
|
})
|
|
25
50
|
})
|
|
@@ -29,5 +54,4 @@ async function render(pagePath, helmetContext) {
|
|
|
29
54
|
pageData: initialPageData
|
|
30
55
|
};
|
|
31
56
|
}
|
|
32
|
-
|
|
33
|
-
export { render, __webpack_exports__routes as routes };
|
|
57
|
+
export { render, routes };
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ShikiTransformer } from 'shiki';
|
|
2
|
+
|
|
3
|
+
declare interface ITransformerLineNumberOptions {
|
|
4
|
+
classActivePre?: string;
|
|
5
|
+
classActiveLine?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export declare const SHIKI_TRANSFORMER_ADD_TITLE = "shiki-transformer:add-title";
|
|
9
|
+
|
|
10
|
+
export declare const SHIKI_TRANSFORMER_LINE_NUMBER = "shiki-transformer:line-number";
|
|
11
|
+
|
|
12
|
+
export declare const SHIKI_TRANSFORMER_META_HIGHLIGHT = "shiki-transformer:compatible-meta-highlight";
|
|
13
|
+
|
|
14
|
+
export declare function transformerAddTitle(): ShikiTransformer;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Allow using `{1,3-5}` in the code snippet meta to mark highlighted lines.
|
|
18
|
+
* @deprecated This is a workaround when migrating to Rspress 2.0, you should migrate to `import { transformerNotationHighlight } from '@shikijs/transformers'` instead.
|
|
19
|
+
*/
|
|
20
|
+
export declare function transformerCompatibleMetaHighlight(options?: TransformerMetaHighlightOptions): ShikiTransformer;
|
|
21
|
+
|
|
22
|
+
export declare function transformerLineNumber(options?: ITransformerLineNumberOptions): ShikiTransformer;
|
|
23
|
+
|
|
24
|
+
declare interface TransformerMetaHighlightOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Class for highlighted lines
|
|
27
|
+
*
|
|
28
|
+
* @default 'highlighted'
|
|
29
|
+
*/
|
|
30
|
+
classActiveLine?: string;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @default 'has-highlighted'
|
|
34
|
+
*/
|
|
35
|
+
classActivePre?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { }
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*! For license information please see shiki-transformers.js.LICENSE.txt */
|
|
2
|
+
const SHIKI_TRANSFORMER_LINE_NUMBER = 'shiki-transformer:line-number';
|
|
3
|
+
function transformerLineNumber(options = {}) {
|
|
4
|
+
const { classActiveLine = 'line-number', classActivePre = 'has-line-number' } = options;
|
|
5
|
+
return {
|
|
6
|
+
name: SHIKI_TRANSFORMER_LINE_NUMBER,
|
|
7
|
+
pre (pre) {
|
|
8
|
+
return this.addClassToHast(pre, classActivePre);
|
|
9
|
+
},
|
|
10
|
+
line (node) {
|
|
11
|
+
this.addClassToHast(node, classActiveLine);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const SHIKI_TRANSFORMER_ADD_TITLE = 'shiki-transformer:add-title';
|
|
16
|
+
function parseTitleFromMeta(meta) {
|
|
17
|
+
if (!meta) return '';
|
|
18
|
+
const kvList = meta.split(' ').filter(Boolean);
|
|
19
|
+
for (const item of kvList){
|
|
20
|
+
const [k, v] = item.split('=');
|
|
21
|
+
if ('title' === k && v.length > 0) return v.replace(/["'`]/g, '');
|
|
22
|
+
}
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
function transformerAddTitle() {
|
|
26
|
+
return {
|
|
27
|
+
name: SHIKI_TRANSFORMER_ADD_TITLE,
|
|
28
|
+
pre (pre) {
|
|
29
|
+
const title = parseTitleFromMeta(this.options.meta?.__raw);
|
|
30
|
+
if (title.length > 0) pre.properties = {
|
|
31
|
+
...pre.properties,
|
|
32
|
+
title
|
|
33
|
+
};
|
|
34
|
+
return pre;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* these codes are copied from @shiki/transformers, transformerMetaHighlight
|
|
40
|
+
* @source https://github.com/shikijs/shiki/blob/f5cf06f55a0b4643d7b02f15ee2c5033be6f1245/packages/transformers/src/transformers/meta-highlight.ts#L56
|
|
41
|
+
* @license MIT
|
|
42
|
+
*/ function parseMetaHighlightString(meta) {
|
|
43
|
+
if (!meta) return null;
|
|
44
|
+
const match = meta.match(/\{([\d,-]+)\}/);
|
|
45
|
+
if (!match) return null;
|
|
46
|
+
const lines = match[1].split(',').flatMap((v)=>{
|
|
47
|
+
const num = v.split('-').map((v)=>Number.parseInt(v, 10));
|
|
48
|
+
if (1 === num.length) return [
|
|
49
|
+
num[0]
|
|
50
|
+
];
|
|
51
|
+
return Array.from({
|
|
52
|
+
length: num[1] - num[0] + 1
|
|
53
|
+
}, (_, i)=>i + num[0]);
|
|
54
|
+
});
|
|
55
|
+
return lines;
|
|
56
|
+
}
|
|
57
|
+
const symbol = Symbol('highlighted-lines');
|
|
58
|
+
const SHIKI_TRANSFORMER_META_HIGHLIGHT = 'shiki-transformer:compatible-meta-highlight';
|
|
59
|
+
function transformerCompatibleMetaHighlight(options = {}) {
|
|
60
|
+
const { classActiveLine = 'highlighted', classActivePre = 'has-highlighted' } = options;
|
|
61
|
+
return {
|
|
62
|
+
name: '@shikijs/transformers:meta-highlight',
|
|
63
|
+
line (node, line) {
|
|
64
|
+
if (!this.options.meta?.__raw) return;
|
|
65
|
+
const meta = this.meta;
|
|
66
|
+
meta[symbol] ??= parseMetaHighlightString(this.options.meta.__raw);
|
|
67
|
+
const lines = meta[symbol] ?? [];
|
|
68
|
+
if (lines.includes(line)) this.addClassToHast(node, classActiveLine);
|
|
69
|
+
return node;
|
|
70
|
+
},
|
|
71
|
+
pre (hast) {
|
|
72
|
+
this.addClassToHast(hast, classActivePre);
|
|
73
|
+
return hast;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export { SHIKI_TRANSFORMER_ADD_TITLE, SHIKI_TRANSFORMER_LINE_NUMBER, SHIKI_TRANSFORMER_META_HIGHLIGHT, transformerAddTitle, transformerCompatibleMetaHighlight, transformerLineNumber };
|
package/dist/theme.d.ts
ADDED
package/dist/theme.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@rspress/theme-default";
|
package/package.json
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.21",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/web-infra-dev/rspress.git",
|
|
9
|
-
"directory": "packages/
|
|
9
|
+
"directory": "packages/core"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"sideEffects": [
|
|
13
13
|
"*.css",
|
|
14
14
|
"*.less",
|
|
15
15
|
"*.sass",
|
|
16
|
-
"*.scss"
|
|
17
|
-
"**/virtual-global-styles.js",
|
|
18
|
-
"virtual-global-styles"
|
|
16
|
+
"*.scss"
|
|
19
17
|
],
|
|
20
18
|
"type": "module",
|
|
21
19
|
"exports": {
|
|
@@ -26,10 +24,16 @@
|
|
|
26
24
|
"./dist/*": "./dist/*",
|
|
27
25
|
"./package.json": "./package.json",
|
|
28
26
|
"./theme": {
|
|
29
|
-
"
|
|
27
|
+
"types": "./dist/theme.d.ts",
|
|
28
|
+
"default": "./dist/theme.js"
|
|
30
29
|
},
|
|
31
30
|
"./runtime": {
|
|
32
|
-
"
|
|
31
|
+
"types": "./dist/runtime.d.ts",
|
|
32
|
+
"default": "./dist/runtime.js"
|
|
33
|
+
},
|
|
34
|
+
"./shiki-transformers": {
|
|
35
|
+
"types": "./dist/shiki-transformers.d.ts",
|
|
36
|
+
"default": "./dist/shiki-transformers.js"
|
|
33
37
|
}
|
|
34
38
|
},
|
|
35
39
|
"main": "./dist/index.js",
|
|
@@ -37,69 +41,72 @@
|
|
|
37
41
|
"types": "./dist/index.d.ts",
|
|
38
42
|
"files": [
|
|
39
43
|
"dist",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"theme.ts"
|
|
44
|
+
"static",
|
|
45
|
+
"index.html"
|
|
43
46
|
],
|
|
44
47
|
"dependencies": {
|
|
45
48
|
"@mdx-js/loader": "^3.1.0",
|
|
46
49
|
"@mdx-js/mdx": "^3.1.0",
|
|
47
50
|
"@mdx-js/react": "^3.1.0",
|
|
48
|
-
"@rsbuild/core": "1.
|
|
49
|
-
"@rsbuild/plugin-react": "~1.
|
|
51
|
+
"@rsbuild/core": "~1.4.6",
|
|
52
|
+
"@rsbuild/plugin-react": "~1.3.4",
|
|
50
53
|
"@rspress/mdx-rs": "0.6.6",
|
|
51
|
-
"
|
|
54
|
+
"@shikijs/rehype": "^3.4.2",
|
|
55
|
+
"@types/unist": "^3.0.3",
|
|
56
|
+
"@unhead/react": "^2.0.12",
|
|
57
|
+
"enhanced-resolve": "5.18.2",
|
|
52
58
|
"github-slugger": "^2.0.0",
|
|
53
59
|
"hast-util-from-html": "^2.0.3",
|
|
54
60
|
"hast-util-heading-rank": "^3.0.0",
|
|
55
61
|
"html-to-text": "^9.0.5",
|
|
56
62
|
"lodash-es": "^4.17.21",
|
|
57
63
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
64
|
+
"medium-zoom": "1.1.0",
|
|
58
65
|
"picocolors": "^1.1.1",
|
|
59
66
|
"react": "^19.1.0",
|
|
60
67
|
"react-dom": "^19.1.0",
|
|
61
|
-
"react-helmet-async": "^2.0.5",
|
|
62
68
|
"react-lazy-with-preload": "^2.2.1",
|
|
63
69
|
"react-router-dom": "^6.29.0",
|
|
64
|
-
"react-syntax-highlighter": "^15.6.1",
|
|
65
70
|
"rehype-external-links": "^3.0.0",
|
|
71
|
+
"rehype-raw": "^7.0.0",
|
|
66
72
|
"remark": "^15.0.1",
|
|
67
73
|
"remark-gfm": "^4.0.1",
|
|
68
|
-
"rspack-plugin-virtual-module": "0.1
|
|
69
|
-
"
|
|
74
|
+
"rspack-plugin-virtual-module": "1.0.1",
|
|
75
|
+
"shiki": "^3.4.2",
|
|
76
|
+
"tinyglobby": "^0.2.14",
|
|
70
77
|
"unified": "^11.0.5",
|
|
71
78
|
"unist-util-visit": "^5.0.0",
|
|
72
79
|
"unist-util-visit-children": "^3.0.0",
|
|
73
|
-
"@rspress/
|
|
74
|
-
"@rspress/
|
|
75
|
-
"@rspress/
|
|
76
|
-
"@rspress/plugin-medium-zoom": "2.0.0-beta.2",
|
|
77
|
-
"@rspress/runtime": "2.0.0-beta.2",
|
|
78
|
-
"@rspress/shared": "2.0.0-beta.2",
|
|
79
|
-
"@rspress/theme-default": "2.0.0-beta.2"
|
|
80
|
+
"@rspress/runtime": "2.0.0-beta.21",
|
|
81
|
+
"@rspress/shared": "2.0.0-beta.21",
|
|
82
|
+
"@rspress/theme-default": "2.0.0-beta.21"
|
|
80
83
|
},
|
|
81
84
|
"devDependencies": {
|
|
82
|
-
"@microsoft/api-extractor": "^7.52.
|
|
83
|
-
"@rslib/core": "0.
|
|
85
|
+
"@microsoft/api-extractor": "^7.52.8",
|
|
86
|
+
"@rslib/core": "0.10.5",
|
|
84
87
|
"@rspress-dev/plugin-preview": "link:../plugin-preview",
|
|
85
88
|
"@types/hast": "^3.0.4",
|
|
86
89
|
"@types/html-to-text": "^9.0.4",
|
|
87
90
|
"@types/jest": "~29.5.14",
|
|
88
91
|
"@types/lodash-es": "^4.17.12",
|
|
89
92
|
"@types/mdast": "^4.0.4",
|
|
90
|
-
"@types/node": "^
|
|
91
|
-
"@types/react": "^
|
|
92
|
-
"@types/react-dom": "^
|
|
93
|
-
"
|
|
94
|
-
"
|
|
93
|
+
"@types/node": "^22.8.1",
|
|
94
|
+
"@types/react": "^19.1.8",
|
|
95
|
+
"@types/react-dom": "^19.1.6",
|
|
96
|
+
"execa": "8.0.1",
|
|
97
|
+
"mdast-util-mdx-expression": "^2.0.1",
|
|
98
|
+
"memfs": "^4.17.2",
|
|
99
|
+
"p-map": "^7.0.3",
|
|
100
|
+
"postcss": "8.5.6",
|
|
95
101
|
"rehype-stringify": "^10.0.1",
|
|
102
|
+
"remark-directive": "^4.0.0",
|
|
96
103
|
"remark-mdx": "^3.1.0",
|
|
97
104
|
"remark-parse": "^11.0.0",
|
|
98
105
|
"remark-rehype": "^11.1.2",
|
|
99
106
|
"remark-stringify": "^11.0.0",
|
|
100
107
|
"rimraf": "^6.0.1",
|
|
101
|
-
"rsbuild-plugin-publint": "^0.3.
|
|
102
|
-
"rsbuild-plugin-virtual-module": "0.
|
|
108
|
+
"rsbuild-plugin-publint": "^0.3.2",
|
|
109
|
+
"rsbuild-plugin-virtual-module": "0.3.0",
|
|
103
110
|
"tailwindcss": "^3.4.17",
|
|
104
111
|
"typescript": "^5.8.2",
|
|
105
112
|
"vfile": "^6.0.3",
|