@brainfish-ai/devdoc 0.1.44 → 0.1.46
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 +45 -2
- package/dist/cli/commands/create.js +25 -8
- package/dist/cli/commands/sdk.d.ts +30 -0
- package/dist/cli/commands/sdk.js +365 -0
- package/dist/cli/index.js +28 -1
- package/dist/sdk/index.d.ts +126 -0
- package/dist/sdk/index.js +871 -0
- package/package.json +7 -3
- package/renderer/app/api/collections/route.js +38 -9
- package/renderer/app/api/docs/route.js +9 -4
- package/renderer/components/docs-viewer/agent/agent-chat.js +146 -109
- package/renderer/components/docs-viewer/content/doc-page.js +54 -44
- package/renderer/components/docs-viewer/content/mdx-error-boundary.js +184 -0
- package/renderer/components/docs-viewer/index.js +21 -3
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
function _define_property(obj, key, value) {
|
|
3
|
+
if (key in obj) {
|
|
4
|
+
Object.defineProperty(obj, key, {
|
|
5
|
+
value: value,
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
writable: true
|
|
9
|
+
});
|
|
10
|
+
} else {
|
|
11
|
+
obj[key] = value;
|
|
12
|
+
}
|
|
13
|
+
return obj;
|
|
14
|
+
}
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
import { Component } from 'react';
|
|
17
|
+
import { Warning, ArrowClockwise, Code, FileText } from '@phosphor-icons/react';
|
|
18
|
+
/**
|
|
19
|
+
* Error boundary for MDX content rendering.
|
|
20
|
+
* Catches rendering errors and displays helpful guidance.
|
|
21
|
+
*/ export class MDXErrorBoundary extends Component {
|
|
22
|
+
static getDerivedStateFromError(error) {
|
|
23
|
+
return {
|
|
24
|
+
hasError: true,
|
|
25
|
+
error
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
componentDidCatch(error, errorInfo) {
|
|
29
|
+
console.error('[MDX Rendering Error]', error, errorInfo);
|
|
30
|
+
}
|
|
31
|
+
render() {
|
|
32
|
+
if (this.state.hasError) {
|
|
33
|
+
const errorMessage = this.state.error?.message || 'Unknown error';
|
|
34
|
+
const suggestions = getErrorSuggestions(errorMessage);
|
|
35
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
36
|
+
className: "docs-page docs-page-error w-full min-h-[200px] max-w-4xl mx-auto px-4 py-6 sm:px-8 sm:py-8",
|
|
37
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
38
|
+
className: "rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-950/50 p-6",
|
|
39
|
+
children: [
|
|
40
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
41
|
+
className: "flex items-start gap-3 mb-4",
|
|
42
|
+
children: [
|
|
43
|
+
/*#__PURE__*/ _jsx(Warning, {
|
|
44
|
+
className: "h-6 w-6 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5",
|
|
45
|
+
weight: "fill"
|
|
46
|
+
}),
|
|
47
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
48
|
+
children: [
|
|
49
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
50
|
+
className: "text-lg font-semibold text-amber-900 dark:text-amber-100",
|
|
51
|
+
children: "Unable to render this page"
|
|
52
|
+
}),
|
|
53
|
+
/*#__PURE__*/ _jsx("p", {
|
|
54
|
+
className: "text-sm text-amber-700 dark:text-amber-300 mt-1",
|
|
55
|
+
children: "There's a syntax error in the MDX content that prevented rendering."
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
}),
|
|
61
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
62
|
+
className: "bg-amber-100 dark:bg-amber-900/50 rounded-md p-3 mb-4",
|
|
63
|
+
children: [
|
|
64
|
+
/*#__PURE__*/ _jsx("p", {
|
|
65
|
+
className: "text-xs font-medium text-amber-800 dark:text-amber-200 mb-1",
|
|
66
|
+
children: "Error message:"
|
|
67
|
+
}),
|
|
68
|
+
/*#__PURE__*/ _jsx("code", {
|
|
69
|
+
className: "text-sm text-amber-900 dark:text-amber-100 break-all",
|
|
70
|
+
children: errorMessage
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
}),
|
|
74
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
75
|
+
className: "space-y-3",
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ _jsx("p", {
|
|
78
|
+
className: "text-sm font-medium text-amber-800 dark:text-amber-200",
|
|
79
|
+
children: "Common causes and fixes:"
|
|
80
|
+
}),
|
|
81
|
+
/*#__PURE__*/ _jsx("ul", {
|
|
82
|
+
className: "space-y-2",
|
|
83
|
+
children: suggestions.map((suggestion, index)=>/*#__PURE__*/ _jsxs("li", {
|
|
84
|
+
className: "flex items-start gap-2 text-sm text-amber-700 dark:text-amber-300",
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ _jsx(suggestion.icon, {
|
|
87
|
+
className: "h-4 w-4 flex-shrink-0 mt-0.5",
|
|
88
|
+
weight: "bold"
|
|
89
|
+
}),
|
|
90
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
91
|
+
children: [
|
|
92
|
+
/*#__PURE__*/ _jsxs("span", {
|
|
93
|
+
className: "font-medium",
|
|
94
|
+
children: [
|
|
95
|
+
suggestion.title,
|
|
96
|
+
":"
|
|
97
|
+
]
|
|
98
|
+
}),
|
|
99
|
+
' ',
|
|
100
|
+
suggestion.description
|
|
101
|
+
]
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
}, index))
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
}),
|
|
108
|
+
/*#__PURE__*/ _jsxs("button", {
|
|
109
|
+
onClick: this.handleRetry,
|
|
110
|
+
className: "mt-6 inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-md bg-amber-200 dark:bg-amber-800 text-amber-900 dark:text-amber-100 hover:bg-amber-300 dark:hover:bg-amber-700 transition-colors",
|
|
111
|
+
children: [
|
|
112
|
+
/*#__PURE__*/ _jsx(ArrowClockwise, {
|
|
113
|
+
className: "h-4 w-4",
|
|
114
|
+
weight: "bold"
|
|
115
|
+
}),
|
|
116
|
+
"Try again"
|
|
117
|
+
]
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return this.props.children;
|
|
124
|
+
}
|
|
125
|
+
constructor(props){
|
|
126
|
+
super(props), _define_property(this, "handleRetry", ()=>{
|
|
127
|
+
this.setState({
|
|
128
|
+
hasError: false,
|
|
129
|
+
error: null
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
this.state = {
|
|
133
|
+
hasError: false,
|
|
134
|
+
error: null
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get context-aware error suggestions based on the error message
|
|
140
|
+
*/ function getErrorSuggestions(errorMessage) {
|
|
141
|
+
const suggestions = [];
|
|
142
|
+
// Check for common MDX errors
|
|
143
|
+
if (errorMessage.includes('Unexpected') || errorMessage.includes('Expected')) {
|
|
144
|
+
suggestions.push({
|
|
145
|
+
icon: Code,
|
|
146
|
+
title: 'JSX Syntax',
|
|
147
|
+
description: 'Check for unclosed tags, missing quotes in attributes, or invalid JSX expressions. All tags must be properly closed (e.g., <Image /> not <Image>).'
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
if (errorMessage.includes('is not defined') || errorMessage.includes('is not a function')) {
|
|
151
|
+
suggestions.push({
|
|
152
|
+
icon: Code,
|
|
153
|
+
title: 'Unknown Component',
|
|
154
|
+
description: 'A component used in this page may not be available. Check that all component names are spelled correctly and are supported.'
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (errorMessage.includes('mermaid') || errorMessage.includes('Mermaid')) {
|
|
158
|
+
suggestions.push({
|
|
159
|
+
icon: Code,
|
|
160
|
+
title: 'Mermaid Syntax',
|
|
161
|
+
description: 'Check your Mermaid diagram syntax. Ensure proper indentation and valid diagram type (flowchart, sequenceDiagram, etc.).'
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (errorMessage.includes('frontmatter') || errorMessage.includes('yaml')) {
|
|
165
|
+
suggestions.push({
|
|
166
|
+
icon: FileText,
|
|
167
|
+
title: 'Frontmatter Format',
|
|
168
|
+
description: 'Ensure frontmatter is valid YAML between --- markers at the top of the file.'
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
// Always add generic suggestions
|
|
172
|
+
suggestions.push({
|
|
173
|
+
icon: Code,
|
|
174
|
+
title: 'Curly Braces',
|
|
175
|
+
description: 'In MDX, curly braces {} are for JavaScript expressions. Use {"{"} and {"}"} to display literal braces.'
|
|
176
|
+
});
|
|
177
|
+
suggestions.push({
|
|
178
|
+
icon: FileText,
|
|
179
|
+
title: 'Special Characters',
|
|
180
|
+
description: 'Characters like <, >, and & may need to be escaped or wrapped in JSX expressions.'
|
|
181
|
+
});
|
|
182
|
+
return suggestions.slice(0, 4) // Limit to 4 suggestions
|
|
183
|
+
;
|
|
184
|
+
}
|
|
@@ -737,8 +737,15 @@ function DocsContent() {
|
|
|
737
737
|
setIsVersionLoading(true);
|
|
738
738
|
}
|
|
739
739
|
setError(null);
|
|
740
|
-
// Build URL with version
|
|
741
|
-
const
|
|
740
|
+
// Build URL with version and tab params
|
|
741
|
+
const params = new URLSearchParams();
|
|
742
|
+
if (selectedApiVersion) {
|
|
743
|
+
params.set('version', selectedApiVersion);
|
|
744
|
+
}
|
|
745
|
+
if (activeTab) {
|
|
746
|
+
params.set('tab', activeTab);
|
|
747
|
+
}
|
|
748
|
+
const url = params.toString() ? `/api/collections?${params.toString()}` : '/api/collections';
|
|
742
749
|
const response = await fetch(url);
|
|
743
750
|
if (!response.ok) {
|
|
744
751
|
throw new Error(`Failed to fetch collection: ${response.status}`);
|
|
@@ -807,7 +814,18 @@ function DocsContent() {
|
|
|
807
814
|
fetchCollection();
|
|
808
815
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
809
816
|
}, [
|
|
810
|
-
selectedApiVersion
|
|
817
|
+
selectedApiVersion,
|
|
818
|
+
activeTab
|
|
819
|
+
]);
|
|
820
|
+
// Reset API version when tab changes (each tab has its own versions)
|
|
821
|
+
const prevTabRef = useRef(activeTab);
|
|
822
|
+
useEffect(()=>{
|
|
823
|
+
if (prevTabRef.current !== activeTab) {
|
|
824
|
+
setSelectedApiVersion(null);
|
|
825
|
+
prevTabRef.current = activeTab;
|
|
826
|
+
}
|
|
827
|
+
}, [
|
|
828
|
+
activeTab
|
|
811
829
|
]);
|
|
812
830
|
// Only show full-page loading on initial load
|
|
813
831
|
if (loading && !collection) {
|