@rspress/plugin-api-docgen 1.45.2 → 1.45.3

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/index.js CHANGED
@@ -281,6 +281,12 @@ var __webpack_exports__ = {};
281
281
  parseToolOptions,
282
282
  isProd
283
283
  });
284
+ config.builderConfig = config.builderConfig || {};
285
+ config.builderConfig.source = config.builderConfig.source || {};
286
+ config.builderConfig.source.define = {
287
+ ...config.builderConfig.source.define,
288
+ RSPRESS_PLUGIN_API_DOCGEN_MAP: JSON.stringify(apiDocMap)
289
+ };
284
290
  },
285
291
  async modifySearchIndexData (pages) {
286
292
  const apiCompRegExp = /(<API\s+moduleName=['"](\S+)['"]\s*(.*)?\/>)|(<API\s+moduleName=['"](\S+)['"]\s*(.*)?>(.*)?<\/API>)/;
@@ -300,11 +306,6 @@ var __webpack_exports__ = {};
300
306
  page.content = content;
301
307
  }));
302
308
  },
303
- extendPageData (pageData) {
304
- pageData.apiDocMap = {
305
- ...apiDocMap
306
- };
307
- },
308
309
  markdown: {
309
310
  globalComponents: [
310
311
  external_node_path_default().join(__dirname, '..', 'static', 'global-components', 'API.tsx')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/plugin-api-docgen",
3
- "version": "1.45.2",
3
+ "version": "1.45.3",
4
4
  "description": "A plugin for rspress to generate api doc.",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "license": "MIT",
12
12
  "main": "./dist/index.js",
13
- "types": "./index.d.ts",
13
+ "types": "./dist/index.d.ts",
14
14
  "files": [
15
15
  "dist",
16
16
  "static",
@@ -25,7 +25,7 @@
25
25
  "react-markdown": "8.0.7",
26
26
  "remark-gfm": "3.0.1",
27
27
  "unist-util-visit": "^4.1.2",
28
- "@rspress/shared": "1.45.2"
28
+ "@rspress/shared": "1.45.3"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@microsoft/api-extractor": "^7.49.2",
@@ -42,7 +42,7 @@
42
42
  "unified": "^10.1.2"
43
43
  },
44
44
  "peerDependencies": {
45
- "@rspress/core": "^1.45.2",
45
+ "@rspress/core": "^1.45.3",
46
46
  "react": ">=17.0.0",
47
47
  "react-router-dom": "^6.8.1",
48
48
  "typescript": "^5.5.3"
@@ -1,17 +1,19 @@
1
- /// <reference path="../../index.d.ts" />
2
-
3
- import { useLang, usePageData } from '@rspress/core/runtime';
1
+ import { useLang } from '@rspress/core/runtime';
4
2
  import { getCustomMDXComponent } from '@rspress/core/theme';
3
+ import GithubSlugger from 'github-slugger';
4
+ import type { Content, Element, Root } from 'hast';
5
5
  import ReactMarkdown from 'react-markdown';
6
6
  import remarkGfm from 'remark-gfm';
7
7
  import './API.scss';
8
- import GithubSlugger from 'github-slugger';
9
- import type { Content, Element, Root } from 'hast';
10
8
  // biome-ignore lint/style/useImportType: <exact>
11
9
  import React from 'react';
12
10
  import type { Plugin } from 'unified';
13
11
  import { visit } from 'unist-util-visit';
14
12
 
13
+ declare global {
14
+ var RSPRESS_PLUGIN_API_DOCGEN_MAP: Record<string, string>;
15
+ }
16
+
15
17
  function headingRank(node: Root | Content): number | null {
16
18
  const name =
17
19
  (node && node.type === 'element' && node.tagName.toLowerCase()) || '';
@@ -97,12 +99,11 @@ const collectHeaderText = (node: Element): string => {
97
99
  return text;
98
100
  };
99
101
 
100
- export default (props: { moduleName: string }) => {
102
+ const API = (props: { moduleName: string }) => {
101
103
  const lang = useLang();
102
- const { page } = usePageData();
103
104
  const { moduleName } = props;
104
105
  // some api doc have two languages.
105
- const apiDocMap = page.apiDocMap;
106
+ const apiDocMap = RSPRESS_PLUGIN_API_DOCGEN_MAP;
106
107
  // avoid error when no page data
107
108
  const apiDoc =
108
109
  apiDocMap?.[moduleName] || apiDocMap?.[`${moduleName}-${lang}`] || '';
@@ -118,3 +119,5 @@ export default (props: { moduleName: string }) => {
118
119
  </ReactMarkdown>
119
120
  );
120
121
  };
122
+
123
+ export default API;
package/index.d.ts DELETED
@@ -1,7 +0,0 @@
1
- declare module '@rspress/shared' {
2
- interface PageIndexInfo {
3
- apiDocMap?: Record<string, string>;
4
- }
5
- }
6
-
7
- export * from './dist'