@clarify-labs/renderer 0.10.1 → 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/index.cjs CHANGED
@@ -2,8 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_i18n = require("./i18n-b4iTLeia.cjs");
3
3
  const require_ClarifyShell = require("./ClarifyShell-C6li72Ce.cjs");
4
4
  const require_PageActions = require("./PageActions-BjB6PYmL.cjs");
5
- const require_OpenApiOperation = require("./OpenApiOperation-DK46w2dq.cjs");
6
- const require_remark = require("./remark-zSQT0MBv.cjs");
5
+ const require_OpenApiOperation = require("./OpenApiOperation-B52IWlKb.cjs");
6
+ const require_remark = require("./remark-DTLbG8PK.cjs");
7
7
  const require_render = require("./render-Di5B6Zc0.cjs");
8
8
  let react = require("react");
9
9
  let react_router_dom = require("react-router-dom");
@@ -79,28 +79,21 @@ function useOpenApiSpec(spec, specPath) {
79
79
  const locale = require_i18n.useLocale();
80
80
  const specs = require_i18n.useOpenApiSpecs();
81
81
  const location = (0, react_router_dom.useLocation)();
82
- const [loadedSpec, setLoadedSpec] = (0, react.useState)({
83
- spec: null,
84
- loading: false
85
- });
82
+ const [loadedSpec, setLoadedSpec] = (0, react.useState)({ spec: null });
86
83
  const normalized = specPath ? normalizeSpecPath(specPath, location.pathname, config.routePrefix) : void 0;
87
84
  const registryValue = (specPath && normalized ? specModuleCandidates(normalized, specPath, locale) : []).map((candidate) => specs[candidate]).find(Boolean);
88
85
  (0, react.useEffect)(() => {
89
86
  let cancelled = false;
90
87
  if (!isOpenApiSpecLoader(registryValue)) return;
91
- setLoadedSpec({
92
- spec: null,
93
- loading: true
94
- });
95
88
  registryValue().then((module) => {
96
89
  if (!cancelled) setLoadedSpec({
97
- spec: getLoadedSpec(module),
98
- loading: false
90
+ loader: registryValue,
91
+ spec: getLoadedSpec(module)
99
92
  });
100
93
  }).catch(() => {
101
94
  if (!cancelled) setLoadedSpec({
102
- spec: null,
103
- loading: false
95
+ loader: registryValue,
96
+ spec: null
104
97
  });
105
98
  });
106
99
  return () => {
@@ -115,7 +108,13 @@ function useOpenApiSpec(spec, specPath) {
115
108
  spec: null,
116
109
  loading: false
117
110
  };
118
- if (isOpenApiSpecLoader(registryValue)) return loadedSpec;
111
+ if (isOpenApiSpecLoader(registryValue)) return loadedSpec.loader === registryValue ? {
112
+ spec: loadedSpec.spec,
113
+ loading: false
114
+ } : {
115
+ spec: null,
116
+ loading: true
117
+ };
119
118
  return {
120
119
  spec: registryValue ?? null,
121
120
  loading: false
@@ -309,6 +308,7 @@ exports.applyThemeVariables = require_ClarifyShell.applyThemeVariables;
309
308
  exports.createContentDiagnosticComponent = createContentDiagnosticComponent;
310
309
  exports.createOpenApiRouteComponent = createOpenApiRouteComponent;
311
310
  exports.markdownRemarkPlugins = require_remark.markdownRemarkPlugins;
311
+ exports.parseCodeMeta = require_remark.parseCodeMeta;
312
312
  exports.remToPx = require_PageActions.remToPx;
313
313
  exports.render = require_render.render;
314
314
  exports.themeBootstrapScript = require_ClarifyShell.themeBootstrapScript;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../source/app/ContentDiagnostic.tsx","../source/openapi/lib/spec-path.ts","../source/openapi/entry.tsx","../source/mdx/components.ts","../source/mdx/DocShell.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\n\nimport { RenderErrorPanel } from './RenderErrorPanel'\n\nexport type ContentDiagnostic = {\n kind: string\n title: string\n message: string\n details?: string\n filePath?: string\n}\n\ntype ContentDiagnosticPanelProps = {\n data: ContentDiagnostic\n}\n\nfunction ContentDiagnosticPanel(params: ContentDiagnosticPanelProps) {\n const { data } = params\n const typeLabel = data.kind === 'mdx' ? 'MDX' : data.kind === 'openapi' ? 'OpenAPI' : 'Route'\n const detailsLabel = data.kind === 'mdx' ? 'Why it happened' : 'Details'\n const pathLabel = 'File'\n\n return (\n <RenderErrorPanel\n title={data.title}\n description={data.message}\n titleId=\"clarify-content-diagnostic-title\"\n metadata={[\n { label: pathLabel, value: data.filePath ?? 'Unknown' },\n { label: 'Type', value: typeLabel },\n ]}\n detailsLabel={detailsLabel}\n detailsContent={data.details ? (\n <pre className=\"max-h-(--clarify-error-details-max-height) overflow-auto whitespace-pre-wrap wrap-break-word font-mono\">\n {data.details}\n </pre>\n ) : null}\n />\n )\n}\n\nexport function createContentDiagnosticComponent(data: ContentDiagnostic): ComponentType {\n return function ContentDiagnosticComponent() {\n return <ContentDiagnosticPanel data={data} />\n }\n}\n","import { useEffect, useState } from 'react'\nimport { useLocation } from 'react-router-dom'\n\nimport { useConfig, useLocale, useOpenApiSpecs } from '../../core/context'\n\nimport type { OpenAPISpec } from './utils'\n\ntype OpenApiSpecResult = {\n spec: OpenAPISpec | null\n loading: boolean\n}\n\ntype OpenApiSpecModule = { default: OpenAPISpec } | OpenAPISpec\n\ntype LoadedSpecState = {\n spec: OpenAPISpec | null\n loading: boolean\n}\n\nfunction isOpenApiSpecLoader(value: unknown): value is () => Promise<OpenApiSpecModule> {\n return typeof value === 'function'\n}\n\nfunction getLoadedSpec(value: OpenApiSpecModule): OpenAPISpec {\n return value && typeof value === 'object' && 'default' in value\n ? value.default\n : value\n}\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 * Prefer a locale-qualified registry key for absolute specPath values, then\n * fall back to the normalized key. The CLI registers visible route aliases,\n * while relative paths already resolve through the current localized route.\n */\nfunction specModuleCandidates(moduleId: string, specPath: string, locale: string | undefined): string[] {\n const candidates: string[] = []\n if (locale && specPath.startsWith('/') && !specPath.startsWith(VIRTUAL_PREFIX)) {\n const rest = moduleId.slice(VIRTUAL_PREFIX.length)\n if (!rest.startsWith(`${locale}/`) && rest !== locale) candidates.push(`${VIRTUAL_PREFIX}${locale}/${rest}`)\n }\n candidates.push(moduleId)\n return candidates\n}\n\nexport function useOpenApiSpec(spec?: OpenAPISpec, specPath?: string): OpenApiSpecResult {\n const config = useConfig()\n const locale = useLocale()\n const specs = useOpenApiSpecs()\n const location = useLocation()\n const [loadedSpec, setLoadedSpec] = useState<LoadedSpecState>({ spec: null, loading: false })\n const normalized = specPath ? normalizeSpecPath(specPath, location.pathname, config.routePrefix) : undefined\n const candidates = specPath && normalized ? specModuleCandidates(normalized, specPath, locale) : []\n const registryValue = candidates.map(candidate => specs[candidate]).find(Boolean)\n\n useEffect(() => {\n let cancelled = false\n\n if (!isOpenApiSpecLoader(registryValue)) return\n\n setLoadedSpec({ spec: null, loading: true })\n registryValue().then(module => {\n if (!cancelled) setLoadedSpec({ spec: getLoadedSpec(module), loading: false })\n }).catch(() => {\n if (!cancelled) setLoadedSpec({ spec: null, loading: false })\n })\n\n return () => {\n cancelled = true\n }\n }, [registryValue])\n\n if (spec) return { spec, loading: false }\n if (!specPath) return { spec: null, loading: false }\n if (isOpenApiSpecLoader(registryValue)) {\n return loadedSpec\n }\n return { spec: registryValue ?? null, loading: false }\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 { getOpenApiOperationEntry, 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\nexport type OpenApiRouteData = {\n spec: OpenAPISpec\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, source }) => ({\n path,\n method: method.toUpperCase(),\n operation,\n source,\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, source }) => (\n <OpenApiOperationComponent key={`${source}-${method}-${path}`} spec={spec} path={path} method={method} operation={operation} operationSource={source} />\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 { spec: resolved, loading } = useOpenApiSpec(spec, specPath)\n\n if (loading) {\n return <WarningBox>{t('openapi.loading')}</WarningBox>\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 entry = getOpenApiOperationEntry(spec, path, method)\n\n if (!entry) {\n return <WarningBox tone=\"red\">{t('openapi.endpointNotFound', { endpoint: `${method.toUpperCase()} ${path}` })}</WarningBox>\n }\n\n const normalizedMethod = entry.method.toUpperCase()\n return <OpenApiOperationComponent key={`${entry.source}-${normalizedMethod}-${path}`} spec={spec} path={path} method={normalizedMethod} operation={entry.operation} operationSource={entry.source} />\n}\n\nexport function OpenApiOperation(arg0: OpenApiOperationProps): ReactNode {\n const { specPath, path, method } = arg0\n const t = useBuiltInText()\n const { spec, loading } = useOpenApiSpec(undefined, specPath)\n\n if (loading) {\n return <WarningBox>{t('openapi.loading')}</WarningBox>\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\nexport function createOpenApiRouteComponent(data: OpenApiRouteData) {\n return function OpenApiRoutePage() {\n return <OpenApiDocument spec={data.spec} />\n }\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":";;;;;;;;;;;AAgBA,SAAS,uBAAuB,QAAqC;CACnE,MAAM,EAAE,SAAS;CACjB,MAAM,YAAY,KAAK,SAAS,QAAQ,QAAQ,KAAK,SAAS,YAAY,YAAY;CACtF,MAAM,eAAe,KAAK,SAAS,QAAQ,oBAAoB;CAG/D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,qBAAA,kBAAD;EACE,OAAO,KAAK;EACZ,aAAa,KAAK;EAClB,SAAQ;EACR,UAAU,CACR;GAAE,OAAO;GAAW,OAAO,KAAK,YAAY;EAAU,GACtD;GAAE,OAAO;GAAQ,OAAO;EAAU,CACpC;EACc;EACd,gBAAgB,KAAK,UACnB,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,WAAU;aACZ,KAAK;EACH,CAAA,IACH;CACL,CAAA;AAEL;AAEA,SAAgB,iCAAiC,MAAwC;CACvF,OAAO,SAAS,6BAA6B;EAC3C,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,wBAAD,EAA8B,KAAO,CAAA;CAC9C;AACF;;;AC1BA,SAAS,oBAAoB,OAA2D;CACtF,OAAO,OAAO,UAAU;AAC1B;AAEA,SAAS,cAAc,OAAuC;CAC5D,OAAO,SAAS,OAAO,UAAU,YAAY,aAAa,QACtD,MAAM,UACN;AACN;AAEA,IAAM,iBAAiB;AAEvB,SAAS,oBAAoB,SAAiB,IAAoB;CAChE,MAAM,SAAS,UAAU,MAAM,GAAA,CAAI,MAAM,GAAG,C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aAAf,CACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,UAAD;IAAQ,WAAU;cAAlB,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;KAAI,WAAU;eAAiD;IAAU,CAAA,GACxE,WAAW,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;KAAG,WAAU;eAAgD;IAAY,CAAA,IAAI,IACnF;OACR,iBAAA,GAAA,kBAAA,IAAA,CAAC,yBAAA,OAAD,EAAQ,SAAgB,CAAA,CACrB;;CACD,CAAA;AAEV"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../source/app/ContentDiagnostic.tsx","../source/openapi/lib/spec-path.ts","../source/openapi/entry.tsx","../source/mdx/components.ts","../source/mdx/DocShell.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\n\nimport { RenderErrorPanel } from './RenderErrorPanel'\n\nexport type ContentDiagnostic = {\n kind: string\n title: string\n message: string\n details?: string\n filePath?: string\n}\n\ntype ContentDiagnosticPanelProps = {\n data: ContentDiagnostic\n}\n\nfunction ContentDiagnosticPanel(params: ContentDiagnosticPanelProps) {\n const { data } = params\n const typeLabel = data.kind === 'mdx' ? 'MDX' : data.kind === 'openapi' ? 'OpenAPI' : 'Route'\n const detailsLabel = data.kind === 'mdx' ? 'Why it happened' : 'Details'\n const pathLabel = 'File'\n\n return (\n <RenderErrorPanel\n title={data.title}\n description={data.message}\n titleId=\"clarify-content-diagnostic-title\"\n metadata={[\n { label: pathLabel, value: data.filePath ?? 'Unknown' },\n { label: 'Type', value: typeLabel },\n ]}\n detailsLabel={detailsLabel}\n detailsContent={data.details ? (\n <pre className=\"max-h-(--clarify-error-details-max-height) overflow-auto whitespace-pre-wrap wrap-break-word font-mono\">\n {data.details}\n </pre>\n ) : null}\n />\n )\n}\n\nexport function createContentDiagnosticComponent(data: ContentDiagnostic): ComponentType {\n return function ContentDiagnosticComponent() {\n return <ContentDiagnosticPanel data={data} />\n }\n}\n","import { useEffect, useState } from 'react'\nimport { useLocation } from 'react-router-dom'\n\nimport { useConfig, useLocale, useOpenApiSpecs } from '../../core/context'\n\nimport type { OpenAPISpec } from './utils'\n\ntype OpenApiSpecResult = {\n spec: OpenAPISpec | null\n loading: boolean\n}\n\ntype OpenApiSpecModule = { default: OpenAPISpec } | OpenAPISpec\n\ntype LoadedSpecState = {\n loader?: () => Promise<OpenApiSpecModule>\n spec: OpenAPISpec | null\n}\n\nfunction isOpenApiSpecLoader(value: unknown): value is () => Promise<OpenApiSpecModule> {\n return typeof value === 'function'\n}\n\nfunction getLoadedSpec(value: OpenApiSpecModule): OpenAPISpec {\n return value && typeof value === 'object' && 'default' in value\n ? value.default\n : value\n}\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 * Prefer a locale-qualified registry key for absolute specPath values, then\n * fall back to the normalized key. The CLI registers visible route aliases,\n * while relative paths already resolve through the current localized route.\n */\nfunction specModuleCandidates(moduleId: string, specPath: string, locale: string | undefined): string[] {\n const candidates: string[] = []\n if (locale && specPath.startsWith('/') && !specPath.startsWith(VIRTUAL_PREFIX)) {\n const rest = moduleId.slice(VIRTUAL_PREFIX.length)\n if (!rest.startsWith(`${locale}/`) && rest !== locale) candidates.push(`${VIRTUAL_PREFIX}${locale}/${rest}`)\n }\n candidates.push(moduleId)\n return candidates\n}\n\nexport function useOpenApiSpec(spec?: OpenAPISpec, specPath?: string): OpenApiSpecResult {\n const config = useConfig()\n const locale = useLocale()\n const specs = useOpenApiSpecs()\n const location = useLocation()\n const [loadedSpec, setLoadedSpec] = useState<LoadedSpecState>({ spec: null })\n const normalized = specPath ? normalizeSpecPath(specPath, location.pathname, config.routePrefix) : undefined\n const candidates = specPath && normalized ? specModuleCandidates(normalized, specPath, locale) : []\n const registryValue = candidates.map(candidate => specs[candidate]).find(Boolean)\n\n useEffect(() => {\n let cancelled = false\n\n if (!isOpenApiSpecLoader(registryValue)) return\n\n registryValue().then(module => {\n if (!cancelled) setLoadedSpec({ loader: registryValue, spec: getLoadedSpec(module) })\n }).catch(() => {\n if (!cancelled) setLoadedSpec({ loader: registryValue, spec: null })\n })\n\n return () => {\n cancelled = true\n }\n }, [registryValue])\n\n if (spec) return { spec, loading: false }\n if (!specPath) return { spec: null, loading: false }\n if (isOpenApiSpecLoader(registryValue)) {\n return loadedSpec.loader === registryValue\n ? { spec: loadedSpec.spec, loading: false }\n : { spec: null, loading: true }\n }\n return { spec: registryValue ?? null, loading: false }\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 { getOpenApiOperationEntry, 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\nexport type OpenApiRouteData = {\n spec: OpenAPISpec\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, source }) => ({\n path,\n method: method.toUpperCase(),\n operation,\n source,\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, source }) => (\n <OpenApiOperationComponent key={`${source}-${method}-${path}`} spec={spec} path={path} method={method} operation={operation} operationSource={source} />\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 { spec: resolved, loading } = useOpenApiSpec(spec, specPath)\n\n if (loading) {\n return <WarningBox>{t('openapi.loading')}</WarningBox>\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 entry = getOpenApiOperationEntry(spec, path, method)\n\n if (!entry) {\n return <WarningBox tone=\"red\">{t('openapi.endpointNotFound', { endpoint: `${method.toUpperCase()} ${path}` })}</WarningBox>\n }\n\n const normalizedMethod = entry.method.toUpperCase()\n return <OpenApiOperationComponent key={`${entry.source}-${normalizedMethod}-${path}`} spec={spec} path={path} method={normalizedMethod} operation={entry.operation} operationSource={entry.source} />\n}\n\nexport function OpenApiOperation(arg0: OpenApiOperationProps): ReactNode {\n const { specPath, path, method } = arg0\n const t = useBuiltInText()\n const { spec, loading } = useOpenApiSpec(undefined, specPath)\n\n if (loading) {\n return <WarningBox>{t('openapi.loading')}</WarningBox>\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\nexport function createOpenApiRouteComponent(data: OpenApiRouteData) {\n return function OpenApiRoutePage() {\n return <OpenApiDocument spec={data.spec} />\n }\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":";;;;;;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AAQ,SAAgB,CAAA,CACrB;;CACD,CAAA;AAEV"}
package/output/index.d.ts CHANGED
@@ -9,7 +9,7 @@ import { OpenApiSpecsContext, useOpenApiSpecs } from './context';
9
9
  import { useMDXComponents } from './mdx/components';
10
10
  import { DocShell } from './mdx/DocShell';
11
11
  import { Markdown } from './mdx/Markdown';
12
- import { markdownRemarkPlugins } from './mdx/remark';
12
+ import { markdownRemarkPlugins, parseCodeMeta } from './mdx/remark';
13
13
  import { OpenApiDocument, OpenApiOperation, createOpenApiRouteComponent } from './openapi';
14
14
  import { render } from './runtime/render';
15
15
  import { SlotProvider, RuntimeSlot, RuntimeSlotsProvider, useSlot } from './slots';
@@ -26,6 +26,6 @@ export type { Config, RouteItem, RouteSection, RenderOptions, ServerRenderOption
26
26
  export type { RuntimeSlotEntry, RuntimeSlotRegistry, UISlotRegistration, UISlotName, UISlotContext } from './slots';
27
27
  export { AppShell, render, OpenApiSpecsContext, useOpenApiSpecs, BuiltWithClarify, PageBanner, PageFooter, ThemeProvider, ThemeToggle, ThemeEditor, useTheme, SectionProvider, useSectionStore, remToPx, applyThemeVariables, themeEditorPresets, themePresets, themeBootstrapScript, createContentDiagnosticComponent, createOpenApiRouteComponent };
28
28
  export { Button, Callout, Card, CardGroup, Code, CodeGroup, Collapse, Pre, Prose, Heading, Logo, Mermaid, GridPattern, HeroPattern, Feedback, Tag, WebFrame };
29
- export { DocShell, Markdown, useMDXComponents, markdownRemarkPlugins };
29
+ export { DocShell, Markdown, useMDXComponents, markdownRemarkPlugins, parseCodeMeta };
30
30
  export { SlotProvider, RuntimeSlot, RuntimeSlotsProvider, useSlot };
31
31
  export { OpenApiDocument, OpenApiOperation };
package/output/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { A as CardGroup, C as Feedback, D as Pre, E as CodeGroup, M as Button, O as Mermaid, S as Tag, T as Code, _ as Prose, b as Logo, d as listOpenApiOperations, g as WebFrame, h as primitives_exports, j as Callout, k as Card, m as Markdown, n as OpenApiOperation$1, u as getOpenApiOperationEntry, v as GridPattern, w as Collapse, x as Heading, y as HeroPattern } from "./OpenApiOperation-CqNM-no4.js";
1
+ import { A as CardGroup, C as Feedback, D as Pre, E as CodeGroup, M as Button, O as Mermaid, S as Tag, T as Code, _ as Prose, b as Logo, d as listOpenApiOperations, g as WebFrame, h as primitives_exports, j as Callout, k as Card, m as Markdown, n as OpenApiOperation$1, u as getOpenApiOperationEntry, v as GridPattern, w as Collapse, x as Heading, y as HeroPattern } from "./OpenApiOperation-DgrqzeiS.js";
2
2
  import { a as useConfig, c as useOpenApiSpecs, i as OpenApiSpecsContext, s as useLocale, t as useBuiltInText } from "./i18n-DnqZHFT7.js";
3
3
  import { a as themeBootstrapScript, c as AppShell, d as RenderErrorPanel, f as BuiltWithClarify, g as useSlot, h as SlotProvider, i as themeEditorPresets, l as PageFooter, m as RuntimeSlotsProvider, n as ThemeEditor, o as themePresets, p as RuntimeSlot, r as applyThemeVariables, u as PageBanner } from "./ClarifyShell-1LuBliwt.js";
4
4
  import { a as SectionProvider, h as useTheme, m as ThemeProvider, n as PageTitleActions, o as useSectionStore, p as ThemeToggle, s as remToPx } from "./PageActions-D7K9LDGf.js";
5
- import { t as markdownRemarkPlugins } from "./remark-Dd2WU50s.js";
5
+ import { n as parseCodeMeta, t as markdownRemarkPlugins } from "./remark-C9iRQM0R.js";
6
6
  import { t as render } from "./render-DKj24Jqw.js";
7
7
  import { useEffect, useState } from "react";
8
8
  import { useLocation } from "react-router-dom";
@@ -78,28 +78,21 @@ function useOpenApiSpec(spec, specPath) {
78
78
  const locale = useLocale();
79
79
  const specs = useOpenApiSpecs();
80
80
  const location = useLocation();
81
- const [loadedSpec, setLoadedSpec] = useState({
82
- spec: null,
83
- loading: false
84
- });
81
+ const [loadedSpec, setLoadedSpec] = useState({ spec: null });
85
82
  const normalized = specPath ? normalizeSpecPath(specPath, location.pathname, config.routePrefix) : void 0;
86
83
  const registryValue = (specPath && normalized ? specModuleCandidates(normalized, specPath, locale) : []).map((candidate) => specs[candidate]).find(Boolean);
87
84
  useEffect(() => {
88
85
  let cancelled = false;
89
86
  if (!isOpenApiSpecLoader(registryValue)) return;
90
- setLoadedSpec({
91
- spec: null,
92
- loading: true
93
- });
94
87
  registryValue().then((module) => {
95
88
  if (!cancelled) setLoadedSpec({
96
- spec: getLoadedSpec(module),
97
- loading: false
89
+ loader: registryValue,
90
+ spec: getLoadedSpec(module)
98
91
  });
99
92
  }).catch(() => {
100
93
  if (!cancelled) setLoadedSpec({
101
- spec: null,
102
- loading: false
94
+ loader: registryValue,
95
+ spec: null
103
96
  });
104
97
  });
105
98
  return () => {
@@ -114,7 +107,13 @@ function useOpenApiSpec(spec, specPath) {
114
107
  spec: null,
115
108
  loading: false
116
109
  };
117
- if (isOpenApiSpecLoader(registryValue)) return loadedSpec;
110
+ if (isOpenApiSpecLoader(registryValue)) return loadedSpec.loader === registryValue ? {
111
+ spec: loadedSpec.spec,
112
+ loading: false
113
+ } : {
114
+ spec: null,
115
+ loading: true
116
+ };
118
117
  return {
119
118
  spec: registryValue ?? null,
120
119
  loading: false
@@ -271,6 +270,6 @@ function DocShell(arg0) {
271
270
  });
272
271
  }
273
272
  //#endregion
274
- export { AppShell, BuiltWithClarify, Button, Callout, Card, CardGroup, Code, CodeGroup, Collapse, DocShell, Feedback, GridPattern, Heading, HeroPattern, Logo, Markdown, Mermaid, OpenApiDocument, OpenApiOperation, OpenApiSpecsContext, PageBanner, PageFooter, Pre, Prose, RuntimeSlot, RuntimeSlotsProvider, SectionProvider, SlotProvider, Tag, ThemeEditor, ThemeProvider, ThemeToggle, WebFrame, applyThemeVariables, createContentDiagnosticComponent, createOpenApiRouteComponent, markdownRemarkPlugins, remToPx, render, themeBootstrapScript, themeEditorPresets, themePresets, useMDXComponents, useOpenApiSpecs, useSectionStore, useSlot, useTheme };
273
+ export { AppShell, BuiltWithClarify, Button, Callout, Card, CardGroup, Code, CodeGroup, Collapse, DocShell, Feedback, GridPattern, Heading, HeroPattern, Logo, Markdown, Mermaid, OpenApiDocument, OpenApiOperation, OpenApiSpecsContext, PageBanner, PageFooter, Pre, Prose, RuntimeSlot, RuntimeSlotsProvider, SectionProvider, SlotProvider, Tag, ThemeEditor, ThemeProvider, ThemeToggle, WebFrame, applyThemeVariables, createContentDiagnosticComponent, createOpenApiRouteComponent, markdownRemarkPlugins, parseCodeMeta, remToPx, render, themeBootstrapScript, themeEditorPresets, themePresets, useMDXComponents, useOpenApiSpecs, useSectionStore, useSlot, useTheme };
275
274
 
276
275
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../source/app/ContentDiagnostic.tsx","../source/openapi/lib/spec-path.ts","../source/openapi/entry.tsx","../source/mdx/components.ts","../source/mdx/DocShell.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\n\nimport { RenderErrorPanel } from './RenderErrorPanel'\n\nexport type ContentDiagnostic = {\n kind: string\n title: string\n message: string\n details?: string\n filePath?: string\n}\n\ntype ContentDiagnosticPanelProps = {\n data: ContentDiagnostic\n}\n\nfunction ContentDiagnosticPanel(params: ContentDiagnosticPanelProps) {\n const { data } = params\n const typeLabel = data.kind === 'mdx' ? 'MDX' : data.kind === 'openapi' ? 'OpenAPI' : 'Route'\n const detailsLabel = data.kind === 'mdx' ? 'Why it happened' : 'Details'\n const pathLabel = 'File'\n\n return (\n <RenderErrorPanel\n title={data.title}\n description={data.message}\n titleId=\"clarify-content-diagnostic-title\"\n metadata={[\n { label: pathLabel, value: data.filePath ?? 'Unknown' },\n { label: 'Type', value: typeLabel },\n ]}\n detailsLabel={detailsLabel}\n detailsContent={data.details ? (\n <pre className=\"max-h-(--clarify-error-details-max-height) overflow-auto whitespace-pre-wrap wrap-break-word font-mono\">\n {data.details}\n </pre>\n ) : null}\n />\n )\n}\n\nexport function createContentDiagnosticComponent(data: ContentDiagnostic): ComponentType {\n return function ContentDiagnosticComponent() {\n return <ContentDiagnosticPanel data={data} />\n }\n}\n","import { useEffect, useState } from 'react'\nimport { useLocation } from 'react-router-dom'\n\nimport { useConfig, useLocale, useOpenApiSpecs } from '../../core/context'\n\nimport type { OpenAPISpec } from './utils'\n\ntype OpenApiSpecResult = {\n spec: OpenAPISpec | null\n loading: boolean\n}\n\ntype OpenApiSpecModule = { default: OpenAPISpec } | OpenAPISpec\n\ntype LoadedSpecState = {\n spec: OpenAPISpec | null\n loading: boolean\n}\n\nfunction isOpenApiSpecLoader(value: unknown): value is () => Promise<OpenApiSpecModule> {\n return typeof value === 'function'\n}\n\nfunction getLoadedSpec(value: OpenApiSpecModule): OpenAPISpec {\n return value && typeof value === 'object' && 'default' in value\n ? value.default\n : value\n}\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 * Prefer a locale-qualified registry key for absolute specPath values, then\n * fall back to the normalized key. The CLI registers visible route aliases,\n * while relative paths already resolve through the current localized route.\n */\nfunction specModuleCandidates(moduleId: string, specPath: string, locale: string | undefined): string[] {\n const candidates: string[] = []\n if (locale && specPath.startsWith('/') && !specPath.startsWith(VIRTUAL_PREFIX)) {\n const rest = moduleId.slice(VIRTUAL_PREFIX.length)\n if (!rest.startsWith(`${locale}/`) && rest !== locale) candidates.push(`${VIRTUAL_PREFIX}${locale}/${rest}`)\n }\n candidates.push(moduleId)\n return candidates\n}\n\nexport function useOpenApiSpec(spec?: OpenAPISpec, specPath?: string): OpenApiSpecResult {\n const config = useConfig()\n const locale = useLocale()\n const specs = useOpenApiSpecs()\n const location = useLocation()\n const [loadedSpec, setLoadedSpec] = useState<LoadedSpecState>({ spec: null, loading: false })\n const normalized = specPath ? normalizeSpecPath(specPath, location.pathname, config.routePrefix) : undefined\n const candidates = specPath && normalized ? specModuleCandidates(normalized, specPath, locale) : []\n const registryValue = candidates.map(candidate => specs[candidate]).find(Boolean)\n\n useEffect(() => {\n let cancelled = false\n\n if (!isOpenApiSpecLoader(registryValue)) return\n\n setLoadedSpec({ spec: null, loading: true })\n registryValue().then(module => {\n if (!cancelled) setLoadedSpec({ spec: getLoadedSpec(module), loading: false })\n }).catch(() => {\n if (!cancelled) setLoadedSpec({ spec: null, loading: false })\n })\n\n return () => {\n cancelled = true\n }\n }, [registryValue])\n\n if (spec) return { spec, loading: false }\n if (!specPath) return { spec: null, loading: false }\n if (isOpenApiSpecLoader(registryValue)) {\n return loadedSpec\n }\n return { spec: registryValue ?? null, loading: false }\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 { getOpenApiOperationEntry, 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\nexport type OpenApiRouteData = {\n spec: OpenAPISpec\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, source }) => ({\n path,\n method: method.toUpperCase(),\n operation,\n source,\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, source }) => (\n <OpenApiOperationComponent key={`${source}-${method}-${path}`} spec={spec} path={path} method={method} operation={operation} operationSource={source} />\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 { spec: resolved, loading } = useOpenApiSpec(spec, specPath)\n\n if (loading) {\n return <WarningBox>{t('openapi.loading')}</WarningBox>\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 entry = getOpenApiOperationEntry(spec, path, method)\n\n if (!entry) {\n return <WarningBox tone=\"red\">{t('openapi.endpointNotFound', { endpoint: `${method.toUpperCase()} ${path}` })}</WarningBox>\n }\n\n const normalizedMethod = entry.method.toUpperCase()\n return <OpenApiOperationComponent key={`${entry.source}-${normalizedMethod}-${path}`} spec={spec} path={path} method={normalizedMethod} operation={entry.operation} operationSource={entry.source} />\n}\n\nexport function OpenApiOperation(arg0: OpenApiOperationProps): ReactNode {\n const { specPath, path, method } = arg0\n const t = useBuiltInText()\n const { spec, loading } = useOpenApiSpec(undefined, specPath)\n\n if (loading) {\n return <WarningBox>{t('openapi.loading')}</WarningBox>\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\nexport function createOpenApiRouteComponent(data: OpenApiRouteData) {\n return function OpenApiRoutePage() {\n return <OpenApiDocument spec={data.spec} />\n }\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":";;;;;;;;;;AAgBA,SAAS,uBAAuB,QAAqC;CACnE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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/app/ContentDiagnostic.tsx","../source/openapi/lib/spec-path.ts","../source/openapi/entry.tsx","../source/mdx/components.ts","../source/mdx/DocShell.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\n\nimport { RenderErrorPanel } from './RenderErrorPanel'\n\nexport type ContentDiagnostic = {\n kind: string\n title: string\n message: string\n details?: string\n filePath?: string\n}\n\ntype ContentDiagnosticPanelProps = {\n data: ContentDiagnostic\n}\n\nfunction ContentDiagnosticPanel(params: ContentDiagnosticPanelProps) {\n const { data } = params\n const typeLabel = data.kind === 'mdx' ? 'MDX' : data.kind === 'openapi' ? 'OpenAPI' : 'Route'\n const detailsLabel = data.kind === 'mdx' ? 'Why it happened' : 'Details'\n const pathLabel = 'File'\n\n return (\n <RenderErrorPanel\n title={data.title}\n description={data.message}\n titleId=\"clarify-content-diagnostic-title\"\n metadata={[\n { label: pathLabel, value: data.filePath ?? 'Unknown' },\n { label: 'Type', value: typeLabel },\n ]}\n detailsLabel={detailsLabel}\n detailsContent={data.details ? (\n <pre className=\"max-h-(--clarify-error-details-max-height) overflow-auto whitespace-pre-wrap wrap-break-word font-mono\">\n {data.details}\n </pre>\n ) : null}\n />\n )\n}\n\nexport function createContentDiagnosticComponent(data: ContentDiagnostic): ComponentType {\n return function ContentDiagnosticComponent() {\n return <ContentDiagnosticPanel data={data} />\n }\n}\n","import { useEffect, useState } from 'react'\nimport { useLocation } from 'react-router-dom'\n\nimport { useConfig, useLocale, useOpenApiSpecs } from '../../core/context'\n\nimport type { OpenAPISpec } from './utils'\n\ntype OpenApiSpecResult = {\n spec: OpenAPISpec | null\n loading: boolean\n}\n\ntype OpenApiSpecModule = { default: OpenAPISpec } | OpenAPISpec\n\ntype LoadedSpecState = {\n loader?: () => Promise<OpenApiSpecModule>\n spec: OpenAPISpec | null\n}\n\nfunction isOpenApiSpecLoader(value: unknown): value is () => Promise<OpenApiSpecModule> {\n return typeof value === 'function'\n}\n\nfunction getLoadedSpec(value: OpenApiSpecModule): OpenAPISpec {\n return value && typeof value === 'object' && 'default' in value\n ? value.default\n : value\n}\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 * Prefer a locale-qualified registry key for absolute specPath values, then\n * fall back to the normalized key. The CLI registers visible route aliases,\n * while relative paths already resolve through the current localized route.\n */\nfunction specModuleCandidates(moduleId: string, specPath: string, locale: string | undefined): string[] {\n const candidates: string[] = []\n if (locale && specPath.startsWith('/') && !specPath.startsWith(VIRTUAL_PREFIX)) {\n const rest = moduleId.slice(VIRTUAL_PREFIX.length)\n if (!rest.startsWith(`${locale}/`) && rest !== locale) candidates.push(`${VIRTUAL_PREFIX}${locale}/${rest}`)\n }\n candidates.push(moduleId)\n return candidates\n}\n\nexport function useOpenApiSpec(spec?: OpenAPISpec, specPath?: string): OpenApiSpecResult {\n const config = useConfig()\n const locale = useLocale()\n const specs = useOpenApiSpecs()\n const location = useLocation()\n const [loadedSpec, setLoadedSpec] = useState<LoadedSpecState>({ spec: null })\n const normalized = specPath ? normalizeSpecPath(specPath, location.pathname, config.routePrefix) : undefined\n const candidates = specPath && normalized ? specModuleCandidates(normalized, specPath, locale) : []\n const registryValue = candidates.map(candidate => specs[candidate]).find(Boolean)\n\n useEffect(() => {\n let cancelled = false\n\n if (!isOpenApiSpecLoader(registryValue)) return\n\n registryValue().then(module => {\n if (!cancelled) setLoadedSpec({ loader: registryValue, spec: getLoadedSpec(module) })\n }).catch(() => {\n if (!cancelled) setLoadedSpec({ loader: registryValue, spec: null })\n })\n\n return () => {\n cancelled = true\n }\n }, [registryValue])\n\n if (spec) return { spec, loading: false }\n if (!specPath) return { spec: null, loading: false }\n if (isOpenApiSpecLoader(registryValue)) {\n return loadedSpec.loader === registryValue\n ? { spec: loadedSpec.spec, loading: false }\n : { spec: null, loading: true }\n }\n return { spec: registryValue ?? null, loading: false }\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 { getOpenApiOperationEntry, 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\nexport type OpenApiRouteData = {\n spec: OpenAPISpec\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, source }) => ({\n path,\n method: method.toUpperCase(),\n operation,\n source,\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, source }) => (\n <OpenApiOperationComponent key={`${source}-${method}-${path}`} spec={spec} path={path} method={method} operation={operation} operationSource={source} />\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 { spec: resolved, loading } = useOpenApiSpec(spec, specPath)\n\n if (loading) {\n return <WarningBox>{t('openapi.loading')}</WarningBox>\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 entry = getOpenApiOperationEntry(spec, path, method)\n\n if (!entry) {\n return <WarningBox tone=\"red\">{t('openapi.endpointNotFound', { endpoint: `${method.toUpperCase()} ${path}` })}</WarningBox>\n }\n\n const normalizedMethod = entry.method.toUpperCase()\n return <OpenApiOperationComponent key={`${entry.source}-${normalizedMethod}-${path}`} spec={spec} path={path} method={normalizedMethod} operation={entry.operation} operationSource={entry.source} />\n}\n\nexport function OpenApiOperation(arg0: OpenApiOperationProps): ReactNode {\n const { specPath, path, method } = arg0\n const t = useBuiltInText()\n const { spec, loading } = useOpenApiSpec(undefined, specPath)\n\n if (loading) {\n return <WarningBox>{t('openapi.loading')}</WarningBox>\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\nexport function createOpenApiRouteComponent(data: OpenApiRouteData) {\n return function OpenApiRoutePage() {\n return <OpenApiDocument spec={data.spec} />\n }\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":";;;;;;;;;;AAgBA,SAAS,uBAAuB,QAAqC;CACnE,MAAM,EAAE,SAAS;CACjB,MAAM,YAAY,KAAK,SAAS,QAAQ,QAAQ,KAAK,SAAS,YAAY,YAAY;CAC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AiD;IAAU,CAAA,GACxE,WAAW,oBAAC,KAAD;KAAG,WAAU;eAAgD;IAAY,CAAA,IAAI,IACnF;OACR,oBAAC,OAAD,EAAQ,SAAgB,CAAA,CACrB;;CACD,CAAA;AAEV"}
@@ -1,3 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_remark = require("./remark-zSQT0MBv.cjs");
2
+ const require_remark = require("./remark-DTLbG8PK.cjs");
3
3
  exports.markdownRemarkPlugins = require_remark.markdownRemarkPlugins;
4
+ exports.parseCodeMeta = require_remark.parseCodeMeta;
@@ -1 +1 @@
1
- export { markdownRemarkPlugins } from './mdx/remark';
1
+ export { markdownRemarkPlugins, parseCodeMeta } from './mdx/remark';
@@ -1,2 +1,2 @@
1
- import { t as markdownRemarkPlugins } from "./remark-Dd2WU50s.js";
2
- export { markdownRemarkPlugins };
1
+ import { n as parseCodeMeta, t as markdownRemarkPlugins } from "./remark-C9iRQM0R.js";
2
+ export { markdownRemarkPlugins, parseCodeMeta };
@@ -7,6 +7,7 @@ export type MarkdownNode = {
7
7
  };
8
8
  children?: MarkdownNode[];
9
9
  };
10
+ export declare function parseCodeMeta(meta: string | null | undefined): Record<string, string>;
10
11
  declare function remarkCodeMeta(): (tree: MarkdownNode) => void;
11
12
  export declare const markdownRemarkPlugins: (typeof remarkGfm | typeof remarkCodeMeta)[];
12
13
  export {};
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { buildRequestCodeExamples } from '../lib/request-code';
3
3
  import { OpenAPIOperation, OpenAPIOperationSource, OpenAPISpec } from '../lib/utils';
4
- import { MediaTypeEntry, OpenApiParameter, RequestAuthInput } from '../types';
4
+ import { ExampleEntry, MediaTypeEntry, OpenApiParameter, RequestAuthInput } from '../types';
5
5
  type RequestExamplesPanelProps = {
6
6
  spec: OpenAPISpec;
7
7
  path: string;
@@ -27,5 +27,6 @@ type ResponseExamplesPanelProps = {
27
27
  selectedStatus?: string;
28
28
  onSelectStatus?: (value: string) => void;
29
29
  };
30
+ export declare function getResponseExampleBody(content: MediaTypeEntry | undefined, example: ExampleEntry | undefined): string;
30
31
  export declare function ResponseExamplesPanel(arg0: ResponseExamplesPanelProps): ReactNode;
31
32
  export { getServers, getServerKey, getServerLabel, defaultServerVariables, authPlaceholder, authLabel, getAuthOptions, type AuthOption, } from './helpers';
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_i18n = require("./i18n-b4iTLeia.cjs");
3
3
  const require_PageActions = require("./PageActions-BjB6PYmL.cjs");
4
- const require_OpenApiOperation = require("./OpenApiOperation-DK46w2dq.cjs");
4
+ const require_OpenApiOperation = require("./OpenApiOperation-B52IWlKb.cjs");
5
5
  let react = require("react");
6
6
  let react_router_dom = require("react-router-dom");
7
7
  let lucide_react = require("lucide-react");
package/output/preview.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as authPlaceholder, c as getServerKey, f as getMediaTypeEntries, i as ResponseExamplesPanel, l as getServers, o as defaultServerVariables, p as getRequestBody, r as RequestExamplesPanel, s as getAuthOptions, t as EndpointIdentity } from "./OpenApiOperation-CqNM-no4.js";
1
+ import { a as authPlaceholder, c as getServerKey, f as getMediaTypeEntries, i as ResponseExamplesPanel, l as getServers, o as defaultServerVariables, p as getRequestBody, r as RequestExamplesPanel, s as getAuthOptions, t as EndpointIdentity } from "./OpenApiOperation-DgrqzeiS.js";
2
2
  import { i as OpenApiSpecsContext, n as ConfigContext, r as LocaleContext } from "./i18n-DnqZHFT7.js";
3
3
  import { a as SectionProvider, i as Navigation } from "./PageActions-D7K9LDGf.js";
4
4
  import { useState } from "react";
@@ -19,7 +19,8 @@ function addCodeMetaAttributes(node) {
19
19
  node.data = node.data ?? {};
20
20
  node.data.hProperties = {
21
21
  ...node.data.hProperties,
22
- ...props
22
+ ...props,
23
+ metastring: node.meta
23
24
  };
24
25
  }
25
26
  }
@@ -30,6 +31,6 @@ function remarkCodeMeta() {
30
31
  }
31
32
  var markdownRemarkPlugins = [remarkGfm, remarkCodeMeta];
32
33
  //#endregion
33
- export { markdownRemarkPlugins as t };
34
+ export { parseCodeMeta as n, markdownRemarkPlugins as t };
34
35
 
35
- //# sourceMappingURL=remark-Dd2WU50s.js.map
36
+ //# sourceMappingURL=remark-C9iRQM0R.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remark-C9iRQM0R.js","names":[],"sources":["../source/mdx/remark.ts"],"sourcesContent":["import remarkGfm from 'remark-gfm'\n\nexport type MarkdownNode = {\n type?: string\n meta?: string | null\n data?: {\n hProperties?: Record<string, unknown>\n }\n children?: MarkdownNode[]\n}\n\nexport function parseCodeMeta(meta: string | null | undefined): Record<string, string> {\n if (!meta) return {}\n\n const props: Record<string, string> = {}\n const pattern = /([\\w-]+)(?:=(\"([^\"]*)\"|'([^']*)'|([^\\s\"']+)))?/g\n let match: RegExpExecArray | null\n\n while ((match = pattern.exec(meta))) {\n const [, key, , doubleQuotedValue, singleQuotedValue, bareValue] = match\n if (!key) continue\n props[key] = doubleQuotedValue ?? singleQuotedValue ?? bareValue ?? 'true'\n }\n\n return props\n}\n\nfunction addCodeMetaAttributes(node: MarkdownNode) {\n if (node.type === 'code') {\n const props = parseCodeMeta(node.meta)\n if (Object.keys(props).length) {\n node.data = node.data ?? {}\n node.data.hProperties = {\n ...node.data.hProperties,\n ...props,\n metastring: node.meta,\n }\n }\n }\n\n for (const child of node.children ?? []) addCodeMetaAttributes(child)\n}\n\nfunction remarkCodeMeta() {\n return (tree: MarkdownNode) => addCodeMetaAttributes(tree)\n}\n\nexport const markdownRemarkPlugins = [remarkGfm, remarkCodeMeta]\n"],"mappings":";;AAWA,SAAgB,cAAc,MAAyD;CACrF,IAAI,CAAC,MAAM,OAAO,CAAC;CAEnB,MAAM,QAAgC,CAAC;CACvC,MAAM,UAAU;CAChB,IAAI;CAEJ,OAAQ,QAAQ,QAAQ,KAAK,IAAI,GAAI;EACnC,MAAM,GAAG,OAAO,mBAAmB,mBAAmB,aAAa;EACnE,IAAI,CAAC,KAAK;EACV,MAAM,OAAO,qBAAqB,qBAAqB,aAAa;CACtE;CAEA,OAAO;AACT;AAEA,SAAS,sBAAsB,MAAoB;CACjD,IAAI,KAAK,SAAS,QAAQ;EACxB,MAAM,QAAQ,cAAc,KAAK,IAAI;EACrC,IAAI,OAAO,KAAK,KAAK,CAAC,CAAC,QAAQ;GAC7B,KAAK,OAAO,KAAK,QAAQ,CAAC;GAC1B,KAAK,KAAK,cAAc;IACtB,GAAG,KAAK,KAAK;IACb,GAAG;IACH,YAAY,KAAK;GACnB;EACF;CACF;CAEA,KAAK,MAAM,SAAS,KAAK,YAAY,CAAC,GAAG,sBAAsB,KAAK;AACtE;AAEA,SAAS,iBAAiB;CACxB,QAAQ,SAAuB,sBAAsB,IAAI;AAC3D;AAEA,IAAa,wBAAwB,CAAC,WAAW,cAAc"}
@@ -21,7 +21,8 @@ function addCodeMetaAttributes(node) {
21
21
  node.data = node.data ?? {};
22
22
  node.data.hProperties = {
23
23
  ...node.data.hProperties,
24
- ...props
24
+ ...props,
25
+ metastring: node.meta
25
26
  };
26
27
  }
27
28
  }
@@ -38,5 +39,11 @@ Object.defineProperty(exports, "markdownRemarkPlugins", {
38
39
  return markdownRemarkPlugins;
39
40
  }
40
41
  });
42
+ Object.defineProperty(exports, "parseCodeMeta", {
43
+ enumerable: true,
44
+ get: function() {
45
+ return parseCodeMeta;
46
+ }
47
+ });
41
48
 
42
- //# sourceMappingURL=remark-zSQT0MBv.cjs.map
49
+ //# sourceMappingURL=remark-DTLbG8PK.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remark-DTLbG8PK.cjs","names":[],"sources":["../source/mdx/remark.ts"],"sourcesContent":["import remarkGfm from 'remark-gfm'\n\nexport type MarkdownNode = {\n type?: string\n meta?: string | null\n data?: {\n hProperties?: Record<string, unknown>\n }\n children?: MarkdownNode[]\n}\n\nexport function parseCodeMeta(meta: string | null | undefined): Record<string, string> {\n if (!meta) return {}\n\n const props: Record<string, string> = {}\n const pattern = /([\\w-]+)(?:=(\"([^\"]*)\"|'([^']*)'|([^\\s\"']+)))?/g\n let match: RegExpExecArray | null\n\n while ((match = pattern.exec(meta))) {\n const [, key, , doubleQuotedValue, singleQuotedValue, bareValue] = match\n if (!key) continue\n props[key] = doubleQuotedValue ?? singleQuotedValue ?? bareValue ?? 'true'\n }\n\n return props\n}\n\nfunction addCodeMetaAttributes(node: MarkdownNode) {\n if (node.type === 'code') {\n const props = parseCodeMeta(node.meta)\n if (Object.keys(props).length) {\n node.data = node.data ?? {}\n node.data.hProperties = {\n ...node.data.hProperties,\n ...props,\n metastring: node.meta,\n }\n }\n }\n\n for (const child of node.children ?? []) addCodeMetaAttributes(child)\n}\n\nfunction remarkCodeMeta() {\n return (tree: MarkdownNode) => addCodeMetaAttributes(tree)\n}\n\nexport const markdownRemarkPlugins = [remarkGfm, remarkCodeMeta]\n"],"mappings":";;;;AAWA,SAAgB,cAAc,MAAyD;CACrF,IAAI,CAAC,MAAM,OAAO,CAAC;CAEnB,MAAM,QAAgC,CAAC;CACvC,MAAM,UAAU;CAChB,IAAI;CAEJ,OAAQ,QAAQ,QAAQ,KAAK,IAAI,GAAI;EACnC,MAAM,GAAG,OAAO,mBAAmB,mBAAmB,aAAa;EACnE,IAAI,CAAC,KAAK;EACV,MAAM,OAAO,qBAAqB,qBAAqB,aAAa;CACtE;CAEA,OAAO;AACT;AAEA,SAAS,sBAAsB,MAAoB;CACjD,IAAI,KAAK,SAAS,QAAQ;EACxB,MAAM,QAAQ,cAAc,KAAK,IAAI;EACrC,IAAI,OAAO,KAAK,KAAK,CAAC,CAAC,QAAQ;GAC7B,KAAK,OAAO,KAAK,QAAQ,CAAC;GAC1B,KAAK,KAAK,cAAc;IACtB,GAAG,KAAK,KAAK;IACb,GAAG;IACH,YAAY,KAAK;GACnB;EACF;CACF;CAEA,KAAK,MAAM,SAAS,KAAK,YAAY,CAAC,GAAG,sBAAsB,KAAK;AACtE;AAEA,SAAS,iBAAiB;CACxB,QAAQ,SAAuB,sBAAsB,IAAI;AAC3D;AAEA,IAAa,wBAAwB,CAAC,WAAA,SAAW,cAAc"}