@clarify-labs/renderer 0.10.0 → 0.10.2
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/output/{ClarifyShell-CxhXBtsR.js → ClarifyShell-1LuBliwt.js} +124 -40
- package/output/ClarifyShell-1LuBliwt.js.map +1 -0
- package/output/{ClarifyShell-DjLRRW8T.cjs → ClarifyShell-C6li72Ce.cjs} +136 -52
- package/output/ClarifyShell-C6li72Ce.cjs.map +1 -0
- package/output/MermaidViewer-B6-BMCJG.cjs +101 -0
- package/output/MermaidViewer-B6-BMCJG.cjs.map +1 -0
- package/output/MermaidViewer-dXsomvM7.js +98 -0
- package/output/MermaidViewer-dXsomvM7.js.map +1 -0
- package/output/{OpenApiOperation-qp5tFaWP.cjs → OpenApiOperation-B52IWlKb.cjs} +405 -243
- package/output/OpenApiOperation-B52IWlKb.cjs.map +1 -0
- package/output/{OpenApiOperation-CyBkzvob.js → OpenApiOperation-DgrqzeiS.js} +377 -228
- package/output/OpenApiOperation-DgrqzeiS.js.map +1 -0
- package/output/{PageActions-GS_cxeJN.cjs → PageActions-BjB6PYmL.cjs} +73 -734
- package/output/PageActions-BjB6PYmL.cjs.map +1 -0
- package/output/{PageActions-Dn8IGWoL.js → PageActions-D7K9LDGf.js} +67 -680
- package/output/PageActions-D7K9LDGf.js.map +1 -0
- package/output/SearchDialog-CIPvXMT3.cjs +414 -0
- package/output/SearchDialog-CIPvXMT3.cjs.map +1 -0
- package/output/SearchDialog-CxYLjRi5.js +411 -0
- package/output/SearchDialog-CxYLjRi5.js.map +1 -0
- package/output/app/AppShell.d.ts +2 -2
- package/output/app/SectionHashSync.d.ts +6 -0
- package/output/client.cjs +3 -3
- package/output/client.js +3 -3
- package/output/components/HighlightedCode.d.ts +7 -0
- package/output/components/MermaidViewer.d.ts +7 -0
- package/output/context.d.ts +1 -1
- package/output/core/context.d.ts +3 -4
- package/output/core/i18n.d.ts +1 -1
- package/output/core/index.d.ts +1 -1
- package/output/core/types.d.ts +36 -19
- package/output/i18n-DnqZHFT7.js +247 -0
- package/output/i18n-DnqZHFT7.js.map +1 -0
- package/output/i18n-b4iTLeia.cjs +294 -0
- package/output/i18n-b4iTLeia.cjs.map +1 -0
- package/output/index.cjs +91 -94
- package/output/index.cjs.map +1 -1
- package/output/index.d.ts +7 -7
- package/output/index.js +83 -87
- package/output/index.js.map +1 -1
- package/output/markdown.cjs +2 -1
- package/output/markdown.d.ts +1 -1
- package/output/markdown.js +2 -2
- package/output/mdx/remark.d.ts +1 -0
- package/output/openapi/components/EndpointSections.d.ts +3 -1
- package/output/openapi/components/ExamplePanels.d.ts +5 -2
- package/output/openapi/components/OpenApiOperation.d.ts +3 -1
- package/output/openapi/components/OpenApiOperation.state.d.ts +3 -3
- package/output/openapi/components/SchemaProperties.d.ts +1 -0
- package/output/openapi/components/helpers.d.ts +2 -2
- package/output/openapi/entry.d.ts +0 -1
- package/output/openapi/lib/helpers.d.ts +5 -3
- package/output/openapi/lib/request-code.d.ts +2 -1
- package/output/openapi/lib/spec-path.d.ts +6 -1
- package/output/openapi/lib/utils.d.ts +10 -4
- package/output/preview.cjs +7 -5
- package/output/preview.cjs.map +1 -1
- package/output/preview.js +5 -3
- package/output/preview.js.map +1 -1
- package/output/{remark-Dd2WU50s.js → remark-C9iRQM0R.js} +4 -3
- package/output/remark-C9iRQM0R.js.map +1 -0
- package/output/{remark-zSQT0MBv.cjs → remark-DTLbG8PK.cjs} +9 -2
- package/output/remark-DTLbG8PK.cjs.map +1 -0
- package/output/{render-CV0a-qtD.js → render-DKj24Jqw.js} +15 -8
- package/output/render-DKj24Jqw.js.map +1 -0
- package/output/{render-CCCoUWDP.cjs → render-Di5B6Zc0.cjs} +15 -8
- package/output/render-Di5B6Zc0.cjs.map +1 -0
- package/output/renderer.css +234 -20
- package/output/runtime/ClarifyShell.d.ts +5 -6
- package/output/server.cjs +4 -4
- package/output/server.cjs.map +1 -1
- package/output/server.js +4 -4
- package/output/server.js.map +1 -1
- package/output/shell/Navigation.d.ts +1 -0
- package/output/shell/search/SearchDialog.d.ts +1 -1
- package/output/slots/RuntimeSlot.d.ts +7 -7
- package/output/slots/context.d.ts +5 -5
- package/output/slots/index.d.ts +2 -2
- package/output/slots/types.d.ts +1 -1
- package/output/utils/path.d.ts +1 -1
- package/package.json +3 -1
- package/output/ClarifyShell-CxhXBtsR.js.map +0 -1
- package/output/ClarifyShell-DjLRRW8T.cjs.map +0 -1
- package/output/OpenApiOperation-CyBkzvob.js.map +0 -1
- package/output/OpenApiOperation-qp5tFaWP.cjs.map +0 -1
- package/output/PageActions-Dn8IGWoL.js.map +0 -1
- package/output/PageActions-GS_cxeJN.cjs.map +0 -1
- package/output/remark-Dd2WU50s.js.map +0 -1
- package/output/remark-zSQT0MBv.cjs.map +0 -1
- package/output/render-CCCoUWDP.cjs.map +0 -1
- package/output/render-CV0a-qtD.js.map +0 -1
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
let react = require("react");
|
|
2
|
+
//#region source/core/context.tsx
|
|
3
|
+
var ConfigContext = (0, react.createContext)(null);
|
|
4
|
+
var LocaleContext = (0, react.createContext)(void 0);
|
|
5
|
+
var OpenApiSpecsContext = (0, react.createContext)({});
|
|
6
|
+
function useConfig() {
|
|
7
|
+
const config = (0, react.useContext)(ConfigContext);
|
|
8
|
+
if (!config) throw new Error("[clarify] useConfig must be used within a ConfigContext.Provider");
|
|
9
|
+
return config;
|
|
10
|
+
}
|
|
11
|
+
function useConfigOptional() {
|
|
12
|
+
return (0, react.useContext)(ConfigContext);
|
|
13
|
+
}
|
|
14
|
+
function useLocale() {
|
|
15
|
+
return (0, react.useContext)(LocaleContext);
|
|
16
|
+
}
|
|
17
|
+
function useOpenApiSpecs() {
|
|
18
|
+
return (0, react.useContext)(OpenApiSpecsContext);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region source/core/i18n.ts
|
|
22
|
+
var builtInText = {
|
|
23
|
+
en: {
|
|
24
|
+
"actions.code": "Code",
|
|
25
|
+
"actions.copy": "Copy",
|
|
26
|
+
"actions.copied": "Copied!",
|
|
27
|
+
"builtWith.label": "Built with Clarify",
|
|
28
|
+
"builtWith.prefix": "Built with",
|
|
29
|
+
"callout.danger": "Danger",
|
|
30
|
+
"callout.info": "Info",
|
|
31
|
+
"callout.note": "Note",
|
|
32
|
+
"callout.success": "Success",
|
|
33
|
+
"callout.tip": "Tip",
|
|
34
|
+
"callout.warning": "Warning",
|
|
35
|
+
"contentActions.copyContent": "Copy page",
|
|
36
|
+
"contentActions.copyContentDescription": "Copy this page as {contentType} for LLMs",
|
|
37
|
+
"contentActions.copyLink": "Copy {contentType} link",
|
|
38
|
+
"contentActions.copyLinkDescription": "Copy the raw {contentType} content link for this page",
|
|
39
|
+
"contentActions.copyLlms": "Copy llms.txt",
|
|
40
|
+
"contentActions.copyLlmsDescription": "Copy the llms.txt link for this site",
|
|
41
|
+
"contentActions.copiedLlms": "Copied llms.txt",
|
|
42
|
+
"contentActions.editPage": "Edit this page",
|
|
43
|
+
"contentActions.editPageDescription": "Open the source file for this page",
|
|
44
|
+
"contentActions.copyOptions": "Choose copy option",
|
|
45
|
+
"contentActions.copiedContent": "Copied page",
|
|
46
|
+
"contentActions.copiedLink": "Copied link",
|
|
47
|
+
"contentActions.viewMarkdown": "View as Markdown",
|
|
48
|
+
"contentActions.viewMarkdownDescription": "View this page as plain text",
|
|
49
|
+
"contentActions.viewOpenApi": "View raw OpenAPI",
|
|
50
|
+
"contentActions.viewOpenApiDescription": "Open the API description file in a new tab",
|
|
51
|
+
"feedback.no": "No",
|
|
52
|
+
"feedback.prompt": "Was this page helpful?",
|
|
53
|
+
"feedback.thanks": "Thanks for your feedback!",
|
|
54
|
+
"feedback.yes": "Yes",
|
|
55
|
+
"navigation.documentation": "Documentation",
|
|
56
|
+
"navigation.next": "Next",
|
|
57
|
+
"navigation.previous": "Previous",
|
|
58
|
+
"navigation.previousNext": "Previous and next pages",
|
|
59
|
+
"navigation.toggle": "Toggle navigation",
|
|
60
|
+
"navbar.home": "Home",
|
|
61
|
+
"navbar.openLinks": "Open navigation links",
|
|
62
|
+
"navbar.sections": "Documentation sections",
|
|
63
|
+
"notFound.description": "The page may have moved, been renamed, or never existed. Check the address or return to the homepage.",
|
|
64
|
+
"notFound.home": "Back to homepage",
|
|
65
|
+
"notFound.label": "404",
|
|
66
|
+
"notFound.title": "Page not found",
|
|
67
|
+
"openapi.apiDocumentation": "API Documentation",
|
|
68
|
+
"openapi.bodyProperties": "Body properties",
|
|
69
|
+
"openapi.collapse": "Collapse",
|
|
70
|
+
"openapi.endpointNotFound": "Endpoint not found: {endpoint}",
|
|
71
|
+
"openapi.example": "Example",
|
|
72
|
+
"openapi.expand": "Expand",
|
|
73
|
+
"openapi.headers": "Headers",
|
|
74
|
+
"openapi.language": "Language",
|
|
75
|
+
"openapi.client": "Client",
|
|
76
|
+
"openapi.loading": "Loading OpenAPI spec...",
|
|
77
|
+
"openapi.mediaType": "Media type",
|
|
78
|
+
"openapi.none": "None",
|
|
79
|
+
"openapi.openApiReference": "OpenAPI Reference",
|
|
80
|
+
"openapi.operationParameter": "Operation parameter.",
|
|
81
|
+
"openapi.optional": "Optional.",
|
|
82
|
+
"openapi.parameter": "parameter",
|
|
83
|
+
"openapi.pathParameters": "Path parameters",
|
|
84
|
+
"openapi.queryParameters": "Query parameters",
|
|
85
|
+
"openapi.request": "Request",
|
|
86
|
+
"openapi.requestBody": "Request body",
|
|
87
|
+
"openapi.requestBodyEmpty": "No request body",
|
|
88
|
+
"openapi.responseBodyProperties": "Response body properties",
|
|
89
|
+
"openapi.required": "Required.",
|
|
90
|
+
"openapi.requiredBadge": "required",
|
|
91
|
+
"openapi.response": "Response",
|
|
92
|
+
"openapi.responses": "Responses",
|
|
93
|
+
"openapi.schemaExample": "Schema example",
|
|
94
|
+
"openapi.scrollExamplesLeft": "Scroll examples left",
|
|
95
|
+
"openapi.scrollExamplesRight": "Scroll examples right",
|
|
96
|
+
"openapi.specNotFound": "OpenAPI spec not found: {specPath}",
|
|
97
|
+
"openapi.specPathMissing": "spec or specPath was not provided",
|
|
98
|
+
"openapi.status": "Status",
|
|
99
|
+
"openapi.version": "Version {version}",
|
|
100
|
+
"openapi.webhookResponse": "Webhook response",
|
|
101
|
+
"openapi.webhookResponses": "Webhook responses",
|
|
102
|
+
"search.button": "Search...",
|
|
103
|
+
"search.noResults": "Nothing found for {query}.",
|
|
104
|
+
"search.placeholder": "Find something...",
|
|
105
|
+
"search.shortcutCtrl": "Ctrl ",
|
|
106
|
+
"renderError.componentStack": "React component stack",
|
|
107
|
+
"renderError.description": "Clarify stopped rendering this route to keep the rest of the shell responsive. Review the diagnostics below, fix the page source, then reload the route.",
|
|
108
|
+
"renderError.details": "Runtime diagnostics",
|
|
109
|
+
"renderError.message": "Message",
|
|
110
|
+
"renderError.path": "Route",
|
|
111
|
+
"renderError.reload": "Reload route",
|
|
112
|
+
"renderError.stack": "JavaScript stack trace",
|
|
113
|
+
"renderError.title": "Route render failed",
|
|
114
|
+
"renderError.type": "Error type",
|
|
115
|
+
"renderError.version": "Clarify version",
|
|
116
|
+
"theme.switchToDark": "Switch to dark theme",
|
|
117
|
+
"theme.switchToLight": "Switch to light theme",
|
|
118
|
+
"theme.switchToSystem": "Follow system theme",
|
|
119
|
+
"language.switch": "Switch language",
|
|
120
|
+
"mermaid.zoomIn": "Zoom in",
|
|
121
|
+
"mermaid.zoomOut": "Zoom out",
|
|
122
|
+
"mermaid.resetZoom": "Reset zoom",
|
|
123
|
+
"mermaid.renderError": "Mermaid render error",
|
|
124
|
+
"mermaid.scrollHint": "Click the diagram to enable scroll-to-zoom"
|
|
125
|
+
},
|
|
126
|
+
"zh-CN": {
|
|
127
|
+
"actions.code": "代码",
|
|
128
|
+
"actions.copy": "复制",
|
|
129
|
+
"actions.copied": "已复制!",
|
|
130
|
+
"builtWith.label": "由 Clarify 构建",
|
|
131
|
+
"builtWith.prefix": "构建来自",
|
|
132
|
+
"callout.danger": "危险",
|
|
133
|
+
"callout.info": "信息",
|
|
134
|
+
"callout.note": "注意",
|
|
135
|
+
"callout.success": "成功",
|
|
136
|
+
"callout.tip": "提示",
|
|
137
|
+
"callout.warning": "警告",
|
|
138
|
+
"contentActions.copyContent": "复制页面",
|
|
139
|
+
"contentActions.copyContentDescription": "将页面以 {contentType} 格式复制给 LLMs",
|
|
140
|
+
"contentActions.copyLink": "复制 {contentType} 链接",
|
|
141
|
+
"contentActions.copyLinkDescription": "复制当前页面的 {contentType} 原始内容链接",
|
|
142
|
+
"contentActions.copyLlms": "复制 llms.txt",
|
|
143
|
+
"contentActions.copyLlmsDescription": "复制此站点的 llms.txt 链接",
|
|
144
|
+
"contentActions.copiedLlms": "已复制 llms.txt",
|
|
145
|
+
"contentActions.editPage": "编辑此页面",
|
|
146
|
+
"contentActions.editPageDescription": "打开当前页面的源文件",
|
|
147
|
+
"contentActions.copyOptions": "选择复制选项",
|
|
148
|
+
"contentActions.copiedContent": "已复制页面",
|
|
149
|
+
"contentActions.copiedLink": "已复制链接",
|
|
150
|
+
"contentActions.viewMarkdown": "以 Markdown 格式查看",
|
|
151
|
+
"contentActions.viewMarkdownDescription": "以纯文本查看此页面",
|
|
152
|
+
"contentActions.viewOpenApi": "查看 OpenAPI 原始内容",
|
|
153
|
+
"contentActions.viewOpenApiDescription": "在新标签页打开 API 描述文件",
|
|
154
|
+
"feedback.no": "否",
|
|
155
|
+
"feedback.prompt": "这个页面有帮助吗?",
|
|
156
|
+
"feedback.thanks": "感谢你的反馈!",
|
|
157
|
+
"feedback.yes": "是",
|
|
158
|
+
"navigation.documentation": "文档",
|
|
159
|
+
"navigation.next": "下一页",
|
|
160
|
+
"navigation.previous": "上一页",
|
|
161
|
+
"navigation.previousNext": "上一页和下一页",
|
|
162
|
+
"navigation.toggle": "切换导航",
|
|
163
|
+
"navbar.home": "首页",
|
|
164
|
+
"navbar.openLinks": "打开导航链接",
|
|
165
|
+
"navbar.sections": "文档栏目",
|
|
166
|
+
"notFound.description": "页面可能已移动、重命名或不存在。请检查地址,或返回首页继续浏览。",
|
|
167
|
+
"notFound.home": "返回首页",
|
|
168
|
+
"notFound.label": "404",
|
|
169
|
+
"notFound.title": "页面未找到",
|
|
170
|
+
"openapi.apiDocumentation": "API 文档",
|
|
171
|
+
"openapi.bodyProperties": "请求体属性",
|
|
172
|
+
"openapi.collapse": "收起",
|
|
173
|
+
"openapi.endpointNotFound": "未找到端点:{endpoint}",
|
|
174
|
+
"openapi.example": "示例",
|
|
175
|
+
"openapi.expand": "展开",
|
|
176
|
+
"openapi.headers": "请求头",
|
|
177
|
+
"openapi.language": "语言",
|
|
178
|
+
"openapi.client": "客户端",
|
|
179
|
+
"openapi.loading": "正在加载 OpenAPI 描述文件...",
|
|
180
|
+
"openapi.mediaType": "媒体类型",
|
|
181
|
+
"openapi.none": "无",
|
|
182
|
+
"openapi.openApiReference": "OpenAPI 参考",
|
|
183
|
+
"openapi.operationParameter": "操作参数。",
|
|
184
|
+
"openapi.optional": "可选。",
|
|
185
|
+
"openapi.parameter": "参数",
|
|
186
|
+
"openapi.pathParameters": "路径参数",
|
|
187
|
+
"openapi.queryParameters": "查询参数",
|
|
188
|
+
"openapi.request": "请求",
|
|
189
|
+
"openapi.requestBody": "请求体",
|
|
190
|
+
"openapi.requestBodyEmpty": "暂无请求体",
|
|
191
|
+
"openapi.responseBodyProperties": "响应体属性",
|
|
192
|
+
"openapi.required": "必填。",
|
|
193
|
+
"openapi.requiredBadge": "必填",
|
|
194
|
+
"openapi.response": "响应",
|
|
195
|
+
"openapi.responses": "响应",
|
|
196
|
+
"openapi.schemaExample": "Schema 示例",
|
|
197
|
+
"openapi.scrollExamplesLeft": "向左滚动示例",
|
|
198
|
+
"openapi.scrollExamplesRight": "向右滚动示例",
|
|
199
|
+
"openapi.specNotFound": "未找到 OpenAPI 描述文件:{specPath}",
|
|
200
|
+
"openapi.specPathMissing": "未提供 spec 或 specPath",
|
|
201
|
+
"openapi.status": "状态",
|
|
202
|
+
"openapi.version": "版本 {version}",
|
|
203
|
+
"openapi.webhookResponse": "Webhook 响应",
|
|
204
|
+
"openapi.webhookResponses": "Webhook 响应",
|
|
205
|
+
"search.button": "搜索...",
|
|
206
|
+
"search.noResults": "没有找到与 {query} 相关的结果。",
|
|
207
|
+
"search.placeholder": "搜索内容...",
|
|
208
|
+
"search.shortcutCtrl": "Ctrl ",
|
|
209
|
+
"renderError.componentStack": "React 组件栈",
|
|
210
|
+
"renderError.description": "Clarify 已停止渲染此路由,以保证文档 Shell 仍可响应。请查看下方诊断信息,修复页面源码后重新加载路由。",
|
|
211
|
+
"renderError.details": "运行时诊断",
|
|
212
|
+
"renderError.message": "错误消息",
|
|
213
|
+
"renderError.path": "路由",
|
|
214
|
+
"renderError.reload": "重新加载路由",
|
|
215
|
+
"renderError.stack": "JavaScript 堆栈",
|
|
216
|
+
"renderError.title": "路由渲染失败",
|
|
217
|
+
"renderError.type": "错误类型",
|
|
218
|
+
"renderError.version": "Clarify 版本",
|
|
219
|
+
"theme.switchToDark": "切换到深色主题",
|
|
220
|
+
"theme.switchToLight": "切换到浅色主题",
|
|
221
|
+
"theme.switchToSystem": "跟随系统主题",
|
|
222
|
+
"language.switch": "切换语言",
|
|
223
|
+
"mermaid.zoomIn": "放大",
|
|
224
|
+
"mermaid.zoomOut": "缩小",
|
|
225
|
+
"mermaid.resetZoom": "重置缩放",
|
|
226
|
+
"mermaid.renderError": "Mermaid 渲染错误",
|
|
227
|
+
"mermaid.scrollHint": "点击图表后即可滚轮缩放"
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
function resolveBuiltInLocale(locale) {
|
|
231
|
+
return locale === "zh-CN" || locale?.toLowerCase().startsWith("zh") ? "zh-CN" : "en";
|
|
232
|
+
}
|
|
233
|
+
function translateBuiltInText(locale, key, replacements = {}) {
|
|
234
|
+
let value = builtInText[resolveBuiltInLocale(locale)]?.[key] ?? builtInText.en[key];
|
|
235
|
+
for (const [name, replacement] of Object.entries(replacements)) value = value.replaceAll(`{${name}}`, replacement);
|
|
236
|
+
return value;
|
|
237
|
+
}
|
|
238
|
+
function useBuiltInText(locale) {
|
|
239
|
+
const config = (0, react.useContext)(ConfigContext);
|
|
240
|
+
const currentLocale = (0, react.useContext)(LocaleContext);
|
|
241
|
+
const resolvedLocale = locale ?? currentLocale ?? config?.i18n?.defaultLocale;
|
|
242
|
+
return (key, replacements) => translateBuiltInText(resolvedLocale, key, replacements);
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
Object.defineProperty(exports, "ConfigContext", {
|
|
246
|
+
enumerable: true,
|
|
247
|
+
get: function() {
|
|
248
|
+
return ConfigContext;
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
Object.defineProperty(exports, "LocaleContext", {
|
|
252
|
+
enumerable: true,
|
|
253
|
+
get: function() {
|
|
254
|
+
return LocaleContext;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
Object.defineProperty(exports, "OpenApiSpecsContext", {
|
|
258
|
+
enumerable: true,
|
|
259
|
+
get: function() {
|
|
260
|
+
return OpenApiSpecsContext;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
Object.defineProperty(exports, "useBuiltInText", {
|
|
264
|
+
enumerable: true,
|
|
265
|
+
get: function() {
|
|
266
|
+
return useBuiltInText;
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
Object.defineProperty(exports, "useConfig", {
|
|
270
|
+
enumerable: true,
|
|
271
|
+
get: function() {
|
|
272
|
+
return useConfig;
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
Object.defineProperty(exports, "useConfigOptional", {
|
|
276
|
+
enumerable: true,
|
|
277
|
+
get: function() {
|
|
278
|
+
return useConfigOptional;
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
Object.defineProperty(exports, "useLocale", {
|
|
282
|
+
enumerable: true,
|
|
283
|
+
get: function() {
|
|
284
|
+
return useLocale;
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
Object.defineProperty(exports, "useOpenApiSpecs", {
|
|
288
|
+
enumerable: true,
|
|
289
|
+
get: function() {
|
|
290
|
+
return useOpenApiSpecs;
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
//# sourceMappingURL=i18n-b4iTLeia.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n-b4iTLeia.cjs","names":[],"sources":["../source/core/context.tsx","../source/core/i18n.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\n\nimport type { Config, OpenApiRegistry } from './types'\n\nexport const ConfigContext = createContext<Config | null>(null)\nexport const LocaleContext = createContext<string | undefined>(undefined)\nexport const OpenApiSpecsContext = createContext<OpenApiRegistry>({})\n\nexport function useConfig(): Config {\n const config = useContext(ConfigContext)\n if (!config) {\n throw new Error(\n '[clarify] useConfig must be used within a ConfigContext.Provider'\n )\n }\n return config\n}\n\nexport function useConfigOptional(): Config | null {\n return useContext(ConfigContext)\n}\n\nexport function useLocale(): string | undefined {\n return useContext(LocaleContext)\n}\n\nexport function useOpenApiSpecs(): OpenApiRegistry {\n return useContext(OpenApiSpecsContext)\n}\n","import { useContext } from 'react'\n\nimport { ConfigContext, LocaleContext } from './context'\n\nexport type BuiltInLocale = 'en' | 'zh-CN'\n\nexport type BuiltInTextKey =\n | 'actions.code'\n | 'actions.copy'\n | 'actions.copied'\n | 'builtWith.label'\n | 'builtWith.prefix'\n | 'callout.danger'\n | 'callout.info'\n | 'callout.note'\n | 'callout.success'\n | 'callout.tip'\n | 'callout.warning'\n | 'contentActions.copyContent'\n | 'contentActions.copyContentDescription'\n | 'contentActions.copyLink'\n | 'contentActions.copyLinkDescription'\n | 'contentActions.copyLlms'\n | 'contentActions.copyLlmsDescription'\n | 'contentActions.copiedLlms'\n | 'contentActions.editPage'\n | 'contentActions.editPageDescription'\n | 'contentActions.copyOptions'\n | 'contentActions.copiedContent'\n | 'contentActions.copiedLink'\n | 'contentActions.viewMarkdown'\n | 'contentActions.viewMarkdownDescription'\n | 'contentActions.viewOpenApi'\n | 'contentActions.viewOpenApiDescription'\n | 'feedback.no'\n | 'feedback.prompt'\n | 'feedback.thanks'\n | 'feedback.yes'\n | 'navigation.documentation'\n | 'navigation.next'\n | 'navigation.previous'\n | 'navigation.previousNext'\n | 'navigation.toggle'\n | 'navbar.home'\n | 'navbar.openLinks'\n | 'navbar.sections'\n | 'notFound.description'\n | 'notFound.home'\n | 'notFound.label'\n | 'notFound.title'\n | 'openapi.apiDocumentation'\n | 'openapi.bodyProperties'\n | 'openapi.collapse'\n | 'openapi.endpointNotFound'\n | 'openapi.example'\n | 'openapi.expand'\n | 'openapi.headers'\n | 'openapi.language'\n | 'openapi.client'\n | 'openapi.loading'\n | 'openapi.mediaType'\n | 'openapi.none'\n | 'openapi.openApiReference'\n | 'openapi.operationParameter'\n | 'openapi.optional'\n | 'openapi.parameter'\n | 'openapi.pathParameters'\n | 'openapi.queryParameters'\n | 'openapi.request'\n | 'openapi.requestBody'\n | 'openapi.requestBodyEmpty'\n | 'openapi.responseBodyProperties'\n | 'openapi.required'\n | 'openapi.requiredBadge'\n | 'openapi.response'\n | 'openapi.responses'\n | 'openapi.schemaExample'\n | 'openapi.scrollExamplesLeft'\n | 'openapi.scrollExamplesRight'\n | 'openapi.specNotFound'\n | 'openapi.specPathMissing'\n | 'openapi.status'\n | 'openapi.version'\n | 'openapi.webhookResponse'\n | 'openapi.webhookResponses'\n | 'search.button'\n | 'search.noResults'\n | 'search.placeholder'\n | 'search.shortcutCtrl'\n | 'renderError.componentStack'\n | 'renderError.description'\n | 'renderError.details'\n | 'renderError.message'\n | 'renderError.path'\n | 'renderError.reload'\n | 'renderError.stack'\n | 'renderError.title'\n | 'renderError.version'\n | 'renderError.type'\n | 'theme.switchToDark'\n | 'theme.switchToLight'\n | 'theme.switchToSystem'\n | 'language.switch'\n | 'mermaid.zoomIn'\n | 'mermaid.zoomOut'\n | 'mermaid.resetZoom'\n | 'mermaid.renderError'\n | 'mermaid.scrollHint'\n\nconst builtInText = {\n en: {\n 'actions.code': 'Code',\n 'actions.copy': 'Copy',\n 'actions.copied': 'Copied!',\n 'builtWith.label': 'Built with Clarify',\n 'builtWith.prefix': 'Built with',\n 'callout.danger': 'Danger',\n 'callout.info': 'Info',\n 'callout.note': 'Note',\n 'callout.success': 'Success',\n 'callout.tip': 'Tip',\n 'callout.warning': 'Warning',\n 'contentActions.copyContent': 'Copy page',\n 'contentActions.copyContentDescription': 'Copy this page as {contentType} for LLMs',\n 'contentActions.copyLink': 'Copy {contentType} link',\n 'contentActions.copyLinkDescription': 'Copy the raw {contentType} content link for this page',\n 'contentActions.copyLlms': 'Copy llms.txt',\n 'contentActions.copyLlmsDescription': 'Copy the llms.txt link for this site',\n 'contentActions.copiedLlms': 'Copied llms.txt',\n 'contentActions.editPage': 'Edit this page',\n 'contentActions.editPageDescription': 'Open the source file for this page',\n 'contentActions.copyOptions': 'Choose copy option',\n 'contentActions.copiedContent': 'Copied page',\n 'contentActions.copiedLink': 'Copied link',\n 'contentActions.viewMarkdown': 'View as Markdown',\n 'contentActions.viewMarkdownDescription': 'View this page as plain text',\n 'contentActions.viewOpenApi': 'View raw OpenAPI',\n 'contentActions.viewOpenApiDescription': 'Open the API description file in a new tab',\n 'feedback.no': 'No',\n 'feedback.prompt': 'Was this page helpful?',\n 'feedback.thanks': 'Thanks for your feedback!',\n 'feedback.yes': 'Yes',\n 'navigation.documentation': 'Documentation',\n 'navigation.next': 'Next',\n 'navigation.previous': 'Previous',\n 'navigation.previousNext': 'Previous and next pages',\n 'navigation.toggle': 'Toggle navigation',\n 'navbar.home': 'Home',\n 'navbar.openLinks': 'Open navigation links',\n 'navbar.sections': 'Documentation sections',\n 'notFound.description': 'The page may have moved, been renamed, or never existed. Check the address or return to the homepage.',\n 'notFound.home': 'Back to homepage',\n 'notFound.label': '404',\n 'notFound.title': 'Page not found',\n 'openapi.apiDocumentation': 'API Documentation',\n 'openapi.bodyProperties': 'Body properties',\n 'openapi.collapse': 'Collapse',\n 'openapi.endpointNotFound': 'Endpoint not found: {endpoint}',\n 'openapi.example': 'Example',\n 'openapi.expand': 'Expand',\n 'openapi.headers': 'Headers',\n 'openapi.language': 'Language',\n 'openapi.client': 'Client',\n 'openapi.loading': 'Loading OpenAPI spec...',\n 'openapi.mediaType': 'Media type',\n 'openapi.none': 'None',\n 'openapi.openApiReference': 'OpenAPI Reference',\n 'openapi.operationParameter': 'Operation parameter.',\n 'openapi.optional': 'Optional.',\n 'openapi.parameter': 'parameter',\n 'openapi.pathParameters': 'Path parameters',\n 'openapi.queryParameters': 'Query parameters',\n 'openapi.request': 'Request',\n 'openapi.requestBody': 'Request body',\n 'openapi.requestBodyEmpty': 'No request body',\n 'openapi.responseBodyProperties': 'Response body properties',\n 'openapi.required': 'Required.',\n 'openapi.requiredBadge': 'required',\n 'openapi.response': 'Response',\n 'openapi.responses': 'Responses',\n 'openapi.schemaExample': 'Schema example',\n 'openapi.scrollExamplesLeft': 'Scroll examples left',\n 'openapi.scrollExamplesRight': 'Scroll examples right',\n 'openapi.specNotFound': 'OpenAPI spec not found: {specPath}',\n 'openapi.specPathMissing': 'spec or specPath was not provided',\n 'openapi.status': 'Status',\n 'openapi.version': 'Version {version}',\n 'openapi.webhookResponse': 'Webhook response',\n 'openapi.webhookResponses': 'Webhook responses',\n 'search.button': 'Search...',\n 'search.noResults': 'Nothing found for {query}.',\n 'search.placeholder': 'Find something...',\n 'search.shortcutCtrl': 'Ctrl ',\n 'renderError.componentStack': 'React component stack',\n 'renderError.description': 'Clarify stopped rendering this route to keep the rest of the shell responsive. Review the diagnostics below, fix the page source, then reload the route.',\n 'renderError.details': 'Runtime diagnostics',\n 'renderError.message': 'Message',\n 'renderError.path': 'Route',\n 'renderError.reload': 'Reload route',\n 'renderError.stack': 'JavaScript stack trace',\n 'renderError.title': 'Route render failed',\n 'renderError.type': 'Error type',\n 'renderError.version': 'Clarify version',\n 'theme.switchToDark': 'Switch to dark theme',\n 'theme.switchToLight': 'Switch to light theme',\n 'theme.switchToSystem': 'Follow system theme',\n 'language.switch': 'Switch language',\n 'mermaid.zoomIn': 'Zoom in',\n 'mermaid.zoomOut': 'Zoom out',\n 'mermaid.resetZoom': 'Reset zoom',\n 'mermaid.renderError': 'Mermaid render error',\n 'mermaid.scrollHint': 'Click the diagram to enable scroll-to-zoom',\n },\n 'zh-CN': {\n 'actions.code': '代码',\n 'actions.copy': '复制',\n 'actions.copied': '已复制!',\n 'builtWith.label': '由 Clarify 构建',\n 'builtWith.prefix': '构建来自',\n 'callout.danger': '危险',\n 'callout.info': '信息',\n 'callout.note': '注意',\n 'callout.success': '成功',\n 'callout.tip': '提示',\n 'callout.warning': '警告',\n 'contentActions.copyContent': '复制页面',\n 'contentActions.copyContentDescription': '将页面以 {contentType} 格式复制给 LLMs',\n 'contentActions.copyLink': '复制 {contentType} 链接',\n 'contentActions.copyLinkDescription': '复制当前页面的 {contentType} 原始内容链接',\n 'contentActions.copyLlms': '复制 llms.txt',\n 'contentActions.copyLlmsDescription': '复制此站点的 llms.txt 链接',\n 'contentActions.copiedLlms': '已复制 llms.txt',\n 'contentActions.editPage': '编辑此页面',\n 'contentActions.editPageDescription': '打开当前页面的源文件',\n 'contentActions.copyOptions': '选择复制选项',\n 'contentActions.copiedContent': '已复制页面',\n 'contentActions.copiedLink': '已复制链接',\n 'contentActions.viewMarkdown': '以 Markdown 格式查看',\n 'contentActions.viewMarkdownDescription': '以纯文本查看此页面',\n 'contentActions.viewOpenApi': '查看 OpenAPI 原始内容',\n 'contentActions.viewOpenApiDescription': '在新标签页打开 API 描述文件',\n 'feedback.no': '否',\n 'feedback.prompt': '这个页面有帮助吗?',\n 'feedback.thanks': '感谢你的反馈!',\n 'feedback.yes': '是',\n 'navigation.documentation': '文档',\n 'navigation.next': '下一页',\n 'navigation.previous': '上一页',\n 'navigation.previousNext': '上一页和下一页',\n 'navigation.toggle': '切换导航',\n 'navbar.home': '首页',\n 'navbar.openLinks': '打开导航链接',\n 'navbar.sections': '文档栏目',\n 'notFound.description': '页面可能已移动、重命名或不存在。请检查地址,或返回首页继续浏览。',\n 'notFound.home': '返回首页',\n 'notFound.label': '404',\n 'notFound.title': '页面未找到',\n 'openapi.apiDocumentation': 'API 文档',\n 'openapi.bodyProperties': '请求体属性',\n 'openapi.collapse': '收起',\n 'openapi.endpointNotFound': '未找到端点:{endpoint}',\n 'openapi.example': '示例',\n 'openapi.expand': '展开',\n 'openapi.headers': '请求头',\n 'openapi.language': '语言',\n 'openapi.client': '客户端',\n 'openapi.loading': '正在加载 OpenAPI 描述文件...',\n 'openapi.mediaType': '媒体类型',\n 'openapi.none': '无',\n 'openapi.openApiReference': 'OpenAPI 参考',\n 'openapi.operationParameter': '操作参数。',\n 'openapi.optional': '可选。',\n 'openapi.parameter': '参数',\n 'openapi.pathParameters': '路径参数',\n 'openapi.queryParameters': '查询参数',\n 'openapi.request': '请求',\n 'openapi.requestBody': '请求体',\n 'openapi.requestBodyEmpty': '暂无请求体',\n 'openapi.responseBodyProperties': '响应体属性',\n 'openapi.required': '必填。',\n 'openapi.requiredBadge': '必填',\n 'openapi.response': '响应',\n 'openapi.responses': '响应',\n 'openapi.schemaExample': 'Schema 示例',\n 'openapi.scrollExamplesLeft': '向左滚动示例',\n 'openapi.scrollExamplesRight': '向右滚动示例',\n 'openapi.specNotFound': '未找到 OpenAPI 描述文件:{specPath}',\n 'openapi.specPathMissing': '未提供 spec 或 specPath',\n 'openapi.status': '状态',\n 'openapi.version': '版本 {version}',\n 'openapi.webhookResponse': 'Webhook 响应',\n 'openapi.webhookResponses': 'Webhook 响应',\n 'search.button': '搜索...',\n 'search.noResults': '没有找到与 {query} 相关的结果。',\n 'search.placeholder': '搜索内容...',\n 'search.shortcutCtrl': 'Ctrl ',\n 'renderError.componentStack': 'React 组件栈',\n 'renderError.description': 'Clarify 已停止渲染此路由,以保证文档 Shell 仍可响应。请查看下方诊断信息,修复页面源码后重新加载路由。',\n 'renderError.details': '运行时诊断',\n 'renderError.message': '错误消息',\n 'renderError.path': '路由',\n 'renderError.reload': '重新加载路由',\n 'renderError.stack': 'JavaScript 堆栈',\n 'renderError.title': '路由渲染失败',\n 'renderError.type': '错误类型',\n 'renderError.version': 'Clarify 版本',\n 'theme.switchToDark': '切换到深色主题',\n 'theme.switchToLight': '切换到浅色主题',\n 'theme.switchToSystem': '跟随系统主题',\n 'language.switch': '切换语言',\n 'mermaid.zoomIn': '放大',\n 'mermaid.zoomOut': '缩小',\n 'mermaid.resetZoom': '重置缩放',\n 'mermaid.renderError': 'Mermaid 渲染错误',\n 'mermaid.scrollHint': '点击图表后即可滚轮缩放',\n },\n} satisfies Record<BuiltInLocale, Record<BuiltInTextKey, string>>\n\nexport function resolveBuiltInLocale(locale?: string): BuiltInLocale {\n return locale === 'zh-CN' || locale?.toLowerCase().startsWith('zh') ? 'zh-CN' : 'en'\n}\n\nexport function translateBuiltInText(locale: string | undefined, key: BuiltInTextKey, replacements: Record<string, string> = {}): string {\n let value = builtInText[resolveBuiltInLocale(locale)]?.[key] ?? builtInText.en[key]\n for (const [name, replacement] of Object.entries(replacements)) {\n value = value.replaceAll(`{${name}}`, replacement)\n }\n return value\n}\n\nexport function useBuiltInText(locale?: string) {\n const config = useContext(ConfigContext)\n const currentLocale = useContext(LocaleContext)\n const resolvedLocale = locale ?? currentLocale ?? config?.i18n?.defaultLocale\n return (key: BuiltInTextKey, replacements?: Record<string, string>) => translateBuiltInText(resolvedLocale, key, replacements)\n}\n"],"mappings":";;AAIA,IAAa,iBAAA,GAAA,MAAA,cAAA,CAA6C,IAAI;AAC9D,IAAa,iBAAA,GAAA,MAAA,cAAA,CAAkD,KAAA,CAAS;AACxE,IAAa,uBAAA,GAAA,MAAA,cAAA,CAAqD,CAAC,CAAC;AAEpE,SAAgB,YAAoB;CAClC,MAAM,UAAA,GAAA,MAAA,WAAA,CAAoB,aAAa;CACvC,IAAI,CAAC,QACH,MAAM,IAAI,MACR,kEACF;CAEF,OAAO;AACT;AAEA,SAAgB,o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CAA2B,aAAa;CAC9C,MAAM,iBAAiB,UAAU,iBAAiB,QAAQ,MAAM;CAChE,QAAQ,KAAqB,iBAA0C,qBAAqB,gBAAgB,KAAK,YAAY;AAC/H"}
|
package/output/index.cjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_ClarifyShell = require("./ClarifyShell-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
2
|
+
const require_i18n = require("./i18n-b4iTLeia.cjs");
|
|
3
|
+
const require_ClarifyShell = require("./ClarifyShell-C6li72Ce.cjs");
|
|
4
|
+
const require_PageActions = require("./PageActions-BjB6PYmL.cjs");
|
|
5
|
+
const require_OpenApiOperation = require("./OpenApiOperation-B52IWlKb.cjs");
|
|
6
|
+
const require_remark = require("./remark-DTLbG8PK.cjs");
|
|
7
|
+
const require_render = require("./render-Di5B6Zc0.cjs");
|
|
8
|
+
let react = require("react");
|
|
7
9
|
let react_router_dom = require("react-router-dom");
|
|
8
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
11
|
//#region source/app/ContentDiagnostic.tsx
|
|
@@ -36,6 +38,12 @@ function createContentDiagnosticComponent(data) {
|
|
|
36
38
|
}
|
|
37
39
|
//#endregion
|
|
38
40
|
//#region source/openapi/lib/spec-path.ts
|
|
41
|
+
function isOpenApiSpecLoader(value) {
|
|
42
|
+
return typeof value === "function";
|
|
43
|
+
}
|
|
44
|
+
function getLoadedSpec(value) {
|
|
45
|
+
return value && typeof value === "object" && "default" in value ? value.default : value;
|
|
46
|
+
}
|
|
39
47
|
var VIRTUAL_PREFIX = "virtual:clarify-page/";
|
|
40
48
|
function resolveRelativePath(fromDir, to) {
|
|
41
49
|
const parts = (fromDir + "/" + to).split("/").filter(Boolean);
|
|
@@ -53,84 +61,70 @@ function normalizeSpecPath(specPath, currentRoutePath, routePrefix = "") {
|
|
|
53
61
|
return VIRTUAL_PREFIX + resolveRelativePath(normalizedRoutePrefix && fromDir.startsWith(`${normalizedRoutePrefix}/`) ? fromDir.slice(normalizedRoutePrefix.length + 1) : fromDir, normalizedSpecPath);
|
|
54
62
|
}
|
|
55
63
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* 因此绝对路径(如 `/api`)需要显式注入 locale 前缀才能命中。
|
|
60
|
-
* 相对路径会因为当前路由已含 locale 前缀而自动解析到正确的 spec。
|
|
64
|
+
* Prefer a locale-qualified registry key for absolute specPath values, then
|
|
65
|
+
* fall back to the normalized key. The CLI registers visible route aliases,
|
|
66
|
+
* while relative paths already resolve through the current localized route.
|
|
61
67
|
*/
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
function specModuleCandidates(moduleId, specPath, locale) {
|
|
69
|
+
const candidates = [];
|
|
70
|
+
if (locale && specPath.startsWith("/") && !specPath.startsWith(VIRTUAL_PREFIX)) {
|
|
71
|
+
const rest = moduleId.slice(21);
|
|
72
|
+
if (!rest.startsWith(`${locale}/`) && rest !== locale) candidates.push(`${VIRTUAL_PREFIX}${locale}/${rest}`);
|
|
73
|
+
}
|
|
74
|
+
candidates.push(moduleId);
|
|
75
|
+
return candidates;
|
|
68
76
|
}
|
|
69
77
|
function useOpenApiSpec(spec, specPath) {
|
|
70
|
-
const config =
|
|
71
|
-
const locale =
|
|
72
|
-
const specs =
|
|
78
|
+
const config = require_i18n.useConfig();
|
|
79
|
+
const locale = require_i18n.useLocale();
|
|
80
|
+
const specs = require_i18n.useOpenApiSpecs();
|
|
73
81
|
const location = (0, react_router_dom.useLocation)();
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"get",
|
|
85
|
-
"put",
|
|
86
|
-
"post",
|
|
87
|
-
"delete",
|
|
88
|
-
"options",
|
|
89
|
-
"head",
|
|
90
|
-
"patch",
|
|
91
|
-
"trace"
|
|
92
|
-
];
|
|
93
|
-
function isOpenAPIHttpMethod(method) {
|
|
94
|
-
return OPENAPI_HTTP_METHODS.includes(method.toLowerCase());
|
|
95
|
-
}
|
|
96
|
-
function isRecord(value) {
|
|
97
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
98
|
-
}
|
|
99
|
-
function resolveOpenApiRef(spec, ref) {
|
|
100
|
-
if (!ref.startsWith("#/")) return void 0;
|
|
101
|
-
return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((current, part) => isRecord(current) ? current[part] : void 0, spec);
|
|
102
|
-
}
|
|
103
|
-
function getPathItem(spec, path) {
|
|
104
|
-
const pathItem = spec.paths?.[path];
|
|
105
|
-
const resolved = isRecord(pathItem) && typeof pathItem.$ref === "string" ? resolveOpenApiRef(spec, pathItem.$ref) : pathItem;
|
|
106
|
-
return isRecord(resolved) ? resolved : void 0;
|
|
107
|
-
}
|
|
108
|
-
function getOpenApiOperation(spec, path, method) {
|
|
109
|
-
if (!isOpenAPIHttpMethod(method)) return void 0;
|
|
110
|
-
return getPathItem(spec, path)?.[method.toLowerCase()];
|
|
111
|
-
}
|
|
112
|
-
function listOpenApiOperations(spec) {
|
|
113
|
-
const paths = spec.paths ?? {};
|
|
114
|
-
const operations = [];
|
|
115
|
-
for (const path of Object.keys(paths)) {
|
|
116
|
-
const pathItem = getPathItem(spec, path);
|
|
117
|
-
if (!pathItem) continue;
|
|
118
|
-
for (const method of OPENAPI_HTTP_METHODS) {
|
|
119
|
-
const operation = pathItem[method];
|
|
120
|
-
if (operation) operations.push({
|
|
121
|
-
path,
|
|
122
|
-
method,
|
|
123
|
-
operation
|
|
82
|
+
const [loadedSpec, setLoadedSpec] = (0, react.useState)({ spec: null });
|
|
83
|
+
const normalized = specPath ? normalizeSpecPath(specPath, location.pathname, config.routePrefix) : void 0;
|
|
84
|
+
const registryValue = (specPath && normalized ? specModuleCandidates(normalized, specPath, locale) : []).map((candidate) => specs[candidate]).find(Boolean);
|
|
85
|
+
(0, react.useEffect)(() => {
|
|
86
|
+
let cancelled = false;
|
|
87
|
+
if (!isOpenApiSpecLoader(registryValue)) return;
|
|
88
|
+
registryValue().then((module) => {
|
|
89
|
+
if (!cancelled) setLoadedSpec({
|
|
90
|
+
loader: registryValue,
|
|
91
|
+
spec: getLoadedSpec(module)
|
|
124
92
|
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
93
|
+
}).catch(() => {
|
|
94
|
+
if (!cancelled) setLoadedSpec({
|
|
95
|
+
loader: registryValue,
|
|
96
|
+
spec: null
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
return () => {
|
|
100
|
+
cancelled = true;
|
|
101
|
+
};
|
|
102
|
+
}, [registryValue]);
|
|
103
|
+
if (spec) return {
|
|
104
|
+
spec,
|
|
105
|
+
loading: false
|
|
106
|
+
};
|
|
107
|
+
if (!specPath) return {
|
|
108
|
+
spec: null,
|
|
109
|
+
loading: false
|
|
110
|
+
};
|
|
111
|
+
if (isOpenApiSpecLoader(registryValue)) return loadedSpec.loader === registryValue ? {
|
|
112
|
+
spec: loadedSpec.spec,
|
|
113
|
+
loading: false
|
|
114
|
+
} : {
|
|
115
|
+
spec: null,
|
|
116
|
+
loading: true
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
spec: registryValue ?? null,
|
|
120
|
+
loading: false
|
|
121
|
+
};
|
|
128
122
|
}
|
|
129
123
|
//#endregion
|
|
130
124
|
//#region source/openapi/entry.tsx
|
|
131
125
|
function OpenApiHeader(arg0) {
|
|
132
126
|
const { spec } = arg0;
|
|
133
|
-
const t =
|
|
127
|
+
const t = require_i18n.useBuiltInText();
|
|
134
128
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
135
129
|
className: "clarify-openapi-header mb-16 border-b border-(--clarify-theme-tokens-colors-border) pb-8",
|
|
136
130
|
children: [
|
|
@@ -164,16 +158,18 @@ function OpenApiPaths(arg0) {
|
|
|
164
158
|
const { spec, tagFilter } = arg0;
|
|
165
159
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
166
160
|
className: "clarify-api-endpoints divide-y divide-zinc-200/70 dark:divide-white/10",
|
|
167
|
-
children: listOpenApiOperations(spec).filter(({ operation }) => operationMatchesTags(operation.tags, tagFilter)).map(({ path, method, operation }) => ({
|
|
161
|
+
children: require_OpenApiOperation.listOpenApiOperations(spec).filter(({ operation }) => operationMatchesTags(operation.tags, tagFilter)).map(({ path, method, operation, source }) => ({
|
|
168
162
|
path,
|
|
169
163
|
method: method.toUpperCase(),
|
|
170
|
-
operation
|
|
171
|
-
|
|
164
|
+
operation,
|
|
165
|
+
source
|
|
166
|
+
})).map(({ path, method, operation, source }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_OpenApiOperation.OpenApiOperation, {
|
|
172
167
|
spec,
|
|
173
168
|
path,
|
|
174
169
|
method,
|
|
175
|
-
operation
|
|
176
|
-
|
|
170
|
+
operation,
|
|
171
|
+
operationSource: source
|
|
172
|
+
}, `${source}-${method}-${path}`))
|
|
177
173
|
});
|
|
178
174
|
}
|
|
179
175
|
function WarningBox(arg0) {
|
|
@@ -185,8 +181,9 @@ function WarningBox(arg0) {
|
|
|
185
181
|
}
|
|
186
182
|
function OpenApiDocument(arg0) {
|
|
187
183
|
const { spec, specPath, tagFilter } = arg0;
|
|
188
|
-
const t =
|
|
189
|
-
const resolved = useOpenApiSpec(spec, specPath);
|
|
184
|
+
const t = require_i18n.useBuiltInText();
|
|
185
|
+
const { spec: resolved, loading } = useOpenApiSpec(spec, specPath);
|
|
186
|
+
if (loading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WarningBox, { children: t("openapi.loading") });
|
|
190
187
|
if (!resolved) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WarningBox, { children: t("openapi.specNotFound", { specPath: specPath ?? t("openapi.specPathMissing") }) });
|
|
191
188
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("article", {
|
|
192
189
|
className: "clarify-openapi-page flex h-full flex-col pt-16 pb-10",
|
|
@@ -201,24 +198,26 @@ function OpenApiDocument(arg0) {
|
|
|
201
198
|
}
|
|
202
199
|
function OpenApiOperationWithSpec(arg0) {
|
|
203
200
|
const { spec, path, method } = arg0;
|
|
204
|
-
const t =
|
|
205
|
-
const
|
|
206
|
-
if (!
|
|
201
|
+
const t = require_i18n.useBuiltInText();
|
|
202
|
+
const entry = require_OpenApiOperation.getOpenApiOperationEntry(spec, path, method);
|
|
203
|
+
if (!entry) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WarningBox, {
|
|
207
204
|
tone: "red",
|
|
208
205
|
children: t("openapi.endpointNotFound", { endpoint: `${method.toUpperCase()} ${path}` })
|
|
209
206
|
});
|
|
210
|
-
const normalizedMethod = method.toUpperCase();
|
|
207
|
+
const normalizedMethod = entry.method.toUpperCase();
|
|
211
208
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_OpenApiOperation.OpenApiOperation, {
|
|
212
209
|
spec,
|
|
213
210
|
path,
|
|
214
211
|
method: normalizedMethod,
|
|
215
|
-
operation:
|
|
216
|
-
|
|
212
|
+
operation: entry.operation,
|
|
213
|
+
operationSource: entry.source
|
|
214
|
+
}, `${entry.source}-${normalizedMethod}-${path}`);
|
|
217
215
|
}
|
|
218
216
|
function OpenApiOperation(arg0) {
|
|
219
217
|
const { specPath, path, method } = arg0;
|
|
220
|
-
const t =
|
|
221
|
-
const spec = useOpenApiSpec(void 0, specPath);
|
|
218
|
+
const t = require_i18n.useBuiltInText();
|
|
219
|
+
const { spec, loading } = useOpenApiSpec(void 0, specPath);
|
|
220
|
+
if (loading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WarningBox, { children: t("openapi.loading") });
|
|
222
221
|
if (!spec) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WarningBox, { children: t("openapi.specNotFound", { specPath }) });
|
|
223
222
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiOperationWithSpec, {
|
|
224
223
|
spec,
|
|
@@ -228,10 +227,7 @@ function OpenApiOperation(arg0) {
|
|
|
228
227
|
}
|
|
229
228
|
function createOpenApiRouteComponent(data) {
|
|
230
229
|
return function OpenApiRoutePage() {
|
|
231
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiDocument, {
|
|
232
|
-
spec: data.spec,
|
|
233
|
-
tagFilter: data.tagFilter
|
|
234
|
-
});
|
|
230
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiDocument, { spec: data.spec });
|
|
235
231
|
};
|
|
236
232
|
}
|
|
237
233
|
//#endregion
|
|
@@ -294,7 +290,7 @@ exports.Markdown = require_OpenApiOperation.Markdown;
|
|
|
294
290
|
exports.Mermaid = require_OpenApiOperation.Mermaid;
|
|
295
291
|
exports.OpenApiDocument = OpenApiDocument;
|
|
296
292
|
exports.OpenApiOperation = OpenApiOperation;
|
|
297
|
-
exports.
|
|
293
|
+
exports.OpenApiSpecsContext = require_i18n.OpenApiSpecsContext;
|
|
298
294
|
exports.PageBanner = require_ClarifyShell.PageBanner;
|
|
299
295
|
exports.PageFooter = require_ClarifyShell.PageFooter;
|
|
300
296
|
exports.Pre = require_OpenApiOperation.Pre;
|
|
@@ -312,13 +308,14 @@ exports.applyThemeVariables = require_ClarifyShell.applyThemeVariables;
|
|
|
312
308
|
exports.createContentDiagnosticComponent = createContentDiagnosticComponent;
|
|
313
309
|
exports.createOpenApiRouteComponent = createOpenApiRouteComponent;
|
|
314
310
|
exports.markdownRemarkPlugins = require_remark.markdownRemarkPlugins;
|
|
311
|
+
exports.parseCodeMeta = require_remark.parseCodeMeta;
|
|
315
312
|
exports.remToPx = require_PageActions.remToPx;
|
|
316
313
|
exports.render = require_render.render;
|
|
317
314
|
exports.themeBootstrapScript = require_ClarifyShell.themeBootstrapScript;
|
|
318
315
|
exports.themeEditorPresets = require_ClarifyShell.themeEditorPresets;
|
|
319
316
|
exports.themePresets = require_ClarifyShell.themePresets;
|
|
320
317
|
exports.useMDXComponents = useMDXComponents;
|
|
321
|
-
exports.
|
|
318
|
+
exports.useOpenApiSpecs = require_i18n.useOpenApiSpecs;
|
|
322
319
|
exports.useSectionStore = require_PageActions.useSectionStore;
|
|
323
320
|
exports.useSlot = require_ClarifyShell.useSlot;
|
|
324
321
|
exports.useTheme = require_PageActions.useTheme;
|