@rspress-theme-anatole/core 0.0.1

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.
@@ -0,0 +1,111 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
2
+ import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress-theme-anatole/shared";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme";
5
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__ from "react-helmet-async";
7
+ import * as __WEBPACK_EXTERNAL_MODULE_virtual_global_components_43dbb356__ from "virtual-global-components";
8
+ import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data";
9
+ import "virtual-global-styles";
10
+ var App_rslib_entry_QueryStatus = /*#__PURE__*/ function(QueryStatus) {
11
+ QueryStatus["Show"] = "1";
12
+ QueryStatus["Hide"] = "0";
13
+ return QueryStatus;
14
+ }({});
15
+ async function initPageData(routePath) {
16
+ var _siteData_multiVersion;
17
+ const matchedRoute = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.pathnameToRouteService)(routePath);
18
+ if (matchedRoute) {
19
+ var _mod_default___RSPRESS_PAGE_META;
20
+ const mod = await matchedRoute.preload();
21
+ const pagePath = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.cleanUrl)(matchedRoute.filePath);
22
+ const extractPageInfo = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].pages.find((page)=>{
23
+ const normalize = (p)=>p.replace(/\/$/, '').toLowerCase();
24
+ return (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.isEqualPath)(normalize(page.routePath), normalize(matchedRoute.path));
25
+ });
26
+ const encodedPagePath = encodeURIComponent(pagePath);
27
+ const meta = (null === (_mod_default___RSPRESS_PAGE_META = mod.default.__RSPRESS_PAGE_META) || void 0 === _mod_default___RSPRESS_PAGE_META ? void 0 : _mod_default___RSPRESS_PAGE_META[encodedPagePath]) || {};
28
+ const { toc = [], title = '', frontmatter = {}, ...rest } = __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(matchedRoute.filePath) ? meta : mod;
29
+ return {
30
+ siteData: __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"],
31
+ page: {
32
+ ...rest,
33
+ pagePath,
34
+ ...extractPageInfo,
35
+ pageType: (null == frontmatter ? void 0 : frontmatter.pageType) || 'doc',
36
+ title,
37
+ frontmatter,
38
+ toc
39
+ }
40
+ };
41
+ }
42
+ let lang = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang || '';
43
+ let version = (null === (_siteData_multiVersion = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion) || void 0 === _siteData_multiVersion ? void 0 : _siteData_multiVersion.default) || '';
44
+ if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang && 'undefined' != typeof window) {
45
+ const path = location.pathname.replace(__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].base, '').split('/').slice(0, 2);
46
+ if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].locales.length) {
47
+ const result = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].locales.find(({ lang })=>path.includes(lang));
48
+ if (result) lang = result.lang;
49
+ }
50
+ if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion.versions) {
51
+ const result = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion.versions.find((version)=>path.includes(version));
52
+ if (result) version = result;
53
+ }
54
+ }
55
+ return {
56
+ siteData: __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"],
57
+ page: {
58
+ pagePath: '',
59
+ pageType: '404',
60
+ routePath: '/404',
61
+ lang,
62
+ frontmatter: {},
63
+ title: '404',
64
+ toc: [],
65
+ version,
66
+ _filepath: '',
67
+ _relativePath: ''
68
+ }
69
+ };
70
+ }
71
+ function App({ helmetContext }) {
72
+ const { setData: setPageData, data } = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext);
73
+ const frontmatter = data.page.frontmatter || {};
74
+ const { pathname, search } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)();
75
+ const query = new URLSearchParams(search);
76
+ const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
77
+ const hideGlobalUIComponents = false === frontmatter[GLOBAL_COMPONENTS_KEY] || "0" === query.get(GLOBAL_COMPONENTS_KEY);
78
+ (0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
79
+ async function refetchData() {
80
+ try {
81
+ const pageData = await initPageData(pathname);
82
+ null == setPageData || setPageData(pageData);
83
+ } catch (e) {
84
+ console.log(e);
85
+ }
86
+ }
87
+ refetchData();
88
+ }, [
89
+ pathname,
90
+ setPageData
91
+ ]);
92
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__.HelmetProvider, {
93
+ context: helmetContext,
94
+ children: [
95
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__["default"].Layout, {}),
96
+ !hideGlobalUIComponents && __WEBPACK_EXTERNAL_MODULE_virtual_global_components_43dbb356__["default"].map((componentInfo, index)=>{
97
+ if (Array.isArray(componentInfo)) {
98
+ const [component, props] = componentInfo;
99
+ return /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(component, {
100
+ key: index,
101
+ ...props
102
+ });
103
+ }
104
+ return /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(componentInfo, {
105
+ key: index
106
+ });
107
+ })
108
+ ]
109
+ });
110
+ }
111
+ export { App, App_rslib_entry_QueryStatus as QueryStatus, initPageData };
@@ -0,0 +1 @@
1
+ export declare function renderInBrowser(): Promise<void>;
@@ -0,0 +1,77 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_react_dom_7136dc57__ from "react-dom";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__ from "react-dom/client";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
5
+ import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
6
+ import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress-theme-anatole/shared";
7
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
8
+ import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data";
9
+ import * as __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__ from "./App.js";
10
+ var __webpack_modules__ = {
11
+ "@theme": function(module) {
12
+ module.exports = __WEBPACK_EXTERNAL_MODULE__theme_75e53063__;
13
+ },
14
+ "react-dom": function(module) {
15
+ module.exports = __WEBPACK_EXTERNAL_MODULE_react_dom_7136dc57__;
16
+ },
17
+ "react-dom/client": function(module) {
18
+ module.exports = __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__;
19
+ }
20
+ };
21
+ var __webpack_module_cache__ = {};
22
+ function __webpack_require__(moduleId) {
23
+ var cachedModule = __webpack_module_cache__[moduleId];
24
+ if (void 0 !== cachedModule) return cachedModule.exports;
25
+ var module = __webpack_module_cache__[moduleId] = {
26
+ exports: {}
27
+ };
28
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
29
+ return module.exports;
30
+ }
31
+ const enableSSG = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].ssg;
32
+ const { default: Theme, useThemeState } = __webpack_require__("@theme");
33
+ async function renderInBrowser() {
34
+ const container = document.getElementById('root');
35
+ const enhancedApp = async ()=>{
36
+ const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.initPageData)(window.location.pathname);
37
+ return function() {
38
+ const [data, setData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(initialPageData);
39
+ const [theme, setTheme] = useThemeState();
40
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.ThemeContext.Provider, {
41
+ value: (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
42
+ theme,
43
+ setTheme
44
+ }), [
45
+ theme,
46
+ setTheme
47
+ ]),
48
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext.Provider, {
49
+ value: (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
50
+ data,
51
+ setData
52
+ }), [
53
+ data,
54
+ setData
55
+ ]),
56
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.BrowserRouter, {
57
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {})
58
+ })
59
+ })
60
+ });
61
+ };
62
+ };
63
+ const RootApp = await enhancedApp();
64
+ if (process.env.__REACT_GTE_18__) {
65
+ const { createRoot, hydrateRoot } = __webpack_require__("react-dom/client");
66
+ if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)() && enableSSG) hydrateRoot(container, /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(RootApp, {}));
67
+ else createRoot(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(RootApp, {}));
68
+ } else {
69
+ const ReactDOM = __webpack_require__("react-dom");
70
+ if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)()) ReactDOM.hydrate(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(RootApp, {}), container);
71
+ else ReactDOM.render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(RootApp, {}), container);
72
+ }
73
+ }
74
+ renderInBrowser().then(()=>{
75
+ Theme.setup();
76
+ });
77
+ export { renderInBrowser };
@@ -0,0 +1,6 @@
1
+ import type { PageData } from '@rspress-theme-anatole/shared';
2
+ export declare function render(pagePath: string, helmetContext: object): Promise<{
3
+ appHtml: string;
4
+ pageData: PageData;
5
+ }>;
6
+ export { routes } from 'virtual-routes-ssr';
@@ -0,0 +1,32 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
2
+ import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_server_673c713a__ from "@rspress/runtime/server";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_react_dom_server_98c38d5c__ from "react-dom/server";
5
+ import * as __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__ from "./App.js";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_virtual_routes_ssr_f802e6e5__ from "virtual-routes-ssr";
7
+ const DEFAULT_THEME = 'light';
8
+ async function render(pagePath, helmetContext) {
9
+ const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.initPageData)(pagePath);
10
+ const appHtml = (0, __WEBPACK_EXTERNAL_MODULE_react_dom_server_98c38d5c__.renderToString)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.ThemeContext.Provider, {
11
+ value: {
12
+ theme: DEFAULT_THEME
13
+ },
14
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext.Provider, {
15
+ value: {
16
+ data: initialPageData
17
+ },
18
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_server_673c713a__.StaticRouter, {
19
+ location: pagePath,
20
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {
21
+ helmetContext: helmetContext
22
+ })
23
+ })
24
+ })
25
+ }));
26
+ return {
27
+ appHtml,
28
+ pageData: initialPageData
29
+ };
30
+ }
31
+ var __webpack_exports__routes = __WEBPACK_EXTERNAL_MODULE_virtual_routes_ssr_f802e6e5__.routes;
32
+ export { render, __webpack_exports__routes as routes };
@@ -0,0 +1,4 @@
1
+ var tsconfig_rslib_entry_namespaceObject = JSON.parse('{"compilerOptions":{"rootDir":".","baseUrl":".","skipLibCheck":true,"jsx":"react-jsx","esModuleInterop":true},"include":["./**/*"]}');
2
+ var __webpack_exports__compilerOptions = tsconfig_rslib_entry_namespaceObject.compilerOptions;
3
+ var __webpack_exports__include = tsconfig_rslib_entry_namespaceObject.include;
4
+ export { __webpack_exports__compilerOptions as compilerOptions, __webpack_exports__include as include };
package/index.html ADDED
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <!--<?- GENERATOR ?>-->
8
+ <!--<?- HEAD ?>-->
9
+ </head>
10
+
11
+ <body>
12
+ <div id="root"><!--<?- DOC_CONTENT ?>--></div>
13
+ <div id="search-container"></div>
14
+ </body>
15
+ </html>
package/package.json ADDED
@@ -0,0 +1,104 @@
1
+ {
2
+ "name": "@rspress-theme-anatole/core",
3
+ "version": "0.0.1",
4
+ "license": "MIT",
5
+ "sideEffects": [
6
+ "*.css",
7
+ "*.less",
8
+ "*.sass",
9
+ "*.scss",
10
+ "**/virtual-global-styles.js",
11
+ "virtual-global-styles"
12
+ ],
13
+ "type": "module",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
+ },
19
+ "./dist/*": "./dist/*",
20
+ "./package.json": "./package.json",
21
+ "./theme": {
22
+ "default": "./theme.ts"
23
+ },
24
+ "./runtime": {
25
+ "default": "./runtime.ts"
26
+ }
27
+ },
28
+ "main": "./dist/index.js",
29
+ "module": "./dist/node/index.js",
30
+ "types": "./dist/index.d.ts",
31
+ "files": [
32
+ "dist",
33
+ "index.html",
34
+ "runtime.ts",
35
+ "theme.ts"
36
+ ],
37
+ "dependencies": {
38
+ "@mdx-js/loader": "2.3.0",
39
+ "@mdx-js/mdx": "2.3.0",
40
+ "@mdx-js/react": "2.3.0",
41
+ "@rsbuild/core": "1.2.3",
42
+ "@rsbuild/plugin-less": "~1.1.0",
43
+ "@rsbuild/plugin-react": "~1.1.0",
44
+ "@rsbuild/plugin-sass": "~1.2.0",
45
+ "@rspress/mdx-rs": "0.6.6",
46
+ "enhanced-resolve": "5.18.0",
47
+ "github-slugger": "^2.0.0",
48
+ "hast-util-from-html": "^2.0.3",
49
+ "hast-util-heading-rank": "^2.1.1",
50
+ "html-to-text": "^9.0.5",
51
+ "htmr": "^1.0.2",
52
+ "lodash-es": "^4.17.21",
53
+ "mdast-util-mdxjs-esm": "^1.3.1",
54
+ "memfs": "^4.17.0",
55
+ "picocolors": "^1.1.1",
56
+ "react": "^18.3.1",
57
+ "react-dom": "^18.3.1",
58
+ "react-helmet-async": "^1.3.0",
59
+ "react-lazy-with-preload": "^2.2.1",
60
+ "react-syntax-highlighter": "^15.6.1",
61
+ "rehype-external-links": "^3.0.0",
62
+ "remark": "^14.0.3",
63
+ "remark-gfm": "3.0.1",
64
+ "rspack-plugin-virtual-module": "0.1.13",
65
+ "tinyglobby": "^0.2.10",
66
+ "unified": "^10.1.2",
67
+ "unist-util-visit": "^4.1.2",
68
+ "unist-util-visit-children": "^2.0.2",
69
+ "@rspress/plugin-auto-nav-sidebar": "1.43.8",
70
+ "@rspress-theme-anatole/plugin-container-syntax": "0.0.3",
71
+ "@rspress/plugin-last-updated": "1.43.8",
72
+ "@rspress/plugin-medium-zoom": "1.43.8",
73
+ "@rspress/runtime": "1.43.8",
74
+ "@rspress-theme-anatole/theme-default": "0.1.26",
75
+ "@rspress-theme-anatole/shared": "0.1.19"
76
+ },
77
+ "devDependencies": {
78
+ "@microsoft/api-extractor": "^7.49.2",
79
+ "@rslib/core": "0.5.2",
80
+ "@rspress-dev/plugin-preview": "link:../plugin-preview",
81
+ "@types/hast": "^2.3.10",
82
+ "@types/html-to-text": "^9.0.4",
83
+ "@types/jest": "~29.5.14",
84
+ "@types/lodash-es": "^4.17.12",
85
+ "@types/mdast": "^3.0.15",
86
+ "@types/node": "^18.11.17",
87
+ "@types/react": "^18.3.18",
88
+ "@types/react-dom": "^18.3.5",
89
+ "postcss": "8.5.1",
90
+ "rehype-stringify": "^9.0.4",
91
+ "remark-mdx": "2.3.0",
92
+ "remark-parse": "^10.0.2",
93
+ "remark-rehype": "^10.1.0",
94
+ "remark-stringify": "^10.0.3",
95
+ "rimraf": "^3.0.2",
96
+ "tailwindcss": "^3.4.17",
97
+ "typescript": "^5.5.3",
98
+ "vfile": "^5.3.7",
99
+ "@rspress/config": "1.0.0"
100
+ },
101
+ "publishConfig": {
102
+ "access": "public"
103
+ }
104
+ }
package/runtime.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@rspress/runtime';
package/theme.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from '@rspress-theme-anatole/theme-default';
2
+ export { default } from '@rspress-theme-anatole/theme-default';