@bpmnkit/canvas 0.0.8 → 0.0.10
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/LICENSE +21 -0
- package/README.md +7 -3
- package/package.json +48 -29
- package/dist/minimap.d.ts +0 -37
- package/dist/minimap.js +0 -171
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 urbanisierung
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/
|
|
2
|
+
<img src="https://raw.githubusercontent.com/bpmnkit/monorepo/main/doc/logos/logo-2-gateway.svg" width="72" height="72" alt="BPMN Kit logo">
|
|
3
3
|
<h1>@bpmnkit/canvas</h1>
|
|
4
4
|
<p>Zero-dependency SVG BPMN viewer with pan/zoom, theming, and a plugin API</p>
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://github.com/bpmnkit/monorepo/blob/main/LICENSE)
|
|
8
8
|
[](https://github.com/bpmnkit/monorepo)
|
|
9
9
|
|
|
10
|
-
[Documentation](https://
|
|
10
|
+
[Website](https://bpmnkit.com) · [Documentation](https://docs.bpmnkit.com) · [GitHub](https://github.com/bpmnkit/monorepo) · [Changelog](https://github.com/bpmnkit/monorepo/blob/main/packages/canvas/CHANGELOG.md)
|
|
11
11
|
</div>
|
|
12
12
|
|
|
13
13
|
---
|
|
@@ -120,9 +120,13 @@ const myPlugin: CanvasPlugin = {
|
|
|
120
120
|
| [`@bpmnkit/plugins`](https://www.npmjs.com/package/@bpmnkit/plugins) | 22 composable canvas plugins |
|
|
121
121
|
| [`@bpmnkit/api`](https://www.npmjs.com/package/@bpmnkit/api) | Camunda 8 REST API TypeScript client |
|
|
122
122
|
| [`@bpmnkit/ascii`](https://www.npmjs.com/package/@bpmnkit/ascii) | Render BPMN diagrams as Unicode ASCII art |
|
|
123
|
+
| [`@bpmnkit/ui`](https://www.npmjs.com/package/@bpmnkit/ui) | Shared design tokens and UI components |
|
|
123
124
|
| [`@bpmnkit/profiles`](https://www.npmjs.com/package/@bpmnkit/profiles) | Shared auth, profile storage, and client factories for CLI & proxy |
|
|
124
125
|
| [`@bpmnkit/operate`](https://www.npmjs.com/package/@bpmnkit/operate) | Monitoring & operations frontend for Camunda clusters |
|
|
126
|
+
| [`@bpmnkit/connector-gen`](https://www.npmjs.com/package/@bpmnkit/connector-gen) | Generate connector templates from OpenAPI specs |
|
|
127
|
+
| [`@bpmnkit/cli`](https://www.npmjs.com/package/@bpmnkit/cli) | Camunda 8 command-line interface (casen) |
|
|
128
|
+
| [`@bpmnkit/proxy`](https://www.npmjs.com/package/@bpmnkit/proxy) | Local AI bridge and Camunda API proxy server |
|
|
125
129
|
|
|
126
130
|
## License
|
|
127
131
|
|
|
128
|
-
[MIT](https://github.com/bpmnkit/monorepo/blob/main/LICENSE) ©
|
|
132
|
+
[MIT](https://github.com/bpmnkit/monorepo/blob/main/LICENSE) © BPMN Kit — made by [u11g](https://u11g.com)
|
package/package.json
CHANGED
|
@@ -1,30 +1,49 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
"name": "@bpmnkit/canvas",
|
|
3
|
+
"version": "0.0.10",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"README.md",
|
|
16
|
+
"dist/**/*.js",
|
|
17
|
+
"dist/**/*.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@bpmnkit/core": "0.0.10"
|
|
21
|
+
},
|
|
22
|
+
"description": "Zero-dependency SVG BPMN viewer with pan/zoom, theming, and a plugin API",
|
|
23
|
+
"keywords": [
|
|
24
|
+
"bpmn",
|
|
25
|
+
"viewer",
|
|
26
|
+
"svg",
|
|
27
|
+
"canvas",
|
|
28
|
+
"workflow",
|
|
29
|
+
"typescript"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/bpmnkit/monorepo"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://bpmnkit.com",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/bpmnkit/monorepo/issues"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"check": "biome check .",
|
|
47
|
+
"test": "vitest run"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/dist/minimap.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { BpmnDefinitions } from "@bpmn-sdk/core";
|
|
2
|
-
import type { ViewportState } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* A scaled-down overview of the BPMN diagram that shows the current viewport
|
|
5
|
-
* position as a highlighted rectangle.
|
|
6
|
-
*
|
|
7
|
-
* Clicking the minimap pans the canvas to that position.
|
|
8
|
-
*/
|
|
9
|
-
export declare class Minimap {
|
|
10
|
-
/** Invoked when the user clicks the minimap to request a viewport pan. */
|
|
11
|
-
private readonly _onNavigate;
|
|
12
|
-
private readonly _host;
|
|
13
|
-
private readonly _svg;
|
|
14
|
-
private readonly _shapesG;
|
|
15
|
-
private readonly _edgesG;
|
|
16
|
-
private readonly _viewportRect;
|
|
17
|
-
private _scale;
|
|
18
|
-
private _offsetX;
|
|
19
|
-
private _offsetY;
|
|
20
|
-
private _diagramMinX;
|
|
21
|
-
private _diagramMinY;
|
|
22
|
-
private _diagramW;
|
|
23
|
-
private _diagramH;
|
|
24
|
-
private readonly _mmW;
|
|
25
|
-
private readonly _mmH;
|
|
26
|
-
constructor(container: HTMLElement,
|
|
27
|
-
/** Invoked when the user clicks the minimap to request a viewport pan. */
|
|
28
|
-
_onNavigate: (tx: number, ty: number) => void);
|
|
29
|
-
/** Updates the minimap with shapes and edges from a newly loaded diagram. */
|
|
30
|
-
update(defs: BpmnDefinitions): void;
|
|
31
|
-
/** Syncs the viewport indicator rectangle with the current pan/zoom state. */
|
|
32
|
-
syncViewport(state: ViewportState, svgWidth: number, svgHeight: number): void;
|
|
33
|
-
/** Removes the minimap from the DOM. */
|
|
34
|
-
destroy(): void;
|
|
35
|
-
private readonly _onClick;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=minimap.d.ts.map
|
package/dist/minimap.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
const NS = "http://www.w3.org/2000/svg";
|
|
2
|
-
function svgEl(tag) {
|
|
3
|
-
return document.createElementNS(NS, tag);
|
|
4
|
-
}
|
|
5
|
-
function attr(el, attrs) {
|
|
6
|
-
for (const [k, v] of Object.entries(attrs))
|
|
7
|
-
el.setAttribute(k, String(v));
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* A scaled-down overview of the BPMN diagram that shows the current viewport
|
|
11
|
-
* position as a highlighted rectangle.
|
|
12
|
-
*
|
|
13
|
-
* Clicking the minimap pans the canvas to that position.
|
|
14
|
-
*/
|
|
15
|
-
export class Minimap {
|
|
16
|
-
_onNavigate;
|
|
17
|
-
_host;
|
|
18
|
-
_svg;
|
|
19
|
-
_shapesG;
|
|
20
|
-
_edgesG;
|
|
21
|
-
_viewportRect;
|
|
22
|
-
// Minimap-space transform from diagram-space coordinates
|
|
23
|
-
_scale = 1;
|
|
24
|
-
_offsetX = 0;
|
|
25
|
-
_offsetY = 0;
|
|
26
|
-
// Diagram bounding box
|
|
27
|
-
_diagramMinX = 0;
|
|
28
|
-
_diagramMinY = 0;
|
|
29
|
-
_diagramW = 1;
|
|
30
|
-
_diagramH = 1;
|
|
31
|
-
// Minimap pixel dimensions
|
|
32
|
-
_mmW = 160;
|
|
33
|
-
_mmH = 100;
|
|
34
|
-
constructor(container,
|
|
35
|
-
/** Invoked when the user clicks the minimap to request a viewport pan. */
|
|
36
|
-
_onNavigate) {
|
|
37
|
-
this._onNavigate = _onNavigate;
|
|
38
|
-
this._host = document.createElement("div");
|
|
39
|
-
this._host.className = "bpmn-minimap";
|
|
40
|
-
this._host.setAttribute("aria-hidden", "true");
|
|
41
|
-
this._svg = document.createElementNS(NS, "svg");
|
|
42
|
-
attr(this._svg, {
|
|
43
|
-
viewBox: `0 0 ${this._mmW} ${this._mmH}`,
|
|
44
|
-
preserveAspectRatio: "none",
|
|
45
|
-
});
|
|
46
|
-
this._host.appendChild(this._svg);
|
|
47
|
-
this._edgesG = svgEl("g");
|
|
48
|
-
this._shapesG = svgEl("g");
|
|
49
|
-
this._viewportRect = svgEl("rect");
|
|
50
|
-
attr(this._viewportRect, { class: "bpmn-minimap-viewport", rx: 1 });
|
|
51
|
-
this._svg.appendChild(this._edgesG);
|
|
52
|
-
this._svg.appendChild(this._shapesG);
|
|
53
|
-
this._svg.appendChild(this._viewportRect);
|
|
54
|
-
container.appendChild(this._host);
|
|
55
|
-
this._host.addEventListener("click", this._onClick);
|
|
56
|
-
}
|
|
57
|
-
/** Updates the minimap with shapes and edges from a newly loaded diagram. */
|
|
58
|
-
update(defs) {
|
|
59
|
-
this._edgesG.innerHTML = "";
|
|
60
|
-
this._shapesG.innerHTML = "";
|
|
61
|
-
const plane = defs.diagrams[0]?.plane;
|
|
62
|
-
if (!plane)
|
|
63
|
-
return;
|
|
64
|
-
// Compute diagram bounding box
|
|
65
|
-
let minX = Number.POSITIVE_INFINITY;
|
|
66
|
-
let minY = Number.POSITIVE_INFINITY;
|
|
67
|
-
let maxX = Number.NEGATIVE_INFINITY;
|
|
68
|
-
let maxY = Number.NEGATIVE_INFINITY;
|
|
69
|
-
for (const s of plane.shapes) {
|
|
70
|
-
minX = Math.min(minX, s.bounds.x);
|
|
71
|
-
minY = Math.min(minY, s.bounds.y);
|
|
72
|
-
maxX = Math.max(maxX, s.bounds.x + s.bounds.width);
|
|
73
|
-
maxY = Math.max(maxY, s.bounds.y + s.bounds.height);
|
|
74
|
-
}
|
|
75
|
-
for (const e of plane.edges) {
|
|
76
|
-
for (const wp of e.waypoints) {
|
|
77
|
-
minX = Math.min(minX, wp.x);
|
|
78
|
-
minY = Math.min(minY, wp.y);
|
|
79
|
-
maxX = Math.max(maxX, wp.x);
|
|
80
|
-
maxY = Math.max(maxY, wp.y);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (!Number.isFinite(minX))
|
|
84
|
-
return;
|
|
85
|
-
const padding = 8;
|
|
86
|
-
const dW = maxX - minX;
|
|
87
|
-
const dH = maxY - minY;
|
|
88
|
-
const scaleX = (this._mmW - padding * 2) / dW;
|
|
89
|
-
const scaleY = (this._mmH - padding * 2) / dH;
|
|
90
|
-
this._scale = Math.min(scaleX, scaleY);
|
|
91
|
-
this._offsetX = padding + (this._mmW - padding * 2 - dW * this._scale) / 2 - minX * this._scale;
|
|
92
|
-
this._offsetY = padding + (this._mmH - padding * 2 - dH * this._scale) / 2 - minY * this._scale;
|
|
93
|
-
this._diagramMinX = minX;
|
|
94
|
-
this._diagramMinY = minY;
|
|
95
|
-
this._diagramW = dW;
|
|
96
|
-
this._diagramH = dH;
|
|
97
|
-
// Render simplified shapes (just rects/circles)
|
|
98
|
-
for (const s of plane.shapes) {
|
|
99
|
-
const x = s.bounds.x * this._scale + this._offsetX;
|
|
100
|
-
const y = s.bounds.y * this._scale + this._offsetY;
|
|
101
|
-
const w = s.bounds.width * this._scale;
|
|
102
|
-
const h = s.bounds.height * this._scale;
|
|
103
|
-
// Approximate shape type from size: very small square → event or gateway
|
|
104
|
-
const isSmall = w < 10;
|
|
105
|
-
if (isSmall) {
|
|
106
|
-
const circle = svgEl("circle");
|
|
107
|
-
attr(circle, {
|
|
108
|
-
cx: x + w / 2,
|
|
109
|
-
cy: y + h / 2,
|
|
110
|
-
r: Math.max(w / 2, 2),
|
|
111
|
-
class: "bpmn-minimap-shape",
|
|
112
|
-
});
|
|
113
|
-
this._shapesG.appendChild(circle);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
const rect = svgEl("rect");
|
|
117
|
-
attr(rect, {
|
|
118
|
-
x,
|
|
119
|
-
y,
|
|
120
|
-
width: Math.max(w, 1),
|
|
121
|
-
height: Math.max(h, 1),
|
|
122
|
-
rx: 1,
|
|
123
|
-
class: "bpmn-minimap-shape",
|
|
124
|
-
});
|
|
125
|
-
this._shapesG.appendChild(rect);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
// Render simplified edges
|
|
129
|
-
for (const e of plane.edges) {
|
|
130
|
-
if (e.waypoints.length < 2)
|
|
131
|
-
continue;
|
|
132
|
-
const pts = e.waypoints
|
|
133
|
-
.map((wp) => `${wp.x * this._scale + this._offsetX},${wp.y * this._scale + this._offsetY}`)
|
|
134
|
-
.join(" ");
|
|
135
|
-
const poly = svgEl("polyline");
|
|
136
|
-
attr(poly, { points: pts, class: "bpmn-minimap-edge" });
|
|
137
|
-
this._edgesG.appendChild(poly);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
/** Syncs the viewport indicator rectangle with the current pan/zoom state. */
|
|
141
|
-
syncViewport(state, svgWidth, svgHeight) {
|
|
142
|
-
// Visible diagram area in diagram coordinates
|
|
143
|
-
const left = -state.tx / state.scale;
|
|
144
|
-
const top = -state.ty / state.scale;
|
|
145
|
-
const visW = svgWidth / state.scale;
|
|
146
|
-
const visH = svgHeight / state.scale;
|
|
147
|
-
// Map to minimap coordinates
|
|
148
|
-
const mx = left * this._scale + this._offsetX;
|
|
149
|
-
const my = top * this._scale + this._offsetY;
|
|
150
|
-
const mw = visW * this._scale;
|
|
151
|
-
const mh = visH * this._scale;
|
|
152
|
-
attr(this._viewportRect, { x: mx, y: my, width: Math.max(mw, 2), height: Math.max(mh, 2) });
|
|
153
|
-
}
|
|
154
|
-
/** Removes the minimap from the DOM. */
|
|
155
|
-
destroy() {
|
|
156
|
-
this._host.removeEventListener("click", this._onClick);
|
|
157
|
-
this._host.remove();
|
|
158
|
-
}
|
|
159
|
-
_onClick = (e) => {
|
|
160
|
-
const rect = this._host.getBoundingClientRect();
|
|
161
|
-
const mmX = e.clientX - rect.left;
|
|
162
|
-
const mmY = e.clientY - rect.top;
|
|
163
|
-
// Convert minimap coordinates to diagram coordinates
|
|
164
|
-
const diagX = (mmX - this._offsetX) / this._scale;
|
|
165
|
-
const diagY = (mmY - this._offsetY) / this._scale;
|
|
166
|
-
// The requested diagram point should be centred in the SVG
|
|
167
|
-
// The caller determines the SVG size and computes the correct translation
|
|
168
|
-
this._onNavigate(diagX, diagY);
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
//# sourceMappingURL=minimap.js.map
|