@bpmnkit/core 1.13.0 → 1.14.0

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/README.md CHANGED
@@ -394,6 +394,7 @@ const { serviceTask, problems } = applyConnectorTemplate("io.camunda.connectors.
394
394
  | [`@bpmnkit/api`](https://www.npmjs.com/package/@bpmnkit/api) | Camunda 8 REST API TypeScript client |
395
395
  | [`@bpmnkit/ascii`](https://www.npmjs.com/package/@bpmnkit/ascii) | Render BPMN diagrams as Unicode ASCII art |
396
396
  | [`@bpmnkit/markdown`](https://www.npmjs.com/package/@bpmnkit/markdown) | BPMN diagrams in Markdown — remark, markdown-it and README pre-rendering |
397
+ | [`@bpmnkit/viewer-lite`](https://www.npmjs.com/package/@bpmnkit/viewer-lite) | 8.5 KB BPMN viewer for one self-contained HTML file |
397
398
  | [`@bpmnkit/docspack`](https://www.npmjs.com/package/@bpmnkit/docspack) | BPMN Kit docs as an offline docspack package for AI agents |
398
399
  | [`@bpmnkit/camunda-docspack`](https://www.npmjs.com/package/@bpmnkit/camunda-docspack) | Camunda 8 docs as an offline docspack package for AI agents |
399
400
  | [`@bpmnkit/ui`](https://www.npmjs.com/package/@bpmnkit/ui) | Shared design tokens and UI components |
@@ -0,0 +1,155 @@
1
+ import type { BpmnBounds, BpmnDefinitions, BpmnFlowElement } from "./bpmn-model.js";
2
+ import { type BpmnLabelFont, type LabelFontCss } from "./label-style.js";
3
+ /** The model `exportSvg` draws, for `@bpmnkit/core/svg` users. */
4
+ export type { BpmnDefinitions } from "./bpmn-model.js";
5
+ /** The colours a theme is made of. Pass one as `theme` for a custom palette. */
6
+ export interface SvgThemeColors {
7
+ bg: string;
8
+ shapeFill: string;
9
+ shapeStroke: string;
10
+ flowStroke: string;
11
+ text: string;
12
+ poolHeader: string;
13
+ textHalo: string;
14
+ }
15
+ type Theme = SvgThemeColors;
16
+ /** Theme colours plus the resolved font settings every text helper needs. */
17
+ export interface SvgCtx extends Theme {
18
+ fontFamily: string;
19
+ fontSize: number;
20
+ lineH: number;
21
+ }
22
+ /** The built-in palettes, so a custom theme can start from one. */
23
+ export declare const SVG_THEMES: {
24
+ readonly light: SvgThemeColors;
25
+ readonly dark: SvgThemeColors;
26
+ };
27
+ export interface SvgExportOptions {
28
+ /** Visual theme: a preset name or a full custom palette. Default: "light". */
29
+ theme?: "light" | "dark" | SvgThemeColors;
30
+ /** Padding around the diagram content in pixels. Default: 20. */
31
+ padding?: number;
32
+ /** Multiplies `width`/`height` only; the viewBox is unchanged. Default: 1. */
33
+ scale?: number;
34
+ /**
35
+ * Fit-inside box `[width, height]` (e.g. a chat thumbnail). Applied after
36
+ * `scale`; never upscales. Only `width`/`height` change.
37
+ */
38
+ maxSize?: [number, number];
39
+ /**
40
+ * `"di"` honours `bioc:`/`color:` fill and stroke from the diagram interchange.
41
+ * Default: `"ignore"`.
42
+ */
43
+ colors?: "ignore" | "di";
44
+ /**
45
+ * Which plane to draw. `{ id }` matches a `BPMNDiagram` or plane id,
46
+ * `{ process }` the element a plane points at (e.g. a collapsed sub-process).
47
+ * Default: the first diagram. Throws when nothing matches.
48
+ */
49
+ plane?: {
50
+ id: string;
51
+ } | {
52
+ process: string;
53
+ };
54
+ /** Lay out the model first when the chosen plane has no shapes. Default: false. */
55
+ autoLayout?: boolean;
56
+ /**
57
+ * The layout `autoLayout` runs. `exportSvg` from `@bpmnkit/core` defaults it
58
+ * to the semantic auto-layout; `@bpmnkit/core/svg` has none, so it stays out
59
+ * of small bundles, and `autoLayout` without `layout` draws nothing new.
60
+ */
61
+ layout?: (defs: BpmnDefinitions) => BpmnDefinitions;
62
+ /**
63
+ * Reads the `bpmndi:BPMNLabelStyle` fonts labels refer to. `exportSvg` from
64
+ * `@bpmnkit/core` defaults it to `collectLabelStyles`; `@bpmnkit/core/svg`
65
+ * has none, so every label gets the default font.
66
+ */
67
+ labelStyles?: (defs: BpmnDefinitions) => ReadonlyMap<string, BpmnLabelFont>;
68
+ /** Label font. Defaults: `system-ui,-apple-system,sans-serif`, 11px, 14px line height. */
69
+ font?: {
70
+ family?: string;
71
+ size?: number;
72
+ lineHeight?: number;
73
+ };
74
+ /** Add `data-element-id="…"` to each element's `<g>`/`<path>`. Default: false. */
75
+ elementIds?: boolean;
76
+ /** `false` omits the background `<rect>` (transparent). Default: true. */
77
+ background?: boolean;
78
+ }
79
+ export type SvgElementKind = BpmnFlowElement["type"] | "sequenceFlow" | "messageFlow" | "association" | "participant" | "lane" | "textAnnotation" | "group";
80
+ export type SvgGeometry = {
81
+ kind: "shape";
82
+ bounds: BpmnBounds;
83
+ } | {
84
+ kind: "edge";
85
+ waypoints: Array<[number, number]>;
86
+ };
87
+ /** An element that was actually drawn. */
88
+ export interface SvgRenderedElement {
89
+ id: string;
90
+ kind: SvgElementKind;
91
+ geometry: SvgGeometry;
92
+ }
93
+ export type SvgWarning = {
94
+ type: "autoLayoutApplied";
95
+ } | {
96
+ type: "elementWithoutDi";
97
+ id: string;
98
+ };
99
+ export interface SvgExportResult {
100
+ svg: string;
101
+ viewBox: {
102
+ x: number;
103
+ y: number;
104
+ w: number;
105
+ h: number;
106
+ };
107
+ /** CSS px after `scale` and `maxSize`. */
108
+ width: number;
109
+ height: number;
110
+ elements: SvgRenderedElement[];
111
+ warnings: SvgWarning[];
112
+ }
113
+ /**
114
+ * {@link exportSvgDetailed}`.svg`. Unlike the `@bpmnkit/core` export, `autoLayout`
115
+ * needs an explicit `layout` here.
116
+ */
117
+ export declare function exportSvg(defs: BpmnDefinitions, options?: SvgExportOptions): string;
118
+ /** Like {@link exportSvg}, plus the drawn size, viewBox, element geometry and warnings. */
119
+ export declare function exportSvgDetailed(input: BpmnDefinitions, options?: SvgExportOptions): SvgExportResult;
120
+ /** @internal Theme colours and font settings from the shared export options. */
121
+ export declare function resolveCtx(options: Pick<SvgExportOptions, "theme" | "font"> | undefined): SvgCtx;
122
+ /** @internal `width`/`height` after `scale` and `maxSize` (the viewBox never changes). */
123
+ export declare function fitSize(vw: number, vh: number, options: Pick<SvgExportOptions, "scale" | "maxSize"> | undefined): {
124
+ width: number;
125
+ height: number;
126
+ };
127
+ /** Estimated glyph width for a label font — scaled from the 11px default. */
128
+ /** @internal */
129
+ export declare function charPx(font: LabelFontCss | undefined, t: SvgCtx): number;
130
+ /** @internal */
131
+ export declare function wrapText(text: string, maxPx: number, charW?: number): string[];
132
+ /** @internal */
133
+ export declare function esc(s: string): string;
134
+ /** @internal */
135
+ export declare function fontStyle(font: LabelFontCss | undefined, t: SvgCtx): string;
136
+ /**
137
+ * Generates SVG text element(s) for a label centred at (cx, cy).
138
+ * topAlign=true makes multi-line text flow downward from cy rather than
139
+ * being centred around it — prevents long labels from overlapping the shape above.
140
+ */
141
+ /** @internal */
142
+ export declare function labelSvg(text: string, cx: number, cy: number, maxWidth: number, t: SvgCtx, topAlign?: boolean, font?: LabelFontCss): string;
143
+ /** @internal */
144
+ export declare function shapeStyle(t: SvgCtx, sw?: number, dash?: string): string;
145
+ /** @internal */
146
+ export declare function iconStyle(t: SvgCtx): string;
147
+ /**
148
+ * Wraps raw icon SVG (which uses class="bi", "bis", "gm", "gms")
149
+ * in a `<g>` that provides those class definitions as inline style overrides.
150
+ * CSS classes cannot be used in standalone SVGs, so we map them to inline styles
151
+ * via a local `<style>` element scoped to the enclosing `<g>`.
152
+ */
153
+ /** @internal */
154
+ export declare function iconGroup(content: string, x: number, y: number, t: SvgCtx): string;
155
+ //# sourceMappingURL=svg-render.d.ts.map