diff options
| author | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-15 16:30:22 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-16 00:19:32 +0100 |
| commit | 566eb2c9cce799ed8a3becc6d81560f1540eaacf (patch) | |
| tree | 4a711b16ff15c61842856a2bf2b830079f30bbcf /dist/index.d.ts | |
Initial Release
Diffstat (limited to 'dist/index.d.ts')
| -rw-r--r-- | dist/index.d.ts | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..5aa1192 --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,71 @@ +/** + * @typedef {import('./configuration.js').tConfiguration} tConfiguration + * @typedef {import('./image_type.js').ImageType} ImageType + * @typedef {import('./stage_type.js').StageType} StageType + * @typedef {import('wmap-parser').Map} ParsedMap + * @typedef {import('canvas').Canvas} Canvas + */ +/** + * Render a parsed Wardley map to a canvas element + * Works in both browser and Node.js environments + * + * @param {ParsedMap} map - Parsed map object from wmap-parser + * @param {HTMLCanvasElement|Canvas} canvas - Canvas element (browser) or Canvas instance (Node.js) + * @param {StageType} [stageType=StageType.ACTIVITIES] - The labels to use for each stage in the map. + * @param {tConfiguration} overrides - User configuration overrides + * @returns {Promise<void>} + * + * @example + * // Browser + * import { parse } from 'wmap-parser'; + * import { renderToCanvas } from 'wmap-renderer-canvas'; + * + * const map = parse(wmapSource); + * const canvas = document.getElementById('myCanvas'); + * await renderToCanvas(map, canvas); + * + * @example + * // Node.js + * import { createCanvas } from 'canvas'; + * import { parse } from 'wmap-parser'; + * import { renderToCanvas } from 'wmap-renderer-canvas'; + * + * const map = parse(wmapSource); + * const canvas = createCanvas(1384, 1084); + * await renderToCanvas(map, canvas); + */ +export function renderToCanvas(map: ParsedMap, canvas: HTMLCanvasElement | Canvas, stageType?: StageType, overrides?: tConfiguration): Promise<void>; +/** + * Render a parsed Wardley map to an image stream + * Only available in Node.js environments + * + * @param {ParsedMap} map - Parsed map object from wmap-parser + * @param {ImageType} imageType - Output image format ('png', 'jpeg', or 'pdf') + * @param {StageType} [stageType=StageType.ACTIVITIES] - The labels to use for each stage in the map. + * @param {tConfiguration} overrides - User configuration overrides + * @returns {Promise<Stream>} Stream of the rendered image + * + * @throws {Error} If not in Node.js environment + * @throws {Error} If canvas module is not available + * @throws {Error} If imageType is not supported + * + * @example + * import { parse } from 'wmap-parser'; + * import { renderToImage } from 'wmap-renderer-canvas'; + * import fs from 'fs'; + * + * const map = parse(wmapSource); + * const stream = await renderToImage(map, 'png'); + * const out = fs.createWriteStream('map.png'); + * stream.pipe(out); + */ +export function renderToImage(map: ParsedMap, imageType?: ImageType, stageType?: StageType, overrides?: tConfiguration): Promise<Stream>; +export type ImageType = import("./image_type.js").ImageType; +export { ImageType } from "./image_type.js"; +export type StageType = import("./stage_type.js").StageType; +export { StageType } from "./stage_type.js"; +export type tConfiguration = import("./configuration.js").tConfiguration; +export type ParsedMap = import("wmap-parser").Map; +export type Canvas = import("canvas").Canvas; +import { StageType } from "./stage_type.js"; +import { ImageType } from "./image_type.js"; |