@bpmn-nova/studio 0.3.9-preview → 0.4.1

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.
Files changed (79) hide show
  1. package/README.md +2 -2
  2. package/dist/canvas.js +97 -25
  3. package/dist/config.js +13 -0
  4. package/dist/context-menu.js +41 -32
  5. package/dist/controller.js +45 -19
  6. package/dist/flow-tree.d.ts +4 -0
  7. package/dist/flow-tree.js +14 -0
  8. package/dist/index.d.ts +47 -2
  9. package/dist/index.js +1 -0
  10. package/dist/interactions.js +6 -1
  11. package/dist/modules/bpmn-model/index.d.ts +2 -1
  12. package/dist/modules/bpmn-model/index.js +12 -10
  13. package/dist/modules/core/gateway.js +16 -13
  14. package/dist/modules/core/index.d.ts +6 -4
  15. package/dist/modules/core/model.js +12 -7
  16. package/dist/modules/designer/index.d.ts +5 -1
  17. package/dist/modules/designer/index.js +36 -15
  18. package/dist/modules/export-svg/index.d.ts +12 -5
  19. package/dist/modules/export-svg/preview.js +34 -24
  20. package/dist/modules/export-svg/render.js +102 -50
  21. package/dist/modules/flow-tree/controller.js +364 -0
  22. package/dist/modules/flow-tree/index.d.ts +248 -0
  23. package/dist/modules/flow-tree/index.js +5 -0
  24. package/dist/modules/flow-tree/operations.js +484 -0
  25. package/dist/modules/flow-tree/sample.js +445 -0
  26. package/dist/modules/flow-tree/schema.js +588 -0
  27. package/dist/modules/flow-tree/validate.js +125 -0
  28. package/dist/modules/flow-tree-bpmn/compiler.js +547 -0
  29. package/dist/modules/flow-tree-bpmn/decompiler.js +524 -0
  30. package/dist/modules/flow-tree-bpmn/expression.js +135 -0
  31. package/dist/modules/flow-tree-bpmn/index.d.ts +53 -0
  32. package/dist/modules/flow-tree-bpmn/index.js +14 -0
  33. package/dist/modules/flow-tree-renderer/canvas.js +1003 -0
  34. package/dist/modules/flow-tree-renderer/export-svg.js +325 -0
  35. package/dist/modules/flow-tree-renderer/index.d.ts +143 -0
  36. package/dist/modules/flow-tree-renderer/index.js +3 -0
  37. package/dist/modules/flow-tree-renderer/shell.js +970 -0
  38. package/dist/modules/i18n/index.d.ts +647 -0
  39. package/dist/modules/i18n/index.js +247 -0
  40. package/dist/modules/i18n/locales/en-US.js +1222 -0
  41. package/dist/modules/i18n/locales/zh-CN.js +1204 -0
  42. package/dist/modules/icons/index.js +23 -0
  43. package/dist/modules/node-presentation/index.d.ts +3 -2
  44. package/dist/modules/node-presentation/index.js +14 -11
  45. package/dist/modules/palette/index.d.ts +6 -1
  46. package/dist/modules/palette/index.js +26 -8
  47. package/dist/modules/palette/panel.js +44 -6
  48. package/dist/modules/properties/index.d.ts +2 -1
  49. package/dist/modules/properties/index.js +2 -2
  50. package/dist/modules/properties-activiti/index.js +84 -59
  51. package/dist/modules/properties-bpmn/index.js +151 -128
  52. package/dist/modules/properties-core/index.d.ts +9 -3
  53. package/dist/modules/properties-core/index.js +16 -4
  54. package/dist/modules/properties-flow-tree/index.d.ts +56 -0
  55. package/dist/modules/properties-flow-tree/index.js +2 -0
  56. package/dist/modules/properties-flow-tree/panel.js +1136 -0
  57. package/dist/modules/properties-flow-tree/widgets.js +625 -0
  58. package/dist/modules/properties-flowable/index.js +55 -34
  59. package/dist/modules/properties-renderer/index.d.ts +5 -1
  60. package/dist/modules/properties-renderer/index.js +110 -42
  61. package/dist/modules/renderer-svg/index.d.ts +6 -2
  62. package/dist/modules/renderer-svg/index.js +113 -38
  63. package/dist/modules/runtime/index.d.ts +33 -5
  64. package/dist/modules/runtime/index.js +97 -73
  65. package/dist/modules/runtime/time.js +89 -4
  66. package/dist/modules/runtime/visits.js +6 -4
  67. package/dist/modules/theme/index.d.ts +5 -2
  68. package/dist/modules/theme/index.js +8 -4
  69. package/dist/modules/viewer/index.d.ts +28 -7
  70. package/dist/modules/viewer/index.js +223 -58
  71. package/dist/modules/viewer/runtime-content.js +26 -20
  72. package/dist/modules/viewer/runtime-trace.js +43 -25
  73. package/dist/modules/viewer/timeline.js +103 -36
  74. package/dist/shell.js +258 -75
  75. package/dist/sidebars.js +3 -1
  76. package/dist/styles.css +2371 -2
  77. package/llms-full.txt +586 -47
  78. package/llms.txt +6 -5
  79. package/package.json +7 -3
