@bpmnkit/core 1.11.0 → 1.13.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/dist/bpmn/bpmn-diff.d.ts +78 -0
- package/dist/bpmn/bpmn-diff.js +202 -0
- package/dist/bpmn/diff-html.d.ts +36 -0
- package/dist/bpmn/diff-html.js +182 -0
- package/dist/bpmn/svg.d.ts +128 -4
- package/dist/bpmn/svg.js +228 -48
- package/dist/dmn/svg.d.ts +25 -0
- package/dist/dmn/svg.js +282 -0
- package/dist/generated/diff-viewer.d.ts +6 -0
- package/dist/generated/diff-viewer.js +7 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +4 -1
- package/package.json +1 -1
package/dist/dmn/svg.js
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { esc, fitSize, fontStyle, iconStyle, labelSvg, resolveCtx, shapeStyle, wrapText, } from "../bpmn/svg.js";
|
|
2
|
+
import { layoutDmn } from "./dmn-layout.js";
|
|
3
|
+
function svgRoot(ox, oy, vw, vh, options, t, body, defs = []) {
|
|
4
|
+
const { width, height } = fitSize(vw, vh, options);
|
|
5
|
+
return [
|
|
6
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${ox} ${oy} ${vw} ${vh}" width="${width}" height="${height}">`,
|
|
7
|
+
...(options?.background !== false
|
|
8
|
+
? [`<rect x="${ox}" y="${oy}" width="${vw}" height="${vh}" fill="${t.bg}"/>`]
|
|
9
|
+
: []),
|
|
10
|
+
...(defs.length > 0 ? ["<defs>", ...defs, "</defs>"] : []),
|
|
11
|
+
...body,
|
|
12
|
+
"</svg>",
|
|
13
|
+
].join("\n");
|
|
14
|
+
}
|
|
15
|
+
function emptySvg(options, t) {
|
|
16
|
+
const rect = options?.background !== false ? `<rect width="1" height="1" fill="${t.bg}"/>` : "";
|
|
17
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1" width="1" height="1">${rect}</svg>`;
|
|
18
|
+
}
|
|
19
|
+
// ── DRD ───────────────────────────────────────────────────────────────────────
|
|
20
|
+
/**
|
|
21
|
+
* Generates a self-contained SVG of a DMN requirements diagram (DRD): decisions
|
|
22
|
+
* (rectangles), input data (stadiums), knowledge sources (wavy bottom), business
|
|
23
|
+
* knowledge models (clipped corners), and information (solid arrow), knowledge
|
|
24
|
+
* (dashed arrow) and authority (dotted, circle end) requirements.
|
|
25
|
+
*
|
|
26
|
+
* Definitions without diagram interchange are laid out with `layoutDmn` first.
|
|
27
|
+
*/
|
|
28
|
+
export function exportDrdSvg(input, options) {
|
|
29
|
+
const t = resolveCtx(options);
|
|
30
|
+
const padding = options?.padding ?? 20;
|
|
31
|
+
const withIds = options?.elementIds === true;
|
|
32
|
+
const idAttr = (id) => (withIds ? ` data-element-id="${esc(id)}"` : "");
|
|
33
|
+
const defs = input.diagram && input.diagram.shapes.length > 0 ? input : layoutDmn(input);
|
|
34
|
+
const diagram = defs.diagram;
|
|
35
|
+
if (!diagram || diagram.shapes.length === 0)
|
|
36
|
+
return emptySvg(options, t);
|
|
37
|
+
const kinds = new Map();
|
|
38
|
+
const names = new Map();
|
|
39
|
+
const note = (id, kind, name) => {
|
|
40
|
+
kinds.set(id, kind);
|
|
41
|
+
if (name)
|
|
42
|
+
names.set(id, name);
|
|
43
|
+
};
|
|
44
|
+
for (const d of defs.decisions)
|
|
45
|
+
note(d.id, "decision", d.name);
|
|
46
|
+
for (const d of defs.inputData)
|
|
47
|
+
note(d.id, "inputData", d.name);
|
|
48
|
+
for (const k of defs.knowledgeSources)
|
|
49
|
+
note(k.id, "knowledgeSource", k.name);
|
|
50
|
+
for (const b of defs.businessKnowledgeModels)
|
|
51
|
+
note(b.id, "businessKnowledgeModel", b.name);
|
|
52
|
+
for (const a of defs.textAnnotations)
|
|
53
|
+
note(a.id, "annotation", a.text);
|
|
54
|
+
const edgeKinds = new Map();
|
|
55
|
+
for (const d of defs.decisions) {
|
|
56
|
+
for (const r of d.informationRequirements)
|
|
57
|
+
edgeKinds.set(r.id, "information");
|
|
58
|
+
for (const r of d.knowledgeRequirements)
|
|
59
|
+
edgeKinds.set(r.id, "knowledge");
|
|
60
|
+
for (const r of d.authorityRequirements)
|
|
61
|
+
edgeKinds.set(r.id, "authority");
|
|
62
|
+
}
|
|
63
|
+
for (const b of defs.businessKnowledgeModels) {
|
|
64
|
+
for (const r of b.knowledgeRequirements)
|
|
65
|
+
edgeKinds.set(r.id, "knowledge");
|
|
66
|
+
for (const r of b.authorityRequirements)
|
|
67
|
+
edgeKinds.set(r.id, "authority");
|
|
68
|
+
}
|
|
69
|
+
for (const k of defs.knowledgeSources) {
|
|
70
|
+
for (const r of k.authorityRequirements)
|
|
71
|
+
edgeKinds.set(r.id, "authority");
|
|
72
|
+
}
|
|
73
|
+
for (const a of defs.associations)
|
|
74
|
+
edgeKinds.set(a.id, "association");
|
|
75
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
76
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
77
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
78
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
79
|
+
for (const { bounds: b } of diagram.shapes) {
|
|
80
|
+
minX = Math.min(minX, b.x);
|
|
81
|
+
minY = Math.min(minY, b.y);
|
|
82
|
+
maxX = Math.max(maxX, b.x + b.width);
|
|
83
|
+
maxY = Math.max(maxY, b.y + b.height);
|
|
84
|
+
}
|
|
85
|
+
for (const e of diagram.edges) {
|
|
86
|
+
for (const wp of e.waypoints) {
|
|
87
|
+
minX = Math.min(minX, wp.x);
|
|
88
|
+
minY = Math.min(minY, wp.y);
|
|
89
|
+
maxX = Math.max(maxX, wp.x);
|
|
90
|
+
maxY = Math.max(maxY, wp.y);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const ox = minX - padding;
|
|
94
|
+
const oy = minY - padding;
|
|
95
|
+
const vw = maxX - minX + padding * 2;
|
|
96
|
+
const vh = maxY - minY + padding * 2;
|
|
97
|
+
const edgeParts = [];
|
|
98
|
+
for (const edge of diagram.edges) {
|
|
99
|
+
if (edge.waypoints.length < 2)
|
|
100
|
+
continue;
|
|
101
|
+
const kind = edgeKinds.get(edge.dmnElementRef) ?? "association";
|
|
102
|
+
const d = edge.waypoints.map((w, i) => `${i === 0 ? "M" : "L"}${w.x},${w.y}`).join(" ");
|
|
103
|
+
const dash = kind === "knowledge"
|
|
104
|
+
? ' stroke-dasharray="6 3"'
|
|
105
|
+
: kind === "authority"
|
|
106
|
+
? ' stroke-dasharray="2 3"'
|
|
107
|
+
: kind === "association"
|
|
108
|
+
? ' stroke-dasharray="5 3"'
|
|
109
|
+
: "";
|
|
110
|
+
const marker = kind === "information"
|
|
111
|
+
? ' marker-end="url(#drd-info)"'
|
|
112
|
+
: kind === "knowledge"
|
|
113
|
+
? ' marker-end="url(#drd-know)"'
|
|
114
|
+
: kind === "authority"
|
|
115
|
+
? ' marker-end="url(#drd-auth)"'
|
|
116
|
+
: "";
|
|
117
|
+
edgeParts.push(`<path d="${d}"${idAttr(edge.dmnElementRef)} fill="none" stroke="${t.flowStroke}" stroke-width="1.5"${dash}${marker}/>`);
|
|
118
|
+
}
|
|
119
|
+
const shapeParts = [];
|
|
120
|
+
for (const shape of diagram.shapes) {
|
|
121
|
+
const { x, y, width, height } = shape.bounds;
|
|
122
|
+
const kind = kinds.get(shape.dmnElementRef);
|
|
123
|
+
if (!kind)
|
|
124
|
+
continue;
|
|
125
|
+
const name = names.get(shape.dmnElementRef);
|
|
126
|
+
const style = shapeStyle(t);
|
|
127
|
+
let body;
|
|
128
|
+
switch (kind) {
|
|
129
|
+
case "decision":
|
|
130
|
+
body = `<rect x="0" y="0" width="${width}" height="${height}" style="${style}"/>`;
|
|
131
|
+
break;
|
|
132
|
+
case "inputData":
|
|
133
|
+
body = `<rect x="0" y="0" width="${width}" height="${height}" rx="${height / 2}" style="${style}"/>`;
|
|
134
|
+
break;
|
|
135
|
+
case "knowledgeSource": {
|
|
136
|
+
const wave = Math.min(8, height / 6);
|
|
137
|
+
body = `<path d="M0 0 H${width} V${height - wave} Q${(width * 3) / 4} ${height - wave * 2} ${width / 2} ${height - wave} T0 ${height - wave} Z" style="${style}"/>`;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case "businessKnowledgeModel": {
|
|
141
|
+
const c = Math.min(15, width / 6, height / 4);
|
|
142
|
+
body = `<path d="M${c} 0 H${width - c} L${width} ${c} V${height} H0 V${c} Z" style="${style}"/>`;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
case "annotation":
|
|
146
|
+
body = `<path d="M${Math.min(12, width / 4)} 0 H0 V${height} H${Math.min(12, width / 4)}" style="fill:none;stroke:${t.shapeStroke};stroke-width:1.5"/>`;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
const label = name ? labelSvg(name, width / 2, height / 2, width - 16, t, false) : "";
|
|
150
|
+
shapeParts.push(`<g transform="translate(${x} ${y})"${idAttr(shape.dmnElementRef)}>${body}${label}</g>`);
|
|
151
|
+
}
|
|
152
|
+
const sf = t.flowStroke;
|
|
153
|
+
return svgRoot(ox, oy, vw, vh, options, t, [...edgeParts, ...shapeParts], [
|
|
154
|
+
` <marker id="drd-info" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto" markerUnits="strokeWidth"><path d="M0,0 L8,3 L0,6 Z" fill="${sf}"/></marker>`,
|
|
155
|
+
` <marker id="drd-know" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto" markerUnits="strokeWidth"><path d="M0,0 L8,3 L0,6" fill="none" stroke="${sf}" stroke-width="1"/></marker>`,
|
|
156
|
+
` <marker id="drd-auth" markerWidth="6" markerHeight="6" refX="5" refY="3" orient="auto" markerUnits="strokeWidth"><circle cx="3" cy="3" r="2.5" fill="${t.shapeFill}" stroke="${sf}" stroke-width="1"/></marker>`,
|
|
157
|
+
]);
|
|
158
|
+
}
|
|
159
|
+
// ── Decision table ────────────────────────────────────────────────────────────
|
|
160
|
+
const HIT_LETTER = {
|
|
161
|
+
UNIQUE: "U",
|
|
162
|
+
FIRST: "F",
|
|
163
|
+
PRIORITY: "P",
|
|
164
|
+
ANY: "A",
|
|
165
|
+
COLLECT: "C",
|
|
166
|
+
"RULE ORDER": "R",
|
|
167
|
+
"OUTPUT ORDER": "O",
|
|
168
|
+
};
|
|
169
|
+
const AGG_SUFFIX = { SUM: "+", MIN: "<", MAX: ">", COUNT: "#" };
|
|
170
|
+
const MIN_COL = 60;
|
|
171
|
+
const MAX_COL = 280;
|
|
172
|
+
const CELL_PAD = 8;
|
|
173
|
+
const TITLE_H = 28;
|
|
174
|
+
const MIN_ROW_H = 28;
|
|
175
|
+
function hitLabel(table) {
|
|
176
|
+
const letter = HIT_LETTER[table.hitPolicy ?? "UNIQUE"] ?? "U";
|
|
177
|
+
const agg = table.hitPolicy === "COLLECT" && table.aggregation ? AGG_SUFFIX[table.aggregation] : "";
|
|
178
|
+
return `${letter}${agg ?? ""}`;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Generates a self-contained SVG of a decision table: hit-policy letter and rule
|
|
182
|
+
* numbers in the first column, then input and output columns, then an annotation
|
|
183
|
+
* column when any rule has a description. Column widths follow the longest text
|
|
184
|
+
* (6.5 px per character) clamped to 60–280 px; longer text wraps.
|
|
185
|
+
*/
|
|
186
|
+
export function exportDecisionTableSvg(table, options) {
|
|
187
|
+
const t = resolveCtx(options);
|
|
188
|
+
const padding = options?.padding ?? 20;
|
|
189
|
+
const withIds = options?.elementIds === true;
|
|
190
|
+
const idAttr = (id) => (withIds ? ` data-element-id="${esc(id)}"` : "");
|
|
191
|
+
const charW = 6.5 * (t.fontSize / 11);
|
|
192
|
+
const dash = (s) => (s && s.trim() !== "" ? s : "-");
|
|
193
|
+
const cols = [
|
|
194
|
+
{
|
|
195
|
+
header: hitLabel(table),
|
|
196
|
+
cells: table.rules.map((_, i) => String(i + 1)),
|
|
197
|
+
w: 0,
|
|
198
|
+
group: "index",
|
|
199
|
+
},
|
|
200
|
+
...table.inputs.map((inp, i) => ({
|
|
201
|
+
header: inp.label || inp.inputExpression.text || `Input ${i + 1}`,
|
|
202
|
+
cells: table.rules.map((r) => dash(r.inputEntries[i]?.text)),
|
|
203
|
+
w: 0,
|
|
204
|
+
group: "in",
|
|
205
|
+
})),
|
|
206
|
+
...table.outputs.map((out, i) => ({
|
|
207
|
+
header: out.label || out.name || `Output ${i + 1}`,
|
|
208
|
+
cells: table.rules.map((r) => dash(r.outputEntries[i]?.text)),
|
|
209
|
+
w: 0,
|
|
210
|
+
group: "out",
|
|
211
|
+
})),
|
|
212
|
+
];
|
|
213
|
+
if (table.rules.some((r) => r.description)) {
|
|
214
|
+
cols.push({
|
|
215
|
+
header: "Annotations",
|
|
216
|
+
cells: table.rules.map((r) => r.description ?? ""),
|
|
217
|
+
w: 0,
|
|
218
|
+
group: "note",
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
for (const col of cols) {
|
|
222
|
+
const longest = Math.max(col.header.length, ...col.cells.map((c) => Math.max(...c.split("\n").map((l) => l.length), 0)));
|
|
223
|
+
col.w = Math.min(MAX_COL, Math.max(MIN_COL, Math.ceil(longest * charW + CELL_PAD * 2)));
|
|
224
|
+
}
|
|
225
|
+
const rowHeight = (texts) => {
|
|
226
|
+
let lines = 1;
|
|
227
|
+
texts.forEach((txt, i) => {
|
|
228
|
+
const w = cols[i]?.w ?? MIN_COL;
|
|
229
|
+
lines = Math.max(lines, wrapText(txt, w - CELL_PAD * 2, charW).length);
|
|
230
|
+
});
|
|
231
|
+
return Math.max(MIN_ROW_H, lines * t.lineH + 12);
|
|
232
|
+
};
|
|
233
|
+
const totalW = cols.reduce((s, c) => s + c.w, 0);
|
|
234
|
+
const headerH = rowHeight(cols.map((c) => c.header));
|
|
235
|
+
const rowHs = table.rules.map((_, ri) => rowHeight(cols.map((c) => c.cells[ri] ?? "")));
|
|
236
|
+
const titleH = options?.name ? TITLE_H : 0;
|
|
237
|
+
const totalH = titleH + headerH + rowHs.reduce((s, h) => s + h, 0);
|
|
238
|
+
const textAt = (text, x, top, w, h, bold) => {
|
|
239
|
+
const lines = wrapText(text, w - CELL_PAD * 2, charW);
|
|
240
|
+
const startY = top + h / 2 - (lines.length * t.lineH) / 2 + t.lineH / 2;
|
|
241
|
+
const style = esc(`fill:${t.text};${fontStyle(undefined, t)}${bold ? ";font-weight:bold" : ""};dominant-baseline:central`);
|
|
242
|
+
return lines
|
|
243
|
+
.map((l, i) => `<text style="${style}" x="${x + CELL_PAD}" y="${startY + i * t.lineH}">${esc(l)}</text>`)
|
|
244
|
+
.join("");
|
|
245
|
+
};
|
|
246
|
+
const parts = [];
|
|
247
|
+
const cellStyle = shapeStyle(t, 1);
|
|
248
|
+
const headStyle = `fill:${t.poolHeader};stroke:${t.shapeStroke};stroke-width:1`;
|
|
249
|
+
if (titleH > 0 && options?.name) {
|
|
250
|
+
parts.push(`<rect x="0" y="0" width="${totalW}" height="${titleH}" style="${cellStyle}"/>`, textAt(options.name, 0, 0, totalW, titleH, true));
|
|
251
|
+
}
|
|
252
|
+
// Header row
|
|
253
|
+
let x = 0;
|
|
254
|
+
for (const col of cols) {
|
|
255
|
+
parts.push(`<rect x="${x}" y="${titleH}" width="${col.w}" height="${headerH}" style="${cellStyle}"/>`, `<rect x="${x}" y="${titleH}" width="${col.w}" height="${headerH}" style="${headStyle}"/>`, textAt(col.header, x, titleH, col.w, headerH, true));
|
|
256
|
+
x += col.w;
|
|
257
|
+
}
|
|
258
|
+
// Rule rows
|
|
259
|
+
let y = titleH + headerH;
|
|
260
|
+
for (const [ri, rule] of table.rules.entries()) {
|
|
261
|
+
const h = rowHs[ri] ?? MIN_ROW_H;
|
|
262
|
+
let cx = 0;
|
|
263
|
+
const row = [];
|
|
264
|
+
for (const col of cols) {
|
|
265
|
+
const style = col.group === "index" ? headStyle : cellStyle;
|
|
266
|
+
row.push(`<rect x="${cx}" y="${y}" width="${col.w}" height="${h}" style="${style}"/>`, textAt(col.cells[ri] ?? "", cx, y, col.w, h, false));
|
|
267
|
+
cx += col.w;
|
|
268
|
+
}
|
|
269
|
+
parts.push(withIds ? `<g${idAttr(rule.id)}>${row.join("")}</g>` : row.join(""));
|
|
270
|
+
y += h;
|
|
271
|
+
}
|
|
272
|
+
// Heavier divider between inputs and outputs
|
|
273
|
+
const firstOut = cols.findIndex((c) => c.group === "out");
|
|
274
|
+
if (firstOut > 0) {
|
|
275
|
+
const dx = cols.slice(0, firstOut).reduce((s, c) => s + c.w, 0);
|
|
276
|
+
parts.push(`<path d="M${dx} ${titleH} V${totalH}" style="${iconStyle(t)};stroke-width:2.5"/>`);
|
|
277
|
+
}
|
|
278
|
+
const ox = -padding;
|
|
279
|
+
const oy = -padding;
|
|
280
|
+
return svgRoot(ox, oy, totalW + padding * 2, totalH + padding * 2, options, t, parts);
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=svg.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The self-contained diff viewer page. Placeholders: {{TITLE}}, {{SUMMARY}}, {{BEFORE_LABEL}},
|
|
3
|
+
* {{AFTER_LABEL}}, {{BEFORE_SVG}}, {{AFTER_SVG}}, {{CHANGES}}, {{DIFF_JSON}}.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DIFF_VIEWER_TEMPLATE: string;
|
|
6
|
+
//# sourceMappingURL=diff-viewer.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @generated by scripts/spec-gen.mjs from spec/templates/diff-viewer.{html,css,js} — do not edit; run `pnpm spec:gen`.
|
|
2
|
+
/**
|
|
3
|
+
* The self-contained diff viewer page. Placeholders: {{TITLE}}, {{SUMMARY}}, {{BEFORE_LABEL}},
|
|
4
|
+
* {{AFTER_LABEL}}, {{BEFORE_SVG}}, {{AFTER_SVG}}, {{CHANGES}}, {{DIFF_JSON}}.
|
|
5
|
+
*/
|
|
6
|
+
export const DIFF_VIEWER_TEMPLATE = "<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'\">\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n<meta name=\"generator\" content=\"BPMN Kit\">\n<title>{{TITLE}}</title>\n<style>\n:root {\n\tcolor-scheme: light dark;\n\t--bk-bg: var(--bpmnkit-bg, #f4f4f8);\n\t--bk-surface: var(--bpmnkit-surface, #ffffff);\n\t--bk-border: var(--bpmnkit-border, #d0d0e8);\n\t--bk-fg: var(--bpmnkit-fg, #1a1a2e);\n\t--bk-muted: var(--bpmnkit-fg-muted, #6666a0);\n\t--bk-accent: var(--bpmnkit-accent, #1a56db);\n\t--bk-accent-subtle: var(--bpmnkit-accent-subtle, rgba(26, 86, 219, 0.12));\n\t--bk-mono: var(--bpmnkit-font-mono, ui-monospace, \"Cascadia Code\", \"JetBrains Mono\", monospace);\n\t--bk-added: #16a34a;\n\t--bk-removed: #dc2626;\n\t--bk-changed: #d97706;\n\t--bk-moved: #2563eb;\n\t--bk-fade: 0.35;\n}\n@media (prefers-color-scheme: dark) {\n\t:root {\n\t\t--bk-bg: var(--bpmnkit-bg, #0d0d16);\n\t\t--bk-surface: var(--bpmnkit-surface, #161626);\n\t\t--bk-border: var(--bpmnkit-border, #2a2a42);\n\t\t--bk-fg: var(--bpmnkit-fg, #cdd6f4);\n\t\t--bk-muted: var(--bpmnkit-fg-muted, #8888a8);\n\t\t--bk-accent: var(--bpmnkit-accent, #6b9df7);\n\t\t--bk-accent-subtle: var(--bpmnkit-accent-subtle, rgba(107, 157, 247, 0.15));\n\t}\n}\n* { box-sizing: border-box; }\nbody { margin: 0; padding: 16px; background: var(--bk-bg); color: var(--bk-fg); font: 14px/1.45 var(--bpmnkit-font, system-ui, -apple-system, sans-serif); }\nh1 { margin: 0 0 8px; font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }\ncode, .bk-sum, .bk-bar, figcaption, .bk-group h2, .bk-type { font-family: var(--bk-mono); font-size: 12px; }\n.bk-ctl { position: absolute; opacity: 0; pointer-events: none; }\n.bk-sum { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }\n.bk-chip { padding: 2px 8px; border: 1px solid currentColor; }\n.bk-zero { opacity: 0.45; }\n.bk-same { color: var(--bk-accent); background: var(--bk-accent-subtle); }\n.bk-k-added { color: var(--bk-added); }\n.bk-k-removed { color: var(--bk-removed); }\n.bk-k-changed { color: var(--bk-changed); }\n.bk-k-moved { color: var(--bk-moved); }\n.bk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 12px; }\n.bk-seg { display: inline-flex; border: 1px solid var(--bk-border); background: var(--bk-surface); }\n.bk-seg label { padding: 4px 10px; cursor: pointer; user-select: none; border-right: 1px solid var(--bk-border); }\n.bk-seg label:last-child { border-right: 0; }\n.bk-fade { display: none; align-items: center; gap: 6px; }\n.bk-hint { color: var(--bk-muted); }\nbody:not(.bk-js) .bk-hint, body:not(.bk-js) .bk-fade { display: none !important; }\n#bk-m-side:checked ~ .bk-bar label[for=\"bk-m-side\"], #bk-m-overlay:checked ~ .bk-bar label[for=\"bk-m-overlay\"],\n#bk-m-before:checked ~ .bk-bar label[for=\"bk-m-before\"], #bk-m-after:checked ~ .bk-bar label[for=\"bk-m-after\"] { background: var(--bk-accent); color: var(--bpmnkit-accent-fg, #ffffff); }\n#bk-f-added:not(:checked) ~ .bk-bar label[for=\"bk-f-added\"], #bk-f-removed:not(:checked) ~ .bk-bar label[for=\"bk-f-removed\"],\n#bk-f-changed:not(:checked) ~ .bk-bar label[for=\"bk-f-changed\"], #bk-f-moved:not(:checked) ~ .bk-bar label[for=\"bk-f-moved\"] { opacity: 0.4; text-decoration: line-through; }\n.bk-ctl:focus-visible ~ .bk-bar .bk-seg { outline: 2px solid var(--bk-accent); outline-offset: 2px; }\n#bk-f-added:not(:checked) ~ .bk-main .bk-k-added, #bk-f-removed:not(:checked) ~ .bk-main .bk-k-removed,\n#bk-f-changed:not(:checked) ~ .bk-main .bk-k-changed, #bk-f-moved:not(:checked) ~ .bk-main .bk-k-moved { display: none; }\n.bk-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }\n@media (min-width: 1100px) { .bk-main { grid-template-columns: minmax(0, 1fr) 360px; } }\n.bk-views { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; height: min(75vh, 760px); min-height: 280px; }\n@media (max-width: 700px) { .bk-views { grid-template-columns: minmax(0, 1fr); grid-template-rows: 1fr 1fr; height: 90vh; } }\n.bk-pane { margin: 0; display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--bk-border); background: var(--bk-surface); }\nfigcaption { padding: 4px 8px; border-bottom: 1px solid var(--bk-border); color: var(--bk-muted); }\n.bk-canvas { flex: 1; min-height: 0; overflow: hidden; touch-action: none; }\n.bk-svg { display: block; width: 100%; height: 100%; }\n.bk-js .bk-canvas { cursor: grab; }\n.bk-js .bk-canvas.bk-drag { cursor: grabbing; }\n#bk-m-overlay:checked ~ .bk-main .bk-views, #bk-m-before:checked ~ .bk-main .bk-views, #bk-m-after:checked ~ .bk-main .bk-views { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }\n#bk-m-overlay:checked ~ .bk-main .bk-pane { grid-area: 1 / 1; }\n#bk-m-overlay:checked ~ .bk-main .bk-pane-before { opacity: var(--bk-fade); }\n#bk-m-overlay:checked ~ .bk-main .bk-pane-after { background: transparent; }\n#bk-m-overlay:checked ~ .bk-main .bk-pane-after .bk-svg > g > svg > rect:first-child { fill-opacity: 0; }\n#bk-m-overlay:checked ~ .bk-main .bk-pane-before figcaption { visibility: hidden; }\n#bk-m-overlay:checked ~ .bk-bar .bk-fade { display: inline-flex; }\n#bk-m-before:checked ~ .bk-main .bk-pane-after, #bk-m-after:checked ~ .bk-main .bk-pane-before { display: none; }\n.bk-hl { cursor: pointer; }\n.bk-hl.bk-pulse { animation: bk-pulse 0.9s ease-out 2; }\n@keyframes bk-pulse { 50% { opacity: 0.2; } }\n@media (prefers-reduced-motion: reduce) { .bk-hl.bk-pulse { animation: none; } }\n.bk-list { border: 1px solid var(--bk-border); background: var(--bk-surface); padding: 8px 12px; overflow: auto; max-height: min(75vh, 760px); }\n@media (max-width: 1099px) { .bk-list { max-height: none; } }\n.bk-group h2 { margin: 8px 0 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }\n.bk-group ol { list-style: none; margin: 0; padding: 0; }\n.bk-row { color: var(--bk-fg); padding: 6px 8px; border-left: 3px solid currentColor; margin-bottom: 4px; cursor: pointer; overflow-wrap: anywhere; }\n.bk-row.bk-k-added { border-left-color: var(--bk-added); }\n.bk-row.bk-k-removed { border-left-color: var(--bk-removed); }\n.bk-row.bk-k-changed { border-left-color: var(--bk-changed); }\n.bk-row.bk-k-moved { border-left-color: var(--bk-moved); }\n.bk-row:hover, .bk-row.bk-sel, .bk-row:target { background: var(--bk-accent-subtle); }\n.bk-row:focus-visible { outline: 2px solid var(--bk-accent); }\n.bk-name { font-weight: 600; }\n.bk-type, .bk-id { color: var(--bk-muted); }\n.bk-fields { margin: 4px 0 0; padding-left: 16px; font-size: 12px; }\n.bk-fields del { color: var(--bk-removed); }\n.bk-fields ins { color: var(--bk-added); text-decoration: none; }\n.bk-empty { color: var(--bk-muted); }\n</style>\n</head>\n<body>\n<input type=\"radio\" name=\"bk-mode\" id=\"bk-m-side\" class=\"bk-ctl\" checked>\n<input type=\"radio\" name=\"bk-mode\" id=\"bk-m-overlay\" class=\"bk-ctl\">\n<input type=\"radio\" name=\"bk-mode\" id=\"bk-m-before\" class=\"bk-ctl\">\n<input type=\"radio\" name=\"bk-mode\" id=\"bk-m-after\" class=\"bk-ctl\">\n<input type=\"checkbox\" id=\"bk-f-added\" class=\"bk-ctl\" checked>\n<input type=\"checkbox\" id=\"bk-f-removed\" class=\"bk-ctl\" checked>\n<input type=\"checkbox\" id=\"bk-f-changed\" class=\"bk-ctl\" checked>\n<input type=\"checkbox\" id=\"bk-f-moved\" class=\"bk-ctl\" checked>\n<header class=\"bk-head\">\n<h1>{{TITLE}}</h1>\n{{SUMMARY}}\n</header>\n<nav class=\"bk-bar\" aria-label=\"View\">\n<span class=\"bk-seg\" role=\"group\" aria-label=\"Mode\"><label for=\"bk-m-side\">Side by side</label><label for=\"bk-m-overlay\">Overlay</label><label for=\"bk-m-before\">{{BEFORE_LABEL}}</label><label for=\"bk-m-after\">{{AFTER_LABEL}}</label></span>\n<span class=\"bk-seg\" role=\"group\" aria-label=\"Show changes\"><label for=\"bk-f-added\" class=\"bk-k-added\">+ added</label><label for=\"bk-f-removed\" class=\"bk-k-removed\">− removed</label><label for=\"bk-f-changed\" class=\"bk-k-changed\">~ changed</label><label for=\"bk-f-moved\" class=\"bk-k-moved\">↔ moved</label></span>\n<label class=\"bk-fade\">{{BEFORE_LABEL}} opacity <input type=\"range\" id=\"bk-fade\" min=\"0\" max=\"100\" value=\"35\"></label>\n<span class=\"bk-hint\">j/k next/prev · wheel zoom · drag pan · 0 fit</span>\n</nav>\n<main class=\"bk-main\">\n<section class=\"bk-views\">\n<figure class=\"bk-pane bk-pane-before\"><figcaption>{{BEFORE_LABEL}}</figcaption><div class=\"bk-canvas\">{{BEFORE_SVG}}</div></figure>\n<figure class=\"bk-pane bk-pane-after\"><figcaption>{{AFTER_LABEL}}</figcaption><div class=\"bk-canvas\">{{AFTER_SVG}}</div></figure>\n</section>\n<aside class=\"bk-list\" aria-label=\"Changes\">\n{{CHANGES}}\n</aside>\n</main>\n<script type=\"application/json\" id=\"bk-diff\">{{DIFF_JSON}}</script>\n<script>\n// Progressive enhancement: everything above works without this script.\n;(() => {\n\tconst body = document.body\n\tbody.classList.add(\"bk-js\")\n\tconst diff = JSON.parse(document.getElementById(\"bk-diff\").textContent)\n\tconst svgs = [...document.querySelectorAll(\".bk-svg\")]\n\tif (svgs.length === 0) return\n\tconst home = svgs[0].getAttribute(\"viewBox\").split(\" \").map(Number)\n\tlet vb = home.slice()\n\tlet anim = 0\n\tconst reduce = matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n\n\tconst apply = (v) => {\n\t\tvb = v\n\t\tconst s = v.join(\" \")\n\t\tfor (const svg of svgs) svg.setAttribute(\"viewBox\", s)\n\t}\n\tconst animate = (to) => {\n\t\tcancelAnimationFrame(anim)\n\t\tif (reduce) return apply(to)\n\t\tconst from = vb.slice()\n\t\tconst t0 = performance.now()\n\t\tconst step = (now) => {\n\t\t\tconst t = Math.min(1, (now - t0) / 280)\n\t\t\tconst e = 1 - (1 - t) ** 3\n\t\t\tapply(from.map((f, i) => f + (to[i] - f) * e))\n\t\t\tif (t < 1) anim = requestAnimationFrame(step)\n\t\t}\n\t\tanim = requestAnimationFrame(step)\n\t}\n\n\tconst boxOf = (g) => {\n\t\tif (!g) return null\n\t\tif (g.waypoints?.length) {\n\t\t\tconst xs = g.waypoints.map((p) => p.x)\n\t\t\tconst ys = g.waypoints.map((p) => p.y)\n\t\t\tconst x = Math.min(...xs)\n\t\t\tconst y = Math.min(...ys)\n\t\t\treturn [x, y, Math.max(...xs) - x, Math.max(...ys) - y]\n\t\t}\n\t\tif (g.width === undefined) return null\n\t\treturn [g.x, g.y, g.width, g.height]\n\t}\n\tconst zoomTo = (change) => {\n\t\tconst b = boxOf(change.geometryAfter) ?? boxOf(change.geometryBefore)\n\t\tif (!b) return\n\t\tconst w = Math.max(b[2] * 3, 360)\n\t\tconst h = Math.max(b[3] * 3, 240)\n\t\tanimate([b[0] + b[2] / 2 - w / 2, b[1] + b[3] / 2 - h / 2, w, h])\n\t}\n\n\tconst rows = [...document.querySelectorAll(\".bk-row\")]\n\tlet current = -1\n\tconst select = (i, zoom) => {\n\t\tconst row = rows.find((r) => Number(r.dataset.i) === i)\n\t\tif (!row) return\n\t\tcurrent = i\n\t\tfor (const r of rows) r.classList.toggle(\"bk-sel\", r === row)\n\t\trow.scrollIntoView({ block: \"nearest\", behavior: reduce ? \"auto\" : \"smooth\" })\n\t\tif (zoom) zoomTo(diff.changes[i])\n\t\tfor (const g of document.querySelectorAll(`.bk-hl[data-i=\"${i}\"]`)) {\n\t\t\tg.classList.remove(\"bk-pulse\")\n\t\t\tvoid g.getBBox()\n\t\t\tg.classList.add(\"bk-pulse\")\n\t\t}\n\t}\n\tfor (const row of rows) {\n\t\trow.addEventListener(\"click\", () => select(Number(row.dataset.i), true))\n\t\trow.addEventListener(\"keydown\", (e) => {\n\t\t\tif (e.key === \"Enter\" || e.key === \" \") {\n\t\t\t\te.preventDefault()\n\t\t\t\tselect(Number(row.dataset.i), true)\n\t\t\t}\n\t\t})\n\t}\n\n\tlet moved = false\n\tfor (const a of document.querySelectorAll(\".bk-diff a\")) {\n\t\ta.addEventListener(\"click\", (e) => {\n\t\t\te.preventDefault()\n\t\t\tif (!moved) select(Number(a.firstElementChild.dataset.i), false)\n\t\t})\n\t}\n\n\tconst visible = () => rows.filter((r) => r.offsetParent !== null)\n\tdocument.addEventListener(\"keydown\", (e) => {\n\t\tif (e.target instanceof HTMLInputElement && e.target.type === \"range\") return\n\t\tif (e.metaKey || e.ctrlKey || e.altKey) return\n\t\tif (e.key === \"0\") return animate(home)\n\t\tif (e.key !== \"j\" && e.key !== \"k\") return\n\t\tconst list = visible()\n\t\tif (list.length === 0) return\n\t\tconst at = list.findIndex((r) => Number(r.dataset.i) === current)\n\t\tconst next = e.key === \"j\" ? Math.min(list.length - 1, at + 1) : Math.max(0, at - 1)\n\t\tselect(Number(list[at === -1 ? 0 : next].dataset.i), true)\n\t})\n\n\tconst scaleOf = (svg) => {\n\t\tconst r = svg.getBoundingClientRect()\n\t\treturn Math.max(vb[2] / r.width, vb[3] / r.height)\n\t}\n\tconst toUser = (svg, cx, cy) => {\n\t\tconst r = svg.getBoundingClientRect()\n\t\tconst s = scaleOf(svg)\n\t\treturn [vb[0] + (cx - r.left - (r.width - vb[2] / s) / 2) * s, vb[1] + (cy - r.top - (r.height - vb[3] / s) / 2) * s]\n\t}\n\tfor (const canvas of document.querySelectorAll(\".bk-canvas\")) {\n\t\tconst svg = canvas.querySelector(\".bk-svg\")\n\t\tcanvas.addEventListener(\n\t\t\t\"wheel\",\n\t\t\t(e) => {\n\t\t\t\te.preventDefault()\n\t\t\t\tcancelAnimationFrame(anim)\n\t\t\t\tconst f = Math.exp(e.deltaY * 0.0015)\n\t\t\t\tconst [px, py] = toUser(svg, e.clientX, e.clientY)\n\t\t\t\tapply([px - (px - vb[0]) * f, py - (py - vb[1]) * f, vb[2] * f, vb[3] * f])\n\t\t\t},\n\t\t\t{ passive: false },\n\t\t)\n\t\tlet start = null\n\t\tcanvas.addEventListener(\"pointerdown\", (e) => {\n\t\t\tif (e.button !== 0) return\n\t\t\tcancelAnimationFrame(anim)\n\t\t\tstart = { x: e.clientX, y: e.clientY, vb: vb.slice(), s: scaleOf(svg) }\n\t\t\tmoved = false\n\t\t})\n\t\tcanvas.addEventListener(\"pointermove\", (e) => {\n\t\t\tif (!start) return\n\t\t\tconst dx = e.clientX - start.x\n\t\t\tconst dy = e.clientY - start.y\n\t\t\tif (!moved && Math.hypot(dx, dy) < 4) return\n\t\t\tif (!moved) canvas.setPointerCapture(e.pointerId)\n\t\t\tmoved = true\n\t\t\tcanvas.classList.add(\"bk-drag\")\n\t\t\tapply([start.vb[0] - dx * start.s, start.vb[1] - dy * start.s, start.vb[2], start.vb[3]])\n\t\t})\n\t\tconst end = () => {\n\t\t\tstart = null\n\t\t\tcanvas.classList.remove(\"bk-drag\")\n\t\t}\n\t\tcanvas.addEventListener(\"pointerup\", end)\n\t\tcanvas.addEventListener(\"pointercancel\", end)\n\t\tcanvas.addEventListener(\"dblclick\", () => animate(home))\n\t}\n\n\tconst fade = document.getElementById(\"bk-fade\")\n\tfade.addEventListener(\"input\", () => body.style.setProperty(\"--bk-fade\", String(fade.value / 100)))\n})()\n</script>\n</body>\n</html>\n";
|
|
7
|
+
//# sourceMappingURL=diff-viewer.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,10 @@ export type { CamundaCompatConfig } from "./bpmn/camunda-compat.js";
|
|
|
34
34
|
export { CAMUNDA_COMPAT_PLUGIN_VERSION, CAMUNDA_COMPAT_RULES, CAMUNDA_COMPAT_VERSIONS, } from "./bpmn/camunda-compat-data.js";
|
|
35
35
|
export type { CamundaCompatCoverage, CamundaCompatRule, CamundaCompatVersion, } from "./bpmn/camunda-compat-data.js";
|
|
36
36
|
export { diffDiagram } from "./bpmn/diagram-diff.js";
|
|
37
|
+
export { diffBpmn } from "./bpmn/bpmn-diff.js";
|
|
38
|
+
export { diffToSvg, renderDiffHtml } from "./bpmn/diff-html.js";
|
|
39
|
+
export type { DiffHtmlOptions } from "./bpmn/diff-html.js";
|
|
40
|
+
export type { BpmnChangeKind, BpmnDiff, BpmnDiffSummary, BpmnElementChange, BpmnFieldChange, BpmnGeometry, } from "./bpmn/bpmn-diff.js";
|
|
37
41
|
export { exportPreserving, exportPreservingResult, preserveBpmnFormatting, } from "./bpmn/preserving-writer.js";
|
|
38
42
|
export type { PreservingWriteResult } from "./bpmn/preserving-writer.js";
|
|
39
43
|
export { exportDmnPreserving, preserveDmnFormatting } from "./dmn/preserving-writer.js";
|
|
@@ -113,8 +117,10 @@ export type { Camunda8ExportFinding, Camunda8To7Conversion } from "./bpmn/camund
|
|
|
113
117
|
export type { Camunda7Conversion, Camunda7ConvertOptions, Camunda7Finding, Camunda7Report, Camunda7Severity, } from "./bpmn/camunda7/migrate.js";
|
|
114
118
|
export { translateJuelToFeel } from "./bpmn/camunda7/juel.js";
|
|
115
119
|
export type { JuelToFeelOptions, JuelToFeelResult } from "./bpmn/camunda7/juel.js";
|
|
116
|
-
export { exportSvg } from "./bpmn/svg.js";
|
|
117
|
-
export type { SvgExportOptions } from "./bpmn/svg.js";
|
|
120
|
+
export { exportSvg, exportSvgDetailed } from "./bpmn/svg.js";
|
|
121
|
+
export type { SvgElementKind, SvgExportOptions, SvgExportResult, SvgGeometry, SvgRenderedElement, SvgThemeColors, SvgWarning, } from "./bpmn/svg.js";
|
|
122
|
+
export { exportDrdSvg, exportDecisionTableSvg } from "./dmn/svg.js";
|
|
123
|
+
export type { DecisionTableSvgOptions, DmnSvgOptions } from "./dmn/svg.js";
|
|
118
124
|
export { buildProcessDocumentation, documentationToDocx, documentationToHtml, documentationToMarkdown, renderDocumentationDocx, renderDocumentationHtml, renderDocumentationMarkdown, } from "./doc/index.js";
|
|
119
125
|
export type { DocumentationLink, DocumentationOptions, DocumentedDecision, DocumentedElement, DocumentedForm, DocumentedFormField, DocumentedLane, DocumentedMessageFlow, DocumentedProcess, DocumentedProperty, DocxDocumentationOptions, ProcessDocumentation, } from "./doc/index.js";
|
|
120
126
|
export type { CompactDiagram, CompactElement, CompactFlow, CompactNote, CompactProcess, ExpandOptions, } from "./bpmn/compact.js";
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,8 @@ export { BPMNLINT_RULE_MAP, applyBpmnlintConfig, bpmnlintRuleForFinding, normali
|
|
|
21
21
|
export { analyzeCamundaCompat, applyCamundaCompatConfig, isCamundaCompatFinding, normalizeCamundaVersion, splitCamundaCompatConfig, } from "./bpmn/camunda-compat.js";
|
|
22
22
|
export { CAMUNDA_COMPAT_PLUGIN_VERSION, CAMUNDA_COMPAT_RULES, CAMUNDA_COMPAT_VERSIONS, } from "./bpmn/camunda-compat-data.js";
|
|
23
23
|
export { diffDiagram } from "./bpmn/diagram-diff.js";
|
|
24
|
+
export { diffBpmn } from "./bpmn/bpmn-diff.js";
|
|
25
|
+
export { diffToSvg, renderDiffHtml } from "./bpmn/diff-html.js";
|
|
24
26
|
export { exportPreserving, exportPreservingResult, preserveBpmnFormatting, } from "./bpmn/preserving-writer.js";
|
|
25
27
|
export { exportDmnPreserving, preserveDmnFormatting } from "./dmn/preserving-writer.js";
|
|
26
28
|
export { sha256Hex } from "./bpmn/sha256.js";
|
|
@@ -62,7 +64,8 @@ export { buildValidationDmn, findValidationStructure, getValidationInputNames, i
|
|
|
62
64
|
export { analyzeCamunda7, convertCamunda7 } from "./bpmn/camunda7/migrate.js";
|
|
63
65
|
export { convertCamunda8To7 } from "./bpmn/camunda7/export.js";
|
|
64
66
|
export { translateJuelToFeel } from "./bpmn/camunda7/juel.js";
|
|
65
|
-
export { exportSvg } from "./bpmn/svg.js";
|
|
67
|
+
export { exportSvg, exportSvgDetailed } from "./bpmn/svg.js";
|
|
68
|
+
export { exportDrdSvg, exportDecisionTableSvg } from "./dmn/svg.js";
|
|
66
69
|
export { buildProcessDocumentation, documentationToDocx, documentationToHtml, documentationToMarkdown, renderDocumentationDocx, renderDocumentationHtml, renderDocumentationMarkdown, } from "./doc/index.js";
|
|
67
70
|
export { compilePlan, extractPlan, mergePlan, slugify, uniqueId, } from "./plan/index.js";
|
|
68
71
|
export { listSecrets } from "./bpmn/secrets.js";
|