@clarify-labs/renderer 0.7.2 → 0.8.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.
Files changed (59) hide show
  1. package/output/{ThemeRoot-UWj0iK1X.cjs → ClarifyShell-B74Fq4UU.cjs} +389 -161
  2. package/output/ClarifyShell-B74Fq4UU.cjs.map +1 -0
  3. package/output/{ThemeRoot-QULrwQf6.js → ClarifyShell-BPv2bxI4.js} +361 -157
  4. package/output/ClarifyShell-BPv2bxI4.js.map +1 -0
  5. package/output/{OpenApiOperation-BcyW_ULy.cjs → OpenApiOperation-BMXfV15v.cjs} +209 -7
  6. package/output/OpenApiOperation-BMXfV15v.cjs.map +1 -0
  7. package/output/{OpenApiOperation-tUKf7lZ4.js → OpenApiOperation-fJ3QQOJX.js} +205 -9
  8. package/output/OpenApiOperation-fJ3QQOJX.js.map +1 -0
  9. package/output/{PageActions-yoDRjkq8.js → PageActions-BwY7ierv.js} +55 -81
  10. package/output/PageActions-BwY7ierv.js.map +1 -0
  11. package/output/{PageActions-1RDCHcUY.cjs → PageActions-DOKkt2zo.cjs} +59 -79
  12. package/output/PageActions-DOKkt2zo.cjs.map +1 -0
  13. package/output/app/AppShell.d.ts +2 -3
  14. package/output/app/PageBanner.d.ts +0 -2
  15. package/output/app/PageFooter.d.ts +1 -5
  16. package/output/client.cjs +8 -8
  17. package/output/client.js +3 -3
  18. package/output/components/Code.d.ts +5 -1
  19. package/output/components/Mermaid.d.ts +7 -0
  20. package/output/components/index.d.ts +1 -0
  21. package/output/context.d.ts +1 -1
  22. package/output/core/i18n.d.ts +1 -1
  23. package/output/core/types.d.ts +8 -14
  24. package/output/index.cjs +27 -24
  25. package/output/index.cjs.map +1 -1
  26. package/output/index.d.ts +7 -4
  27. package/output/index.js +14 -14
  28. package/output/index.js.map +1 -1
  29. package/output/mdx/components.d.ts +3 -0
  30. package/output/mdx/primitives.d.ts +1 -0
  31. package/output/preview.cjs +3 -2
  32. package/output/preview.cjs.map +1 -1
  33. package/output/preview.js +3 -2
  34. package/output/preview.js.map +1 -1
  35. package/output/{render-psutGbsg.js → render-Cghgq1AQ.js} +10 -20
  36. package/output/render-Cghgq1AQ.js.map +1 -0
  37. package/output/{render-ByWbJbrA.cjs → render-ZSckbg74.cjs} +10 -20
  38. package/output/render-ZSckbg74.cjs.map +1 -0
  39. package/output/renderer.css +77 -21
  40. package/output/runtime/ClarifyShell.d.ts +22 -0
  41. package/output/server.cjs +10 -19
  42. package/output/server.cjs.map +1 -1
  43. package/output/server.js +10 -19
  44. package/output/server.js.map +1 -1
  45. package/output/shell/search/pagefind.d.ts +0 -1
  46. package/output/slots/RuntimeSlot.d.ts +58 -0
  47. package/output/slots/context.d.ts +20 -0
  48. package/output/slots/index.d.ts +5 -0
  49. package/output/slots/types.d.ts +50 -0
  50. package/output/utils/localized-text.d.ts +7 -0
  51. package/package.json +8 -3
  52. package/output/OpenApiOperation-BcyW_ULy.cjs.map +0 -1
  53. package/output/OpenApiOperation-tUKf7lZ4.js.map +0 -1
  54. package/output/PageActions-1RDCHcUY.cjs.map +0 -1
  55. package/output/PageActions-yoDRjkq8.js.map +0 -1
  56. package/output/ThemeRoot-QULrwQf6.js.map +0 -1
  57. package/output/ThemeRoot-UWj0iK1X.cjs.map +0 -1
  58. package/output/render-ByWbJbrA.cjs.map +0 -1
  59. package/output/render-psutGbsg.js.map +0 -1
package/output/index.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_PageActions = require("./PageActions-1RDCHcUY.cjs");
3
- const require_ThemeRoot = require("./ThemeRoot-UWj0iK1X.cjs");
4
- const require_OpenApiOperation = require("./OpenApiOperation-BcyW_ULy.cjs");
2
+ const require_PageActions = require("./PageActions-DOKkt2zo.cjs");
3
+ const require_ClarifyShell = require("./ClarifyShell-B74Fq4UU.cjs");
4
+ const require_OpenApiOperation = require("./OpenApiOperation-BMXfV15v.cjs");
5
5
  const require_remark = require("./remark-Dv3owbSH.cjs");
6
- const require_render = require("./render-ByWbJbrA.cjs");
6
+ const require_render = require("./render-ZSckbg74.cjs");
7
7
  let react_router_dom = require("react-router-dom");
8
8
  let react_jsx_runtime = require("react/jsx-runtime");
9
9
  //#region source/openapi/lib/spec-path.ts