@@ -0,0 +1,325 @@
1
+ import { resolveI18n } from '../i18n/index.js';
2
+ import { sanitizeSvgFilename } from '../export-svg/index.js';
3
+ import {
4
+ FLOW_TREE_NODE_DEFINITIONS,
5
+ formatFlowTreeNodeSummary,
6
+ isBranchNode,
7
+ isRouteNode,
8
+ resolveFlowTreeTypeLabel,
9
+ } from '../flow-tree/index.js';
10
+
11
+ const CARD_W = 224;
12
+ const CARD_H = 74;
13
+ const END_H = 38;
14
+ const GAP_Y = 38;
15
+ const GAP_X = 36;
16
+ const ROUTE_TOP_PAD = 32;
17
+ const ROUTE_BOTTOM_PAD = 24;
18
+ const CORNER_R = 12;
19
+
20
+ const LIGHT_HEADER_COLORS = Object.freeze({
21
+ starter: '#576a95',
22
+ approver: '#f58220',
23
+ cc: '#3370ff',
24
+ handler: '#0ea687',
25
+ delay: '#d98a16',
26
+ trigger: '#5b5ce6',
27
+ subFlow: '#7a5af8',
28
+ });
29
+
30
+ const DARK_HEADER_COLORS = Object.freeze({
31
+ starter: '#3f527d',
32
+ approver: '#c96a1b',
33
+ cc: '#295cc7',
34
+ handler: '#0e826a',
35
+ delay: '#b07012',
36
+ trigger: '#4d4ec4',
37
+ subFlow: '#6548cc',
38
+ });
39
+
40
+ const LIGHT_BRANCH_ACCENTS = Object.freeze({
41
+ conditionBranch: '#12966c',
42
+ parallelBranch: '#6652d6',
43
+ inclusiveBranch: '#8a4fd6',
44
+ });
45
+
46
+ const DARK_BRANCH_ACCENTS = Object.freeze({
47
+ conditionBranch: '#52c99c',
48
+ parallelBranch: '#a899ff',
49
+ inclusiveBranch: '#c39bff',
50
+ });
51
+
52
+ function escapeXml(value = '') {
53
+ return String(value)
54
+ .replaceAll('&', '&')
55
+ .replaceAll('<', '&lt;')
56
+ .replaceAll('>', '&gt;')
57
+ .replaceAll('"', '&quot;')
58
+ .replaceAll("'", '&apos;');
59
+ }
60
+
61
+ function truncateText(text = '', maxChars = 24) {
62
+ const chars = Array.from(String(text || ''));
63
+ return chars.length > maxChars ? `${chars.slice(0, maxChars - 1).join('')}…` : chars.join('');
64
+ }
65
+
66
+ function measureSteps(steps) {
67
+ let width = CARD_W;
68
+ let height = 0;
69
+ const items = [];
70
+ for (const step of steps || []) {
71
+ const measured = measureStep(step);
72
+ width = Math.max(width, measured.width);
73
+ if (height > 0) height += GAP_Y;
74
+ items.push({ step, measured, offsetY: height });
75
+ height += measured.height;
76
+ }
77
+ return { width, height, items };
78
+ }
79
+
80
+ function measureStep(step) {
81
+ if (!isRouteNode(step)) {
82
+ return { kind: 'card', width: CARD_W, height: CARD_H };
83
+ }
84
+ const branches = (step.branches || []).map((branch) => {
85
+ const body = measureSteps(branch.steps || []);
86
+ const colW = Math.max(CARD_W, body.width);
87
+ const colH = CARD_H + (body.height > 0 ? GAP_Y + body.height : 12);
88
+ return { branch, body, width: colW, height: colH };
89
+ });
90
+ const totalW = branches.reduce((sum, item, idx) => sum + item.width + (idx ? GAP_X : 0), 0);
91
+ const maxBranchH = Math.max(CARD_H, ...branches.map((item) => item.height));
92
+ return {
93
+ kind: 'route',
94
+ width: Math.max(CARD_W, totalW),
95
+ height: ROUTE_TOP_PAD + maxBranchH + ROUTE_BOTTOM_PAD,
96
+ branches,
97
+ maxBranchH,
98
+ };
99
+ }
100
+
101
+ export function exportFlowTreeSvg(context = {}, options = {}) {
102
+ const {
103
+ document: doc,
104
+ runtimePresentation = null,
105
+ themeController = null,
106
+ nodeRegistry = null,
107
+ nodeSummaryResolver = null,
108
+ i18n = null,
109
+ } = context;
110
+
111
+ const translator = resolveI18n(i18n);
112
+ const requestedTheme = options.theme || 'current';
113
+ const snapshot = themeController?.getSnapshot?.(requestedTheme) || {
114
+ resolvedTheme: requestedTheme === 'dark' ? 'dark' : 'light',
115
+ colors: {
116
+ canvas: requestedTheme === 'dark' ? '#10131a' : '#f5f6f9',
117
+ surface: requestedTheme === 'dark' ? '#171b24' : '#ffffff',
118
+ text: requestedTheme === 'dark' ? '#edf1f7' : '#1f2430',
119
+ textSecondary: requestedTheme === 'dark' ? '#bdc6d5' : '#596477',
120
+ textMuted: requestedTheme === 'dark' ? '#8f9aad' : '#7d8798',
121
+ border: requestedTheme === 'dark' ? '#303847' : '#e2e6ef',
122
+ primary: requestedTheme === 'dark' ? '#918cff' : '#635bff',
123
+ },
124
+ tones: {},
125
+ };
126
+
127
+ const isDark = snapshot.resolvedTheme === 'dark';
128
+ const c = snapshot.colors || {};
129
+ const lineColor = isDark ? '#3f4a5e' : '#c2cad6';
130
+ const arrowColor = isDark ? '#55627a' : '#aeb8c7';
131
+ const headerPalette = isDark ? DARK_HEADER_COLORS : LIGHT_HEADER_COLORS;
132
+ const branchPalette = isDark ? DARK_BRANCH_ACCENTS : LIGHT_BRANCH_ACCENTS;
133
+
134
+ const bodyMeasure = measureSteps(doc?.steps || []);
135
+ const pad = 48;
136
+ const contentW = Math.max(CARD_W, bodyMeasure.width);
137
+ const totalW = Math.ceil(contentW + pad * 2);
138
+ const starterY = pad;
139
+ const stepsStartY = starterY + CARD_H + GAP_Y;
140
+ const endY = stepsStartY + (bodyMeasure.height > 0 ? bodyMeasure.height + GAP_Y : 0);
141
+ const totalH = Math.ceil(endY + END_H + pad);
142
+ const centerX = totalW / 2;
143
+
144
+ const lines = [];
145
+ const cards = [];
146
+
147
+ const pushPath = (d) => {
148
+ lines.push(`<path d="${d}" fill="none" stroke="${escapeXml(lineColor)}" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" />`);
149
+ };
150
+
151
+ const pushLine = (x1, y1, x2, y2) => {
152
+ lines.push(`<line x1="${Math.round(x1)}" y1="${Math.round(y1)}" x2="${Math.round(x2)}" y2="${Math.round(y2)}" stroke="${escapeXml(lineColor)}" stroke-width="1.8" stroke-linecap="round" />`);
153
+ };
154
+
155
+ const pushArrow = (cx, tipY) => {
156
+ const x = Math.round(cx);
157
+ const y = Math.round(tipY);
158
+ lines.push(`<polygon points="${x - 5},${y - 6} ${x + 5},${y - 6} ${x},${y}" fill="${escapeXml(arrowColor)}" />`);
159
+ };
160
+
161
+ const pushCard = (node, cx, y, { badgeText = '', withArrow = true } = {}) => {
162
+ const def = nodeRegistry?.resolve?.(node.type) || FLOW_TREE_NODE_DEFINITIONS[node.type] || { tone: 'primary' };
163
+ const rt = runtimePresentation?.getNode?.(node.id);
164
+ const branchCard = isBranchNode(node);
165
+ const x = Math.round(cx - CARD_W / 2);
166
+ const top = Math.round(y);
167
+ const title = truncateText(node.name || resolveFlowTreeTypeLabel(node.type, { i18n: translator, nodeRegistry }), 18);
168
+ const summary = truncateText(formatFlowTreeNodeSummary(node, {
169
+ i18n: translator,
170
+ nodeRegistry,
171
+ nodeSummaryResolver,
172
+ document: doc,
173
+ }), 28);
174
+
175
+ if (withArrow) pushArrow(cx, top);
176
+
177
+ if (branchCard) {
178
+ const titleColor = node.isDefault
179
+ ? (c.textSecondary || '#596477')
180
+ : (branchPalette[node.type] || '#12966c');
181
+ cards.push(`
182
+ <g>
183
+ <rect x="${x}" y="${top}" width="${CARD_W}" height="${CARD_H}" rx="8" fill="${escapeXml(c.surface || '#ffffff')}" stroke="${escapeXml(c.border || '#e2e6ef')}" stroke-width="1.2" />
184
+ <text x="${x + 12}" y="${top + 25}" font-size="12.5" font-weight="600" fill="${escapeXml(titleColor)}">${escapeXml(title)}</text>
185
+ ${badgeText ? `<text x="${x + CARD_W - 12}" y="${top + 24}" text-anchor="end" font-size="11" fill="${escapeXml(c.textMuted || '#7d8798')}">${escapeXml(badgeText)}</text>` : ''}
186
+ <text x="${x + 12}" y="${top + 52}" font-size="11.5" fill="${escapeXml(c.text || '#1f2430')}">${escapeXml(summary)}</text>
187
+ </g>
188
+ `);
189
+ return;
190
+ }
191
+
192
+ let headerFill = headerPalette[node.type] || c.primary || '#576a95';
193
+ let cardBorder = c.border || '#e2e6ef';
194
+ let strokeW = '1.2';
195
+ if (rt && rt.status === 'completed') {
196
+ headerFill = '#22a06b';
197
+ cardBorder = '#22a06b';
198
+ } else if (rt && rt.status === 'active') {
199
+ cardBorder = c.primary || '#3370ff';
200
+ strokeW = '2';
201
+ } else if (rt && (rt.status === 'rejected' || rt.status === 'failed')) {
202
+ headerFill = '#df4b55';
203
+ cardBorder = '#df4b55';
204
+ }
205
+ const rtBadge = rt && rt.status !== 'idle' && rt.statusLabel ? truncateText(rt.statusLabel, 8) : '';
206
+
207
+ cards.push(`
208
+ <g${rt?.status === 'skipped' ? ' opacity="0.54"' : ''}>
209
+ <rect x="${x}" y="${top}" width="${CARD_W}" height="${CARD_H}" rx="8" fill="${escapeXml(c.surface || '#ffffff')}" stroke="${escapeXml(cardBorder)}" stroke-width="${strokeW}" />
210
+ <path d="M ${x + 8} ${top} L ${x + CARD_W - 8} ${top} Q ${x + CARD_W} ${top} ${x + CARD_W} ${top + 8} L ${x + CARD_W} ${top + 30} L ${x} ${top + 30} L ${x} ${top + 8} Q ${x} ${top} ${x + 8} ${top} Z" fill="${escapeXml(headerFill)}" />
211
+ <text x="${x + 12}" y="${top + 20}" font-size="12.5" font-weight="600" fill="#ffffff">${escapeXml(title)}</text>
212
+ ${rtBadge ? `<text x="${x + CARD_W - 10}" y="${top + 19}" text-anchor="end" font-size="10" font-weight="600" fill="rgba(255,255,255,0.92)">${escapeXml(rtBadge)}</text>` : ''}
213
+ <text x="${x + 12}" y="${top + 55}" font-size="12" fill="${escapeXml(c.text || '#1f2430')}">${escapeXml(summary)}</text>
214
+ </g>
215
+ `);
216
+ };
217
+
218
+ const renderSteps = (measured, cx, startY) => {
219
+ let prevBottom = null;
220
+ for (const entry of measured.items) {
221
+ const y = startY + entry.offsetY;
222
+ if (prevBottom !== null) pushLine(cx, prevBottom, cx, y);
223
+ if (entry.measured.kind === 'card') {
224
+ pushCard(entry.step, cx, y, { withArrow: true });
225
+ prevBottom = y + CARD_H;
226
+ } else {
227
+ const route = entry.step;
228
+ const m = entry.measured;
229
+ const railTopY = y;
230
+ const branchStartY = y + ROUTE_TOP_PAD;
231
+ const railBottomY = y + m.height;
232
+
233
+ let cursorX = cx - m.width / 2;
234
+ const branchCenters = m.branches.map((b) => {
235
+ const bCx = cursorX + b.width / 2;
236
+ cursorX += b.width + GAP_X;
237
+ return { b, bCx };
238
+ });
239
+
240
+ const firstX = branchCenters[0]?.bCx ?? cx;
241
+ const lastX = branchCenters.at(-1)?.bCx ?? cx;
242
+ const r = Math.min(CORNER_R, (lastX - firstX) / 4);
243
+
244
+ // Rounded outer top & bottom brackets
245
+ if (branchCenters.length >= 2) {
246
+ pushPath(`M ${Math.round(firstX)} ${Math.round(branchStartY)} L ${Math.round(firstX)} ${Math.round(railTopY + r)} Q ${Math.round(firstX)} ${Math.round(railTopY)} ${Math.round(firstX + r)} ${Math.round(railTopY)} L ${Math.round(lastX - r)} ${Math.round(railTopY)} Q ${Math.round(lastX)} ${Math.round(railTopY)} ${Math.round(lastX)} ${Math.round(railTopY + r)} L ${Math.round(lastX)} ${Math.round(branchStartY)}`);
247
+ }
248
+
249
+ branchCenters.forEach(({ b, bCx }, idx) => {
250
+ const isOuter = idx === 0 || idx === branchCenters.length - 1;
251
+ if (!isOuter) pushLine(bCx, railTopY, bCx, branchStartY);
252
+ const badge = b.branch.isDefault
253
+ ? translator.t('flowTree.canvas.defaultBranchBadge')
254
+ : (route.type !== 'parallelRoute' ? translator.t('flowTree.canvas.priorityBadge', { priority: b.branch.priority }) : '');
255
+ pushCard(b.branch, bCx, branchStartY, { badgeText: badge, withArrow: true });
256
+
257
+ let branchBottom = branchStartY + CARD_H;
258
+ if (b.body.items.length) {
259
+ const innerY = branchStartY + CARD_H + GAP_Y;
260
+ pushLine(bCx, branchBottom, bCx, innerY);
261
+ branchBottom = renderSteps(b.body, bCx, innerY);
262
+ }
263
+
264
+ if (idx === 0 && branchCenters.length >= 2) {
265
+ pushPath(`M ${Math.round(bCx)} ${Math.round(branchBottom)} L ${Math.round(bCx)} ${Math.round(railBottomY - r)} Q ${Math.round(bCx)} ${Math.round(railBottomY)} ${Math.round(bCx + r)} ${Math.round(railBottomY)} L ${Math.round(lastX - r)} ${Math.round(railBottomY)} Q ${Math.round(lastX)} ${Math.round(railBottomY)} ${Math.round(lastX)} ${Math.round(railBottomY - r)}`);
266
+ } else if (idx === branchCenters.length - 1 && branchCenters.length >= 2) {
267
+ pushLine(bCx, branchBottom, bCx, railBottomY - r);
268
+ } else {
269
+ pushLine(bCx, branchBottom, bCx, railBottomY);
270
+ }
271
+ });
272
+ prevBottom = railBottomY;
273
+ }
274
+ }
275
+ return prevBottom ?? startY;
276
+ };
277
+
278
+ // Starter -> Steps -> End
279
+ pushCard(doc.starter, centerX, starterY, { withArrow: false });
280
+ if (bodyMeasure.items.length) {
281
+ pushLine(centerX, starterY + CARD_H, centerX, stepsStartY);
282
+ const lastBottom = renderSteps(bodyMeasure, centerX, stepsStartY);
283
+ pushLine(centerX, lastBottom, centerX, endY);
284
+ } else {
285
+ pushLine(centerX, starterY + CARD_H, centerX, endY);
286
+ }
287
+
288
+ // Minimal dot + caption End node
289
+ const endRt = runtimePresentation?.getNode?.(doc?.end?.id);
290
+ const endDotFill = endRt?.status === 'completed' ? '#22a06b' : arrowColor;
291
+ pushArrow(centerX, endY);
292
+ cards.push(`
293
+ <g>
294
+ <circle cx="${Math.round(centerX)}" cy="${Math.round(endY + 8)}" r="6" fill="${escapeXml(endDotFill)}" stroke="${escapeXml(c.surface || '#ffffff')}" stroke-width="2" />
295
+ <text x="${Math.round(centerX)}" y="${Math.round(endY + 30)}" text-anchor="middle" font-size="12" font-weight="500" fill="${escapeXml(c.textMuted || '#7d8798')}">${escapeXml(doc.end?.name || translator.t('flowTree.defaultEndName'))}</text>
296
+ </g>
297
+ `);
298
+
299
+ const transparent = options.transparentBackground === true || options.background === 'transparent';
300
+ const title = escapeXml(options.title || doc?.name || doc?.id || 'BPMN Nova FlowTree');
301
+ const svgBody = [
302
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${totalW}" height="${totalH}" viewBox="0 0 ${totalW} ${totalH}" data-nova-svg-export="true" data-nova-theme="${escapeXml(snapshot.resolvedTheme)}" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif">`,
303
+ ` <title>${title}</title>`,
304
+ ...(transparent ? [] : [` <rect width="${totalW}" height="${totalH}" fill="${escapeXml(c.canvas || '#f5f6f9')}" />`]),
305
+ ` <g>${lines.join('')}</g>`,
306
+ ` <g>${cards.join('')}</g>`,
307
+ '</svg>',
308
+ ].join('\n');
309
+ const source = `<?xml version="1.0" encoding="UTF-8"?>\n${svgBody}`;
310
+ const blob = typeof Blob !== 'undefined' ? new Blob([source], { type: 'image/svg+xml;charset=utf-8' }) : null;
311
+ const filename = sanitizeSvgFilename(options.filename || `${doc?.name || doc?.id || 'approval-flow'}`);
312
+
313
+ return Object.freeze({
314
+ svg: source,
315
+ blob,
316
+ filename,
317
+ fileName: filename,
318
+ mimeType: 'image/svg+xml',
319
+ width: totalW,
320
+ height: totalH,
321
+ viewBox: { x: 0, y: 0, width: totalW, height: totalH },
322
+ warnings: Object.freeze([]),
323
+ theme: snapshot.resolvedTheme,
324
+ });
325
+ }
@@ -0,0 +1,143 @@
1
+ import type { I18nController, LocaleMessages, LocaleState } from '../i18n/index.js';
2
+ import type { IconRegistry } from '../icons/index.js';
3
+ import type { RuntimeSnapshot } from '../runtime/index.js';
4
+ import type { RuntimeAppearanceOptions, ThemeController, ThemeInput, ThemeState } from '../theme/index.js';
5
+ import type { FlowTreeController, FlowTreeDocument, FlowTreeEngine, FlowTreeNodeBase, FlowTreeSelection, FlowTreeValidationIssue } from '../flow-tree/index.js';
6
+ import type { FlowTreeDecompileResult } from '../flow-tree-bpmn/index.js';
7
+ import type { FlowTreeDataProviders, FlowTreeNodePanelRenderer } from '../properties-flow-tree/index.js';
8
+
9
+ export type FlowTreeShellMode = 'design' | 'viewer' | 'instance';
10
+ export type FlowTreeShellView = 'tree' | 'bpmn' | 'timeline';
11
+
12
+ export interface FlowTreeCanvasOptions {
13
+ container: HTMLElement;
14
+ controller: FlowTreeController;
15
+ mode?: FlowTreeShellMode;
16
+ runtime?: RuntimeSnapshot | null;
17
+ runtimeAppearance?: RuntimeAppearanceOptions | null;
18
+ runtimeAssetResolver?: any;
19
+ formatRuntimeTime?: any;
20
+ runtimeTimeFormat?: any;
21
+ nodeSummaryResolver?: (context: { node: FlowTreeNodeBase; defaultSummary: string; document: FlowTreeDocument }) => string | null | undefined;
22
+ nodeCardRenderer?: (context: any) => (() => void) | void;
23
+ iconRegistry?: IconRegistry;
24
+ themeController?: ThemeController | null;
25
+ theme?: ThemeInput | null;
26
+ onThemeChange?: ((state: ThemeState) => void) | null;
27
+ onNodeClick?: ((node: FlowTreeNodeBase, runtimeState: any) => void) | null;
28
+ onViewportChange?: ((viewport: { zoom: number; pan: { x: number; y: number } }) => void) | null;
29
+ i18n?: I18nController | null;
30
+ locale?: string;
31
+ messages?: LocaleMessages;
32
+ }
33
+
34
+ export class FlowTreeCanvas {
35
+ constructor(options: FlowTreeCanvasOptions);
36
+ zoomIn(): void;
37
+ zoomOut(): void;
38
+ actualSize(): void;
39
+ fitView(padding?: number): void;
40
+ revealNode(nodeId: string): boolean;
41
+ getViewportState(): { zoom: number; pan: { x: number; y: number } };
42
+ setViewportState(state: { zoom: number; pan: { x: number; y: number } }): boolean;
43
+ setMode(mode: FlowTreeShellMode): void;
44
+ setRuntime(runtime: RuntimeSnapshot | null): void;
45
+ setTheme(theme: ThemeInput): ThemeState;
46
+ setLocale(locale?: string | null, messages?: LocaleMessages | null): LocaleState;
47
+ exportSvg(options?: Record<string, any>): { svg: string; width: number; height: number; fileName: string; warnings: string[]; theme: string };
48
+ openSvgExportPreview(options?: Record<string, any>): any;
49
+ render(): void;
50
+ destroy(): void;
51
+ }
52
+
53
+ export interface FlowTreeValidationResult {
54
+ source: string;
55
+ issues: FlowTreeValidationIssue[];
56
+ errorCount: number;
57
+ warningCount: number;
58
+ valid: boolean;
59
+ }
60
+
61
+ export interface FlowTreeShellOptions {
62
+ container: HTMLElement;
63
+ controller: FlowTreeController;
64
+ mode?: FlowTreeShellMode;
65
+ allowedModes?: FlowTreeShellMode[] | null;
66
+ view?: FlowTreeShellView;
67
+ runtime?: RuntimeSnapshot | null;
68
+ runtimeAppearance?: RuntimeAppearanceOptions | null;
69
+ runtimeAssetResolver?: any;
70
+ formatRuntimeTime?: any;
71
+ runtimeTimeFormat?: any;
72
+ dataProviders?: FlowTreeDataProviders;
73
+ nodePanels?: Record<string, FlowTreeNodePanelRenderer>;
74
+ nodeSummaryResolver?: FlowTreeCanvasOptions['nodeSummaryResolver'];
75
+ nodeCardRenderer?: FlowTreeCanvasOptions['nodeCardRenderer'];
76
+ slots?: {
77
+ header?: HTMLElement | ((context: any) => (() => void) | void);
78
+ headerStart?: HTMLElement | ((context: any) => (() => void) | void);
79
+ headerActions?: HTMLElement | ((context: any) => (() => void) | void);
80
+ right?: HTMLElement | ((context: any) => (() => void) | void);
81
+ };
82
+ regions?: {
83
+ header?: 'default' | 'hidden';
84
+ right?: 'default' | 'hidden';
85
+ footer?: 'default' | 'hidden';
86
+ };
87
+ rightWidth?: number;
88
+ rightCollapsed?: boolean;
89
+ iconRegistry?: IconRegistry;
90
+ theme?: ThemeInput | null;
91
+ onThemeChange?: ((state: ThemeState) => void) | null;
92
+ onModeChange?: ((event: { mode: FlowTreeShellMode; view: FlowTreeShellView }) => void) | null;
93
+ onValidation?: ((result: FlowTreeValidationResult) => void) | null;
94
+ onImportError?: ((error: Error, raw: string) => void) | null;
95
+ i18n?: I18nController | null;
96
+ locale?: string;
97
+ messages?: LocaleMessages;
98
+ }
99
+
100
+ export class FlowTreeShell {
101
+ readonly controller: FlowTreeController;
102
+ readonly actions: {
103
+ undo(): boolean;
104
+ redo(): boolean;
105
+ validate(): FlowTreeValidationResult;
106
+ fitView(): void;
107
+ exportXml(engine?: FlowTreeEngine): string;
108
+ importXml(xml: string, engine?: FlowTreeEngine): FlowTreeDecompileResult;
109
+ exportJson(): FlowTreeDocument;
110
+ importJson(json: string | Partial<FlowTreeDocument>): FlowTreeDocument;
111
+ exportSvg(options?: Record<string, any>): any;
112
+ openSvgExportPreview(options?: Record<string, any>): any;
113
+ openXmlPreview(): void;
114
+ };
115
+ constructor(options: FlowTreeShellOptions);
116
+ getMode(): FlowTreeShellMode;
117
+ setMode(mode: FlowTreeShellMode): boolean;
118
+ getView(): FlowTreeShellView;
119
+ setView(view: FlowTreeShellView): boolean;
120
+ setRuntime(runtime: RuntimeSnapshot | null): void;
121
+ setDataProviders(providers: FlowTreeDataProviders): void;
122
+ setSidebarCollapsed(collapsed: boolean): boolean;
123
+ getSidebarState(): { rightCollapsed: boolean };
124
+ subscribeSidebarChange(listener: (state: { rightCollapsed: boolean }) => void): () => void;
125
+ getPanelSelection(): { selection: FlowTreeSelection | null; selectedNode: any };
126
+ subscribePanelSelection(listener: (snapshot: { selection: FlowTreeSelection | null; selectedNode: any }) => void): () => void;
127
+ subscribeMode(listener: (event: { mode: FlowTreeShellMode; view: FlowTreeShellView }) => void): () => void;
128
+ subscribeValidation(listener: (result: FlowTreeValidationResult) => void): () => void;
129
+ validate(source?: string): FlowTreeValidationResult;
130
+ exportXml(engine?: FlowTreeEngine, options?: Record<string, any>): string;
131
+ importXml(xml: string, engine?: FlowTreeEngine | null, options?: Record<string, any>): FlowTreeDecompileResult;
132
+ exportSvg(options?: Record<string, any>): any;
133
+ openSvgExportPreview(options?: Record<string, any>): any;
134
+ openXmlPreview(): void;
135
+ fitView(): void;
136
+ revealNode(nodeId: string): boolean;
137
+ setTheme(theme: ThemeInput): ThemeState;
138
+ setLocale(locale?: string | null, messages?: LocaleMessages | null): LocaleState;
139
+ getLocale(): LocaleState;
140
+ destroy(): void;
141
+ }
142
+
143
+ export function exportFlowTreeSvg(context: Record<string, any>, options?: Record<string, any>): { svg: string; width: number; height: number; fileName: string; warnings: string[]; theme: string };
@@ -0,0 +1,3 @@
1
+ export * from './canvas.js';
2
+ export * from './export-svg.js';
3
+ export * from './shell.js';