vike-plugin-typedoc 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.
Files changed (59) hide show
  1. package/README.md +148 -0
  2. package/README.md.template +148 -0
  3. package/dist/+config.d.ts +41 -0
  4. package/dist/+config.d.ts.map +1 -0
  5. package/dist/+config.js +21 -0
  6. package/dist/+config.js.map +1 -0
  7. package/dist/client.d.ts +14 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +29 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/context.d.ts +83 -0
  12. package/dist/context.d.ts.map +1 -0
  13. package/dist/context.js +129 -0
  14. package/dist/context.js.map +1 -0
  15. package/dist/hooks/onBeforePrerenderStart.d.ts +9 -0
  16. package/dist/hooks/onBeforePrerenderStart.d.ts.map +1 -0
  17. package/dist/hooks/onBeforePrerenderStart.js +37 -0
  18. package/dist/hooks/onBeforePrerenderStart.js.map +1 -0
  19. package/dist/hooks/onCreateGlobalContext.d.ts +17 -0
  20. package/dist/hooks/onCreateGlobalContext.d.ts.map +1 -0
  21. package/dist/hooks/onCreateGlobalContext.js +28 -0
  22. package/dist/hooks/onCreateGlobalContext.js.map +1 -0
  23. package/dist/index.d.ts +12 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +15 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/linkify.d.ts +53 -0
  28. package/dist/linkify.d.ts.map +1 -0
  29. package/dist/linkify.js +118 -0
  30. package/dist/linkify.js.map +1 -0
  31. package/dist/markdown.d.ts +41 -0
  32. package/dist/markdown.d.ts.map +1 -0
  33. package/dist/markdown.js +89 -0
  34. package/dist/markdown.js.map +1 -0
  35. package/dist/navigation.d.ts +7 -0
  36. package/dist/navigation.d.ts.map +1 -0
  37. package/dist/navigation.js +20 -0
  38. package/dist/navigation.js.map +1 -0
  39. package/dist/parser.d.ts +10 -0
  40. package/dist/parser.d.ts.map +1 -0
  41. package/dist/parser.js +253 -0
  42. package/dist/parser.js.map +1 -0
  43. package/dist/server.d.ts +89 -0
  44. package/dist/server.d.ts.map +1 -0
  45. package/dist/server.js +158 -0
  46. package/dist/server.js.map +1 -0
  47. package/dist/symbols.d.ts +11 -0
  48. package/dist/symbols.d.ts.map +1 -0
  49. package/dist/symbols.js +32 -0
  50. package/dist/symbols.js.map +1 -0
  51. package/dist/types.d.ts +223 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/types.js +27 -0
  54. package/dist/types.js.map +1 -0
  55. package/dist/utils.d.ts +22 -0
  56. package/dist/utils.d.ts.map +1 -0
  57. package/dist/utils.js +164 -0
  58. package/dist/utils.js.map +1 -0
  59. package/package.json +100 -0
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # vike-plugin-typedoc
2
+
3
+ Headless TypeDoc integration for Vike documentation sites.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install vike-plugin-typedoc
9
+ ```
10
+
11
+ Peer dependencies:
12
+
13
+ - `vike >= 0.4.250`
14
+ - `vike-react >= 0.5` (if you use the React hooks)
15
+ - `react >= 18` (if you use the React hooks)
16
+
17
+ ## What It Does
18
+
19
+ - Loads TypeDoc JSON files into a cached `TypedocContext`.
20
+ - Builds package and symbol URLs (default `/api/:pkg/:symbol`).
21
+ - Builds API navigation trees.
22
+ - Pre-renders markdown fields and auto-links type references.
23
+ - Provides Vike data helpers (`withApiPackage`, `withApiExport`) and React hooks (`useApiPackage`, `useApiExport`).
24
+ - Provides a Vike config extension that auto-loads context and prerender URLs.
25
+
26
+ ## Quick Start
27
+
28
+ Add the plugin extension and `typedoc` config:
29
+
30
+ ```ts
31
+ import { join } from 'node:path';
32
+ import vikePluginTypedoc from 'vike-plugin-typedoc/config';
33
+ import vikeReact from 'vike-react/config';
34
+ import type { Config } from 'vike/types';
35
+
36
+ const root = process.cwd();
37
+
38
+ export default {
39
+ extends: [vikeReact, vikePluginTypedoc],
40
+ prerender: true,
41
+ typedoc: {
42
+ typedocDir: join(root, '.typedoc'),
43
+ packagesDir: join(root, 'packages'),
44
+ basePath: '/api',
45
+ },
46
+ } satisfies Config;
47
+ ```
48
+
49
+ The plugin expects one TypeDoc JSON file per package slug in `typedocDir` (for example `.typedoc/devkit.json`).
50
+
51
+ ## Package and Symbol Pages
52
+
53
+ Package route data loader:
54
+
55
+ ```ts
56
+ // pages/api/@pkg/+data.ts
57
+ import { withApiPackage } from 'vike-plugin-typedoc/server';
58
+ import type { PageContextServer } from 'vike/types';
59
+
60
+ export function data(pageContext: PageContextServer) {
61
+ return withApiPackage(pageContext, pageContext.routeParams.pkg);
62
+ }
63
+ ```
64
+
65
+ Package route component:
66
+
67
+ ```tsx
68
+ // pages/api/@pkg/+Page.tsx
69
+ import { useApiPackage } from 'vike-plugin-typedoc/client';
70
+
71
+ export default function Page() {
72
+ const { apiPackage, packageName } = useApiPackage();
73
+ if (!apiPackage) return <h1>Package not found: {packageName}</h1>;
74
+ return <h1>{packageName}</h1>;
75
+ }
76
+ ```
77
+
78
+ Symbol route data loader:
79
+
80
+ ```ts
81
+ // pages/api/@pkg/@symbol/+data.ts
82
+ import { withApiExport } from 'vike-plugin-typedoc/server';
83
+ import type { PageContextServer } from 'vike/types';
84
+
85
+ export function data(pageContext: PageContextServer) {
86
+ const { pkg, symbol } = pageContext.routeParams;
87
+ return withApiExport(pageContext, pkg, symbol);
88
+ }
89
+ ```
90
+
91
+ Symbol route component:
92
+
93
+ ```tsx
94
+ // pages/api/@pkg/@symbol/+Page.tsx
95
+ import { useApiExport } from 'vike-plugin-typedoc/client';
96
+
97
+ export default function Page() {
98
+ const { apiExport, packageName } = useApiExport();
99
+ if (!apiExport) return <h1>Symbol not found in {packageName}</h1>;
100
+ return <h1>{apiExport.name}</h1>;
101
+ }
102
+ ```
103
+
104
+ ## `typedoc` Config Options
105
+
106
+ | Option | Type | Description |
107
+ |--------|------|-------------|
108
+ | `typedocDir` | `string` | Directory containing `*.json` TypeDoc output files. |
109
+ | `packageNames` | `Record<string, string>` | Optional slug-to-npm-name overrides. |
110
+ | `packagesDir` | `string` | Reads missing package names from `<packagesDir>/<slug>/package.json`. |
111
+ | `exclude` | `string[]` | Package slugs to skip when loading docs. |
112
+ | `buildUrl` | `(packageSlug: string, symbolSlug?: string) => string` | Custom URL builder for package and symbol pages. |
113
+ | `basePath` | `string` | Prefix used by default URL builder. Defaults to `/api`. |
114
+ | `baseUrl` | `string` | Deployment base URL used when generating HTML links. |
115
+ | `remarkPlugins` | `PluggableList` | Extra remark plugins for markdown rendering. |
116
+ | `rehypePlugins` | `PluggableList` | Extra rehype plugins for markdown rendering (for example syntax highlighting). |
117
+
118
+ ## Server and Client Entrypoints
119
+
120
+ - `vike-plugin-typedoc/server`:
121
+ - `loadTypedocContext()`
122
+ - `getTypedocContext()`
123
+ - `withApiPackage()`
124
+ - `withApiExport()`
125
+ - `vike-plugin-typedoc/client`:
126
+ - `useApiPackage()`
127
+ - `useApiExport()`
128
+
129
+ ## Headless Utilities (Without Vike Hooks)
130
+
131
+ Root exports are usable even outside Vike page hooks:
132
+
133
+ ```ts
134
+ import {
135
+ buildApiNavigation,
136
+ buildMarkdownProcessor,
137
+ buildSymbolsMap,
138
+ combineApiDocs,
139
+ createTypedocContext,
140
+ parseTypedocJson,
141
+ } from 'vike-plugin-typedoc';
142
+ ```
143
+
144
+ This is useful if you want to parse TypeDoc JSON once and feed another renderer, while reusing the same symbol-linking logic.
145
+
146
+ ## License
147
+
148
+ MIT
@@ -0,0 +1,148 @@
1
+ # vike-plugin-typedoc
2
+
3
+ Headless TypeDoc integration for Vike documentation sites.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install vike-plugin-typedoc
9
+ ```
10
+
11
+ Peer dependencies:
12
+
13
+ - `vike >= 0.4.250`
14
+ - `vike-react >= 0.5` (if you use the React hooks)
15
+ - `react >= 18` (if you use the React hooks)
16
+
17
+ ## What It Does
18
+
19
+ - Loads TypeDoc JSON files into a cached `TypedocContext`.
20
+ - Builds package and symbol URLs (default `/api/:pkg/:symbol`).
21
+ - Builds API navigation trees.
22
+ - Pre-renders markdown fields and auto-links type references.
23
+ - Provides Vike data helpers (`withApiPackage`, `withApiExport`) and React hooks (`useApiPackage`, `useApiExport`).
24
+ - Provides a Vike config extension that auto-loads context and prerender URLs.
25
+
26
+ ## Quick Start
27
+
28
+ Add the plugin extension and `typedoc` config:
29
+
30
+ ```ts
31
+ import { join } from 'node:path';
32
+ import vikePluginTypedoc from 'vike-plugin-typedoc/config';
33
+ import vikeReact from 'vike-react/config';
34
+ import type { Config } from 'vike/types';
35
+
36
+ const root = process.cwd();
37
+
38
+ export default {
39
+ extends: [vikeReact, vikePluginTypedoc],
40
+ prerender: true,
41
+ typedoc: {
42
+ typedocDir: join(root, '.typedoc'),
43
+ packagesDir: join(root, 'packages'),
44
+ basePath: '/api',
45
+ },
46
+ } satisfies Config;
47
+ ```
48
+
49
+ The plugin expects one TypeDoc JSON file per package slug in `typedocDir` (for example `.typedoc/devkit.json`).
50
+
51
+ ## Package and Symbol Pages
52
+
53
+ Package route data loader:
54
+
55
+ ```ts
56
+ // pages/api/@pkg/+data.ts
57
+ import { withApiPackage } from 'vike-plugin-typedoc/server';
58
+ import type { PageContextServer } from 'vike/types';
59
+
60
+ export function data(pageContext: PageContextServer) {
61
+ return withApiPackage(pageContext, pageContext.routeParams.pkg);
62
+ }
63
+ ```
64
+
65
+ Package route component:
66
+
67
+ ```tsx
68
+ // pages/api/@pkg/+Page.tsx
69
+ import { useApiPackage } from 'vike-plugin-typedoc/client';
70
+
71
+ export default function Page() {
72
+ const { apiPackage, packageName } = useApiPackage();
73
+ if (!apiPackage) return <h1>Package not found: {packageName}</h1>;
74
+ return <h1>{packageName}</h1>;
75
+ }
76
+ ```
77
+
78
+ Symbol route data loader:
79
+
80
+ ```ts
81
+ // pages/api/@pkg/@symbol/+data.ts
82
+ import { withApiExport } from 'vike-plugin-typedoc/server';
83
+ import type { PageContextServer } from 'vike/types';
84
+
85
+ export function data(pageContext: PageContextServer) {
86
+ const { pkg, symbol } = pageContext.routeParams;
87
+ return withApiExport(pageContext, pkg, symbol);
88
+ }
89
+ ```
90
+
91
+ Symbol route component:
92
+
93
+ ```tsx
94
+ // pages/api/@pkg/@symbol/+Page.tsx
95
+ import { useApiExport } from 'vike-plugin-typedoc/client';
96
+
97
+ export default function Page() {
98
+ const { apiExport, packageName } = useApiExport();
99
+ if (!apiExport) return <h1>Symbol not found in {packageName}</h1>;
100
+ return <h1>{apiExport.name}</h1>;
101
+ }
102
+ ```
103
+
104
+ ## `typedoc` Config Options
105
+
106
+ | Option | Type | Description |
107
+ |--------|------|-------------|
108
+ | `typedocDir` | `string` | Directory containing `*.json` TypeDoc output files. |
109
+ | `packageNames` | `Record<string, string>` | Optional slug-to-npm-name overrides. |
110
+ | `packagesDir` | `string` | Reads missing package names from `<packagesDir>/<slug>/package.json`. |
111
+ | `exclude` | `string[]` | Package slugs to skip when loading docs. |
112
+ | `buildUrl` | `(packageSlug: string, symbolSlug?: string) => string` | Custom URL builder for package and symbol pages. |
113
+ | `basePath` | `string` | Prefix used by default URL builder. Defaults to `/api`. |
114
+ | `baseUrl` | `string` | Deployment base URL used when generating HTML links. |
115
+ | `remarkPlugins` | `PluggableList` | Extra remark plugins for markdown rendering. |
116
+ | `rehypePlugins` | `PluggableList` | Extra rehype plugins for markdown rendering (for example syntax highlighting). |
117
+
118
+ ## Server and Client Entrypoints
119
+
120
+ - `vike-plugin-typedoc/server`:
121
+ - `loadTypedocContext()`
122
+ - `getTypedocContext()`
123
+ - `withApiPackage()`
124
+ - `withApiExport()`
125
+ - `vike-plugin-typedoc/client`:
126
+ - `useApiPackage()`
127
+ - `useApiExport()`
128
+
129
+ ## Headless Utilities (Without Vike Hooks)
130
+
131
+ Root exports are usable even outside Vike page hooks:
132
+
133
+ ```ts
134
+ import {
135
+ buildApiNavigation,
136
+ buildMarkdownProcessor,
137
+ buildSymbolsMap,
138
+ combineApiDocs,
139
+ createTypedocContext,
140
+ parseTypedocJson,
141
+ } from 'vike-plugin-typedoc';
142
+ ```
143
+
144
+ This is useful if you want to parse TypeDoc JSON once and feed another renderer, while reusing the same symbol-linking logic.
145
+
146
+ ## License
147
+
148
+ MIT
@@ -0,0 +1,41 @@
1
+ import type { TypedocContext } from './context.js';
2
+ import type { LoadTypedocContextOptions } from './server.js';
3
+ declare global {
4
+ namespace Vike {
5
+ interface Config {
6
+ /** Configuration for vike-plugin-typedoc. */
7
+ typedoc?: LoadTypedocContextOptions;
8
+ }
9
+ interface GlobalContextServer {
10
+ $$VIKE_PLUGIN_TYPEDOC$$?: TypedocContext;
11
+ }
12
+ }
13
+ }
14
+ declare const _default: {
15
+ name: string;
16
+ require: {
17
+ vike: string;
18
+ };
19
+ onCreateGlobalContext: "import:vike-plugin-typedoc/__internal/hooks/onCreateGlobalContext:onCreateGlobalContext";
20
+ onBeforePrerenderStart: "import:vike-plugin-typedoc/__internal/hooks/onBeforePrerenderStart:onBeforePrerenderStart";
21
+ meta: {
22
+ typedoc: {
23
+ env: {
24
+ server: true;
25
+ };
26
+ global: true;
27
+ };
28
+ onCreateGlobalContext: {
29
+ env: {
30
+ server: true;
31
+ };
32
+ };
33
+ onBeforePrerenderStart: {
34
+ env: {
35
+ server: true;
36
+ };
37
+ };
38
+ };
39
+ };
40
+ export default _default;
41
+ //# sourceMappingURL=+config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"+config.d.ts","sourceRoot":"","sources":["../src/+config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,IAAI,CAAC;QACb,UAAU,MAAM;YACd,6CAA6C;YAC7C,OAAO,CAAC,EAAE,yBAAyB,CAAC;SACrC;QACD,UAAU,mBAAmB;YAC3B,uBAAuB,CAAC,EAAE,cAAc,CAAC;SAC1C;KACF;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;AAED,wBAqBmB"}
@@ -0,0 +1,21 @@
1
+ export default {
2
+ name: 'vike-plugin-typedoc',
3
+ require: {
4
+ vike: '>=0.4.250',
5
+ },
6
+ onCreateGlobalContext: 'import:vike-plugin-typedoc/__internal/hooks/onCreateGlobalContext:onCreateGlobalContext',
7
+ onBeforePrerenderStart: 'import:vike-plugin-typedoc/__internal/hooks/onBeforePrerenderStart:onBeforePrerenderStart',
8
+ meta: {
9
+ typedoc: {
10
+ env: { server: true },
11
+ global: true,
12
+ },
13
+ onCreateGlobalContext: {
14
+ env: { server: true },
15
+ },
16
+ onBeforePrerenderStart: {
17
+ env: { server: true },
18
+ },
19
+ },
20
+ };
21
+ //# sourceMappingURL=+config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"+config.js","sourceRoot":"","sources":["../src/+config.ts"],"names":[],"mappings":"AAiBA,eAAe;IACb,IAAI,EAAE,qBAAqB;IAC3B,OAAO,EAAE;QACP,IAAI,EAAE,WAAW;KAClB;IACD,qBAAqB,EACnB,yFAAyF;IAC3F,sBAAsB,EACpB,2FAA2F;IAC7F,IAAI,EAAE;QACJ,OAAO,EAAE;YACP,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;YACrB,MAAM,EAAE,IAAI;SACb;QACD,qBAAqB,EAAE;YACrB,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;SACtB;QACD,sBAAsB,EAAE;YACtB,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;SACtB;KACF;CACe,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { ApiExportData, ApiPackageData } from './server.js';
2
+ /**
3
+ * Read API package data from page data in a `+Page.tsx` component.
4
+ *
5
+ * Requires that `+data.ts` returns `withApiPackage()` from the server entry.
6
+ */
7
+ export declare function useApiPackage(): ApiPackageData;
8
+ /**
9
+ * Read API export/symbol data from page data in a `+Page.tsx` component.
10
+ *
11
+ * Requires that `+data.ts` returns `withApiExport()` from the server entry.
12
+ */
13
+ export declare function useApiExport(): ApiExportData;
14
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIjE;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,cAAc,CAS9C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,aAAa,CAS5C"}
package/dist/client.js ADDED
@@ -0,0 +1,29 @@
1
+ import { useData } from 'vike-react/useData';
2
+ const DATA_KEY = '$$VIKE_PLUGIN_TYPEDOC$$';
3
+ /**
4
+ * Read API package data from page data in a `+Page.tsx` component.
5
+ *
6
+ * Requires that `+data.ts` returns `withApiPackage()` from the server entry.
7
+ */
8
+ export function useApiPackage() {
9
+ const data = useData();
10
+ const pluginData = data[DATA_KEY];
11
+ if (!pluginData) {
12
+ throw new Error('No API package data found in page data. Ensure your +data.ts returns withApiPackage().');
13
+ }
14
+ return pluginData;
15
+ }
16
+ /**
17
+ * Read API export/symbol data from page data in a `+Page.tsx` component.
18
+ *
19
+ * Requires that `+data.ts` returns `withApiExport()` from the server entry.
20
+ */
21
+ export function useApiExport() {
22
+ const data = useData();
23
+ const pluginData = data[DATA_KEY];
24
+ if (!pluginData) {
25
+ throw new Error('No API export data found in page data. Ensure your +data.ts returns withApiExport().');
26
+ }
27
+ return pluginData;
28
+ }
29
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,MAAM,QAAQ,GAAG,yBAAyB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,IAAI,GAAG,OAAO,EAA2B,CAAC;IAChD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAA+B,CAAC;IAChE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACb,wFAAwF,CACzF,CAAC;IACJ,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,IAAI,GAAG,OAAO,EAA2B,CAAC;IAChD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAA8B,CAAC;IAC/D,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACb,sFAAsF,CACvF,CAAC;IACJ,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,83 @@
1
+ import type { RehypeTypedocOptions, SymbolEntry } from 'rehype-typedoc';
2
+ import type { PluggableList } from 'unified';
3
+ import type { LinkedApiExport } from './linkify.js';
4
+ import type { ApiDocs, ApiPackage, NavigationItem } from './types.js';
5
+ export interface TypedocContextOptions {
6
+ /**
7
+ * Build a URL for a package or symbol page.
8
+ * Called for every link the plugin generates.
9
+ *
10
+ * @default (pkg, sym) => sym ? `/api/${pkg}/${sym}` : `/api/${pkg}`
11
+ */
12
+ buildUrl?: (packageSlug: string, symbolSlug?: string) => string;
13
+ /**
14
+ * Base path prefix for generated URLs.
15
+ * Used to build the default `buildUrl` when no custom function is provided.
16
+ *
17
+ * @default '/api'
18
+ * @example '/docs/api' → URLs like `/docs/api/devkit/parse-json`
19
+ */
20
+ basePath?: string;
21
+ /**
22
+ * Deployment base URL to prepend to rendered HTML links.
23
+ *
24
+ * When set, `buildLink` (used by rehype-typedoc for inline type links and
25
+ * rendered markdown) prepends this base to every route-relative path.
26
+ * Stored paths (`exp.path`, `navItem.path`) and prerender URLs are
27
+ * **not** affected — they remain route-relative.
28
+ *
29
+ * Typically read from `globalContext.baseServer` in the Vike hook.
30
+ *
31
+ * @default '/'
32
+ */
33
+ baseUrl?: string;
34
+ /**
35
+ * Additional remark plugins to include in the markdown pipeline.
36
+ * These run after the baked-in plugins (remark-gfm, remark-code-props)
37
+ * and before remark-rehype.
38
+ */
39
+ remarkPlugins?: PluggableList;
40
+ /**
41
+ * Additional rehype plugins to include in the markdown pipeline.
42
+ * These run after the baked-in rehype-typedoc plugin and before
43
+ * rehype-stringify. Use this to add syntax highlighting
44
+ * (e.g., `@shikijs/rehype`).
45
+ */
46
+ rehypePlugins?: PluggableList;
47
+ }
48
+ export interface TypedocContext {
49
+ /** All parsed API documentation */
50
+ apiDocs: ApiDocs;
51
+ /** Symbols map (for rehype-typedoc or custom use) */
52
+ symbolsMap: Map<string, SymbolEntry>;
53
+ /** Navigation items for sidebar */
54
+ navigation: NavigationItem[];
55
+ /** Pre-built options to pass to rehype-typedoc */
56
+ rehypeOptions: RehypeTypedocOptions;
57
+ /** The resolved base URL (from options.baseUrl, normalized) */
58
+ baseUrl: string;
59
+ /** Prepend the deployment base URL to a route-relative path */
60
+ applyBaseUrl(path: string): string;
61
+ /** Get a linked export by package + symbol slug */
62
+ getLinkedExport(packageSlug: string, symbolSlug: string): LinkedApiExport | null;
63
+ /** Get package info */
64
+ getPackage(packageSlug: string): ApiPackage | null;
65
+ /** Get all export URLs (for pre-rendering) */
66
+ getExportUrls(): string[];
67
+ /** Get all package-level URLs (for pre-rendering) */
68
+ getPackageUrls(): string[];
69
+ /** Get all prerender URLs (packages + exports) */
70
+ getAllPrerenderUrls(): string[];
71
+ }
72
+ /**
73
+ * Create a TypedocContext from pre-parsed packages.
74
+ *
75
+ * This is the low-level API — use `loadTypedocContext` for the common case
76
+ * of loading TypeDoc JSON files from disk.
77
+ *
78
+ * The function is async because it eagerly pre-renders all markdown fields
79
+ * (descriptions, remarks, examples) through a unified pipeline so that
80
+ * `getLinkedExport()` can return fully-rendered HTML synchronously.
81
+ */
82
+ export declare function createTypedocContext(packages: ApiPackage[], options?: TypedocContextOptions): Promise<TypedocContext>;
83
+ //# sourceMappingURL=context.d.ts.map
@@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G,IAAI,CAAC;IACnD,8CAA8C;IAC9C,aAAa,IAAI,MAAM,EAAE,CAAC;IAC1B,qDAAqD;IACrD,cAAc,IAAI,MAAM,EAAE,CAAC;IAC3B,kDAAkD;IAClD,mBAAmB,IAAI,MAAM,EAAE,CAAC;CACjC;AA+BD;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,UAAU,EAAE,EACtB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,cAAc,CAAC,CAqHzB"}
@@ -0,0 +1,129 @@
1
+ import { linkifyApiExport, linkifyType } from './linkify.js';
2
+ import { buildMarkdownProcessor, renderExportMarkdown, } from './markdown.js';
3
+ import { buildApiNavigation } from './navigation.js';
4
+ import { combineApiDocs } from './parser.js';
5
+ import { buildSymbolsMap } from './symbols.js';
6
+ function createDefaultBuildUrl(basePath) {
7
+ return (packageSlug, symbolSlug) => symbolSlug ? `${basePath}/${packageSlug}/${symbolSlug}` : `${basePath}/${packageSlug}`;
8
+ }
9
+ /**
10
+ * Build an `applyBaseUrl` function from a raw base URL string.
11
+ *
12
+ * Returns the identity function when the base is falsy, `/`, `./`, or `.`
13
+ * (i.e., no deployment prefix). Otherwise normalizes and prepends the base.
14
+ */
15
+ function createApplyBaseUrl(raw) {
16
+ if (!raw || raw === '/' || raw === './' || raw === '.') {
17
+ return (path) => path;
18
+ }
19
+ const normalizedBase = raw.endsWith('/') ? raw : raw + '/';
20
+ return (path) => {
21
+ const normalizedPath = path.startsWith('/') ? path.substring(1) : path;
22
+ return normalizedBase + normalizedPath;
23
+ };
24
+ }
25
+ /**
26
+ * Build a cache key for a rendered export: `packageSlug::symbolSlug`
27
+ */
28
+ function markdownCacheKey(packageSlug, symbolSlug) {
29
+ return `${packageSlug}::${symbolSlug}`;
30
+ }
31
+ /**
32
+ * Create a TypedocContext from pre-parsed packages.
33
+ *
34
+ * This is the low-level API — use `loadTypedocContext` for the common case
35
+ * of loading TypeDoc JSON files from disk.
36
+ *
37
+ * The function is async because it eagerly pre-renders all markdown fields
38
+ * (descriptions, remarks, examples) through a unified pipeline so that
39
+ * `getLinkedExport()` can return fully-rendered HTML synchronously.
40
+ */
41
+ export async function createTypedocContext(packages, options = {}) {
42
+ const buildUrl = options.buildUrl ?? createDefaultBuildUrl(options.basePath ?? '/api');
43
+ const applyBaseUrl = createApplyBaseUrl(options.baseUrl);
44
+ const baseUrl = options.baseUrl ?? '/';
45
+ // Apply buildUrl to every export path
46
+ for (const pkg of packages) {
47
+ for (const exp of pkg.exports) {
48
+ exp.path = buildUrl(pkg.slug, exp.slug);
49
+ }
50
+ for (const mod of pkg.modules) {
51
+ for (const exp of mod.exports) {
52
+ exp.path = buildUrl(pkg.slug, exp.slug);
53
+ }
54
+ }
55
+ }
56
+ const apiDocs = combineApiDocs(packages);
57
+ const symbolsMap = buildSymbolsMap(apiDocs);
58
+ const navigation = buildApiNavigation(apiDocs);
59
+ // Update navigation paths using buildUrl
60
+ for (const navItem of navigation) {
61
+ const pkg = Object.values(apiDocs.packages).find((p) => p.name === navItem.title);
62
+ if (pkg) {
63
+ navItem.path = buildUrl(pkg.slug);
64
+ }
65
+ }
66
+ const buildLink = (symbol) => symbol.path ? applyBaseUrl(symbol.path) : undefined;
67
+ const rehypeOptions = {
68
+ symbols: symbolsMap,
69
+ buildLink,
70
+ };
71
+ // Build the markdown processor and pre-render all exports
72
+ const processor = buildMarkdownProcessor(rehypeOptions, options.remarkPlugins, options.rehypePlugins);
73
+ const renderedMarkdown = new Map();
74
+ await Promise.all(apiDocs.allExports.map(async (exp) => {
75
+ const rendered = await renderExportMarkdown(processor, exp.comment, exp.description, exp.signature, exp.returnType);
76
+ renderedMarkdown.set(markdownCacheKey(exp.package, exp.slug), rendered);
77
+ }));
78
+ return {
79
+ apiDocs,
80
+ symbolsMap,
81
+ navigation,
82
+ rehypeOptions,
83
+ baseUrl,
84
+ applyBaseUrl,
85
+ getLinkedExport(packageSlug, symbolSlug) {
86
+ const apiPackage = apiDocs.packages[packageSlug];
87
+ if (!apiPackage)
88
+ return null;
89
+ const rawExport = apiPackage.exports.find((e) => e.slug === symbolSlug);
90
+ if (!rawExport)
91
+ return null;
92
+ const linked = linkifyApiExport(rawExport, (typeStr) => linkifyType(typeStr, symbolsMap, buildLink));
93
+ // Merge pre-rendered markdown HTML (code block linkification is now
94
+ // handled by rehypeTypedocCodeBlocks in the unified pipeline)
95
+ const md = renderedMarkdown.get(markdownCacheKey(packageSlug, symbolSlug));
96
+ if (md) {
97
+ if (md.signatureCodeHtml)
98
+ linked.signatureCodeHtml = md.signatureCodeHtml;
99
+ if (md.returnTypeCodeHtml)
100
+ linked.returnTypeCodeHtml = md.returnTypeCodeHtml;
101
+ if (md.descriptionHtml)
102
+ linked.descriptionHtml = md.descriptionHtml;
103
+ if (md.remarksHtml)
104
+ linked.remarksHtml = md.remarksHtml;
105
+ if (md.examplesHtml)
106
+ linked.examplesHtml = md.examplesHtml;
107
+ }
108
+ return linked;
109
+ },
110
+ getPackage(packageSlug) {
111
+ return apiDocs.packages[packageSlug] ?? null;
112
+ },
113
+ getExportUrls() {
114
+ return apiDocs.allExports.map((exp) => exp.path);
115
+ },
116
+ getPackageUrls() {
117
+ return Object.values(apiDocs.packages).map((pkg) => buildUrl(pkg.slug));
118
+ },
119
+ getAllPrerenderUrls() {
120
+ return [
121
+ ...new Set([
122
+ ...Object.values(apiDocs.packages).map((pkg) => buildUrl(pkg.slug)),
123
+ ...apiDocs.allExports.map((exp) => exp.path),
124
+ ]),
125
+ ];
126
+ },
127
+ };
128
+ }
129
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GAErB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,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CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBACnE,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;iBAC7C,CAAC;aACH,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Vike extension hook — called automatically during pre-rendering to
3
+ * generate the list of API URLs that need static HTML.
4
+ *
5
+ * Reads the TypedocContext previously stored on the global context by
6
+ * the `onCreateGlobalContext` hook and returns all package + export URLs.
7
+ */
8
+ export declare function onBeforePrerenderStart(): Promise<string[]>;
9
+ //# sourceMappingURL=onBeforePrerenderStart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onBeforePrerenderStart.d.ts","sourceRoot":"","sources":["../../src/hooks/onBeforePrerenderStart.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAqBhE"}