@@ -26,23 +26,22 @@ function normalizeSpecPath(specPath, currentRoutePath, routePrefix = "") {
26
26
  /**
27
27
  * 为绝对 specPath 生成带 locale 前缀的候选模块 ID。
28
28
  *
29
- * 局部嵌入(OpenApiOperation / OpenApiDocument)通常使用 `/api` 这样的绝对路径。
30
- * 默认 locale 的 spec 注册在 `virtual:clarify-page/api`,而其他 locale 的 spec
31
- * 注册在 `virtual:clarify-page/<locale>/api`。相对路径会因为当前路由已含 locale 前缀
32
- * 而自动解析到正确的 spec,但绝对路径不会,因此这里显式注入 locale 前缀。
29
+ * 所有 locale 的 spec 都注册在 `virtual:clarify-page/<locale>/...` 下,
30
+ * 因此绝对路径(如 `/api`)需要显式注入 locale 前缀才能命中。
31
+ * 相对路径会因为当前路由已含 locale 前缀而自动解析到正确的 spec。
33
32
  */
34
- function localizeSpecModuleId(moduleId, specPath, locale, defaultLocale) {
35
- if (!locale || locale === defaultLocale) return void 0;
33
+ function localizeSpecModuleId(moduleId, specPath, locale, _defaultLocale) {
34
+ if (!locale) return void 0;
36
35
  if (!specPath.startsWith("/") || specPath.startsWith(VIRTUAL_PREFIX)) return void 0;
37
36
  const rest = moduleId.slice(21);
38
37
  if (rest.startsWith(`${locale}/`) || rest === locale) return void 0;
39
38
  return `${VIRTUAL_PREFIX}${locale}/${rest}`;
40
39
  }
41
40
  function useOpenApiSpec(spec, specPath) {
42
- const specs = require_PageActions.useOpenApis();
43
- const location = (0, react_router_dom.useLocation)();
44
41
  const config = require_PageActions.useConfig();
45
42
  const locale = require_PageActions.useLocale();
43
+ const specs = require_PageActions.useOpenApis();
44
+ const location = (0, react_router_dom.useLocation)();
46
45
  if (spec) return spec;
47
46
  if (!specPath) return null;
48
47
  const normalized = normalizeSpecPath(specPath, location.pathname, config.routePrefix);
@@ -203,7 +202,8 @@ function OpenApiOperation(arg0) {
203
202
  var builtInMDXComponents = {
204
203
  ...require_OpenApiOperation.primitives_exports,
205
204
  Markdown: require_OpenApiOperation.Markdown,
206
- Collapse: require_OpenApiOperation.Collapse
205
+ Collapse: require_OpenApiOperation.Collapse,
206
+ Mermaid: require_OpenApiOperation.Mermaid
207
207
  };
208
208
  var builtInOpenAPIComponents = {
209
209
  OpenApiDocument,
@@ -238,8 +238,8 @@ function DocShell(arg0) {
238
238
  });
239
239
  }
240
240
  //#endregion
241
- exports.AppShell = require_ThemeRoot.AppShell;
242
- exports.BuiltWithClarify = require_ThemeRoot.BuiltWithClarify;
241
+ exports.AppShell = require_ClarifyShell.AppShell;
242
+ exports.BuiltWithClarify = require_ClarifyShell.BuiltWithClarify;
243
243
  exports.Button = require_OpenApiOperation.Button;
244
244
  exports.Callout = require_OpenApiOperation.Callout;
245
245
  exports.Card = require_OpenApiOperation.Card;
@@ -247,7 +247,6 @@ exports.CardGroup = require_OpenApiOperation.CardGroup;
247
247
  exports.Code = require_OpenApiOperation.Code;
248
248
  exports.CodeGroup = require_OpenApiOperation.CodeGroup;
249
249
  exports.Collapse = require_OpenApiOperation.Collapse;
250
- exports.ConfigContext = require_PageActions.ConfigContext;
251
250
  exports.DocShell = DocShell;
252
251
  exports.Feedback = require_OpenApiOperation.Feedback;
253
252
  exports.GridPattern = require_OpenApiOperation.GridPattern;
@@ -255,30 +254,34 @@ exports.Heading = require_OpenApiOperation.Heading;
255
254
  exports.HeroPattern = require_OpenApiOperation.HeroPattern;
256
255
  exports.Logo = require_OpenApiOperation.Logo;
257
256
  exports.Markdown = require_OpenApiOperation.Markdown;
257
+ exports.Mermaid = require_OpenApiOperation.Mermaid;
258
258
  exports.OpenApiDocument = OpenApiDocument;
259
259
  exports.OpenApiOperation = OpenApiOperation;
260
260
  exports.OpenApisContext = require_PageActions.OpenApisContext;
261
- exports.PageBanner = require_ThemeRoot.PageBanner;
262
- exports.PageFooter = require_ThemeRoot.PageFooter;
261
+ exports.PageBanner = require_ClarifyShell.PageBanner;
262
+ exports.PageFooter = require_ClarifyShell.PageFooter;
263
263
  exports.Pre = require_OpenApiOperation.Pre;
264
264
  exports.Prose = require_OpenApiOperation.Prose;
265
+ exports.RuntimeSlot = require_ClarifyShell.RuntimeSlot;
266
+ exports.RuntimeSlotsProvider = require_ClarifyShell.RuntimeSlotsProvider;
265
267
  exports.SectionProvider = require_PageActions.SectionProvider;
268
+ exports.SlotProvider = require_ClarifyShell.SlotProvider;
266
269
  exports.Tag = require_OpenApiOperation.Tag;
267
- exports.ThemeEditor = require_ThemeRoot.ThemeEditor;
270
+ exports.ThemeEditor = require_ClarifyShell.ThemeEditor;
268
271
  exports.ThemeProvider = require_PageActions.ThemeProvider;
269
272
  exports.ThemeToggle = require_PageActions.ThemeToggle;
270
273
  exports.WebFrame = require_OpenApiOperation.WebFrame;
271
- exports.applyThemeVariables = require_ThemeRoot.applyThemeVariables;
274
+ exports.applyThemeVariables = require_ClarifyShell.applyThemeVariables;
272
275
  exports.markdownRemarkPlugins = require_remark.markdownRemarkPlugins;
273
276
  exports.remToPx = require_PageActions.remToPx;
274
277
  exports.render = require_render.render;
275
- exports.themeBootstrapScript = require_ThemeRoot.themeBootstrapScript;
276
- exports.themeEditorPresets = require_ThemeRoot.themeEditorPresets;
277
- exports.themePresets = require_ThemeRoot.themePresets;
278
- exports.useConfig = require_PageActions.useConfig;
278
+ exports.themeBootstrapScript = require_ClarifyShell.themeBootstrapScript;
279
+ exports.themeEditorPresets = require_ClarifyShell.themeEditorPresets;
280
+ exports.themePresets = require_ClarifyShell.themePresets;
279
281
  exports.useMDXComponents = useMDXComponents;
280
282
  exports.useOpenApis = require_PageActions.useOpenApis;
281
283
  exports.useSectionStore = require_PageActions.useSectionStore;
284
+ exports.useSlot = require_ClarifyShell.useSlot;
282
285
  exports.useTheme = require_PageActions.useTheme;
283
286
 
284
287
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../source/openapi/lib/spec-path.ts","../source/openapi/lib/utils.ts","../source/openapi/entry.tsx","../source/mdx/components.ts","../source/mdx/DocShell.tsx"],"sourcesContent":["import { useLocation } from 'react-router-dom'\n\nimport { useConfig, useLocale, useOpenApis } from '../../core/context'\n\nimport type { OpenAPISpec } from './utils'\n\nconst VIRTUAL_PREFIX = 'virtual:clarify-page/'\n\nfunction resolveRelativePath(fromDir: string, to: string): string {\n const parts = (fromDir + '/' + to).split('/').filter(Boolean)\n const stack: string[] = []\n for (const part of parts) {\n if (part === '..') {\n stack.pop()\n } else if (part !== '.') {\n stack.push(part)\n }\n }\n return stack.join('/')\n}\n\nfunction normalizeSpecPath(specPath: string, currentRoutePath?: string, routePrefix = ''): string {\n if (specPath.startsWith(VIRTUAL_PREFIX)) return specPath\n\n const normalizedRoutePrefix = routePrefix.replace(/^\\/+|\\/+$/g, '')\n const normalizedSpecPath = specPath.startsWith('/') && normalizedRoutePrefix && specPath.slice(1).startsWith(`${normalizedRoutePrefix}/`)\n ? '/' + specPath.slice(normalizedRoutePrefix.length + 2)\n : specPath\n\n if (normalizedSpecPath.startsWith('/')) {\n return VIRTUAL_PREFIX + normalizedSpecPath.replace(/^\\//, '')\n }\n const fromDir = currentRoutePath === '/' ? '' : currentRoutePath?.replace(/^\\//, '').replace(/\\/[^/]*$/, '') ?? ''\n const normalizedFromDir = normalizedRoutePrefix && fromDir.startsWith(`${normalizedRoutePrefix}/`)\n ? fromDir.slice(normalizedRoutePrefix.length + 1)\n : fromDir\n return VIRTUAL_PREFIX + resolveRelativePath(normalizedFromDir, normalizedSpecPath)\n}\n\n/**\n * 为绝对 specPath 生成带 locale 前缀的候选模块 ID。\n *\n * 局部嵌入(OpenApiOperation / OpenApiDocument)通常使用 `/api` 这样的绝对路径。\n * 默认 locale 的 spec 注册在 `virtual:clarify-page/api`,而其他 locale 的 spec\n * 注册在 `virtual:clarify-page/<locale>/api`。相对路径会因为当前路由已含 locale 前缀\n * 而自动解析到正确的 spec,但绝对路径不会,因此这里显式注入 locale 前缀。\n */\nfunction localizeSpecModuleId(moduleId: string, specPath: string, locale: string | undefined, defaultLocale: string | undefined): string | undefined {\n if (!locale || locale === defaultLocale) return undefined\n // 仅处理绝对路径;相对路径已经基于含 locale 前缀的当前路由解析。\n if (!specPath.startsWith('/') || specPath.startsWith(VIRTUAL_PREFIX)) return undefined\n const rest = moduleId.slice(VIRTUAL_PREFIX.length)\n if (rest.startsWith(`${locale}/`) || rest === locale) return undefined\n return `${VIRTUAL_PREFIX}${locale}/${rest}`\n}\n\nexport function useOpenApiSpec(spec?: OpenAPISpec, specPath?: string): OpenAPISpec | null {\n const specs = useOpenApis()\n const location = useLocation()\n const config = useConfig()\n const locale = useLocale()\n\n if (spec) return spec\n if (!specPath) return null\n\n const normalized = normalizeSpecPath(specPath, location.pathname, config.routePrefix)\n const localized = localizeSpecModuleId(normalized, specPath, locale, config.i18n?.defaultLocale)\n\n if (localized && specs[localized]) return specs[localized]\n return specs[normalized] ?? null\n}\n","import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types'\n\nimport type { OpenApiRecord } from '../types'\n\nexport type OpenAPISpec = OpenAPIV3.Document | OpenAPIV3_1.Document\nexport type OpenAPIOperation = OpenAPIV3.OperationObject | OpenAPIV3_1.OperationObject\n\nexport const OPENAPI_HTTP_METHODS = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'] as const\n\nexport type OpenAPIHttpMethod = typeof OPENAPI_HTTP_METHODS[number]\n\nexport function isOpenAPIHttpMethod(method: string): method is OpenAPIHttpMethod {\n return (OPENAPI_HTTP_METHODS as readonly string[]).includes(method.toLowerCase())\n}\n\nfunction isRecord(value: unknown): value is OpenApiRecord {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction resolveOpenApiRef(spec: OpenAPISpec, ref: string): unknown {\n if (!ref.startsWith('#/')) return undefined\n\n return ref\n .slice(2)\n .split('/')\n .map((part) => part.replace(/~1/g, '/').replace(/~0/g, '~'))\n .reduce<unknown>((current, part) => (isRecord(current) ? current[part] : undefined), spec)\n}\n\nfunction getPathItem(spec: OpenAPISpec, path: string): OpenApiRecord | undefined {\n const pathItem = spec.paths?.[path]\n const resolved = isRecord(pathItem) && typeof pathItem.$ref === 'string' ? resolveOpenApiRef(spec, pathItem.$ref) : pathItem\n return isRecord(resolved) ? resolved : undefined\n}\n\nexport function getOpenApiOperation(spec: OpenAPISpec, path: string, method: string): OpenAPIOperation | undefined {\n if (!isOpenAPIHttpMethod(method)) return undefined\n return getPathItem(spec, path)?.[method.toLowerCase() as OpenAPIHttpMethod] as OpenAPIOperation | undefined\n}\n\nexport function listOpenApiOperations(spec: OpenAPISpec): Array<{ path: string; method: OpenAPIHttpMethod; operation: OpenAPIOperation }> {\n const paths = spec.paths ?? {}\n const operations: Array<{ path: string; method: OpenAPIHttpMethod; operation: OpenAPIOperation }> = []\n\n for (const path of Object.keys(paths)) {\n const pathItem = getPathItem(spec, path)\n if (!pathItem) continue\n for (const method of OPENAPI_HTTP_METHODS) {\n const operation = pathItem[method]\n if (operation) operations.push({ path, method, operation: operation as OpenAPIOperation })\n }\n }\n\n return operations\n}\n","import type { ReactNode } from 'react'\n\nimport { PageTitleActions } from '../app/PageActions'\nimport { Prose } from '../components/Prose'\nimport { useBuiltInText } from '../core/i18n'\nimport { Markdown } from '../mdx/Markdown'\n\nimport { OpenApiOperation as OpenApiOperationComponent } from './components/OpenApiOperation'\nimport { useOpenApiSpec } from './lib/spec-path'\nimport { getOpenApiOperation, listOpenApiOperations } from './lib/utils'\nimport type { OpenAPISpec } from './lib/utils'\n\ntype OpenApiPathsProps = { spec: OpenAPISpec; tagFilter?: string[] }\n\ntype OpenApiHeaderProps = { spec: OpenAPISpec }\n\ntype WarningBoxProps = {\n children: ReactNode\n tone?: 'amber' | 'red'\n}\n\nexport type OpenApiDocumentProps = {\n spec?: OpenAPISpec\n specPath?: string\n tagFilter?: string[]\n}\n\ntype OpenApiOperationWithSpecProps = {\n spec: OpenAPISpec\n path: string\n method: string\n}\n\nexport type OpenApiOperationProps = {\n specPath: string\n path: string\n method: string\n}\n\nfunction OpenApiHeader(arg0: OpenApiHeaderProps): ReactNode {\n const { spec } = arg0\n\n const t = useBuiltInText()\n return (\n <header className=\"clarify-openapi-header mb-16 border-b border-(--clarify-theme-tokens-colors-border) pb-8\">\n <p className=\"mb-3 text-xs/6 font-medium tracking-widest text-(--clarify-ui-accent-text) uppercase\">\n {t('openapi.openApiReference')}\n </p>\n <div className=\"clarify-page-title-row flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between\">\n <h1 className=\"clarify-page-title min-w-0 flex-1\">{spec.info?.title ?? t('openapi.apiDocumentation')}</h1>\n <PageTitleActions />\n </div>\n {spec.info?.description ? <Markdown className=\"lead mt-4 *:first:mt-0 *:last:mb-0\">{spec.info.description}</Markdown> : null}\n {spec.info?.version ? <p className=\"mt-4 text-sm text-(--clarify-ui-text-faint)\">{t('openapi.version', { version: spec.info.version })}</p> : null}\n </header>\n )\n}\n\nfunction operationMatchesTags(operationTags: string[] | undefined, filterTags: string[] | undefined): boolean {\n if (!filterTags?.length) return true\n return operationTags?.some(tag => filterTags.includes(tag)) ?? false\n}\n\nfunction OpenApiPaths(arg0: OpenApiPathsProps): ReactNode {\n const { spec, tagFilter } = arg0\n\n const entries = listOpenApiOperations(spec)\n .filter(({ operation }) => operationMatchesTags(operation.tags, tagFilter))\n .map(({ path, method, operation }) => ({\n path,\n method: method.toUpperCase(),\n operation,\n }))\n\n return (\n <div className=\"clarify-api-endpoints divide-y divide-zinc-200/70 dark:divide-white/10\">\n {entries.map(({ path, method, operation }) => (\n <OpenApiOperationComponent key={`${method}-${path}`} spec={spec} path={path} method={method} operation={operation} />\n ))}\n </div>\n )\n}\n\nfunction WarningBox(arg0: WarningBoxProps): ReactNode {\n const { children, tone = 'amber' } = arg0\n\n const classes = tone === 'red'\n ? 'rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-200'\n : 'rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200'\n\n return <div className={`clarify-warning ${classes}`}>{children}</div>\n}\n\nexport function OpenApiDocument(arg0: OpenApiDocumentProps): ReactNode {\n const { spec, specPath, tagFilter } = arg0\n const t = useBuiltInText()\n const resolved = useOpenApiSpec(spec, specPath)\n\n if (!resolved) {\n return <WarningBox>{t('openapi.specNotFound', { specPath: specPath ?? t('openapi.specPathMissing') })}</WarningBox>\n }\n\n return (\n <article className=\"clarify-openapi-page flex h-full flex-col pt-16 pb-10\">\n <Prose className=\"flex-auto\">\n <OpenApiHeader spec={resolved} />\n <OpenApiPaths spec={resolved} tagFilter={tagFilter} />\n </Prose>\n </article>\n )\n}\n\nfunction OpenApiOperationWithSpec(arg0: OpenApiOperationWithSpecProps): ReactNode {\n const { spec, path, method } = arg0\n const t = useBuiltInText()\n const op = getOpenApiOperation(spec, path, method)\n\n if (!op) {\n return <WarningBox tone=\"red\">{t('openapi.endpointNotFound', { endpoint: `${method.toUpperCase()} ${path}` })}</WarningBox>\n }\n\n const normalizedMethod = method.toUpperCase()\n return <OpenApiOperationComponent key={`${normalizedMethod}-${path}`} spec={spec} path={path} method={normalizedMethod} operation={op} />\n}\n\nexport function OpenApiOperation(arg0: OpenApiOperationProps): ReactNode {\n const { specPath, path, method } = arg0\n const t = useBuiltInText()\n const spec = useOpenApiSpec(undefined, specPath)\n\n if (!spec) {\n return <WarningBox>{t('openapi.specNotFound', { specPath })}</WarningBox>\n }\n\n return <OpenApiOperationWithSpec spec={spec} path={path} method={method} />\n}\n","import { Collapse } from '../components/Collapse'\nimport { OpenApiDocument, OpenApiOperation } from '../openapi'\n\nimport { Markdown } from './Markdown'\nimport * as mdxPrimitives from './primitives'\n\nconst builtInMDXComponents = {\n ...mdxPrimitives,\n Markdown,\n Collapse,\n}\n\nconst builtInOpenAPIComponents = {\n OpenApiDocument,\n OpenApiOperation,\n}\n\nexport function useMDXComponents(components: Record<string, unknown> = {}) {\n return {\n ...components,\n ...builtInMDXComponents,\n ...builtInOpenAPIComponents,\n }\n}\n","import type { ReactNode } from 'react'\n\nimport { Prose } from '../components/Prose'\n\nexport type DocShellProps = {\n title: string\n subtitle?: string\n children: ReactNode\n}\n\nexport function DocShell(arg0: DocShellProps) {\n const { title, subtitle, children } = arg0\n\n return (\n <main className=\"clarify-doc-shell min-h-screen bg-(--clarify-theme-tokens-colors-background) px-6 py-10 text-(--clarify-theme-tokens-colors-foreground) md:px-10\">\n <div className=\"mx-auto max-w-6xl\">\n <header className=\"mb-10\">\n <h1 className=\"text-3xl font-bold tracking-tight md:text-5xl\">{title}</h1>\n {subtitle ? <p className=\"mt-3 max-w-2xl text-(--clarify-ui-text-soft)\">{subtitle}</p> : null}\n </header>\n <Prose>{children}</Prose>\n </div>\n </main>\n )\n}\n"],"mappings":";;;;;;;;;AAMA,IAAM,iBAAiB;AAEvB,SAAS,oBAAoB,SAAiB,IAAoB;CAChE,MAAM,SAAS,UAAU,MAAM,IAAI,MAAM,GAAG,EAAE,OAAO,OAAO;CAC5D,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,QAAQ,OACjB,IAAI,SAAS,MACX,MAAM,IAAI;MACL,IAAI,SAAS,KAClB,MAAM,KAAK,IAAI;CAGnB,OAAO,MAAM,KAAK,GAAG;AACvB;AAEA,SAAS,kBAAkB,UAAkB,kBAA2B,cAAc,IAAY;CAChG,IAAI,SAAS,WAAW,cAAc,GAAG,OAAO;CAEhD,MAAM,wBAAwB,YAAY,QAAQ,cAAc,EAAE;CAClE,MAAM,qBAAqB,SAAS,WAAW,GAAG,KAAK,yBAAyB,SAAS,MAAM,CAAC,EAAE,WAAW,GAAG,sBAAsB,EAAE,IACpI,MAAM,SAAS,MAAM,sBAAsB,SAAS,CAAC,IACr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AM,WAAW;CACnC,MAAM,IAAI,oBAAA,eAAe;CACzB,MAAM,OAAO,eAAe,KAAA,GAAW,QAAQ;CAE/C,IAAI,CAAC,MACH,OAAO,iBAAA,GAAA,kBAAA,KAAC,YAAD,EAAA,UAAa,EAAE,wBAAwB,EAAE,SAAS,CAAC,EAAc,CAAA;CAG1E,OAAO,iBAAA,GAAA,kBAAA,KAAC,0BAAD;EAAgC;EAAY;EAAc;CAAS,CAAA;AAC5E;;;ACjIA,IAAM,uBAAuB;CAC3B,GAAG,yBAAA;CACH,UAAA,yBAAA;CACA,UAAA,yBAAA;AACF;AAEA,IAAM,2BAA2B;CAC/B;CACA;AACF;AAEA,SAAgB,iBAAiB,aAAsC,CAAC,GAAG;CACzE,OAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;CACL;AACF;;;ACbA,SAAgB,SAAS,MAAqB;CAC5C,MAAM,EAAE,OAAO,UAAU,aAAa;CAEtC,OACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;EAAM,WAAU;YACd,iBAAA,GAAA,kBAAA,MAAC,OAAD;GAAK,WAAU;aAAf,CACE,iBAAA,GAAA,kBAAA,MAAC,UAAD;IAAQ,WAAU;cAAlB,CACE,iBAAA,GAAA,kBAAA,KAAC,MAAD;KAAI,WAAU;eAAiD;IAAU,CAAA,GACxE,WAAW,iBAAA,GAAA,kBAAA,KAAC,KAAD;KAAG,WAAU;eAAgD;IAAY,CAAA,IAAI,IACnF;OACR,iBAAA,GAAA,kBAAA,KAAC,yBAAA,OAAD,EAAQ,SAAgB,CAAA,CACrB;;CACD,CAAA;AAEV"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../source/openapi/lib/spec-path.ts","../source/openapi/lib/utils.ts","../source/openapi/entry.tsx","../source/mdx/components.ts","../source/mdx/DocShell.tsx"],"sourcesContent":["import { useLocation } from 'react-router-dom'\n\nimport { useConfig, useLocale, useOpenApis } from '../../core/context'\n\nimport type { OpenAPISpec } from './utils'\n\nconst VIRTUAL_PREFIX = 'virtual:clarify-page/'\n\nfunction resolveRelativePath(fromDir: string, to: string): string {\n const parts = (fromDir + '/' + to).split('/').filter(Boolean)\n const stack: string[] = []\n for (const part of parts) {\n if (part === '..') {\n stack.pop()\n } else if (part !== '.') {\n stack.push(part)\n }\n }\n return stack.join('/')\n}\n\nfunction normalizeSpecPath(specPath: string, currentRoutePath?: string, routePrefix = ''): string {\n if (specPath.startsWith(VIRTUAL_PREFIX)) return specPath\n\n const normalizedRoutePrefix = routePrefix.replace(/^\\/+|\\/+$/g, '')\n const normalizedSpecPath = specPath.startsWith('/') && normalizedRoutePrefix && specPath.slice(1).startsWith(`${normalizedRoutePrefix}/`)\n ? '/' + specPath.slice(normalizedRoutePrefix.length + 2)\n : specPath\n\n if (normalizedSpecPath.startsWith('/')) {\n return VIRTUAL_PREFIX + normalizedSpecPath.replace(/^\\//, '')\n }\n const fromDir = currentRoutePath === '/' ? '' : currentRoutePath?.replace(/^\\//, '').replace(/\\/[^/]*$/, '') ?? ''\n const normalizedFromDir = normalizedRoutePrefix && fromDir.startsWith(`${normalizedRoutePrefix}/`)\n ? fromDir.slice(normalizedRoutePrefix.length + 1)\n : fromDir\n return VIRTUAL_PREFIX + resolveRelativePath(normalizedFromDir, normalizedSpecPath)\n}\n\n/**\n * 为绝对 specPath 生成带 locale 前缀的候选模块 ID。\n *\n * 所有 locale 的 spec 都注册在 `virtual:clarify-page/<locale>/...` 下,\n * 因此绝对路径(如 `/api`)需要显式注入 locale 前缀才能命中。\n * 相对路径会因为当前路由已含 locale 前缀而自动解析到正确的 spec。\n */\nfunction localizeSpecModuleId(moduleId: string, specPath: string, locale: string | undefined, _defaultLocale: string | undefined): string | undefined {\n if (!locale) return undefined\n // 仅处理绝对路径;相对路径已经基于含 locale 前缀的当前路由解析。\n if (!specPath.startsWith('/') || specPath.startsWith(VIRTUAL_PREFIX)) return undefined\n const rest = moduleId.slice(VIRTUAL_PREFIX.length)\n if (rest.startsWith(`${locale}/`) || rest === locale) return undefined\n return `${VIRTUAL_PREFIX}${locale}/${rest}`\n}\n\nexport function useOpenApiSpec(spec?: OpenAPISpec, specPath?: string): OpenAPISpec | null {\n const config = useConfig()\n const locale = useLocale()\n const specs = useOpenApis()\n const location = useLocation()\n\n if (spec) return spec\n if (!specPath) return null\n\n const normalized = normalizeSpecPath(specPath, location.pathname, config.routePrefix)\n const localized = localizeSpecModuleId(normalized, specPath, locale, config.i18n?.defaultLocale)\n\n if (localized && specs[localized]) return specs[localized]\n return specs[normalized] ?? null\n}\n","import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types'\n\nimport type { OpenApiRecord } from '../types'\n\nexport type OpenAPISpec = OpenAPIV3.Document | OpenAPIV3_1.Document\nexport type OpenAPIOperation = OpenAPIV3.OperationObject | OpenAPIV3_1.OperationObject\n\nexport const OPENAPI_HTTP_METHODS = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'] as const\n\nexport type OpenAPIHttpMethod = typeof OPENAPI_HTTP_METHODS[number]\n\nexport function isOpenAPIHttpMethod(method: string): method is OpenAPIHttpMethod {\n return (OPENAPI_HTTP_METHODS as readonly string[]).includes(method.toLowerCase())\n}\n\nfunction isRecord(value: unknown): value is OpenApiRecord {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction resolveOpenApiRef(spec: OpenAPISpec, ref: string): unknown {\n if (!ref.startsWith('#/')) return undefined\n\n return ref\n .slice(2)\n .split('/')\n .map((part) => part.replace(/~1/g, '/').replace(/~0/g, '~'))\n .reduce<unknown>((current, part) => (isRecord(current) ? current[part] : undefined), spec)\n}\n\nfunction getPathItem(spec: OpenAPISpec, path: string): OpenApiRecord | undefined {\n const pathItem = spec.paths?.[path]\n const resolved = isRecord(pathItem) && typeof pathItem.$ref === 'string' ? resolveOpenApiRef(spec, pathItem.$ref) : pathItem\n return isRecord(resolved) ? resolved : undefined\n}\n\nexport function getOpenApiOperation(spec: OpenAPISpec, path: string, method: string): OpenAPIOperation | undefined {\n if (!isOpenAPIHttpMethod(method)) return undefined\n return getPathItem(spec, path)?.[method.toLowerCase() as OpenAPIHttpMethod] as OpenAPIOperation | undefined\n}\n\nexport function listOpenApiOperations(spec: OpenAPISpec): Array<{ path: string; method: OpenAPIHttpMethod; operation: OpenAPIOperation }> {\n const paths = spec.paths ?? {}\n const operations: Array<{ path: string; method: OpenAPIHttpMethod; operation: OpenAPIOperation }> = []\n\n for (const path of Object.keys(paths)) {\n const pathItem = getPathItem(spec, path)\n if (!pathItem) continue\n for (const method of OPENAPI_HTTP_METHODS) {\n const operation = pathItem[method]\n if (operation) operations.push({ path, method, operation: operation as OpenAPIOperation })\n }\n }\n\n return operations\n}\n","import type { ReactNode } from 'react'\n\nimport { PageTitleActions } from '../app/PageActions'\nimport { Prose } from '../components/Prose'\nimport { useBuiltInText } from '../core/i18n'\nimport { Markdown } from '../mdx/Markdown'\n\nimport { OpenApiOperation as OpenApiOperationComponent } from './components/OpenApiOperation'\nimport { useOpenApiSpec } from './lib/spec-path'\nimport { getOpenApiOperation, listOpenApiOperations } from './lib/utils'\nimport type { OpenAPISpec } from './lib/utils'\n\ntype OpenApiPathsProps = { spec: OpenAPISpec; tagFilter?: string[] }\n\ntype OpenApiHeaderProps = { spec: OpenAPISpec }\n\ntype WarningBoxProps = {\n children: ReactNode\n tone?: 'amber' | 'red'\n}\n\nexport type OpenApiDocumentProps = {\n spec?: OpenAPISpec\n specPath?: string\n tagFilter?: string[]\n}\n\ntype OpenApiOperationWithSpecProps = {\n spec: OpenAPISpec\n path: string\n method: string\n}\n\nexport type OpenApiOperationProps = {\n specPath: string\n path: string\n method: string\n}\n\nfunction OpenApiHeader(arg0: OpenApiHeaderProps): ReactNode {\n const { spec } = arg0\n\n const t = useBuiltInText()\n return (\n <header className=\"clarify-openapi-header mb-16 border-b border-(--clarify-theme-tokens-colors-border) pb-8\">\n <p className=\"mb-3 text-xs/6 font-medium tracking-widest text-(--clarify-ui-accent-text) uppercase\">\n {t('openapi.openApiReference')}\n </p>\n <div className=\"clarify-page-title-row flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between\">\n <h1 className=\"clarify-page-title min-w-0 flex-1\">{spec.info?.title ?? t('openapi.apiDocumentation')}</h1>\n <PageTitleActions />\n </div>\n {spec.info?.description ? <Markdown className=\"lead mt-4 *:first:mt-0 *:last:mb-0\">{spec.info.description}</Markdown> : null}\n {spec.info?.version ? <p className=\"mt-4 text-sm text-(--clarify-ui-text-faint)\">{t('openapi.version', { version: spec.info.version })}</p> : null}\n </header>\n )\n}\n\nfunction operationMatchesTags(operationTags: string[] | undefined, filterTags: string[] | undefined): boolean {\n if (!filterTags?.length) return true\n return operationTags?.some(tag => filterTags.includes(tag)) ?? false\n}\n\nfunction OpenApiPaths(arg0: OpenApiPathsProps): ReactNode {\n const { spec, tagFilter } = arg0\n\n const entries = listOpenApiOperations(spec)\n .filter(({ operation }) => operationMatchesTags(operation.tags, tagFilter))\n .map(({ path, method, operation }) => ({\n path,\n method: method.toUpperCase(),\n operation,\n }))\n\n return (\n <div className=\"clarify-api-endpoints divide-y divide-zinc-200/70 dark:divide-white/10\">\n {entries.map(({ path, method, operation }) => (\n <OpenApiOperationComponent key={`${method}-${path}`} spec={spec} path={path} method={method} operation={operation} />\n ))}\n </div>\n )\n}\n\nfunction WarningBox(arg0: WarningBoxProps): ReactNode {\n const { children, tone = 'amber' } = arg0\n\n const classes = tone === 'red'\n ? 'rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-200'\n : 'rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200'\n\n return <div className={`clarify-warning ${classes}`}>{children}</div>\n}\n\nexport function OpenApiDocument(arg0: OpenApiDocumentProps): ReactNode {\n const { spec, specPath, tagFilter } = arg0\n const t = useBuiltInText()\n const resolved = useOpenApiSpec(spec, specPath)\n\n if (!resolved) {\n return <WarningBox>{t('openapi.specNotFound', { specPath: specPath ?? t('openapi.specPathMissing') })}</WarningBox>\n }\n\n return (\n <article className=\"clarify-openapi-page flex h-full flex-col pt-16 pb-10\">\n <Prose className=\"flex-auto\">\n <OpenApiHeader spec={resolved} />\n <OpenApiPaths spec={resolved} tagFilter={tagFilter} />\n </Prose>\n </article>\n )\n}\n\nfunction OpenApiOperationWithSpec(arg0: OpenApiOperationWithSpecProps): ReactNode {\n const { spec, path, method } = arg0\n const t = useBuiltInText()\n const op = getOpenApiOperation(spec, path, method)\n\n if (!op) {\n return <WarningBox tone=\"red\">{t('openapi.endpointNotFound', { endpoint: `${method.toUpperCase()} ${path}` })}</WarningBox>\n }\n\n const normalizedMethod = method.toUpperCase()\n return <OpenApiOperationComponent key={`${normalizedMethod}-${path}`} spec={spec} path={path} method={normalizedMethod} operation={op} />\n}\n\nexport function OpenApiOperation(arg0: OpenApiOperationProps): ReactNode {\n const { specPath, path, method } = arg0\n const t = useBuiltInText()\n const spec = useOpenApiSpec(undefined, specPath)\n\n if (!spec) {\n return <WarningBox>{t('openapi.specNotFound', { specPath })}</WarningBox>\n }\n\n return <OpenApiOperationWithSpec spec={spec} path={path} method={method} />\n}\n","import { Collapse } from '../components/Collapse'\nimport { Mermaid } from '../components/Mermaid'\nimport { OpenApiDocument, OpenApiOperation } from '../openapi'\n\nimport { Markdown } from './Markdown'\nimport * as mdxPrimitives from './primitives'\n\nconst builtInMDXComponents = {\n ...mdxPrimitives,\n Markdown,\n Collapse,\n Mermaid,\n}\n\nconst builtInOpenAPIComponents = {\n OpenApiDocument,\n OpenApiOperation,\n}\n\nexport function useMDXComponents(components: Record<string, unknown> = {}) {\n return {\n ...components,\n ...builtInMDXComponents,\n ...builtInOpenAPIComponents,\n }\n}\n","import type { ReactNode } from 'react'\n\nimport { Prose } from '../components/Prose'\n\nexport type DocShellProps = {\n title: string\n subtitle?: string\n children: ReactNode\n}\n\nexport function DocShell(arg0: DocShellProps) {\n const { title, subtitle, children } = arg0\n\n return (\n <main className=\"clarify-doc-shell min-h-screen bg-(--clarify-theme-tokens-colors-background) px-6 py-10 text-(--clarify-theme-tokens-colors-foreground) md:px-10\">\n <div className=\"mx-auto max-w-6xl\">\n <header className=\"mb-10\">\n <h1 className=\"text-3xl font-bold tracking-tight md:text-5xl\">{title}</h1>\n {subtitle ? <p className=\"mt-3 max-w-2xl text-(--clarify-ui-text-soft)\">{subtitle}</p> : null}\n </header>\n <Prose>{children}</Prose>\n </div>\n </main>\n )\n}\n"],"mappings":";;;;;;;;;AAMA,IAAM,iBAAiB;AAEvB,SAAS,oBAAoB,SAAiB,IAAoB;CAChE,MAAM,SAAS,UAAU,MAAM,IAAI,MAAM,GAAG,EAAE,OAAO,OAAO;CAC5D,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,QAAQ,OACjB,IAAI,SAAS,MACX,MAAM,IAAI;MACL,IAAI,SAAS,KAClB,MAAM,KAAK,IAAI;CAGnB,OAAO,MAAM,KAAK,GAAG;AACvB;AAEA,SAAS,kBAAkB,UAAkB,kBAA2B,cAAc,IAAY;CAChG,IAAI,SAAS,WAAW,cAAc,GAAG,OAAO;CAEhD,MAAM,wBAAwB,YAAY,QAAQ,cAAc,EAAE;CAClE,MAAM,qBAAqB,SAAS,WAAW,GAAG,KAAK,yBAAyB,SAAS,MAAM,CAAC,EAAE,WAAW,GAAG,sBAAsB,EAAE,IACpI,MAAM,SAAS,MAAM,sBAAsB,SAAS,CAAC,IACrD;CAEJ,IAAI,mBAAmB,WAAW,GAAG,GACnC,OAAO,iBAAiB,mBAAmB,QAAQ,OAAO,EAAE;CAE9D,MAAM,UAAU,qBAAqB,MAAM,KAAK,kBAAkB,QAAQ,OAAO,EAAE,EAAE,QAAQ,YAAY,EAAE,KAAK;CAIhH,OAAO,iBAAiB,oBAHE,yBAAyB,QAAQ,WAAW,GAAG,sBAAsB,EAAE,IAC7F,QAAQ,MAAM,sBAAsB,SAAS,CAAC,IAC9C,SAC2D,kBAAkB;AACnF;;;;;;;;AASA,SA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A,UAAA,yBAAA;CACA,SAAA,yBAAA;AACF;AAEA,IAAM,2BAA2B;CAC/B;CACA;AACF;AAEA,SAAgB,iBAAiB,aAAsC,CAAC,GAAG;CACzE,OAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;CACL;AACF;;;ACfA,SAAgB,SAAS,MAAqB;CAC5C,MAAM,EAAE,OAAO,UAAU,aAAa;CAEtC,OACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;EAAM,WAAU;YACd,iBAAA,GAAA,kBAAA,MAAC,OAAD;GAAK,WAAU;aAAf,CACE,iBAAA,GAAA,kBAAA,MAAC,UAAD;IAAQ,WAAU;cAAlB,CACE,iBAAA,GAAA,kBAAA,KAAC,MAAD;KAAI,WAAU;eAAiD;IAAU,CAAA,GACxE,WAAW,iBAAA,GAAA,kBAAA,KAAC,KAAD;KAAG,WAAU;eAAgD;IAAY,CAAA,IAAI,IACnF;OACR,iBAAA,GAAA,kBAAA,KAAC,yBAAA,OAAD,EAAQ,SAAgB,CAAA,CACrB;;CACD,CAAA;AAEV"}
package/output/index.d.ts CHANGED
@@ -3,14 +3,15 @@ import { BuiltWithClarify } from './app/BuiltWithClarify';
3
3
  import { PageBanner } from './app/PageBanner';
4
4
  import { PageFooter } from './app/PageFooter';
5
5
  import { SectionProvider, useSectionStore, Section } from './app/SectionProvider';
6
- import { Button, Callout, Card, CardGroup, Code, CodeGroup, Collapse, Feedback, GridPattern, Heading, HeroPattern, Logo, Pre, Prose, Tag, WebFrame } from './components';
7
- import { ConfigContext, OpenApisContext, useConfig, useOpenApis } from './context';
6
+ import { Button, Callout, Card, CardGroup, Code, CodeGroup, Collapse, Feedback, GridPattern, Heading, HeroPattern, Logo, Mermaid, Pre, Prose, Tag, WebFrame } from './components';
7
+ import { OpenApisContext, useOpenApis } from './context';
8
8
  import { useMDXComponents } from './mdx/components';
9
9
  import { DocShell } from './mdx/DocShell';
10
10
  import { Markdown } from './mdx/Markdown';
11
11
  import { markdownRemarkPlugins } from './mdx/remark';
12
12
  import { OpenApiDocument, OpenApiOperation } from './openapi';
13
13
  import { render } from './runtime/render';
14
+ import { SlotProvider, RuntimeSlot, RuntimeSlotsProvider, useSlot } from './slots';
14
15
  import { applyThemeVariables, themeEditorPresets, ThemeEditor } from './theme/ThemeEditor';
15
16
  import { ThemeProvider, useTheme } from './theme/ThemeProvider';
16
17
  import { ThemeToggle } from './theme/ThemeToggle';
@@ -20,7 +21,9 @@ import { remToPx } from './utils/remToPx';
20
21
  export type { OpenApiOperationProps, OpenApiDocumentProps, OpenAPIOperation, OpenAPISpec } from './openapi';
21
22
  export type { ThemeEditorProps } from './theme/ThemeEditor';
22
23
  export type { Config, RouteItem, RenderOptions, ServerRenderOptions, Section };
23
- export { AppShell, render, ConfigContext, OpenApisContext, useConfig, useOpenApis, BuiltWithClarify, PageBanner, PageFooter, ThemeProvider, ThemeToggle, ThemeEditor, useTheme, SectionProvider, useSectionStore, remToPx, applyThemeVariables, themeEditorPresets, themePresets, themeBootstrapScript };
24
- export { Button, Callout, Card, CardGroup, Code, CodeGroup, Collapse, Pre, Prose, Heading, Logo, GridPattern, HeroPattern, Feedback, Tag, WebFrame };
24
+ export type { RuntimeSlotEntry, RuntimeSlots, UISlotRegistration, UISlotName, SlotContext } from './slots';
25
+ export { AppShell, render, OpenApisContext, useOpenApis, BuiltWithClarify, PageBanner, PageFooter, ThemeProvider, ThemeToggle, ThemeEditor, useTheme, SectionProvider, useSectionStore, remToPx, applyThemeVariables, themeEditorPresets, themePresets, themeBootstrapScript };
26
+ export { Button, Callout, Card, CardGroup, Code, CodeGroup, Collapse, Pre, Prose, Heading, Logo, Mermaid, GridPattern, HeroPattern, Feedback, Tag, WebFrame };
25
27
  export { DocShell, Markdown, useMDXComponents, markdownRemarkPlugins };
28
+ export { SlotProvider, RuntimeSlot, RuntimeSlotsProvider, useSlot };
26
29
  export { OpenApiDocument, OpenApiOperation };
package/output/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { C as Code, D as CardGroup, E as Card, O as Callout, S as Collapse, T as Pre, _ as HeroPattern, b as Tag, f as Markdown, g as GridPattern, h as Prose, k as Button, m as WebFrame, n as OpenApiOperation$1, p as primitives_exports, v as Logo, w as CodeGroup, x as Feedback, y as Heading } from "./OpenApiOperation-tUKf7lZ4.js";
2
- import { A as OpenApisContext, D as useBuiltInText, M as useLocale, N as useOpenApis, O as ConfigContext, c as remToPx, h as useTheme, j as useConfig, m as ThemeProvider, n as PageTitleActions, o as SectionProvider, p as ThemeToggle, s as useSectionStore } from "./PageActions-yoDRjkq8.js";
3
- import { a as themeBootstrapScript, c as AppShell, d as PageBanner, i as themeEditorPresets, l as PageFooter, n as ThemeEditor, o as themePresets, r as applyThemeVariables, u as BuiltWithClarify } from "./ThemeRoot-QULrwQf6.js";
1
+ import { A as Button, C as Code, D as Card, E as Mermaid, O as CardGroup, S as Collapse, T as Pre, _ as HeroPattern, b as Tag, f as Markdown, g as GridPattern, h as Prose, k as Callout, m as WebFrame, n as OpenApiOperation$1, p as primitives_exports, v as Logo, w as CodeGroup, x as Feedback, y as Heading } from "./OpenApiOperation-fJ3QQOJX.js";
2
+ import { M as useConfig, N as useLocale, O as useBuiltInText, P as useOpenApis, c as remToPx, g as useTheme, h as ThemeProvider, j as OpenApisContext, m as ThemeToggle, n as PageTitleActions, o as SectionProvider, s as useSectionStore } from "./PageActions-BwY7ierv.js";
3
+ import { a as themeBootstrapScript, c as AppShell, d as BuiltWithClarify, f as RuntimeSlot, h as useSlot, i as themeEditorPresets, l as PageFooter, m as SlotProvider, n as ThemeEditor, o as themePresets, p as RuntimeSlotsProvider, r as applyThemeVariables, u as PageBanner } from "./ClarifyShell-BPv2bxI4.js";
4
4
  import { t as markdownRemarkPlugins } from "./remark-Dd2WU50s.js";
5
- import { t as render } from "./render-psutGbsg.js";
5
+ import { t as render } from "./render-Cghgq1AQ.js";
6
6
  import { useLocation } from "react-router-dom";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  //#region source/openapi/lib/spec-path.ts
@@ -25,23 +25,22 @@ function normalizeSpecPath(specPath, currentRoutePath, routePrefix = "") {
25
25
  /**
26
26
  * 为绝对 specPath 生成带 locale 前缀的候选模块 ID。
27
27
  *
28
- * 局部嵌入(OpenApiOperation / OpenApiDocument)通常使用 `/api` 这样的绝对路径。
29
- * 默认 locale 的 spec 注册在 `virtual:clarify-page/api`,而其他 locale 的 spec
30
- * 注册在 `virtual:clarify-page/<locale>/api`。相对路径会因为当前路由已含 locale 前缀
31
- * 而自动解析到正确的 spec,但绝对路径不会,因此这里显式注入 locale 前缀。
28
+ * 所有 locale 的 spec 都注册在 `virtual:clarify-page/<locale>/...` 下,
29
+ * 因此绝对路径(如 `/api`)需要显式注入 locale 前缀才能命中。
30
+ * 相对路径会因为当前路由已含 locale 前缀而自动解析到正确的 spec。
32
31
  */
33
- function localizeSpecModuleId(moduleId, specPath, locale, defaultLocale) {
34
- if (!locale || locale === defaultLocale) return void 0;
32
+ function localizeSpecModuleId(moduleId, specPath, locale, _defaultLocale) {
33
+ if (!locale) return void 0;
35
34
  if (!specPath.startsWith("/") || specPath.startsWith(VIRTUAL_PREFIX)) return void 0;
36
35
  const rest = moduleId.slice(21);
37
36
  if (rest.startsWith(`${locale}/`) || rest === locale) return void 0;
38
37
  return `${VIRTUAL_PREFIX}${locale}/${rest}`;
39
38
  }
40
39
  function useOpenApiSpec(spec, specPath) {
41
- const specs = useOpenApis();
42
- const location = useLocation();
43
40
  const config = useConfig();
44
41
  const locale = useLocale();
42
+ const specs = useOpenApis();
43
+ const location = useLocation();
45
44
  if (spec) return spec;
46
45
  if (!specPath) return null;
47
46
  const normalized = normalizeSpecPath(specPath, location.pathname, config.routePrefix);
@@ -202,7 +201,8 @@ function OpenApiOperation(arg0) {
202
201
  var builtInMDXComponents = {
203
202
  ...primitives_exports,
204
203
  Markdown,
205
- Collapse
204
+ Collapse,
205
+ Mermaid
206
206
  };
207
207
  var builtInOpenAPIComponents = {
208
208
  OpenApiDocument,
@@ -237,6 +237,6 @@ function DocShell(arg0) {
237
237
  });
238
238
  }
239
239
  //#endregion
240
- export { AppShell, BuiltWithClarify, Button, Callout, Card, CardGroup, Code, CodeGroup, Collapse, ConfigContext, DocShell, Feedback, GridPattern, Heading, HeroPattern, Logo, Markdown, OpenApiDocument, OpenApiOperation, OpenApisContext, PageBanner, PageFooter, Pre, Prose, SectionProvider, Tag, ThemeEditor, ThemeProvider, ThemeToggle, WebFrame, applyThemeVariables, markdownRemarkPlugins, remToPx, render, themeBootstrapScript, themeEditorPresets, themePresets, useConfig, useMDXComponents, useOpenApis, useSectionStore, useTheme };
240
+ export { AppShell, BuiltWithClarify, Button, Callout, Card, CardGroup, Code, CodeGroup, Collapse, DocShell, Feedback, GridPattern, Heading, HeroPattern, Logo, Markdown, Mermaid, OpenApiDocument, OpenApiOperation, OpenApisContext, PageBanner, PageFooter, Pre, Prose, RuntimeSlot, RuntimeSlotsProvider, SectionProvider, SlotProvider, Tag, ThemeEditor, ThemeProvider, ThemeToggle, WebFrame, applyThemeVariables, markdownRemarkPlugins, remToPx, render, themeBootstrapScript, themeEditorPresets, themePresets, useMDXComponents, useOpenApis, useSectionStore, useSlot, useTheme };
241
241
 
242
242
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../source/openapi/lib/spec-path.ts","../source/openapi/lib/utils.ts","../source/openapi/entry.tsx","../source/mdx/components.ts","../source/mdx/DocShell.tsx"],"sourcesContent":["import { useLocation } from 'react-router-dom'\n\nimport { useConfig, useLocale, useOpenApis } from '../../core/context'\n\nimport type { OpenAPISpec } from './utils'\n\nconst VIRTUAL_PREFIX = 'virtual:clarify-page/'\n\nfunction resolveRelativePath(fromDir: string, to: string): string {\n const parts = (fromDir + '/' + to).split('/').filter(Boolean)\n const stack: string[] = []\n for (const part of parts) {\n if (part === '..') {\n stack.pop()\n } else if (part !== '.') {\n stack.push(part)\n }\n }\n return stack.join('/')\n}\n\nfunction normalizeSpecPath(specPath: string, currentRoutePath?: string, routePrefix = ''): string {\n if (specPath.startsWith(VIRTUAL_PREFIX)) return specPath\n\n const normalizedRoutePrefix = routePrefix.replace(/^\\/+|\\/+$/g, '')\n const normalizedSpecPath = specPath.startsWith('/') && normalizedRoutePrefix && specPath.slice(1).startsWith(`${normalizedRoutePrefix}/`)\n ? '/' + specPath.slice(normalizedRoutePrefix.length + 2)\n : specPath\n\n if (normalizedSpecPath.startsWith('/')) {\n return VIRTUAL_PREFIX + normalizedSpecPath.replace(/^\\//, '')\n }\n const fromDir = currentRoutePath === '/' ? '' : currentRoutePath?.replace(/^\\//, '').replace(/\\/[^/]*$/, '') ?? ''\n const normalizedFromDir = normalizedRoutePrefix && fromDir.startsWith(`${normalizedRoutePrefix}/`)\n ? fromDir.slice(normalizedRoutePrefix.length + 1)\n : fromDir\n return VIRTUAL_PREFIX + resolveRelativePath(normalizedFromDir, normalizedSpecPath)\n}\n\n/**\n * 为绝对 specPath 生成带 locale 前缀的候选模块 ID。\n *\n * 局部嵌入(OpenApiOperation / OpenApiDocument)通常使用 `/api` 这样的绝对路径。\n * 默认 locale 的 spec 注册在 `virtual:clarify-page/api`,而其他 locale 的 spec\n * 注册在 `virtual:clarify-page/<locale>/api`。相对路径会因为当前路由已含 locale 前缀\n * 而自动解析到正确的 spec,但绝对路径不会,因此这里显式注入 locale 前缀。\n */\nfunction localizeSpecModuleId(moduleId: string, specPath: string, locale: string | undefined, defaultLocale: string | undefined): string | undefined {\n if (!locale || locale === defaultLocale) return undefined\n // 仅处理绝对路径;相对路径已经基于含 locale 前缀的当前路由解析。\n if (!specPath.startsWith('/') || specPath.startsWith(VIRTUAL_PREFIX)) return undefined\n const rest = moduleId.slice(VIRTUAL_PREFIX.length)\n if (rest.startsWith(`${locale}/`) || rest === locale) return undefined\n return `${VIRTUAL_PREFIX}${locale}/${rest}`\n}\n\nexport function useOpenApiSpec(spec?: OpenAPISpec, specPath?: string): OpenAPISpec | null {\n const specs = useOpenApis()\n const location = useLocation()\n const config = useConfig()\n const locale = useLocale()\n\n if (spec) return spec\n if (!specPath) return null\n\n const normalized = normalizeSpecPath(specPath, location.pathname, config.routePrefix)\n const localized = localizeSpecModuleId(normalized, specPath, locale, config.i18n?.defaultLocale)\n\n if (localized && specs[localized]) return specs[localized]\n return specs[normalized] ?? null\n}\n","import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types'\n\nimport type { OpenApiRecord } from '../types'\n\nexport type OpenAPISpec = OpenAPIV3.Document | OpenAPIV3_1.Document\nexport type OpenAPIOperation = OpenAPIV3.OperationObject | OpenAPIV3_1.OperationObject\n\nexport const OPENAPI_HTTP_METHODS = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'] as const\n\nexport type OpenAPIHttpMethod = typeof OPENAPI_HTTP_METHODS[number]\n\nexport function isOpenAPIHttpMethod(method: string): method is OpenAPIHttpMethod {\n return (OPENAPI_HTTP_METHODS as readonly string[]).includes(method.toLowerCase())\n}\n\nfunction isRecord(value: unknown): value is OpenApiRecord {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction resolveOpenApiRef(spec: OpenAPISpec, ref: string): unknown {\n if (!ref.startsWith('#/')) return undefined\n\n return ref\n .slice(2)\n .split('/')\n .map((part) => part.replace(/~1/g, '/').replace(/~0/g, '~'))\n .reduce<unknown>((current, part) => (isRecord(current) ? current[part] : undefined), spec)\n}\n\nfunction getPathItem(spec: OpenAPISpec, path: string): OpenApiRecord | undefined {\n const pathItem = spec.paths?.[path]\n const resolved = isRecord(pathItem) && typeof pathItem.$ref === 'string' ? resolveOpenApiRef(spec, pathItem.$ref) : pathItem\n return isRecord(resolved) ? resolved : undefined\n}\n\nexport function getOpenApiOperation(spec: OpenAPISpec, path: string, method: string): OpenAPIOperation | undefined {\n if (!isOpenAPIHttpMethod(method)) return undefined\n return getPathItem(spec, path)?.[method.toLowerCase() as OpenAPIHttpMethod] as OpenAPIOperation | undefined\n}\n\nexport function listOpenApiOperations(spec: OpenAPISpec): Array<{ path: string; method: OpenAPIHttpMethod; operation: OpenAPIOperation }> {\n const paths = spec.paths ?? {}\n const operations: Array<{ path: string; method: OpenAPIHttpMethod; operation: OpenAPIOperation }> = []\n\n for (const path of Object.keys(paths)) {\n const pathItem = getPathItem(spec, path)\n if (!pathItem) continue\n for (const method of OPENAPI_HTTP_METHODS) {\n const operation = pathItem[method]\n if (operation) operations.push({ path, method, operation: operation as OpenAPIOperation })\n }\n }\n\n return operations\n}\n","import type { ReactNode } from 'react'\n\nimport { PageTitleActions } from '../app/PageActions'\nimport { Prose } from '../components/Prose'\nimport { useBuiltInText } from '../core/i18n'\nimport { Markdown } from '../mdx/Markdown'\n\nimport { OpenApiOperation as OpenApiOperationComponent } from './components/OpenApiOperation'\nimport { useOpenApiSpec } from './lib/spec-path'\nimport { getOpenApiOperation, listOpenApiOperations } from './lib/utils'\nimport type { OpenAPISpec } from './lib/utils'\n\ntype OpenApiPathsProps = { spec: OpenAPISpec; tagFilter?: string[] }\n\ntype OpenApiHeaderProps = { spec: OpenAPISpec }\n\ntype WarningBoxProps = {\n children: ReactNode\n tone?: 'amber' | 'red'\n}\n\nexport type OpenApiDocumentProps = {\n spec?: OpenAPISpec\n specPath?: string\n tagFilter?: string[]\n}\n\ntype OpenApiOperationWithSpecProps = {\n spec: OpenAPISpec\n path: string\n method: string\n}\n\nexport type OpenApiOperationProps = {\n specPath: string\n path: string\n method: string\n}\n\nfunction OpenApiHeader(arg0: OpenApiHeaderProps): ReactNode {\n const { spec } = arg0\n\n const t = useBuiltInText()\n return (\n <header className=\"clarify-openapi-header mb-16 border-b border-(--clarify-theme-tokens-colors-border) pb-8\">\n <p className=\"mb-3 text-xs/6 font-medium tracking-widest text-(--clarify-ui-accent-text) uppercase\">\n {t('openapi.openApiReference')}\n </p>\n <div className=\"clarify-page-title-row flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between\">\n <h1 className=\"clarify-page-title min-w-0 flex-1\">{spec.info?.title ?? t('openapi.apiDocumentation')}</h1>\n <PageTitleActions />\n </div>\n {spec.info?.description ? <Markdown className=\"lead mt-4 *:first:mt-0 *:last:mb-0\">{spec.info.description}</Markdown> : null}\n {spec.info?.version ? <p className=\"mt-4 text-sm text-(--clarify-ui-text-faint)\">{t('openapi.version', { version: spec.info.version })}</p> : null}\n </header>\n )\n}\n\nfunction operationMatchesTags(operationTags: string[] | undefined, filterTags: string[] | undefined): boolean {\n if (!filterTags?.length) return true\n return operationTags?.some(tag => filterTags.includes(tag)) ?? false\n}\n\nfunction OpenApiPaths(arg0: OpenApiPathsProps): ReactNode {\n const { spec, tagFilter } = arg0\n\n const entries = listOpenApiOperations(spec)\n .filter(({ operation }) => operationMatchesTags(operation.tags, tagFilter))\n .map(({ path, method, operation }) => ({\n path,\n method: method.toUpperCase(),\n operation,\n }))\n\n return (\n <div className=\"clarify-api-endpoints divide-y divide-zinc-200/70 dark:divide-white/10\">\n {entries.map(({ path, method, operation }) => (\n <OpenApiOperationComponent key={`${method}-${path}`} spec={spec} path={path} method={method} operation={operation} />\n ))}\n </div>\n )\n}\n\nfunction WarningBox(arg0: WarningBoxProps): ReactNode {\n const { children, tone = 'amber' } = arg0\n\n const classes = tone === 'red'\n ? 'rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-200'\n : 'rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200'\n\n return <div className={`clarify-warning ${classes}`}>{children}</div>\n}\n\nexport function OpenApiDocument(arg0: OpenApiDocumentProps): ReactNode {\n const { spec, specPath, tagFilter } = arg0\n const t = useBuiltInText()\n const resolved = useOpenApiSpec(spec, specPath)\n\n if (!resolved) {\n return <WarningBox>{t('openapi.specNotFound', { specPath: specPath ?? t('openapi.specPathMissing') })}</WarningBox>\n }\n\n return (\n <article className=\"clarify-openapi-page flex h-full flex-col pt-16 pb-10\">\n <Prose className=\"flex-auto\">\n <OpenApiHeader spec={resolved} />\n <OpenApiPaths spec={resolved} tagFilter={tagFilter} />\n </Prose>\n </article>\n )\n}\n\nfunction OpenApiOperationWithSpec(arg0: OpenApiOperationWithSpecProps): ReactNode {\n const { spec, path, method } = arg0\n const t = useBuiltInText()\n const op = getOpenApiOperation(spec, path, method)\n\n if (!op) {\n return <WarningBox tone=\"red\">{t('openapi.endpointNotFound', { endpoint: `${method.toUpperCase()} ${path}` })}</WarningBox>\n }\n\n const normalizedMethod = method.toUpperCase()\n return <OpenApiOperationComponent key={`${normalizedMethod}-${path}`} spec={spec} path={path} method={normalizedMethod} operation={op} />\n}\n\nexport function OpenApiOperation(arg0: OpenApiOperationProps): ReactNode {\n const { specPath, path, method } = arg0\n const t = useBuiltInText()\n const spec = useOpenApiSpec(undefined, specPath)\n\n if (!spec) {\n return <WarningBox>{t('openapi.specNotFound', { specPath })}</WarningBox>\n }\n\n return <OpenApiOperationWithSpec spec={spec} path={path} method={method} />\n}\n","import { Collapse } from '../components/Collapse'\nimport { OpenApiDocument, OpenApiOperation } from '../openapi'\n\nimport { Markdown } from './Markdown'\nimport * as mdxPrimitives from './primitives'\n\nconst builtInMDXComponents = {\n ...mdxPrimitives,\n Markdown,\n Collapse,\n}\n\nconst builtInOpenAPIComponents = {\n OpenApiDocument,\n OpenApiOperation,\n}\n\nexport function useMDXComponents(components: Record<string, unknown> = {}) {\n return {\n ...components,\n ...builtInMDXComponents,\n ...builtInOpenAPIComponents,\n }\n}\n","import type { ReactNode } from 'react'\n\nimport { Prose } from '../components/Prose'\n\nexport type DocShellProps = {\n title: string\n subtitle?: string\n children: ReactNode\n}\n\nexport function DocShell(arg0: DocShellProps) {\n const { title, subtitle, children } = arg0\n\n return (\n <main className=\"clarify-doc-shell min-h-screen bg-(--clarify-theme-tokens-colors-background) px-6 py-10 text-(--clarify-theme-tokens-colors-foreground) md:px-10\">\n <div className=\"mx-auto max-w-6xl\">\n <header className=\"mb-10\">\n <h1 className=\"text-3xl font-bold tracking-tight md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D;EAAY,MAAK;YAAO,EAAE,4BAA4B,EAAE,UAAU,GAAG,OAAO,YAAY,EAAE,GAAG,OAAO,CAAC;CAAc,CAAA;CAG5H,MAAM,mBAAmB,OAAO,YAAY;CAC5C,OAAO,oBAAC,oBAAD;EAAqE;EAAY;EAAM,QAAQ;EAAkB,WAAW;CAAK,GAAjG,GAAG,iBAAiB,GAAG,MAA0E;AAC1I;AAEA,SAAgB,iBAAiB,MAAwC;CACvE,MAAM,EAAE,UAAU,MAAM,WAAW;CACnC,MAAM,IAAI,eAAe;CACzB,MAAM,OAAO,eAAe,KAAA,GAAW,QAAQ;CAE/C,IAAI,CAAC,MACH,OAAO,oBAAC,YAAD,EAAA,UAAa,EAAE,wBAAwB,EAAE,SAAS,CAAC,EAAc,CAAA;CAG1E,OAAO,oBAAC,0BAAD;EAAgC;EAAY;EAAc;CAAS,CAAA;AAC5E;;;ACjIA,IAAM,uBAAuB;CAC3B,GAAG;CACH;CACA;AACF;AAEA,IAAM,2BAA2B;CAC/B;CACA;AACF;AAEA,SAAgB,iBAAiB,aAAsC,CAAC,GAAG;CACzE,OAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;CACL;AACF;;;ACbA,SAAgB,SAAS,MAAqB;CAC5C,MAAM,EAAE,OAAO,UAAU,aAAa;CAEtC,OACE,oBAAC,QAAD;EAAM,WAAU;YACd,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,qBAAC,UAAD;IAAQ,WAAU;cAAlB,CACE,oBAAC,MAAD;KAAI,WAAU;eAAiD;IAAU,CAAA,GACxE,WAAW,oBAAC,KAAD;KAAG,WAAU;eAAgD;IAAY,CAAA,IAAI,IACnF;OACR,oBAAC,OAAD,EAAQ,SAAgB,CAAA,CACrB;;CACD,CAAA;AAEV"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../source/openapi/lib/spec-path.ts","../source/openapi/lib/utils.ts","../source/openapi/entry.tsx","../source/mdx/components.ts","../source/mdx/DocShell.tsx"],"sourcesContent":["import { useLocation } from 'react-router-dom'\n\nimport { useConfig, useLocale, useOpenApis } from '../../core/context'\n\nimport type { OpenAPISpec } from './utils'\n\nconst VIRTUAL_PREFIX = 'virtual:clarify-page/'\n\nfunction resolveRelativePath(fromDir: string, to: string): string {\n const parts = (fromDir + '/' + to).split('/').filter(Boolean)\n const stack: string[] = []\n for (const part of parts) {\n if (part === '..') {\n stack.pop()\n } else if (part !== '.') {\n stack.push(part)\n }\n }\n return stack.join('/')\n}\n\nfunction normalizeSpecPath(specPath: string, currentRoutePath?: string, routePrefix = ''): string {\n if (specPath.startsWith(VIRTUAL_PREFIX)) return specPath\n\n const normalizedRoutePrefix = routePrefix.replace(/^\\/+|\\/+$/g, '')\n const normalizedSpecPath = specPath.startsWith('/') && normalizedRoutePrefix && specPath.slice(1).startsWith(`${normalizedRoutePrefix}/`)\n ? '/' + specPath.slice(normalizedRoutePrefix.length + 2)\n : specPath\n\n if (normalizedSpecPath.startsWith('/')) {\n return VIRTUAL_PREFIX + normalizedSpecPath.replace(/^\\//, '')\n }\n const fromDir = currentRoutePath === '/' ? '' : currentRoutePath?.replace(/^\\//, '').replace(/\\/[^/]*$/, '') ?? ''\n const normalizedFromDir = normalizedRoutePrefix && fromDir.startsWith(`${normalizedRoutePrefix}/`)\n ? fromDir.slice(normalizedRoutePrefix.length + 1)\n : fromDir\n return VIRTUAL_PREFIX + resolveRelativePath(normalizedFromDir, normalizedSpecPath)\n}\n\n/**\n * 为绝对 specPath 生成带 locale 前缀的候选模块 ID。\n *\n * 所有 locale 的 spec 都注册在 `virtual:clarify-page/<locale>/...` 下,\n * 因此绝对路径(如 `/api`)需要显式注入 locale 前缀才能命中。\n * 相对路径会因为当前路由已含 locale 前缀而自动解析到正确的 spec。\n */\nfunction localizeSpecModuleId(moduleId: string, specPath: string, locale: string | undefined, _defaultLocale: string | undefined): string | undefined {\n if (!locale) return undefined\n // 仅处理绝对路径;相对路径已经基于含 locale 前缀的当前路由解析。\n if (!specPath.startsWith('/') || specPath.startsWith(VIRTUAL_PREFIX)) return undefined\n const rest = moduleId.slice(VIRTUAL_PREFIX.length)\n if (rest.startsWith(`${locale}/`) || rest === locale) return undefined\n return `${VIRTUAL_PREFIX}${locale}/${rest}`\n}\n\nexport function useOpenApiSpec(spec?: OpenAPISpec, specPath?: string): OpenAPISpec | null {\n const config = useConfig()\n const locale = useLocale()\n const specs = useOpenApis()\n const location = useLocation()\n\n if (spec) return spec\n if (!specPath) return null\n\n const normalized = normalizeSpecPath(specPath, location.pathname, config.routePrefix)\n const localized = localizeSpecModuleId(normalized, specPath, locale, config.i18n?.defaultLocale)\n\n if (localized && specs[localized]) return specs[localized]\n return specs[normalized] ?? null\n}\n","import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types'\n\nimport type { OpenApiRecord } from '../types'\n\nexport type OpenAPISpec = OpenAPIV3.Document | OpenAPIV3_1.Document\nexport type OpenAPIOperation = OpenAPIV3.OperationObject | OpenAPIV3_1.OperationObject\n\nexport const OPENAPI_HTTP_METHODS = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'] as const\n\nexport type OpenAPIHttpMethod = typeof OPENAPI_HTTP_METHODS[number]\n\nexport function isOpenAPIHttpMethod(method: string): method is OpenAPIHttpMethod {\n return (OPENAPI_HTTP_METHODS as readonly string[]).includes(method.toLowerCase())\n}\n\nfunction isRecord(value: unknown): value is OpenApiRecord {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction resolveOpenApiRef(spec: OpenAPISpec, ref: string): unknown {\n if (!ref.startsWith('#/')) return undefined\n\n return ref\n .slice(2)\n .split('/')\n .map((part) => part.replace(/~1/g, '/').replace(/~0/g, '~'))\n .reduce<unknown>((current, part) => (isRecord(current) ? current[part] : undefined), spec)\n}\n\nfunction getPathItem(spec: OpenAPISpec, path: string): OpenApiRecord | undefined {\n const pathItem = spec.paths?.[path]\n const resolved = isRecord(pathItem) && typeof pathItem.$ref === 'string' ? resolveOpenApiRef(spec, pathItem.$ref) : pathItem\n return isRecord(resolved) ? resolved : undefined\n}\n\nexport function getOpenApiOperation(spec: OpenAPISpec, path: string, method: string): OpenAPIOperation | undefined {\n if (!isOpenAPIHttpMethod(method)) return undefined\n return getPathItem(spec, path)?.[method.toLowerCase() as OpenAPIHttpMethod] as OpenAPIOperation | undefined\n}\n\nexport function listOpenApiOperations(spec: OpenAPISpec): Array<{ path: string; method: OpenAPIHttpMethod; operation: OpenAPIOperation }> {\n const paths = spec.paths ?? {}\n const operations: Array<{ path: string; method: OpenAPIHttpMethod; operation: OpenAPIOperation }> = []\n\n for (const path of Object.keys(paths)) {\n const pathItem = getPathItem(spec, path)\n if (!pathItem) continue\n for (const method of OPENAPI_HTTP_METHODS) {\n const operation = pathItem[method]\n if (operation) operations.push({ path, method, operation: operation as OpenAPIOperation })\n }\n }\n\n return operations\n}\n","import type { ReactNode } from 'react'\n\nimport { PageTitleActions } from '../app/PageActions'\nimport { Prose } from '../components/Prose'\nimport { useBuiltInText } from '../core/i18n'\nimport { Markdown } from '../mdx/Markdown'\n\nimport { OpenApiOperation as OpenApiOperationComponent } from './components/OpenApiOperation'\nimport { useOpenApiSpec } from './lib/spec-path'\nimport { getOpenApiOperation, listOpenApiOperations } from './lib/utils'\nimport type { OpenAPISpec } from './lib/utils'\n\ntype OpenApiPathsProps = { spec: OpenAPISpec; tagFilter?: string[] }\n\ntype OpenApiHeaderProps = { spec: OpenAPISpec }\n\ntype WarningBoxProps = {\n children: ReactNode\n tone?: 'amber' | 'red'\n}\n\nexport type OpenApiDocumentProps = {\n spec?: OpenAPISpec\n specPath?: string\n tagFilter?: string[]\n}\n\ntype OpenApiOperationWithSpecProps = {\n spec: OpenAPISpec\n path: string\n method: string\n}\n\nexport type OpenApiOperationProps = {\n specPath: string\n path: string\n method: string\n}\n\nfunction OpenApiHeader(arg0: OpenApiHeaderProps): ReactNode {\n const { spec } = arg0\n\n const t = useBuiltInText()\n return (\n <header className=\"clarify-openapi-header mb-16 border-b border-(--clarify-theme-tokens-colors-border) pb-8\">\n <p className=\"mb-3 text-xs/6 font-medium tracking-widest text-(--clarify-ui-accent-text) uppercase\">\n {t('openapi.openApiReference')}\n </p>\n <div className=\"clarify-page-title-row flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between\">\n <h1 className=\"clarify-page-title min-w-0 flex-1\">{spec.info?.title ?? t('openapi.apiDocumentation')}</h1>\n <PageTitleActions />\n </div>\n {spec.info?.description ? <Markdown className=\"lead mt-4 *:first:mt-0 *:last:mb-0\">{spec.info.description}</Markdown> : null}\n {spec.info?.version ? <p className=\"mt-4 text-sm text-(--clarify-ui-text-faint)\">{t('openapi.version', { version: spec.info.version })}</p> : null}\n </header>\n )\n}\n\nfunction operationMatchesTags(operationTags: string[] | undefined, filterTags: string[] | undefined): boolean {\n if (!filterTags?.length) return true\n return operationTags?.some(tag => filterTags.includes(tag)) ?? false\n}\n\nfunction OpenApiPaths(arg0: OpenApiPathsProps): ReactNode {\n const { spec, tagFilter } = arg0\n\n const entries = listOpenApiOperations(spec)\n .filter(({ operation }) => operationMatchesTags(operation.tags, tagFilter))\n .map(({ path, method, operation }) => ({\n path,\n method: method.toUpperCase(),\n operation,\n }))\n\n return (\n <div className=\"clarify-api-endpoints divide-y divide-zinc-200/70 dark:divide-white/10\">\n {entries.map(({ path, method, operation }) => (\n <OpenApiOperationComponent key={`${method}-${path}`} spec={spec} path={path} method={method} operation={operation} />\n ))}\n </div>\n )\n}\n\nfunction WarningBox(arg0: WarningBoxProps): ReactNode {\n const { children, tone = 'amber' } = arg0\n\n const classes = tone === 'red'\n ? 'rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-200'\n : 'rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200'\n\n return <div className={`clarify-warning ${classes}`}>{children}</div>\n}\n\nexport function OpenApiDocument(arg0: OpenApiDocumentProps): ReactNode {\n const { spec, specPath, tagFilter } = arg0\n const t = useBuiltInText()\n const resolved = useOpenApiSpec(spec, specPath)\n\n if (!resolved) {\n return <WarningBox>{t('openapi.specNotFound', { specPath: specPath ?? t('openapi.specPathMissing') })}</WarningBox>\n }\n\n return (\n <article className=\"clarify-openapi-page flex h-full flex-col pt-16 pb-10\">\n <Prose className=\"flex-auto\">\n <OpenApiHeader spec={resolved} />\n <OpenApiPaths spec={resolved} tagFilter={tagFilter} />\n </Prose>\n </article>\n )\n}\n\nfunction OpenApiOperationWithSpec(arg0: OpenApiOperationWithSpecProps): ReactNode {\n const { spec, path, method } = arg0\n const t = useBuiltInText()\n const op = getOpenApiOperation(spec, path, method)\n\n if (!op) {\n return <WarningBox tone=\"red\">{t('openapi.endpointNotFound', { endpoint: `${method.toUpperCase()} ${path}` })}</WarningBox>\n }\n\n const normalizedMethod = method.toUpperCase()\n return <OpenApiOperationComponent key={`${normalizedMethod}-${path}`} spec={spec} path={path} method={normalizedMethod} operation={op} />\n}\n\nexport function OpenApiOperation(arg0: OpenApiOperationProps): ReactNode {\n const { specPath, path, method } = arg0\n const t = useBuiltInText()\n const spec = useOpenApiSpec(undefined, specPath)\n\n if (!spec) {\n return <WarningBox>{t('openapi.specNotFound', { specPath })}</WarningBox>\n }\n\n return <OpenApiOperationWithSpec spec={spec} path={path} method={method} />\n}\n","import { Collapse } from '../components/Collapse'\nimport { Mermaid } from '../components/Mermaid'\nimport { OpenApiDocument, OpenApiOperation } from '../openapi'\n\nimport { Markdown } from './Markdown'\nimport * as mdxPrimitives from './primitives'\n\nconst builtInMDXComponents = {\n ...mdxPrimitives,\n Markdown,\n Collapse,\n Mermaid,\n}\n\nconst builtInOpenAPIComponents = {\n OpenApiDocument,\n OpenApiOperation,\n}\n\nexport function useMDXComponents(components: Record<string, unknown> = {}) {\n return {\n ...components,\n ...builtInMDXComponents,\n ...builtInOpenAPIComponents,\n }\n}\n","import type { ReactNode } from 'react'\n\nimport { Prose } from '../components/Prose'\n\nexport type DocShellProps = {\n title: string\n subtitle?: string\n children: ReactNode\n}\n\nexport function DocShell(arg0: DocShellProps) {\n const { title, subtitle, children } = arg0\n\n return (\n <main className=\"clarify-doc-shell min-h-screen bg-(--clarify-theme-tokens-colors-background) px-6 py-10 text-(--clarify-theme-tokens-colors-foreground) md:px-10\">\n <div className=\"mx-auto max-w-6xl\">\n <header className=\"mb-10\">\n <h1 className=\"text-3xl font-bold tracking-tight md:text-5xl\">{title}</h1>\n {subtitle ? <p className=\"mt-3 max-w-2xl text-(--clarify-ui-text-soft)\">{subtitle}</p> : null}\n </header>\n <Prose>{children}</Prose>\n </div>\n </main>\n )\n}\n"],"mappings":";;;;;;;;AAMA,IAAM,iBAAiB;AAEvB,SAAS,oBAAoB,SAAiB,IAAoB;CAChE,MAAM,SAAS,UAAU,MAAM,IAAI,MAAM,GAAG,EAAE,OAAO,OAAO;CAC5D,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,QAAQ,OACjB,IAAI,SAAS,MACX,MAAM,IAAI;MACL,IAAI,SAAS,KAClB,MAAM,KAAK,IAAI;CAGnB,OAAO,MAAM,KAAK,GAAG;AACvB;AAEA,SAAS,kBAAkB,UAAkB,kBAA2B,cAAc,IAAY;CAChG,IAAI,SAAS,WAAW,cAAc,GAAG,OAAO;CAEhD,MAAM,wBAAwB,YAAY,QAAQ,cAAc,EAAE;CAClE,MAAM,qBAAqB,SAAS,WAAW,GAAG,KAAK,yBAAyB,SAAS,MAAM,CAAC,EAAE,WAAW,GAAG,sBAAsB,EAAE,IACpI,MAAM,SAAS,MAAM,sBAAsB,SAAS,CAAC,IACrD;CAEJ,IAAI,mBAAmB,WAAW,GAAG,GACnC,OAAO,iBAAiB,mBAAmB,QAAQ,OAAO,EAAE;CAE9D,MAAM,UAAU,qBAAqB,MAAM,KAAK,kBAAkB,QAAQ,OAAO,EAAE,EAAE,QAAQ,YAAY,EAAE,KAAK;CAIhH,OAAO,iBAAiB,oBAHE,yBAAyB,QAAQ,WAAW,GAAG,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AC,KAAD;KAAG,WAAU;eAAgD;IAAY,CAAA,IAAI,IACnF;OACR,oBAAC,OAAD,EAAQ,SAAgB,CAAA,CACrB;;CACD,CAAA;AAEV"}
@@ -1,4 +1,5 @@
1
1
  import { Collapse } from '../components/Collapse';
2
+ import { Mermaid } from '../components/Mermaid';
2
3
  import { OpenApiDocument, OpenApiOperation } from '../openapi';
3
4
  import { Markdown } from './Markdown';
4
5
  import * as mdxPrimitives from './primitives';
@@ -7,9 +8,11 @@ export declare function useMDXComponents(components?: Record<string, unknown>):
7
8
  OpenApiOperation: typeof OpenApiOperation;
8
9
  Markdown: typeof Markdown;
9
10
  Collapse: typeof Collapse;
11
+ Mermaid: typeof Mermaid;
10
12
  wrapper(arg0: {
11
13
  children: import('react').ReactNode;
12
14
  }): import("react").JSX.Element;
15
+ table(arg0: import('react').ComponentPropsWithoutRef<"table">): import("react").JSX.Element;
13
16
  a(arg0: import('react').ComponentPropsWithoutRef<"a">): import("react").JSX.Element;
14
17
  h1(arg0: import('react').ComponentPropsWithoutRef<"h1">): import("react").JSX.Element;
15
18
  h2(props: Omit<import('react').ComponentPropsWithoutRef<typeof import('..').Heading>, "level">): import('react').FunctionComponentElement<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & {
@@ -5,6 +5,7 @@ type WrapperProps = {
5
5
  children: ReactNode;
6
6
  };
7
7
  export declare function wrapper(arg0: WrapperProps): import("react").JSX.Element;
8
+ export declare function table(arg0: ComponentPropsWithoutRef<'table'>): import("react").JSX.Element;
8
9
  export declare function a(arg0: ComponentPropsWithoutRef<'a'>): import("react").JSX.Element;
9
10
  export declare function h1(arg0: ComponentPropsWithoutRef<'h1'>): import("react").JSX.Element;
10
11
  export declare const code: typeof Code;
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_PageActions = require("./PageActions-1RDCHcUY.cjs");
3
- const require_OpenApiOperation = require("./OpenApiOperation-BcyW_ULy.cjs");
2
+ const require_PageActions = require("./PageActions-DOKkt2zo.cjs");
3
+ const require_OpenApiOperation = require("./OpenApiOperation-BMXfV15v.cjs");
4
4
  let react = require("react");
5
5
  let react_router_dom = require("react-router-dom");
6
6
  let lucide_react = require("lucide-react");
@@ -340,6 +340,7 @@ var previewConfig = {
340
340
  description: "Renderer preview environment",
341
341
  rootDirectory: "source",
342
342
  routePrefix: "/",
343
+ assetPrefix: "/",
343
344
  outputDirectory: "output",
344
345
  theme: {
345
346
  preset: "default",