import { AsyncAPIDocumentData } from '../types/schema'; import { OpenAPIDocumentData } from '../types/openapi'; import { MarkdownUrlResolver, SidePanelContainment } from '../config/config'; /** Which spec produced the ambient document. The discriminant of DocumentContextValue. */ export type SpecType = "asyncapi" | "openapi"; interface DocumentContextBase { /** Resolves a JSON Pointer $ref string to the object it references in the document. */ deref: (ref: string) => unknown; portalHost: HTMLElement | null; /** The Layout component's own root element, used to scope viewport-fixed overlays (e.g. SidePanel) to where the or widget is actually embedded, rather than the full browser viewport. */ rootElement: HTMLElement | null; /** Host-page safe area above fixed and sticky widget controls, in pixels. */ topOffset?: number; /** Where SidePanel overlays are clipped. Defaults to `"viewport"`. */ sidePanelContainment: SidePanelContainment; /** Host-page safe area above a component-contained SidePanel, in pixels. */ sidePanelTopOffset?: number; /** Whether schema tree nodes start expanded by default. Defaults to false. */ defaultSchemaExpanded?: boolean; /** Resolved schema tree depth-line colors (config-provided or default), cycled by nesting depth. */ depthColors: string[]; /** Whether to render known x-* spec extensions (see the `x-tensions` catalog). Defaults to true. */ showExtensions: boolean; /** Whether to render per-operation / per-endpoint code samples. Defaults to true. */ showCodeSamples: boolean; /** Resolves the hosted URL serving a target as Markdown, if the consumer serves one (config.markdown.url). */ markdownUrl?: MarkdownUrlResolver; } export interface AsyncAPIDocumentContextValue extends DocumentContextBase { specType: "asyncapi"; document: AsyncAPIDocumentData; } export interface OpenAPIDocumentContextValue extends DocumentContextBase { specType: "openapi"; document: OpenAPIDocumentData; } /** * Discriminated on `specType`: checking it narrows `document` to the matching * spec's shape, so spec-specific consumers don't need to cast. Spec-agnostic * consumers that only need deref/portalHost/rootElement/depthColors (SidePanel, * SearchPanel, SchemaTree, ExpandToggle, ...) work under any provider without * looking at the discriminant. */ export type DocumentContextValue = AsyncAPIDocumentContextValue | OpenAPIDocumentContextValue; export declare const DocumentContext: import('react').Context; export declare const useDocumentContext: () => DocumentContextValue; export declare const AsyncAPIDocumentContext: import('react').Context; export declare const useAsyncAPIDocument: () => DocumentContextValue; export {};