diff options
| -rw-r--r-- | .gitignore | 7 | ||||
| -rw-r--r-- | CHANGELOG | 6 | ||||
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | dist/configuration.d.ts | 264 | ||||
| -rw-r--r-- | dist/image_type.d.ts | 6 | ||||
| -rw-r--r-- | dist/index.d.ts | 18 | ||||
| -rw-r--r-- | dist/patterns.d.ts | 16 | ||||
| -rw-r--r-- | dist/renderer.d.ts | 7 | ||||
| -rw-r--r-- | dist/smart-label-positioning.d.ts | 38 | ||||
| -rw-r--r-- | dist/stage_type.d.ts | 276 | ||||
| -rw-r--r-- | dist/utils.d.ts | 6 | ||||
| -rw-r--r-- | package.json | 3 | ||||
| -rw-r--r-- | test-output-no-bg.png | bin | 204982 -> 0 bytes | |||
| -rw-r--r-- | test-output.jpeg | bin | 325379 -> 0 bytes | |||
| -rw-r--r-- | test-output.pdf | bin | 136718 -> 0 bytes | |||
| -rw-r--r-- | test-output.png | bin | 204929 -> 0 bytes |
16 files changed, 353 insertions, 300 deletions
@@ -1,4 +1,5 @@ node_modules -test_output.pdf -test_output.png -test_output.jpeg +test-output-no-bg.png +test-output.pdf +test-output.png +test-output.jpeg @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## 1.0.1 - 2025-12-16 + +### Added + +* Add types + ## 1.0.0 - 2025-12-16 ### Added @@ -76,7 +76,11 @@ const jpegStream = await renderToImage(map, ImageType.JPEG, StageType.UBIQUITY); jpegStream.pipe(fs.createWriteStream("map.jpeg")); // PDF, with a stage type override -const pdfStream = await renderToImage(map, ImageType.PDF, StageType.PUBLICATION_TYPES); +const pdfStream = await renderToImage( + map, + ImageType.PDF, + StageType.PUBLICATION_TYPES, +); pdfStream.pipe(fs.createWriteStream("map.pdf")); ``` diff --git a/dist/configuration.d.ts b/dist/configuration.d.ts index af84a53..e956709 100644 --- a/dist/configuration.d.ts +++ b/dist/configuration.d.ts @@ -9,171 +9,171 @@ export function extendConfiguration(overrides?: tConfiguration): tConfiguration; * The configuration options to control the render. */ export type tConfiguration = { - /** - * - Options that control how the map is rendered. - */ - options: tConfigurationOptions; - /** - * - Options that control the look of the map. - */ - theme: tConfigurationTheme; + /** + * - Options that control how the map is rendered. + */ + options: tConfigurationOptions; + /** + * - Options that control the look of the map. + */ + theme: tConfigurationTheme; }; /** * Options that control how the map is rendered */ export type tConfigurationOptions = { - /** - * - Whether to render the background patterns. - */ - showBackground: boolean; - /** - * - Whether to activate smart label positioning. - */ - smartLabelPositioning: boolean; + /** + * - Whether to render the background patterns. + */ + showBackground: boolean; + /** + * - Whether to activate smart label positioning. + */ + smartLabelPositioning: boolean; }; /** * Options that control how the map is rendered */ export type tConfigurationTheme = { - /** - * - The colors of map elements. - */ - colors: tConfigurationThemeColors; - /** - * - The sizes of map elements. - */ - sizes: tConfigurationThemeSizes; - /** - * - The font family and sizes. - */ - fonts: tConfigurationThemeFonts; - /** - * - The line heights of map text. - */ - lineHeights: tConfigurationThemeLineHeights; - /** - * - Opacity of map elements. - */ - opacity: tConfigurationThemeOpacity; + /** + * - The colors of map elements. + */ + colors: tConfigurationThemeColors; + /** + * - The sizes of map elements. + */ + sizes: tConfigurationThemeSizes; + /** + * - The font family and sizes. + */ + fonts: tConfigurationThemeFonts; + /** + * - The line heights of map text. + */ + lineHeights: tConfigurationThemeLineHeights; + /** + * - Opacity of map elements. + */ + opacity: tConfigurationThemeOpacity; }; /** * The colors of map elements */ export type tConfigurationThemeColors = { - /** - * - The color of the background. - */ - background: string; - /** - * : - The color of the axis lines at the edge of the map. - */ - axis: string; - /** - * - The color of component shapes. - */ - vertex: string; - /** - * - The color of component labels. - */ - label: string; - /** - * - The first color of the stage bitmap when the background is drawn. - */ - stageForeground: string; - /** - * - The second color of the stage bitmap when the background is drawn. - */ - stageBackground: string; - /** - * - The color of the inertia element. - */ - inertia: string; - /** - * - The color of the evolution arrow. - */ - evolution: string; - /** - * - A list of colors to use for groups. - */ - groups: Array<string>; + /** + * - The color of the background. + */ + background: string; + /** + * : - The color of the axis lines at the edge of the map. + */ + axis: string; + /** + * - The color of component shapes. + */ + vertex: string; + /** + * - The color of component labels. + */ + label: string; + /** + * - The first color of the stage bitmap when the background is drawn. + */ + stageForeground: string; + /** + * - The second color of the stage bitmap when the background is drawn. + */ + stageBackground: string; + /** + * - The color of the inertia element. + */ + inertia: string; + /** + * - The color of the evolution arrow. + */ + evolution: string; + /** + * - A list of colors to use for groups. + */ + groups: Array<string>; }; /** * The sizes of map elements */ export type tConfigurationThemeSizes = { - /** - * - The width of the map. - */ - mapWidth: number; - /** - * - The height of the map. - */ - mapHeight: number; - /** - * - The padding around the map for axis labels. - */ - padding: number; - /** - * - The default line width. - */ - lineWidth: number; - /** - * - Width of component shapes. - */ - vertexWidth: number; - /** - * - Height of component shapes. - */ - vertexHeight: number; - /** - * - Size of arrowheads. - */ - arrowheadSize: number; - /** - * - Height of stage lines. - */ - stageHeight: number; + /** + * - The width of the map. + */ + mapWidth: number; + /** + * - The height of the map. + */ + mapHeight: number; + /** + * - The padding around the map for axis labels. + */ + padding: number; + /** + * - The default line width. + */ + lineWidth: number; + /** + * - Width of component shapes. + */ + vertexWidth: number; + /** + * - Height of component shapes. + */ + vertexHeight: number; + /** + * - Size of arrowheads. + */ + arrowheadSize: number; + /** + * - Height of stage lines. + */ + stageHeight: number; }; /** * The sizes of map elements */ export type tConfigurationThemeFonts = { - /** - * - The font family to use, in CSS form. - */ - family: string; - /** - * - Font size of the axis labels. - */ - axisLabel: number; - /** - * - Font size of vertex labels. - */ - vertexLabel: number; - /** - * - Font size of note text. - */ - note: number; + /** + * - The font family to use, in CSS form. + */ + family: string; + /** + * - Font size of the axis labels. + */ + axisLabel: number; + /** + * - Font size of vertex labels. + */ + vertexLabel: number; + /** + * - Font size of note text. + */ + note: number; }; /** * The line heights of map text */ export type tConfigurationThemeLineHeights = { - /** - * - Line height of vertex labels. - */ - vertexLabel: number; - /** - * - Line height of note text. - */ - note: number; + /** + * - Line height of vertex labels. + */ + vertexLabel: number; + /** + * - Line height of note text. + */ + note: number; }; /** * The opacity of map elements. */ export type tConfigurationThemeOpacity = { - /** - * - Opacity of the color in groups - */ - groups: number; + /** + * - Opacity of the color in groups + */ + groups: number; }; diff --git a/dist/image_type.d.ts b/dist/image_type.d.ts index 93aa767..e22ce59 100644 --- a/dist/image_type.d.ts +++ b/dist/image_type.d.ts @@ -3,7 +3,7 @@ */ export type ImageType = string; export namespace ImageType { - let PNG: string; - let JPEG: string; - let PDF: string; + let PNG: string; + let JPEG: string; + let PDF: string; } diff --git a/dist/index.d.ts b/dist/index.d.ts index 5aa1192..f33fac9 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -34,7 +34,12 @@ * const canvas = createCanvas(1384, 1084); * await renderToCanvas(map, canvas); */ -export function renderToCanvas(map: ParsedMap, canvas: HTMLCanvasElement | Canvas, stageType?: StageType, overrides?: tConfiguration): Promise<void>; +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 @@ -51,15 +56,20 @@ export function renderToCanvas(map: ParsedMap, canvas: HTMLCanvasElement | Canva * * @example * import { parse } from 'wmap-parser'; - * import { renderToImage } from 'wmap-renderer-canvas'; + * import { renderToImage, ImageType } from 'wmap-renderer-canvas'; * import fs from 'fs'; * * const map = parse(wmapSource); - * const stream = await renderToImage(map, 'png'); + * const stream = await renderToImage(map, ImageType.PNG); * const out = fs.createWriteStream('map.png'); * stream.pipe(out); */ -export function renderToImage(map: ParsedMap, imageType?: ImageType, stageType?: StageType, overrides?: tConfiguration): Promise<Stream>; +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; diff --git a/dist/patterns.d.ts b/dist/patterns.d.ts index bf5188a..6990d1f 100644 --- a/dist/patterns.d.ts +++ b/dist/patterns.d.ts @@ -7,10 +7,16 @@ * @param {string} bgColor - Background color (for 1 values) * @returns {Promise<CanvasPattern>} Canvas pattern */ -export function createPattern(ctx: CanvasRenderingContext2D, patternData: Array<number>, pixelSize: number, fgColor: string, bgColor: string): Promise<CanvasPattern>; +export function createPattern( + ctx: CanvasRenderingContext2D, + patternData: Array<number>, + pixelSize: number, + fgColor: string, + bgColor: string, +): Promise<CanvasPattern>; export namespace patterns { - let stitch: number[]; - let shingles: number[]; - let shadowGrid: number[]; - let wicker: number[]; + let stitch: number[]; + let shingles: number[]; + let shadowGrid: number[]; + let wicker: number[]; } diff --git a/dist/renderer.d.ts b/dist/renderer.d.ts index eb4102a..bf14bfb 100644 --- a/dist/renderer.d.ts +++ b/dist/renderer.d.ts @@ -6,7 +6,12 @@ * @param {tConfiguration} configuration - Configuration object * @returns {Promise<void>} */ -export function render(map: ParsedMap, ctx: CanvasRenderingContext2D, stageType: StageType, configuration: tConfiguration): Promise<void>; +export function render( + map: ParsedMap, + ctx: CanvasRenderingContext2D, + stageType: StageType, + configuration: tConfiguration, +): Promise<void>; export type tConfiguration = import("./configuration.js").tConfiguration; export type StageType = import("./stage_type.js").StageType; export type ParsedMap = import("wmap-parser").Map; diff --git a/dist/smart-label-positioning.d.ts b/dist/smart-label-positioning.d.ts index 32ba4fd..c1774a1 100644 --- a/dist/smart-label-positioning.d.ts +++ b/dist/smart-label-positioning.d.ts @@ -9,19 +9,31 @@ * @param {Array} inertiaRects - Pre-collected inertia rectangles * @returns {Object} Position object with x, y coordinates in pixels */ -export function calculateOptimalLabelPosition(component: any, mapData: any, config: any, ctx: CanvasRenderingContext2D, allLines: any[], noteRects: any[], inertiaRects: any[]): any; +export function calculateOptimalLabelPosition( + component: any, + mapData: any, + config: any, + ctx: CanvasRenderingContext2D, + allLines: any[], + noteRects: any[], + inertiaRects: any[], +): any; /** * Collect all lines from edges, evolutions, inertias, and axes */ -export function collectAllLines(mapData: any, config: any, componentMap: any): { - start: { - x: number; - y: any; - }; - end: { - x: any; - y: any; - }; +export function collectAllLines( + mapData: any, + config: any, + componentMap: any, +): { + start: { + x: number; + y: any; + }; + end: { + x: any; + y: any; + }; }[]; /** * Collect all note rectangles @@ -30,4 +42,8 @@ export function collectNoteRects(mapData: any, config: any, ctx: any): any; /** * Collect all inertia rectangles */ -export function collectInertiaRects(mapData: any, config: any, componentMap: any): any; +export function collectInertiaRects( + mapData: any, + config: any, + componentMap: any, +): any; diff --git a/dist/stage_type.d.ts b/dist/stage_type.d.ts index 24a5e77..764322b 100644 --- a/dist/stage_type.d.ts +++ b/dist/stage_type.d.ts @@ -3,147 +3,147 @@ */ export type StageType = tStageType; export namespace StageType { - namespace BEHAVIOR { - let name: string; - let stages: string[]; - } - namespace CERTAINTY { - let name_1: string; - export { name_1 as name }; - let stages_1: string[]; - export { stages_1 as stages }; - } - namespace COMPARISON { - let name_2: string; - export { name_2 as name }; - let stages_2: string[]; - export { stages_2 as stages }; - } - namespace CYNEFIN { - let name_3: string; - export { name_3 as name }; - let stages_3: string[]; - export { stages_3 as stages }; - } - namespace DATA { - let name_4: string; - export { name_4 as name }; - let stages_4: string[]; - export { stages_4 as stages }; - } - namespace DECISION_DRIVERS { - let name_5: string; - export { name_5 as name }; - let stages_5: string[]; - export { stages_5 as stages }; - } - namespace EFFICIENCY { - let name_6: string; - export { name_6 as name }; - let stages_6: string[]; - export { stages_6 as stages }; - } - namespace FAILURE { - let name_7: string; - export { name_7 as name }; - let stages_7: string[]; - export { stages_7 as stages }; - } - namespace FOCUS_OF_VALUE { - let name_8: string; - export { name_8 as name }; - let stages_8: string[]; - export { stages_8 as stages }; - } - namespace ACTIVITIES { - let name_9: string; - export { name_9 as name }; - let stages_9: string[]; - export { stages_9 as stages }; - } - namespace KNOWLEDGE_MANAGEMENT { - let name_10: string; - export { name_10 as name }; - let stages_10: string[]; - export { stages_10 as stages }; - } - namespace KNOWLEDGE { - let name_11: string; - export { name_11 as name }; - let stages_11: string[]; - export { stages_11 as stages }; - } - namespace MARKET_ACTION { - let name_12: string; - export { name_12 as name }; - let stages_12: string[]; - export { stages_12 as stages }; - } - namespace MARKET_PERCEPTION { - let name_13: string; - export { name_13 as name }; - let stages_13: string[]; - export { stages_13 as stages }; - } - namespace MARKET { - let name_14: string; - export { name_14 as name }; - let stages_14: string[]; - export { stages_14 as stages }; - } - namespace PERCEPTION_IN_INDUSTRY { - let name_15: string; - export { name_15 as name }; - let stages_15: string[]; - export { stages_15 as stages }; - } - namespace EVOLUTION_STAGE { - let name_16: string; - export { name_16 as name }; - let stages_16: string[]; - export { stages_16 as stages }; - } - namespace PRACTICE { - let name_17: string; - export { name_17 as name }; - let stages_17: string[]; - export { stages_17 as stages }; - } - namespace PUBLICATION_TYPES { - let name_18: string; - export { name_18 as name }; - let stages_18: string[]; - export { stages_18 as stages }; - } - namespace UBIQUITY { - let name_19: string; - export { name_19 as name }; - let stages_19: string[]; - export { stages_19 as stages }; - } - namespace UNDERSTANDING { - let name_20: string; - export { name_20 as name }; - let stages_20: string[]; - export { stages_20 as stages }; - } - namespace USER_PERCEPTION { - let name_21: string; - export { name_21 as name }; - let stages_21: string[]; - export { stages_21 as stages }; - } + namespace BEHAVIOR { + let name: string; + let stages: string[]; + } + namespace CERTAINTY { + let name_1: string; + export { name_1 as name }; + let stages_1: string[]; + export { stages_1 as stages }; + } + namespace COMPARISON { + let name_2: string; + export { name_2 as name }; + let stages_2: string[]; + export { stages_2 as stages }; + } + namespace CYNEFIN { + let name_3: string; + export { name_3 as name }; + let stages_3: string[]; + export { stages_3 as stages }; + } + namespace DATA { + let name_4: string; + export { name_4 as name }; + let stages_4: string[]; + export { stages_4 as stages }; + } + namespace DECISION_DRIVERS { + let name_5: string; + export { name_5 as name }; + let stages_5: string[]; + export { stages_5 as stages }; + } + namespace EFFICIENCY { + let name_6: string; + export { name_6 as name }; + let stages_6: string[]; + export { stages_6 as stages }; + } + namespace FAILURE { + let name_7: string; + export { name_7 as name }; + let stages_7: string[]; + export { stages_7 as stages }; + } + namespace FOCUS_OF_VALUE { + let name_8: string; + export { name_8 as name }; + let stages_8: string[]; + export { stages_8 as stages }; + } + namespace ACTIVITIES { + let name_9: string; + export { name_9 as name }; + let stages_9: string[]; + export { stages_9 as stages }; + } + namespace KNOWLEDGE_MANAGEMENT { + let name_10: string; + export { name_10 as name }; + let stages_10: string[]; + export { stages_10 as stages }; + } + namespace KNOWLEDGE { + let name_11: string; + export { name_11 as name }; + let stages_11: string[]; + export { stages_11 as stages }; + } + namespace MARKET_ACTION { + let name_12: string; + export { name_12 as name }; + let stages_12: string[]; + export { stages_12 as stages }; + } + namespace MARKET_PERCEPTION { + let name_13: string; + export { name_13 as name }; + let stages_13: string[]; + export { stages_13 as stages }; + } + namespace MARKET { + let name_14: string; + export { name_14 as name }; + let stages_14: string[]; + export { stages_14 as stages }; + } + namespace PERCEPTION_IN_INDUSTRY { + let name_15: string; + export { name_15 as name }; + let stages_15: string[]; + export { stages_15 as stages }; + } + namespace EVOLUTION_STAGE { + let name_16: string; + export { name_16 as name }; + let stages_16: string[]; + export { stages_16 as stages }; + } + namespace PRACTICE { + let name_17: string; + export { name_17 as name }; + let stages_17: string[]; + export { stages_17 as stages }; + } + namespace PUBLICATION_TYPES { + let name_18: string; + export { name_18 as name }; + let stages_18: string[]; + export { stages_18 as stages }; + } + namespace UBIQUITY { + let name_19: string; + export { name_19 as name }; + let stages_19: string[]; + export { stages_19 as stages }; + } + namespace UNDERSTANDING { + let name_20: string; + export { name_20 as name }; + let stages_20: string[]; + export { stages_20 as stages }; + } + namespace USER_PERCEPTION { + let name_21: string; + export { name_21 as name }; + let stages_21: string[]; + export { stages_21 as stages }; + } } /** * The definition of a stage type used to analyze different aspects of a map. */ export type tStageType = { - /** - * - The name of the stage type - */ - name: string; - /** - * - The four stages - */ - stages: [string, string, string, string]; + /** + * - The name of the stage type + */ + name: string; + /** + * - The four stages + */ + stages: [string, string, string, string]; }; diff --git a/dist/utils.d.ts b/dist/utils.d.ts index 7769666..0fec858 100644 --- a/dist/utils.d.ts +++ b/dist/utils.d.ts @@ -18,4 +18,8 @@ export function getStageValues(stageOverrides: any[]): Array<number>; * @param {number} mapHeight - Map height in pixels * @returns {Map} Pixel value */ -export function createComponentMap(components: any, width: any, height: any): Map<any, any>; +export function createComponentMap( + components: any, + width: any, + height: any, +): Map<any, any>; diff --git a/package.json b/package.json index bb3ed0a..79a4cf3 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "wmap-renderer-canvas", - "version": "1.0.0", + "version": "1.0.1", "description": "Canvas renderer for parsed wardley maps.", "type": "module", "main": "src/index.js", + "types": "dist/index.d.ts", "scripts": {}, "keywords": [ "Wardley Maps", diff --git a/test-output-no-bg.png b/test-output-no-bg.png Binary files differdeleted file mode 100644 index 37f3426..0000000 --- a/test-output-no-bg.png +++ /dev/null diff --git a/test-output.jpeg b/test-output.jpeg Binary files differdeleted file mode 100644 index 77418d5..0000000 --- a/test-output.jpeg +++ /dev/null diff --git a/test-output.pdf b/test-output.pdf Binary files differdeleted file mode 100644 index 095c265..0000000 --- a/test-output.pdf +++ /dev/null diff --git a/test-output.png b/test-output.png Binary files differdeleted file mode 100644 index a0b059a..0000000 --- a/test-output.png +++ /dev/null |