@openpkg-ts/adapters 0.2.0
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 +51 -0
- package/dist/components/index.d.ts +15 -0
- package/dist/components/index.js +6 -0
- package/dist/index.d.ts +118 -0
- package/dist/index.js +232 -0
- package/dist/shared/chunk-t3t704xs.js +26 -0
- package/package.json +66 -0
- package/src/fumadocs/styles/docskit.css +225 -0
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @openpkg-ts/adapters
|
|
2
|
+
|
|
3
|
+
Framework adapters for OpenPkg API documentation.
|
|
4
|
+
|
|
5
|
+
## Fumadocs
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @openpkg-ts/adapters fumadocs-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { loader } from 'fumadocs-core/source';
|
|
13
|
+
import { openpkgSource, openpkgPlugin } from '@openpkg-ts/adapters/fumadocs';
|
|
14
|
+
import spec from './openpkg.json';
|
|
15
|
+
|
|
16
|
+
export const apiSource = loader({
|
|
17
|
+
baseUrl: '/docs/api',
|
|
18
|
+
source: openpkgSource({ spec }),
|
|
19
|
+
plugins: [openpkgPlugin()],
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### CSS
|
|
24
|
+
|
|
25
|
+
```css
|
|
26
|
+
@import '@openpkg-ts/adapters/fumadocs/css';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Components
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { SidebarKindBadge } from '@openpkg-ts/adapters/fumadocs/components';
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Options
|
|
36
|
+
|
|
37
|
+
| Option | Type | Default | Description |
|
|
38
|
+
|--------|------|---------|-------------|
|
|
39
|
+
| `spec` | `OpenPkg` | required | The OpenPkg spec |
|
|
40
|
+
| `baseDir` | `string` | `'api'` | Base directory |
|
|
41
|
+
| `mode` | `'pages' \| 'single'` | `'pages'` | Navigation mode |
|
|
42
|
+
| `indexPage` | `boolean` | `true` | Generate index page |
|
|
43
|
+
|
|
44
|
+
## Future Adapters
|
|
45
|
+
|
|
46
|
+
- `@openpkg-ts/adapters/docusaurus` (planned)
|
|
47
|
+
- `@openpkg-ts/adapters/mintlify` (planned)
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
MIT
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SpecExportKind } from "@openpkg-ts/spec";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
interface SidebarKindBadgeProps {
|
|
4
|
+
kind: SpecExportKind;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Sidebar badge component for fumadocs page tree.
|
|
9
|
+
* Wraps @openpkg-ts/ui KindBadge with size="sm" for sidebar use.
|
|
10
|
+
*
|
|
11
|
+
* Uses createElement instead of JSX for compatibility with
|
|
12
|
+
* fumadocs transformPageTree server context.
|
|
13
|
+
*/
|
|
14
|
+
declare function SidebarKindBadge({ kind, className }: SidebarKindBadgeProps): ReactNode;
|
|
15
|
+
export { SidebarKindBadgeProps, SidebarKindBadge };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { DocsInstance as DocsInstance2, LoadOptions, AlgoliaRecord, PagefindRecord, SearchIndex, SearchOptions } from "@openpkg-ts/sdk";
|
|
2
|
+
import { createDocs, loadSpec, buildSignatureString, formatParameters, formatReturnType, formatSchema, formatTypeParameters, getMethods, getProperties, groupByVisibility, isMethod, isProperty, resolveTypeRef, sortByName, toAlgoliaRecords, toPagefindRecords, toSearchIndex, toSearchIndexJSON, toHTML, toJSON, toJSONString, toMarkdown, toNavigation, toDocusaurusSidebarJS, toFumadocsMetaJSON, exportToMarkdown } from "@openpkg-ts/sdk";
|
|
3
|
+
import { OpenPkg as OpenPkg2, SpecExample, SpecExport as SpecExport2, SpecExportKind as SpecExportKind2, SpecMember, SpecSchema, SpecSignature, SpecSignatureParameter, SpecTag, SpecType, SpecTypeKind, SpecTypeParameter } from "@openpkg-ts/spec";
|
|
4
|
+
import { OpenPkg, SpecExport } from "@openpkg-ts/spec";
|
|
5
|
+
import { DocsInstance } from "@openpkg-ts/sdk";
|
|
6
|
+
import { Source } from "fumadocs-core/source";
|
|
7
|
+
interface OpenPkgSourceOptions {
|
|
8
|
+
/** OpenPkg spec or DocsInstance */
|
|
9
|
+
spec: OpenPkg | DocsInstance;
|
|
10
|
+
/** Base directory for pages (default: 'api') */
|
|
11
|
+
baseDir?: string;
|
|
12
|
+
/** Generate index page at baseDir/index.mdx (default: true) */
|
|
13
|
+
indexPage?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Navigation mode:
|
|
16
|
+
* - 'pages': Individual pages per grouped by kind (default)
|
|
17
|
+
* - 'single': Single page with all exports and in-page navigation
|
|
18
|
+
*/
|
|
19
|
+
mode?: "pages" | "single";
|
|
20
|
+
}
|
|
21
|
+
interface OpenPkgPageData {
|
|
22
|
+
title: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
/** The from the spec */
|
|
25
|
+
export: SpecExport;
|
|
26
|
+
/** The full OpenPkg spec */
|
|
27
|
+
spec: OpenPkg;
|
|
28
|
+
}
|
|
29
|
+
interface OpenPkgIndexPageData {
|
|
30
|
+
title: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
/** Index page marker */
|
|
33
|
+
isIndex: true;
|
|
34
|
+
/** The full OpenPkg spec */
|
|
35
|
+
spec: OpenPkg;
|
|
36
|
+
}
|
|
37
|
+
/** Page data for single-page mode */
|
|
38
|
+
interface OpenPkgSinglePageData {
|
|
39
|
+
title: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
/** Single page mode marker */
|
|
42
|
+
isSinglePage: true;
|
|
43
|
+
/** The full OpenPkg spec */
|
|
44
|
+
spec: OpenPkg;
|
|
45
|
+
}
|
|
46
|
+
interface OpenPkgMetaData {
|
|
47
|
+
title: string;
|
|
48
|
+
pages: string[];
|
|
49
|
+
defaultOpen?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a virtual source for Fumadocs from an OpenPkg spec.
|
|
53
|
+
*
|
|
54
|
+
* This generates virtual pages grouped by kind (functions, types, etc.)
|
|
55
|
+
* that integrate with Fumadocs' loader and sidebar.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* // Multi-page mode (default) - individual pages per * import { loader } from 'fumadocs-core/source';
|
|
60
|
+
* import { openpkgSource } from '@openpkg-ts/adapters/fumadocs';
|
|
61
|
+
* import spec from './openpkg.json';
|
|
62
|
+
*
|
|
63
|
+
* const source = loader({
|
|
64
|
+
* baseUrl: '/docs/api',
|
|
65
|
+
* source: openpkgSource({ spec }),
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* // Single-page mode - all exports on one scrollable page
|
|
72
|
+
* const source = loader({
|
|
73
|
+
* baseUrl: '/docs/api',
|
|
74
|
+
* source: openpkgSource({ spec, mode: 'single' }),
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
declare function openpkgSource(options: OpenPkgSourceOptions): Source<{
|
|
79
|
+
pageData: OpenPkgPageData | OpenPkgIndexPageData | OpenPkgSinglePageData;
|
|
80
|
+
metaData: OpenPkgMetaData;
|
|
81
|
+
}>;
|
|
82
|
+
import { LoaderPlugin } from "fumadocs-core/source";
|
|
83
|
+
import { SpecExportKind } from "@openpkg-ts/spec";
|
|
84
|
+
import { ReactNode } from "react";
|
|
85
|
+
interface SidebarKindBadgeProps {
|
|
86
|
+
kind: SpecExportKind;
|
|
87
|
+
className?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Sidebar badge component for fumadocs page tree.
|
|
91
|
+
* Wraps @openpkg-ts/ui KindBadge with size="sm" for sidebar use.
|
|
92
|
+
*
|
|
93
|
+
* Uses createElement instead of JSX for compatibility with
|
|
94
|
+
* fumadocs transformPageTree server context.
|
|
95
|
+
*/
|
|
96
|
+
declare function SidebarKindBadge({ kind, className }: SidebarKindBadgeProps): ReactNode;
|
|
97
|
+
interface OpenpkgPluginOptions {
|
|
98
|
+
/** Show kind badges in sidebar (default: true) */
|
|
99
|
+
showBadges?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Fumadocs loader plugin that enhances page tree nodes with kind badges.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* import { loader } from 'fumadocs-core/source';
|
|
107
|
+
* import { openpkgSource, openpkgPlugin } from '@openpkg-ts/adapters/fumadocs';
|
|
108
|
+
* import spec from './openpkg.json';
|
|
109
|
+
*
|
|
110
|
+
* const source = loader({
|
|
111
|
+
* baseUrl: '/docs/api',
|
|
112
|
+
* source: openpkgSource({ spec }),
|
|
113
|
+
* plugins: [openpkgPlugin()],
|
|
114
|
+
* });
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
declare function openpkgPlugin(options?: OpenpkgPluginOptions): LoaderPlugin;
|
|
118
|
+
export { toSearchIndexJSON, toSearchIndex, toPagefindRecords, toNavigation, toMarkdown, toJSONString, toJSON, toHTML, toFumadocsMetaJSON, toDocusaurusSidebarJS, toAlgoliaRecords, sortByName, resolveTypeRef, openpkgSource, openpkgPlugin, loadSpec, isProperty, isMethod, groupByVisibility, getProperties, getMethods, formatTypeParameters, formatSchema, formatReturnType, formatParameters, exportToMarkdown, createDocs, buildSignatureString, SpecTypeParameter, SpecTypeKind, SpecType, SpecTag, SpecSignatureParameter, SpecSignature, SpecSchema, SpecMember, SpecExportKind2 as SpecExportKind, SpecExport2 as SpecExport, SpecExample, SidebarKindBadgeProps, SidebarKindBadge, SearchOptions, SearchIndex, PagefindRecord, OpenpkgPluginOptions, OpenPkgSourceOptions, OpenPkgSinglePageData, OpenPkgPageData, OpenPkgMetaData, OpenPkgIndexPageData, OpenPkg2 as OpenPkg, LoadOptions, SidebarKindBadgeProps as KindBadgeProps, SidebarKindBadge as KindBadge, DocsInstance2 as DocsInstance, AlgoliaRecord };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SidebarKindBadge
|
|
3
|
+
} from "./shared/chunk-t3t704xs.js";
|
|
4
|
+
|
|
5
|
+
// src/fumadocs/index.ts
|
|
6
|
+
import {
|
|
7
|
+
createDocs as createDocs2,
|
|
8
|
+
loadSpec,
|
|
9
|
+
buildSignatureString,
|
|
10
|
+
formatParameters,
|
|
11
|
+
formatReturnType,
|
|
12
|
+
formatSchema,
|
|
13
|
+
formatTypeParameters,
|
|
14
|
+
getMethods,
|
|
15
|
+
getProperties,
|
|
16
|
+
groupByVisibility,
|
|
17
|
+
isMethod,
|
|
18
|
+
isProperty,
|
|
19
|
+
resolveTypeRef,
|
|
20
|
+
sortByName,
|
|
21
|
+
toAlgoliaRecords,
|
|
22
|
+
toPagefindRecords,
|
|
23
|
+
toSearchIndex,
|
|
24
|
+
toSearchIndexJSON,
|
|
25
|
+
toHTML,
|
|
26
|
+
toJSON,
|
|
27
|
+
toJSONString,
|
|
28
|
+
toMarkdown,
|
|
29
|
+
toNavigation,
|
|
30
|
+
toDocusaurusSidebarJS,
|
|
31
|
+
toFumadocsMetaJSON,
|
|
32
|
+
exportToMarkdown
|
|
33
|
+
} from "@openpkg-ts/sdk";
|
|
34
|
+
|
|
35
|
+
// src/fumadocs/source.ts
|
|
36
|
+
import { createDocs } from "@openpkg-ts/sdk";
|
|
37
|
+
var KIND_ORDER = ["function", "class", "interface", "type", "enum", "variable"];
|
|
38
|
+
var KIND_LABELS = {
|
|
39
|
+
function: "Functions",
|
|
40
|
+
class: "Classes",
|
|
41
|
+
interface: "Interfaces",
|
|
42
|
+
type: "Types",
|
|
43
|
+
enum: "Enums",
|
|
44
|
+
variable: "Variables",
|
|
45
|
+
namespace: "Namespaces",
|
|
46
|
+
module: "Modules",
|
|
47
|
+
reference: "References",
|
|
48
|
+
external: "External"
|
|
49
|
+
};
|
|
50
|
+
var KIND_SLUGS = {
|
|
51
|
+
function: "functions",
|
|
52
|
+
class: "classes",
|
|
53
|
+
interface: "interfaces",
|
|
54
|
+
type: "types",
|
|
55
|
+
enum: "enums",
|
|
56
|
+
variable: "variables",
|
|
57
|
+
namespace: "namespaces",
|
|
58
|
+
module: "modules",
|
|
59
|
+
reference: "references",
|
|
60
|
+
external: "externals"
|
|
61
|
+
};
|
|
62
|
+
function pluralizeKind(kind) {
|
|
63
|
+
return KIND_SLUGS[kind] || `${kind}s`;
|
|
64
|
+
}
|
|
65
|
+
function openpkgSource(options) {
|
|
66
|
+
const { baseDir = "api", indexPage = true, mode = "pages" } = options;
|
|
67
|
+
const docs = "getAllExports" in options.spec ? options.spec : createDocs(options.spec);
|
|
68
|
+
const spec = docs.spec;
|
|
69
|
+
const exports = docs.getAllExports();
|
|
70
|
+
const files = [];
|
|
71
|
+
if (mode === "single") {
|
|
72
|
+
files.push({
|
|
73
|
+
type: "meta",
|
|
74
|
+
path: `${baseDir}/meta.json`,
|
|
75
|
+
data: {
|
|
76
|
+
title: spec.meta.name || "API Reference",
|
|
77
|
+
pages: ["index"],
|
|
78
|
+
defaultOpen: true
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
files.push({
|
|
82
|
+
type: "page",
|
|
83
|
+
path: `${baseDir}/index.mdx`,
|
|
84
|
+
slugs: [],
|
|
85
|
+
data: {
|
|
86
|
+
title: spec.meta.name || "API Reference",
|
|
87
|
+
description: spec.meta.description,
|
|
88
|
+
isSinglePage: true,
|
|
89
|
+
spec
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return { files };
|
|
93
|
+
}
|
|
94
|
+
const groupedByKind = new Map;
|
|
95
|
+
for (const exp of exports) {
|
|
96
|
+
const kind = exp.kind;
|
|
97
|
+
if (!groupedByKind.has(kind)) {
|
|
98
|
+
groupedByKind.set(kind, []);
|
|
99
|
+
}
|
|
100
|
+
groupedByKind.get(kind).push(exp);
|
|
101
|
+
}
|
|
102
|
+
const rootPages = [];
|
|
103
|
+
if (indexPage) {
|
|
104
|
+
rootPages.push("index");
|
|
105
|
+
}
|
|
106
|
+
for (const kind of KIND_ORDER) {
|
|
107
|
+
if (groupedByKind.has(kind)) {
|
|
108
|
+
rootPages.push(`...${pluralizeKind(kind)}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
files.push({
|
|
112
|
+
type: "meta",
|
|
113
|
+
path: `${baseDir}/meta.json`,
|
|
114
|
+
data: {
|
|
115
|
+
title: spec.meta.name || "API Reference",
|
|
116
|
+
pages: rootPages,
|
|
117
|
+
defaultOpen: true
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
if (indexPage) {
|
|
121
|
+
files.push({
|
|
122
|
+
type: "page",
|
|
123
|
+
path: `${baseDir}/index.mdx`,
|
|
124
|
+
slugs: [],
|
|
125
|
+
data: {
|
|
126
|
+
title: spec.meta.name || "API Reference",
|
|
127
|
+
description: spec.meta.description,
|
|
128
|
+
isIndex: true,
|
|
129
|
+
spec
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
for (const kind of KIND_ORDER) {
|
|
134
|
+
const kindExports = groupedByKind.get(kind);
|
|
135
|
+
if (!kindExports || kindExports.length === 0)
|
|
136
|
+
continue;
|
|
137
|
+
const kindSlug = pluralizeKind(kind);
|
|
138
|
+
const kindDir = `${baseDir}/${kindSlug}`;
|
|
139
|
+
const label = KIND_LABELS[kind] || kindSlug;
|
|
140
|
+
const sortedExports = [...kindExports].sort((a, b) => a.name.localeCompare(b.name));
|
|
141
|
+
files.push({
|
|
142
|
+
type: "meta",
|
|
143
|
+
path: `${kindDir}/meta.json`,
|
|
144
|
+
data: {
|
|
145
|
+
title: label,
|
|
146
|
+
pages: sortedExports.map((exp) => exp.id),
|
|
147
|
+
defaultOpen: false
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
for (const exp of sortedExports) {
|
|
151
|
+
files.push({
|
|
152
|
+
type: "page",
|
|
153
|
+
path: `${kindDir}/${exp.id}.mdx`,
|
|
154
|
+
slugs: [kindSlug, exp.id],
|
|
155
|
+
data: {
|
|
156
|
+
title: exp.name,
|
|
157
|
+
description: exp.description,
|
|
158
|
+
export: exp,
|
|
159
|
+
spec
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return { files };
|
|
165
|
+
}
|
|
166
|
+
// src/fumadocs/plugin.ts
|
|
167
|
+
import { createElement } from "react";
|
|
168
|
+
var SUPPORTED_KINDS = new Set([
|
|
169
|
+
"function",
|
|
170
|
+
"class",
|
|
171
|
+
"interface",
|
|
172
|
+
"type",
|
|
173
|
+
"enum",
|
|
174
|
+
"variable",
|
|
175
|
+
"namespace",
|
|
176
|
+
"module",
|
|
177
|
+
"reference",
|
|
178
|
+
"external"
|
|
179
|
+
]);
|
|
180
|
+
function openpkgPlugin(options = {}) {
|
|
181
|
+
const { showBadges = true } = options;
|
|
182
|
+
return {
|
|
183
|
+
name: "openpkg",
|
|
184
|
+
transformPageTree: {
|
|
185
|
+
file(node, filePath) {
|
|
186
|
+
if (!showBadges || !filePath)
|
|
187
|
+
return node;
|
|
188
|
+
const file = this.storage.read(filePath);
|
|
189
|
+
if (!file || file.format !== "page")
|
|
190
|
+
return node;
|
|
191
|
+
const pageData = file.data;
|
|
192
|
+
const kind = pageData.export?.kind;
|
|
193
|
+
if (!kind || !SUPPORTED_KINDS.has(kind))
|
|
194
|
+
return node;
|
|
195
|
+
const badge = createElement(SidebarKindBadge, { kind });
|
|
196
|
+
return { ...node, icon: badge };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
export {
|
|
202
|
+
toSearchIndexJSON,
|
|
203
|
+
toSearchIndex,
|
|
204
|
+
toPagefindRecords,
|
|
205
|
+
toNavigation,
|
|
206
|
+
toMarkdown,
|
|
207
|
+
toJSONString,
|
|
208
|
+
toJSON,
|
|
209
|
+
toHTML,
|
|
210
|
+
toFumadocsMetaJSON,
|
|
211
|
+
toDocusaurusSidebarJS,
|
|
212
|
+
toAlgoliaRecords,
|
|
213
|
+
sortByName,
|
|
214
|
+
resolveTypeRef,
|
|
215
|
+
openpkgSource,
|
|
216
|
+
openpkgPlugin,
|
|
217
|
+
loadSpec,
|
|
218
|
+
isProperty,
|
|
219
|
+
isMethod,
|
|
220
|
+
groupByVisibility,
|
|
221
|
+
getProperties,
|
|
222
|
+
getMethods,
|
|
223
|
+
formatTypeParameters,
|
|
224
|
+
formatSchema,
|
|
225
|
+
formatReturnType,
|
|
226
|
+
formatParameters,
|
|
227
|
+
exportToMarkdown,
|
|
228
|
+
createDocs2 as createDocs,
|
|
229
|
+
buildSignatureString,
|
|
230
|
+
SidebarKindBadge,
|
|
231
|
+
SidebarKindBadge as KindBadge
|
|
232
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/fumadocs/components/sidebar-badge.tsx
|
|
2
|
+
import { KindBadge as UIKindBadge } from "@openpkg-ts/ui/badge";
|
|
3
|
+
import { createElement } from "react";
|
|
4
|
+
var SUPPORTED_KINDS = new Set([
|
|
5
|
+
"function",
|
|
6
|
+
"class",
|
|
7
|
+
"interface",
|
|
8
|
+
"type",
|
|
9
|
+
"enum",
|
|
10
|
+
"variable",
|
|
11
|
+
"namespace",
|
|
12
|
+
"module",
|
|
13
|
+
"reference",
|
|
14
|
+
"external"
|
|
15
|
+
]);
|
|
16
|
+
function SidebarKindBadge({ kind, className }) {
|
|
17
|
+
if (!SUPPORTED_KINDS.has(kind))
|
|
18
|
+
return null;
|
|
19
|
+
return createElement(UIKindBadge, {
|
|
20
|
+
kind,
|
|
21
|
+
size: "sm",
|
|
22
|
+
className
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { SidebarKindBadge };
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openpkg-ts/adapters",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Framework adapters for OpenPkg - Fumadocs, Docusaurus, Mintlify, etc.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"openpkg",
|
|
7
|
+
"fumadocs",
|
|
8
|
+
"docusaurus",
|
|
9
|
+
"mintlify",
|
|
10
|
+
"documentation",
|
|
11
|
+
"adapter"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/ryanwaits/openpkg-ts#readme",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/ryanwaits/openpkg-ts.git",
|
|
17
|
+
"directory": "packages/adapters"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "Ryan Waits",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
"./fumadocs": {
|
|
24
|
+
"import": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./fumadocs/components": {
|
|
28
|
+
"import": "./dist/components/index.js",
|
|
29
|
+
"types": "./dist/components/index.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./fumadocs/css": "./src/fumadocs/styles/docskit.css"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"src/fumadocs/styles"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "bunup",
|
|
39
|
+
"lint": "biome check src/",
|
|
40
|
+
"lint:fix": "biome check --write src/",
|
|
41
|
+
"typecheck": "tsc --noEmit"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@openpkg-ts/sdk": "workspace:*",
|
|
45
|
+
"@openpkg-ts/spec": "workspace:*",
|
|
46
|
+
"@openpkg-ts/ui": "workspace:*"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"fumadocs-core": "^16.0.0",
|
|
50
|
+
"react": "^18 || ^19"
|
|
51
|
+
},
|
|
52
|
+
"peerDependenciesMeta": {
|
|
53
|
+
"fumadocs-core": {
|
|
54
|
+
"optional": true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/react": "^19.0.0",
|
|
59
|
+
"bunup": "latest",
|
|
60
|
+
"fumadocs-core": "^16.4.0",
|
|
61
|
+
"typescript": "^5.0.0"
|
|
62
|
+
},
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Docskit CSS Variables for Fumadocs
|
|
3
|
+
*
|
|
4
|
+
* This file defines the CSS variables needed for @openpkg-ts/ui docskit components
|
|
5
|
+
* to work within Fumadocs themes.
|
|
6
|
+
*
|
|
7
|
+
* Import this in your global CSS:
|
|
8
|
+
* @import '@openpkg-ts/fumadocs-adapter/css';
|
|
9
|
+
*
|
|
10
|
+
* Or add these variables to your Tailwind CSS:
|
|
11
|
+
* @import 'tailwindcss';
|
|
12
|
+
* @import 'fumadocs-ui/css/neutral.css';
|
|
13
|
+
* @import 'fumadocs-ui/css/preset.css';
|
|
14
|
+
* @import '@openpkg-ts/fumadocs-adapter/css';
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/* Tailwind v4 theme - shadcn-style color utilities */
|
|
18
|
+
@theme {
|
|
19
|
+
--color-background: var(--background);
|
|
20
|
+
--color-foreground: var(--foreground);
|
|
21
|
+
--color-card: var(--card);
|
|
22
|
+
--color-card-foreground: var(--card-foreground);
|
|
23
|
+
--color-muted: var(--muted);
|
|
24
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
25
|
+
--color-border: var(--border);
|
|
26
|
+
--color-primary: var(--primary);
|
|
27
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
28
|
+
--color-secondary: var(--secondary);
|
|
29
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
30
|
+
--color-accent: var(--accent);
|
|
31
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
32
|
+
|
|
33
|
+
/* Kind badge colors */
|
|
34
|
+
--color-kind-function: var(--kind-function);
|
|
35
|
+
--color-kind-class: var(--kind-class);
|
|
36
|
+
--color-kind-interface: var(--kind-interface);
|
|
37
|
+
--color-kind-type: var(--kind-type);
|
|
38
|
+
--color-kind-enum: var(--kind-enum);
|
|
39
|
+
--color-kind-variable: var(--kind-variable);
|
|
40
|
+
--color-kind-namespace: var(--kind-namespace);
|
|
41
|
+
--color-kind-module: var(--kind-module);
|
|
42
|
+
--color-kind-reference: var(--kind-reference);
|
|
43
|
+
--color-kind-external: var(--kind-external);
|
|
44
|
+
|
|
45
|
+
/* Docskit code block colors - mapped to CodeHike GitHub theme vars */
|
|
46
|
+
--color-dk-background: var(--ch-16);
|
|
47
|
+
--color-dk-border: var(--ch-23);
|
|
48
|
+
--color-dk-tabs-background: var(--ch-22);
|
|
49
|
+
--color-dk-tab-inactive-foreground: var(--ch-15);
|
|
50
|
+
--color-dk-tab-active-foreground: var(--ch-4);
|
|
51
|
+
--color-dk-selection: var(--ch-20);
|
|
52
|
+
--color-dk-line-number: var(--ch-24);
|
|
53
|
+
--color-dk-active-border: var(--ch-3);
|
|
54
|
+
|
|
55
|
+
/* CodeHike syntax colors for Tailwind utilities */
|
|
56
|
+
--color-ch-0: var(--ch-0);
|
|
57
|
+
--color-ch-1: var(--ch-1);
|
|
58
|
+
--color-ch-2: var(--ch-2);
|
|
59
|
+
--color-ch-3: var(--ch-3);
|
|
60
|
+
--color-ch-4: var(--ch-4);
|
|
61
|
+
--color-ch-5: var(--ch-5);
|
|
62
|
+
--color-ch-6: var(--ch-6);
|
|
63
|
+
--color-ch-7: var(--ch-7);
|
|
64
|
+
--color-ch-8: var(--ch-8);
|
|
65
|
+
--color-ch-9: var(--ch-9);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@layer base {
|
|
69
|
+
:root {
|
|
70
|
+
/* shadcn/ui style variables mapped to Fumadocs */
|
|
71
|
+
--background: var(--color-fd-background);
|
|
72
|
+
--foreground: var(--color-fd-foreground);
|
|
73
|
+
--card: var(--color-fd-card);
|
|
74
|
+
--card-foreground: var(--color-fd-card-foreground, var(--color-fd-foreground));
|
|
75
|
+
--muted: var(--color-fd-muted);
|
|
76
|
+
--muted-foreground: var(--color-fd-muted-foreground);
|
|
77
|
+
--border: var(--color-fd-border);
|
|
78
|
+
--primary: var(--color-fd-primary);
|
|
79
|
+
--primary-foreground: var(--color-fd-primary-foreground, hsl(0 0% 100%));
|
|
80
|
+
--secondary: var(--color-fd-secondary);
|
|
81
|
+
--secondary-foreground: var(--color-fd-secondary-foreground, var(--color-fd-foreground));
|
|
82
|
+
--accent: var(--color-fd-accent);
|
|
83
|
+
--accent-foreground: var(--color-fd-accent-foreground, var(--color-fd-foreground));
|
|
84
|
+
|
|
85
|
+
/* Kind badge colors - light mode defaults */
|
|
86
|
+
--kind-function: #7c3aed;
|
|
87
|
+
--kind-class: #2563eb;
|
|
88
|
+
--kind-interface: #0891b2;
|
|
89
|
+
--kind-type: #0d9488;
|
|
90
|
+
--kind-enum: #d97706;
|
|
91
|
+
--kind-variable: #57534e;
|
|
92
|
+
--kind-namespace: #9333ea;
|
|
93
|
+
--kind-module: #1d4ed8;
|
|
94
|
+
--kind-reference: #6366f1;
|
|
95
|
+
--kind-external: #78716c;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* Dark mode kind badge colors */
|
|
99
|
+
.dark,
|
|
100
|
+
[data-theme="dark"] {
|
|
101
|
+
--kind-function: #a78bfa;
|
|
102
|
+
--kind-class: #60a5fa;
|
|
103
|
+
--kind-interface: #22d3ee;
|
|
104
|
+
--kind-type: #2dd4bf;
|
|
105
|
+
--kind-enum: #fbbf24;
|
|
106
|
+
--kind-variable: #a8a29e;
|
|
107
|
+
--kind-namespace: #c084fc;
|
|
108
|
+
--kind-module: #93c5fd;
|
|
109
|
+
--kind-reference: #a5b4fc;
|
|
110
|
+
--kind-external: #d6d3d1;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* Tailwind utility classes for docskit - selection needs special handling */
|
|
115
|
+
@layer utilities {
|
|
116
|
+
.selection\:bg-dk-selection::selection,
|
|
117
|
+
.selection\:bg-dk-selection *::selection {
|
|
118
|
+
background-color: var(--ch-20);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* API Reference page layouts */
|
|
123
|
+
@layer components {
|
|
124
|
+
/* Common padding for all doccov pages - matches Fumadocs OpenAPI */
|
|
125
|
+
.doccov-function-page,
|
|
126
|
+
.doccov-class-page,
|
|
127
|
+
.doccov-interface-page,
|
|
128
|
+
.doccov-enum-page,
|
|
129
|
+
.doccov-variable-page,
|
|
130
|
+
.doccov-index-page,
|
|
131
|
+
.doccov-full-reference-page {
|
|
132
|
+
width: 100%;
|
|
133
|
+
max-width: 1200px;
|
|
134
|
+
padding: 32px 24px 24px;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* Mobile-first: stack layout on small screens */
|
|
138
|
+
@media (max-width: 1023px) {
|
|
139
|
+
.doccov-function-page aside,
|
|
140
|
+
.doccov-class-page aside,
|
|
141
|
+
.doccov-interface-page aside {
|
|
142
|
+
margin-top: 2rem;
|
|
143
|
+
position: relative;
|
|
144
|
+
top: auto;
|
|
145
|
+
max-height: none;
|
|
146
|
+
overflow-y: visible;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/* Large screens: two-column with sticky sidebar */
|
|
151
|
+
@media (min-width: 1024px) {
|
|
152
|
+
.doccov-function-page,
|
|
153
|
+
.doccov-class-page,
|
|
154
|
+
.doccov-interface-page {
|
|
155
|
+
overflow: visible;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* CodeHike syntax highlighting theme - github-from-css */
|
|
161
|
+
/* These --ch-* variables are required for the "github-from-css" theme */
|
|
162
|
+
@layer base {
|
|
163
|
+
/* GitHub Dark theme (default) */
|
|
164
|
+
:root {
|
|
165
|
+
--ch-0: #e6edf3; /* default text */
|
|
166
|
+
--ch-1: #ff7b72; /* strings, inherited class */
|
|
167
|
+
--ch-2: #a5d6ff; /* string literals */
|
|
168
|
+
--ch-3: #79c0ff; /* keywords, function names */
|
|
169
|
+
--ch-4: #a5d6ff; /* constants */
|
|
170
|
+
--ch-5: #d2a8ff; /* entity names, types */
|
|
171
|
+
--ch-6: #ffa657; /* variables, tag names */
|
|
172
|
+
--ch-7: #8b949e; /* comments */
|
|
173
|
+
--ch-8: #79c0ff; /* support */
|
|
174
|
+
--ch-9: #e6edf3; /* punctuation */
|
|
175
|
+
--ch-10: #f0f6fc;
|
|
176
|
+
--ch-11: #490202;
|
|
177
|
+
--ch-12: #04260f;
|
|
178
|
+
--ch-13: #5a1e02;
|
|
179
|
+
--ch-14: #161b22;
|
|
180
|
+
--ch-15: #8b949e;
|
|
181
|
+
--ch-16: #0d1117;
|
|
182
|
+
--ch-17: #6e76811a;
|
|
183
|
+
--ch-18: #ffffff0b;
|
|
184
|
+
--ch-19: #3794ff;
|
|
185
|
+
--ch-20: #264f78;
|
|
186
|
+
--ch-21: #1f6feb;
|
|
187
|
+
--ch-22: #010409;
|
|
188
|
+
--ch-23: #30363d;
|
|
189
|
+
--ch-24: #6e7681;
|
|
190
|
+
--ch-25: #6e768166;
|
|
191
|
+
--ch-26: #0d1117e6;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* GitHub Light theme */
|
|
195
|
+
.light,
|
|
196
|
+
[data-theme="light"] {
|
|
197
|
+
--ch-0: #24292f; /* default text */
|
|
198
|
+
--ch-1: #cf222e; /* strings, inherited class */
|
|
199
|
+
--ch-2: #116329; /* string literals */
|
|
200
|
+
--ch-3: #0550ae; /* keywords, function names */
|
|
201
|
+
--ch-4: #0a3069; /* constants */
|
|
202
|
+
--ch-5: #8250df; /* entity names, types */
|
|
203
|
+
--ch-6: #953800; /* variables, tag names */
|
|
204
|
+
--ch-7: #6e7781; /* comments */
|
|
205
|
+
--ch-8: #0550ae; /* support */
|
|
206
|
+
--ch-9: #24292f; /* punctuation */
|
|
207
|
+
--ch-10: #f6f8fa;
|
|
208
|
+
--ch-11: #ffebe9;
|
|
209
|
+
--ch-12: #dafbe1;
|
|
210
|
+
--ch-13: #ffd8b5;
|
|
211
|
+
--ch-14: #eaeef2;
|
|
212
|
+
--ch-15: #57606a;
|
|
213
|
+
--ch-16: #ffffff;
|
|
214
|
+
--ch-17: #eaeef280;
|
|
215
|
+
--ch-18: #fdff0033;
|
|
216
|
+
--ch-19: #1a85ff;
|
|
217
|
+
--ch-20: #add6ff;
|
|
218
|
+
--ch-21: #0969da;
|
|
219
|
+
--ch-22: #f6f8fa;
|
|
220
|
+
--ch-23: #d0d7de;
|
|
221
|
+
--ch-24: #8c959f;
|
|
222
|
+
--ch-25: #afb8c133;
|
|
223
|
+
--ch-26: #ffffffe6;
|
|
224
|
+
}
|
|
225
|
+
}
|