rspress-plugin-api-extractor 0.7.4 → 0.7.5
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/env.d.ts +114 -0
- package/package.json +6 -3
- package/runtime/components/ApiExample/index.js +1 -1
- package/tsconfig/rspress.json +4 -1
package/env.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// // Ambient module + import.meta.env declarations for RSPress plugin runtimes built with
|
|
2
|
+
// // @savvy-web/rspress-builder. Replaces the rslib-era @rslib/core/types reference.
|
|
3
|
+
|
|
4
|
+
type CSSModuleClasses = Readonly<Record<string, string>>;
|
|
5
|
+
|
|
6
|
+
declare module "*.module.css" {
|
|
7
|
+
const classes: CSSModuleClasses;
|
|
8
|
+
export default classes;
|
|
9
|
+
}
|
|
10
|
+
declare module "*.css" {}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The `ImportMetaEnv` interface defines the shape of the `import.meta.env` object, which contains environment variables
|
|
14
|
+
* injected by Vite during the build process. These variables provide information about the build environment,
|
|
15
|
+
* such as whether the app is running in development or production mode, whether it is being server-side rendered, and other relevant details.
|
|
16
|
+
* @see {@link https://vite.dev/guide/env-and-mode|Vite | Env and Modes }
|
|
17
|
+
*/
|
|
18
|
+
interface ImportMetaEnv {
|
|
19
|
+
/**
|
|
20
|
+
* Environment variable so React components can distinguish SSG-MD (markdown)
|
|
21
|
+
* rendering from browser rendering and customize their output
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* export function Tab({ label }: { label: string }) {
|
|
25
|
+
* if (import.meta.env.SSG_MD) {
|
|
26
|
+
* // This will be returned as a static string in the markdown output
|
|
27
|
+
* return <>{`** Here is a Tab named ${label}**`}</>;
|
|
28
|
+
* }
|
|
29
|
+
* // This will be returned as a React component in the browser
|
|
30
|
+
* return <div class="tab">{label}</div>;
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
* @see {@link https://rspress.rs/guide/basic/ssg-md|RSPress | SSG-MD }
|
|
34
|
+
* @see {@link https://vite.dev/guide/env-and-mode|Vite | Env and Modes }
|
|
35
|
+
* */
|
|
36
|
+
|
|
37
|
+
readonly SSG_MD: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* whether the Vite app is running in SSR (server-side rendering) mode. Allows you to
|
|
40
|
+
* conditionally render React components differently for SSR vs. browser rendering.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* export function DebugInfo() {
|
|
45
|
+
* if (import.meta.env.SSR) {
|
|
46
|
+
* return <div class="debug-info">Debug info here</div>;
|
|
47
|
+
* }
|
|
48
|
+
* return null;
|
|
49
|
+
* }
|
|
50
|
+
* @see {@link https://vite.dev/guide/env-and-mode|Vite | Env and Modes }
|
|
51
|
+
*/
|
|
52
|
+
readonly SSR: boolean;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Environment variable so React components can distinguish between development and
|
|
56
|
+
* production builds
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* export function DebugInfo() {
|
|
61
|
+
* if (import.meta.env.MODE === "development") {
|
|
62
|
+
* return <div class="debug-info">Debug info here</div>;
|
|
63
|
+
* }
|
|
64
|
+
* return null;
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
* @see {@link https://vite.dev/guide/env-and-mode#modes|Vite | Modes }
|
|
68
|
+
*/
|
|
69
|
+
readonly MODE: "development" | "production";
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Base public path when served in development or production. Valid values include:
|
|
73
|
+
* Absolute URL pathname, e.g. `/foo/`
|
|
74
|
+
* - Full URL, e.g. `https://bar.com/foo/` (The origin part won't be used in development so the value is the same as /foo/)
|
|
75
|
+
* - Empty string or `./` (for embedded deployment)
|
|
76
|
+
* @see {@link https://vite.dev/guide/env-and-mode|Vite | Env and Modes }
|
|
77
|
+
*/
|
|
78
|
+
readonly BASE_URL: string;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* whether the Vite app is running in production mode:
|
|
82
|
+
* - running the dev server with `NODE_ENV='production'`
|
|
83
|
+
* - running an app built with `NODE_ENV='production'`)
|
|
84
|
+
*
|
|
85
|
+
* Always the opposite of `import.meta.env.DEV`
|
|
86
|
+
*
|
|
87
|
+
* @see {@link https://vite.dev/guide/env-and-mode#env-files|Vite | Modes }
|
|
88
|
+
*/
|
|
89
|
+
readonly PROD: boolean;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* whether the Vite app is running in development mode:
|
|
93
|
+
* - running the dev server with `NODE_ENV='development'`
|
|
94
|
+
* - running an app built with `NODE_ENV='development'`
|
|
95
|
+
*
|
|
96
|
+
* Always the opposite of `import.meta.env.PROD`.
|
|
97
|
+
* @see {@link https://vite.dev/guide/env-and-mode#env-files|Vite | Modes }
|
|
98
|
+
*/
|
|
99
|
+
readonly DEV: boolean;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// biome-ignore lint/correctness/noUnusedVariables: ImportMeta is used by TypeScript but may appear unused to the linter
|
|
103
|
+
interface ImportMeta {
|
|
104
|
+
/**
|
|
105
|
+
* The `import.meta` object contains metadata about the current module. It is a standard
|
|
106
|
+
* feature in JavaScript modules. The `env` property on `import.meta` is a custom property injected
|
|
107
|
+
* by Vite that provides access to environment variables defined in the Vite configuration or `.env` files.
|
|
108
|
+
* RSPress uses this to provide information about the build environment, such as whether the app is running
|
|
109
|
+
* in development or production mode, whether it is being server-side rendered, and other relevant environment details.
|
|
110
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta|}
|
|
111
|
+
* @see {@link https://vite.dev/guide/env-and-mode|Vite | Env and Modes }
|
|
112
|
+
*/
|
|
113
|
+
env: ImportMetaEnv;
|
|
114
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rspress-plugin-api-extractor",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "RSPress plugin for generating API documentation from TypeScript API Extractor models",
|
|
6
6
|
"keywords": [
|
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
"import": "./index.js",
|
|
26
26
|
"default": "./index.js"
|
|
27
27
|
},
|
|
28
|
+
"./env": {
|
|
29
|
+
"types": "./env.d.ts"
|
|
30
|
+
},
|
|
28
31
|
"./runtime": {
|
|
29
32
|
"types": "./runtime/index.d.ts",
|
|
30
33
|
"import": "./runtime/index.js",
|
|
@@ -38,7 +41,7 @@
|
|
|
38
41
|
"@effect/sql-sqlite-node": "4.0.0-beta.101",
|
|
39
42
|
"@effected/semver": "^0.2.1",
|
|
40
43
|
"@effected/store": "^0.1.2",
|
|
41
|
-
"@effected/tsconfig-json": "^0.
|
|
44
|
+
"@effected/tsconfig-json": "^0.4.0",
|
|
42
45
|
"@effected/xdg": "^0.1.9",
|
|
43
46
|
"@microsoft/api-extractor-model": "^7.33.10",
|
|
44
47
|
"@shikijs/twoslash": "^4.3.1",
|
|
@@ -56,7 +59,7 @@
|
|
|
56
59
|
"prettier": "^3.9.6",
|
|
57
60
|
"react-markdown": "^10.1.0",
|
|
58
61
|
"shiki": "^4.3.1",
|
|
59
|
-
"type-registry-effect": "^2.3.
|
|
62
|
+
"type-registry-effect": "^2.3.1",
|
|
60
63
|
"typescript": "^6.0.3",
|
|
61
64
|
"unist-util-visit": "^5.1.0"
|
|
62
65
|
},
|
|
@@ -15,7 +15,7 @@ import { Fragment, jsx } from "react/jsx-runtime";
|
|
|
15
15
|
*/
|
|
16
16
|
function ApiExample({ code, hast }) {
|
|
17
17
|
const parsedHast = useMemo(() => decodeHast(hast, "ApiExample"), [hast]);
|
|
18
|
-
if (import.meta.env
|
|
18
|
+
if (import.meta.env?.SSG_MD === true) return /* @__PURE__ */ jsx(Fragment, { children: `\`\`\`typescript
|
|
19
19
|
${code.trim()}
|
|
20
20
|
\`\`\`
|
|
21
21
|
` });
|
package/tsconfig/rspress.json
CHANGED
|
@@ -36,7 +36,10 @@
|
|
|
36
36
|
"${configDir}/docs/**/*.mdx",
|
|
37
37
|
"${configDir}/theme/**/*.ts",
|
|
38
38
|
"${configDir}/theme/**/*.tsx",
|
|
39
|
-
"${configDir}/theme/**/*.mdx"
|
|
39
|
+
"${configDir}/theme/**/*.mdx",
|
|
40
|
+
"${configDir}/components/**/*.ts",
|
|
41
|
+
"${configDir}/components/**/*.tsx",
|
|
42
|
+
"${configDir}/components/**/*.mdx"
|
|
40
43
|
],
|
|
41
44
|
"mdx": {
|
|
42
45
|
"checkMdx": true
|