asciidoctor-kroki
Version:
Asciidoctor extension to convert diagrams to images using Kroki
77 lines • 3.35 kB
TypeScript
/**
* Represents a Kroki diagram, holding its type, output format, source text, and rendering options.
*/
export declare class KrokiDiagram {
text: string;
type: string;
format: string;
opts: Record<string, string | number>;
/**
* @param {string} type - Diagram type (e.g. `plantuml`, `mermaid`).
* @param {string} format - Output format (e.g. `svg`, `png`).
* @param {string} text - Diagram source text.
* @param {Object<string, string|number>} opts - Diagram-specific rendering options forwarded as query parameters and headers.
*/
constructor(type: string, format: string, text: string, opts: Record<string, string | number>);
/**
* Builds the GET URI for this diagram against the given Kroki server URL.
* Options are appended as URL-encoded query parameters.
*
* @param {string} serverUrl - Base URL of the Kroki server (e.g. `https://kroki.io`).
* @returns {string} Fully-qualified diagram URI.
*/
getDiagramUri(serverUrl: string): string;
/**
* Encodes the diagram source text using zlib deflate (level 9) and base64url encoding,
* as required by the Kroki GET endpoint.
*
* @returns {string} Base64url-encoded deflated representation of the diagram text.
*/
encode(): string;
}
/**
* HTTP client that communicates with a Kroki server to fetch rendered diagrams.
* Supports GET, POST, and adaptive (GET with POST fallback when the URI is too long) strategies.
*/
export declare class KrokiClient {
maxUriLength: number;
httpClient: any;
method: any;
doc: any;
/**
* @param {Object} doc - Asciidoctor document whose attributes configure the client
* (`kroki-server-url`, `kroki-http-method`, `kroki-max-uri-length`).
* @param {Object} httpClient - HTTP adapter exposing `get(uri, headers, encoding)` and
* `post(uri, body, headers, encoding)` methods.
*/
constructor(doc: any, httpClient: any);
/**
* Fetches the diagram from Kroki and returns its content as a UTF-8 string.
* Typically used for text-based formats such as SVG.
*
* @param {KrokiDiagram} krokiDiagram - Diagram to render.
* @returns {Promise<string>} Rendered diagram content.
*/
getTextContent(krokiDiagram: KrokiDiagram): Promise<string>;
/**
* Fetches the rendered diagram from Kroki using the configured HTTP method strategy.
*
* In `adaptive` mode the request is sent as GET; if the resulting URI exceeds
* {@link KrokiClient#maxUriLength} the diagram source is sent via POST instead.
* In `get` mode GET is always used (the server may respond with 414 for very long URIs).
* In `post` mode POST is always used.
*
* @param {KrokiDiagram} krokiDiagram - Diagram to render.
* @param {BufferEncoding|null} encoding - Encoding for the response body, or `null` for binary.
* @returns {Promise<string>} Rendered diagram content.
*/
getImage(krokiDiagram: KrokiDiagram, encoding: BufferEncoding | null): Promise<string>;
/**
* Returns the Kroki server URL, falling back to `https://kroki.io` when the
* `kroki-server-url` document attribute is not set.
*
* @returns {string} Kroki server base URL.
*/
getServerUrl(): string;
}
//# sourceMappingURL=kroki-client.d.ts.map