@transitrix/diagrams 1.0.0 → 1.1.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/LICENSE +21 -21
- package/README.md +47 -47
- package/dist/__tests__/edge-path.test.js +8 -0
- package/dist/activities/cpm.js +11 -2
- package/dist/activities/gantt.js +6 -3
- package/dist/activities/types.d.ts +1 -0
- package/dist/activities/validate.js +3 -3
- package/dist/activity-card/__tests__/example.test.js +20 -1
- package/dist/activity-card/__tests__/layout.test.js +102 -11
- package/dist/activity-card/__tests__/resolver.test.js +161 -7
- package/dist/activity-card/index.d.ts +1 -1
- package/dist/activity-card/layout.d.ts +1 -1
- package/dist/activity-card/layout.js +220 -103
- package/dist/activity-card/resolver.js +115 -28
- package/dist/activity-card/types.d.ts +150 -27
- package/dist/activity-card/validate.js +3 -0
- package/dist/actor/__tests__/validate.test.js +63 -31
- package/dist/actor/index.d.ts +1 -1
- package/dist/actor/index.js +1 -1
- package/dist/actor/types.d.ts +7 -3
- package/dist/actor/types.js +17 -3
- package/dist/actor/validate.js +55 -26
- package/dist/assertion/types.d.ts +3 -1
- package/dist/assertion/types.js +1 -1
- package/dist/change/__tests__/validate.test.js +40 -34
- package/dist/change/index.d.ts +1 -0
- package/dist/change/types.d.ts +1 -1
- package/dist/change/types.js +2 -2
- package/dist/change/validate.d.ts +6 -1
- package/dist/change/validate.js +68 -41
- package/dist/compliance/__tests__/classify.test.js +34 -0
- package/dist/compliance/__tests__/coverage-metric.test.js +146 -46
- package/dist/compliance/__tests__/html.test.js +2 -2
- package/dist/compliance/__tests__/impact.test.js +509 -6
- package/dist/compliance/classify.d.ts +6 -0
- package/dist/compliance/classify.js +9 -1
- package/dist/compliance/coverage-metric.d.ts +31 -11
- package/dist/compliance/coverage-metric.js +149 -39
- package/dist/compliance/html.js +78 -81
- package/dist/compliance/impact.d.ts +100 -16
- package/dist/compliance/impact.js +272 -28
- package/dist/compliance/index.d.ts +2 -2
- package/dist/compliance/index.js +1 -1
- package/dist/compliance/markdown.js +1 -0
- package/dist/compliance/types.d.ts +25 -6
- package/dist/edge-path.d.ts +8 -4
- package/dist/edge-path.js +11 -6
- package/dist/factor/__tests__/validate.test.js +75 -46
- package/dist/factor/index.d.ts +3 -2
- package/dist/factor/index.js +1 -1
- package/dist/factor/types.d.ts +5 -8
- package/dist/factor/types.js +10 -5
- package/dist/factor/validate.d.ts +6 -1
- package/dist/factor/validate.js +68 -50
- package/dist/fgca/__tests__/chain-table.test.js +2 -2
- package/dist/fgca/__tests__/layout.test.js +11 -11
- package/dist/fgca/__tests__/preview-layout.test.js +7 -7
- package/dist/fgca/__tests__/resolver.test.js +185 -0
- package/dist/fgca/chain-table.d.ts +1 -1
- package/dist/fgca/chain-table.js +4 -4
- package/dist/fgca/index.d.ts +4 -2
- package/dist/fgca/index.js +2 -1
- package/dist/fgca/layout.d.ts +2 -2
- package/dist/fgca/layout.js +9 -9
- package/dist/fgca/nodeTypes.d.ts +1 -1
- package/dist/fgca/nodeTypes.js +2 -2
- package/dist/fgca/nodes/FGCAFactorNode.d.ts +3 -3
- package/dist/fgca/nodes/FGCAFactorNode.js +5 -5
- package/dist/fgca/parse-canonical.js +15 -10
- package/dist/fgca/preview-layout.d.ts +1 -1
- package/dist/fgca/preview-layout.js +4 -4
- package/dist/fgca/resolver.d.ts +49 -0
- package/dist/fgca/resolver.js +126 -0
- package/dist/fgca/types.d.ts +11 -11
- package/dist/fgca/types.js +2 -2
- package/dist/fgca/validate.d.ts +2 -2
- package/dist/fgca/validate.js +17 -14
- package/dist/goals/index.d.ts +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/process-blueprint/__tests__/layout.test.js +37 -0
- package/dist/process-blueprint/index.d.ts +1 -1
- package/dist/process-blueprint/layout.js +66 -35
- package/dist/process-blueprint/types.d.ts +36 -1
- package/dist/scenarios/index.d.ts +1 -1
- package/dist/scenarios/types.d.ts +4 -4
- package/dist/stakeholder/__tests__/validate.test.js +49 -47
- package/dist/stakeholder/index.d.ts +1 -0
- package/dist/stakeholder/types.d.ts +3 -4
- package/dist/stakeholder/types.js +2 -3
- package/dist/stakeholder/validate.d.ts +6 -1
- package/dist/stakeholder/validate.js +71 -50
- package/dist/target-state/__tests__/validate.test.js +43 -27
- package/dist/target-state/index.d.ts +2 -0
- package/dist/target-state/index.js +1 -0
- package/dist/target-state/types.d.ts +6 -1
- package/dist/target-state/types.js +8 -7
- package/dist/target-state/validate.d.ts +6 -1
- package/dist/target-state/validate.js +69 -45
- package/dist/theme/themes.js +71 -69
- package/dist/theme/tokens.d.ts +7 -1
- package/dist/theme/tokens.js +3 -1
- package/dist/webview/__tests__/entry-notations.test.js +2 -0
- package/dist/webview/__tests__/entry.test.js +11 -11
- package/dist/webview/__tests__/render-process.test.js +463 -0
- package/dist/webview/__tests__/render-util.test.d.ts +1 -0
- package/dist/webview/__tests__/render-util.test.js +54 -0
- package/dist/webview/entry.d.ts +1 -1
- package/dist/webview/entry.js +9 -5
- package/dist/webview/render-activities.d.ts +24 -2
- package/dist/webview/render-activities.js +92 -57
- package/dist/webview/render-activity-card.d.ts +11 -1
- package/dist/webview/render-activity-card.js +115 -79
- package/dist/webview/render-blocks.d.ts +24 -1
- package/dist/webview/render-blocks.js +58 -24
- package/dist/webview/render-fgca.d.ts +31 -0
- package/dist/webview/render-fgca.js +30 -19
- package/dist/webview/render-goals.d.ts +27 -1
- package/dist/webview/render-goals.js +42 -32
- package/dist/webview/render-process-blueprint.d.ts +11 -1
- package/dist/webview/render-process-blueprint.js +118 -53
- package/dist/webview/render-process.d.ts +95 -0
- package/dist/webview/render-process.js +392 -0
- package/dist/webview/render-scenarios.js +2 -2
- package/dist/webview/render-util.d.ts +19 -6
- package/dist/webview/render-util.js +23 -15
- package/package.json +54 -40
- package/src/__tests__/edge-path.test.ts +58 -46
- package/src/__tests__/scope.test.ts +27 -27
- package/src/__tests__/yaml-normalize.test.ts +158 -158
- package/src/activities/__tests__/cpm.test.ts +164 -164
- package/src/activities/__tests__/gantt.test.ts +245 -245
- package/src/activities/__tests__/layout.test.ts +112 -112
- package/src/activities/__tests__/validate.test.ts +409 -409
- package/src/activities/cpm.ts +107 -95
- package/src/activities/gantt.ts +277 -276
- package/src/activities/index.ts +28 -28
- package/src/activities/layout.ts +112 -112
- package/src/activities/types.ts +149 -148
- package/src/activities/validate.ts +357 -357
- package/src/activity-card/__tests__/example.test.ts +85 -66
- package/src/activity-card/__tests__/layout.test.ts +169 -63
- package/src/activity-card/__tests__/resolver.test.ts +330 -161
- package/src/activity-card/__tests__/validate.test.ts +131 -131
- package/src/activity-card/index.ts +38 -32
- package/src/activity-card/layout.ts +324 -194
- package/src/activity-card/resolver.ts +422 -337
- package/src/activity-card/types.ts +376 -237
- package/src/activity-card/validate.ts +162 -158
- package/src/actor/__tests__/validate.test.ts +70 -31
- package/src/actor/index.ts +1 -1
- package/src/actor/types.ts +21 -7
- package/src/actor/validate.ts +59 -27
- package/src/applications/__tests__/validate.test.ts +256 -256
- package/src/applications/index.ts +11 -11
- package/src/applications/types.ts +43 -43
- package/src/applications/validate.ts +131 -131
- package/src/assertion/__tests__/example.test.ts +37 -37
- package/src/assertion/__tests__/validate.test.ts +142 -142
- package/src/assertion/index.ts +12 -12
- package/src/assertion/types.ts +60 -58
- package/src/assertion/validate.ts +145 -145
- package/src/blocks/__tests__/layout.test.ts +169 -169
- package/src/blocks/__tests__/validate.test.ts +260 -260
- package/src/blocks/index.ts +17 -17
- package/src/blocks/layout.ts +186 -186
- package/src/blocks/types.ts +62 -62
- package/src/blocks/validate.ts +206 -206
- package/src/capability-map/__tests__/validate.test.ts +238 -238
- package/src/capability-map/index.ts +8 -8
- package/src/capability-map/types.ts +29 -29
- package/src/capability-map/validate.ts +127 -127
- package/src/change/__tests__/validate.test.ts +43 -34
- package/src/change/index.ts +1 -0
- package/src/change/types.ts +5 -3
- package/src/change/validate.ts +75 -43
- package/src/compliance/__tests__/classify.test.ts +64 -27
- package/src/compliance/__tests__/confidence.test.ts +98 -98
- package/src/compliance/__tests__/coverage-metric.test.ts +300 -188
- package/src/compliance/__tests__/demo-scenario.test.ts +273 -273
- package/src/compliance/__tests__/example.test.ts +57 -57
- package/src/compliance/__tests__/gap-report.test.ts +128 -128
- package/src/compliance/__tests__/html.test.ts +141 -141
- package/src/compliance/__tests__/impact.test.ts +1059 -481
- package/src/compliance/__tests__/markdown.test.ts +94 -94
- package/src/compliance/__tests__/views.test.ts +64 -64
- package/src/compliance/classify.ts +100 -84
- package/src/compliance/confidence.ts +69 -69
- package/src/compliance/coverage-metric.ts +404 -263
- package/src/compliance/gap-report.ts +94 -94
- package/src/compliance/html.ts +291 -295
- package/src/compliance/impact.ts +979 -677
- package/src/compliance/index.ts +57 -56
- package/src/compliance/markdown.ts +136 -135
- package/src/compliance/reverse-index.ts +33 -33
- package/src/compliance/types.ts +136 -120
- package/src/compliance/views.ts +46 -46
- package/src/compliance-matrix/__tests__/build.test.ts +200 -200
- package/src/compliance-matrix/__tests__/example.test.ts +57 -57
- package/src/compliance-matrix/index.ts +11 -11
- package/src/compliance-matrix/types.ts +102 -102
- package/src/edge-path.ts +50 -44
- package/src/factor/__tests__/validate.test.ts +81 -46
- package/src/factor/index.ts +3 -7
- package/src/factor/types.ts +15 -19
- package/src/factor/validate.ts +77 -51
- package/src/fgca/__tests__/chain-table.test.ts +172 -172
- package/src/fgca/__tests__/layout.test.ts +179 -179
- package/src/fgca/__tests__/parse-canonical.test.ts +248 -248
- package/src/fgca/__tests__/preview-layout.test.ts +124 -124
- package/src/fgca/__tests__/resolver.test.ts +209 -0
- package/src/fgca/__tests__/validate.test.ts +142 -142
- package/src/fgca/chain-table.ts +225 -225
- package/src/fgca/index.ts +47 -45
- package/src/fgca/layout.ts +204 -204
- package/src/fgca/nodeTypes.ts +11 -11
- package/src/fgca/nodes/FGCAActivityNode.tsx +65 -65
- package/src/fgca/nodes/FGCAChangeNode.tsx +64 -64
- package/src/fgca/nodes/FGCAFactorNode.tsx +64 -64
- package/src/fgca/nodes/FGCAGoalNode.tsx +72 -72
- package/src/fgca/parse-canonical.ts +405 -400
- package/src/fgca/preview-layout.ts +217 -217
- package/src/fgca/resolver.ts +159 -0
- package/src/fgca/types.ts +50 -50
- package/src/fgca/validate.ts +129 -126
- package/src/geometry.ts +9 -9
- package/src/goals/__tests__/layout.test.ts +175 -175
- package/src/goals/__tests__/mutations.test.ts +111 -111
- package/src/goals/__tests__/parse-canonical.test.ts +145 -145
- package/src/goals/__tests__/validate.test.ts +202 -202
- package/src/goals/index.ts +20 -21
- package/src/goals/layout.ts +172 -172
- package/src/goals/mutations.ts +123 -123
- package/src/goals/parse-canonical.ts +286 -286
- package/src/goals/types.ts +85 -85
- package/src/goals/validate.ts +136 -136
- package/src/index.ts +28 -23
- package/src/process-blueprint/__tests__/compliance-lane.test.ts +320 -320
- package/src/process-blueprint/__tests__/layout.test.ts +240 -195
- package/src/process-blueprint/__tests__/validate.test.ts +310 -310
- package/src/process-blueprint/index.ts +32 -31
- package/src/process-blueprint/layout.ts +564 -531
- package/src/process-blueprint/types.ts +278 -242
- package/src/process-blueprint/validate.ts +181 -181
- package/src/process-map/__tests__/validate.test.ts +223 -223
- package/src/process-map/index.ts +10 -10
- package/src/process-map/types.ts +36 -36
- package/src/process-map/validate.ts +135 -135
- package/src/products/__tests__/validate.test.ts +239 -239
- package/src/products/index.ts +9 -9
- package/src/products/types.ts +31 -31
- package/src/products/validate.ts +112 -112
- package/src/repo-validate/__tests__/validate-repo.test.ts +149 -149
- package/src/repo-validate/index.ts +2 -2
- package/src/repo-validate/types.ts +50 -50
- package/src/repo-validate/validate-repo.ts +196 -196
- package/src/requirement/__tests__/example.test.ts +24 -24
- package/src/requirement/__tests__/validate.test.ts +96 -96
- package/src/requirement/index.ts +4 -4
- package/src/requirement/types.ts +35 -35
- package/src/requirement/validate.ts +92 -92
- package/src/scenarios/__tests__/validate.test.ts +209 -209
- package/src/scenarios/index.ts +15 -15
- package/src/scenarios/types.ts +37 -37
- package/src/scenarios/validate.ts +122 -122
- package/src/schema-version.ts +16 -16
- package/src/scope.ts +46 -46
- package/src/stakeholder/__tests__/validate.test.ts +51 -47
- package/src/stakeholder/index.ts +1 -0
- package/src/stakeholder/types.ts +7 -7
- package/src/stakeholder/validate.ts +79 -52
- package/src/target-state/__tests__/validate.test.ts +48 -27
- package/src/target-state/index.ts +2 -0
- package/src/target-state/types.ts +11 -7
- package/src/target-state/validate.ts +76 -46
- package/src/theme/index.ts +4 -4
- package/src/theme/themes.ts +239 -237
- package/src/theme/tokens.ts +135 -133
- package/src/typed-id.ts +56 -56
- package/src/validation-types.ts +36 -36
- package/src/webview/__tests__/entry-notations.test.ts +79 -77
- package/src/webview/__tests__/entry.test.ts +64 -64
- package/src/webview/__tests__/render-goals.test.ts +72 -72
- package/src/webview/__tests__/render-process.test.ts +538 -0
- package/src/webview/__tests__/render-util.test.ts +66 -0
- package/src/webview/entry.ts +298 -292
- package/src/webview/render-activities.ts +111 -69
- package/src/webview/render-activity-card.ts +275 -234
- package/src/webview/render-blocks.ts +78 -28
- package/src/webview/render-fgca.ts +53 -28
- package/src/webview/render-goals.ts +133 -110
- package/src/webview/render-process-blueprint.ts +281 -207
- package/src/webview/render-process.ts +507 -0
- package/src/webview/render-scenarios.ts +3 -3
- package/src/webview/render-util.ts +27 -14
- package/src/webview/styles.css +322 -323
- package/src/yaml-normalize.ts +56 -56
- package/dist/element-envelope.d.ts +0 -15
- package/dist/element-envelope.js +0 -55
- package/dist/issues/__tests__/layout.test.js +0 -62
- package/dist/issues/__tests__/validate.test.js +0 -82
- package/dist/issues/index.d.ts +0 -4
- package/dist/issues/index.js +0 -2
- package/dist/issues/layout.d.ts +0 -10
- package/dist/issues/layout.js +0 -82
- package/dist/issues/types.d.ts +0 -61
- package/dist/issues/types.js +0 -6
- package/dist/issues/validate.d.ts +0 -3
- package/dist/issues/validate.js +0 -143
- package/dist/webview/transitrix-render.css +0 -323
- package/dist/webview/transitrix-render.js +0 -6452
- package/dist/webview/transitrix-render.js.map +0 -7
- package/src/element-envelope.ts +0 -76
- /package/dist/{issues/__tests__/layout.test.d.ts → fgca/__tests__/resolver.test.d.ts} +0 -0
- /package/dist/{issues/__tests__/validate.test.d.ts → webview/__tests__/render-process.test.d.ts} +0 -0
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-neutral SVG emitter for the BPMN process notation.
|
|
3
|
+
*
|
|
4
|
+
* Part of the custom process renderer programme (ADR 2026-06-22).
|
|
5
|
+
* P1: skeleton emitter — current DSL element subset: tasks, user/service tasks,
|
|
6
|
+
* XOR/AND gateways, start/end events, data objects, sequence flows (with
|
|
7
|
+
* default-flow markers), and association edges.
|
|
8
|
+
*
|
|
9
|
+
* Single-emitter unification (review C): `renderProcessBody` is the canonical
|
|
10
|
+
* body shared by every host. Callers wrap it with a host-specific title block
|
|
11
|
+
* or a standalone SVG shell.
|
|
12
|
+
*
|
|
13
|
+
* No VS Code APIs. No Node.js built-ins. Browser-safe.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { generateSvgEmbedCss } from '../theme/index.js';
|
|
17
|
+
import { escXml } from './render-util.js';
|
|
18
|
+
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// Structural interface — mirrors LayoutIr from the BPMN core without taking a
|
|
21
|
+
// build-time dependency on that package. TypeScript structural typing ensures
|
|
22
|
+
// any LayoutIr value satisfies ProcessDiagramLayout.
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
export interface ProcessBounds {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ProcessFlowElement {
|
|
33
|
+
id: string;
|
|
34
|
+
type: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ProcessLane {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
elements: ProcessFlowElement[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ProcessInfo {
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
poolId: string;
|
|
48
|
+
poolName: string;
|
|
49
|
+
lanes: ProcessLane[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ProcessFlow {
|
|
53
|
+
id: string;
|
|
54
|
+
from: string;
|
|
55
|
+
to: string;
|
|
56
|
+
condition?: string;
|
|
57
|
+
default?: boolean;
|
|
58
|
+
name?: string;
|
|
59
|
+
waypoints: { x: number; y: number }[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ProcessAssociation {
|
|
63
|
+
id: string;
|
|
64
|
+
from: string;
|
|
65
|
+
to: string;
|
|
66
|
+
waypoints: { x: number; y: number }[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ProcessDiagramLayout {
|
|
70
|
+
process: ProcessInfo;
|
|
71
|
+
elements: Map<string, ProcessBounds>;
|
|
72
|
+
laneBounds: Map<string, ProcessBounds>;
|
|
73
|
+
poolBounds: ProcessBounds;
|
|
74
|
+
flows: ProcessFlow[];
|
|
75
|
+
associations: ProcessAssociation[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface RenderProcessOptions {
|
|
79
|
+
/** Raw SVG injected after `<style>` — a title line or full title block. */
|
|
80
|
+
title?: string;
|
|
81
|
+
/** Extra vertical space (px) reserved above the pool for a title block. */
|
|
82
|
+
topInset?: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
// Constants — match DEFAULT_LAYOUT_DIAGRAM_OPTIONS in src/layout-options.ts
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
/** Width of the lane-name column (px). Matches the laneLabelWidth default. */
|
|
90
|
+
const LANE_LABEL_BAND = 44;
|
|
91
|
+
|
|
92
|
+
/** End margin (px) along the header height axis for rotated pool/lane captions. */
|
|
93
|
+
const HEADER_LABEL_AXIS_PAD = 32;
|
|
94
|
+
|
|
95
|
+
/** Estimated horizontal advance (px) per character at the header label font size. */
|
|
96
|
+
const HEADER_LABEL_CHAR_W = 6.5;
|
|
97
|
+
|
|
98
|
+
/** Maximum characters per wrapped line inside a task box. */
|
|
99
|
+
const TASK_CHARS = 14;
|
|
100
|
+
|
|
101
|
+
/** Line height for wrapped task-name text (px). */
|
|
102
|
+
const TASK_LINE_H = 14;
|
|
103
|
+
|
|
104
|
+
/** Maximum characters per line for below-element labels (events, gateways). */
|
|
105
|
+
const LABEL_CHARS = 18;
|
|
106
|
+
|
|
107
|
+
/** Line height for multi-line below-element labels (px). */
|
|
108
|
+
const LABEL_LINE_H = 13;
|
|
109
|
+
|
|
110
|
+
// ---------------------------------------------------------------------------
|
|
111
|
+
// BPMN-specific CSS — no font-style:italic per CLAUDE.md design rule
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
|
|
114
|
+
export const BPMN_PROCESS_CSS = `
|
|
115
|
+
.bpmn-pool { fill: var(--ts-bg-surface,#f8fafc); stroke: var(--ts-node-stroke,#94a3b8); stroke-width: 1.5; }
|
|
116
|
+
.bpmn-pool-name { fill: var(--ts-bg-elevated,#f1f5f9); stroke: var(--ts-node-stroke,#94a3b8); stroke-width: 0.75; }
|
|
117
|
+
.bpmn-lane { fill: var(--ts-bg,#ffffff); stroke: var(--ts-node-stroke,#94a3b8); stroke-width: 0.75; }
|
|
118
|
+
.bpmn-lane-header { fill: var(--ts-bg-elevated,#f1f5f9); stroke: var(--ts-node-stroke,#94a3b8); stroke-width: 0.75; }
|
|
119
|
+
.bpmn-pool-label { fill: var(--ts-text-primary,#1e293b); font-size: 11px; font-weight: 700; }
|
|
120
|
+
.bpmn-lane-label { fill: var(--ts-text-primary,#1e293b); font-size: 11px; font-weight: 600; }
|
|
121
|
+
.bpmn-task { fill: var(--ts-bg,#ffffff); stroke: var(--ts-node-stroke,#94a3b8); stroke-width: 1.5; }
|
|
122
|
+
.bpmn-task-name { fill: var(--ts-text-primary,#1e293b); font-size: 11px; text-anchor: middle; }
|
|
123
|
+
.bpmn-event { fill: var(--ts-bg,#ffffff); stroke: var(--ts-node-stroke,#94a3b8); }
|
|
124
|
+
.bpmn-event-start { stroke-width: 1.5; }
|
|
125
|
+
.bpmn-event-end { stroke-width: 4; }
|
|
126
|
+
.bpmn-event-label { fill: var(--ts-text-secondary,#64748b); font-size: 10px; text-anchor: middle; }
|
|
127
|
+
.bpmn-gateway { fill: var(--ts-bg,#ffffff); stroke: var(--ts-node-stroke,#94a3b8); stroke-width: 1.5; }
|
|
128
|
+
.bpmn-gateway-marker { stroke: var(--ts-node-stroke,#94a3b8); stroke-width: 2.5; stroke-linecap: round; fill: none; }
|
|
129
|
+
.bpmn-gateway-label { fill: var(--ts-text-secondary,#64748b); font-size: 10px; text-anchor: middle; }
|
|
130
|
+
.bpmn-seq-flow { fill: none; stroke: var(--ts-edge-stroke,#64748b); stroke-width: 1.5; }
|
|
131
|
+
.bpmn-default-mark { stroke: var(--ts-edge-stroke,#64748b); stroke-width: 1.5; stroke-linecap: round; }
|
|
132
|
+
.bpmn-assoc { fill: none; stroke: var(--ts-edge-stroke,#64748b); stroke-width: 1; stroke-dasharray: 4 2; }
|
|
133
|
+
.bpmn-data-obj { fill: var(--ts-bg,#ffffff); stroke: var(--ts-node-stroke,#94a3b8); stroke-width: 1; }
|
|
134
|
+
.bpmn-data-obj-label { fill: var(--ts-text-secondary,#64748b); font-size: 10px; text-anchor: middle; }
|
|
135
|
+
.bpmn-event-intermediate { fill: none; stroke: var(--ts-node-stroke,#94a3b8); stroke-width: 1; }
|
|
136
|
+
.bpmn-event-icon { fill: none; stroke: var(--ts-node-stroke,#94a3b8); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
|
|
137
|
+
`;
|
|
138
|
+
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
// Internal helpers
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
|
|
143
|
+
function r(n: number): number {
|
|
144
|
+
return Math.round(n);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Truncate at a word boundary so rotated header labels never break mid-word. */
|
|
148
|
+
function wordTruncate(text: string, maxChars: number): string {
|
|
149
|
+
if (text.length <= maxChars) return text;
|
|
150
|
+
const cut = text.slice(0, maxChars - 1);
|
|
151
|
+
const lastSpace = cut.lastIndexOf(' ');
|
|
152
|
+
return (lastSpace > maxChars / 2 ? cut.slice(0, lastSpace) : cut) + '…';
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function fitRotatedHeaderText(name: string, spanPx: number): string {
|
|
156
|
+
const maxChars = Math.max(4, Math.floor(spanPx / HEADER_LABEL_CHAR_W));
|
|
157
|
+
return wordTruncate(name, maxChars);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function wrapTaskName(name: string): string[] {
|
|
161
|
+
if (!name) return [];
|
|
162
|
+
const words = name.split(/\s+/);
|
|
163
|
+
const lines: string[] = [];
|
|
164
|
+
let cur = '';
|
|
165
|
+
for (const w of words) {
|
|
166
|
+
const token = w.length > TASK_CHARS ? w.slice(0, TASK_CHARS - 1) + '…' : w;
|
|
167
|
+
if (!cur) {
|
|
168
|
+
cur = token;
|
|
169
|
+
} else if (cur.length + 1 + token.length <= TASK_CHARS) {
|
|
170
|
+
cur += ' ' + token;
|
|
171
|
+
} else {
|
|
172
|
+
lines.push(cur);
|
|
173
|
+
if (lines.length === 3) {
|
|
174
|
+
if (lines[2].length > TASK_CHARS - 1) lines[2] = lines[2].slice(0, TASK_CHARS - 1) + '…';
|
|
175
|
+
return lines;
|
|
176
|
+
}
|
|
177
|
+
cur = token;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (cur && lines.length < 3) lines.push(cur);
|
|
181
|
+
if (lines.length === 0) lines.push(name.slice(0, TASK_CHARS));
|
|
182
|
+
return lines;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function taskNameSvg(name: string | undefined, cx: number, cy: number): string {
|
|
186
|
+
if (!name) return '';
|
|
187
|
+
const lines = wrapTaskName(name);
|
|
188
|
+
const totalH = lines.length * TASK_LINE_H;
|
|
189
|
+
const startY = cy - totalH / 2 + TASK_LINE_H * 0.8;
|
|
190
|
+
const tspans = lines
|
|
191
|
+
.map((ln, i) => `<tspan x="${r(cx)}" y="${r(startY + i * TASK_LINE_H)}">${escXml(ln)}</tspan>`)
|
|
192
|
+
.join('');
|
|
193
|
+
return `<text class="bpmn-task-name">${tspans}</text>`;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function wrapBelowLabel(name: string): string[] {
|
|
197
|
+
const words = name.split(/\s+/).filter(Boolean);
|
|
198
|
+
const allLines: string[] = [];
|
|
199
|
+
let cur = '';
|
|
200
|
+
for (const word of words) {
|
|
201
|
+
const tok = word.length > LABEL_CHARS ? word.slice(0, LABEL_CHARS - 1) + '…' : word;
|
|
202
|
+
const test = cur ? `${cur} ${tok}` : tok;
|
|
203
|
+
if (test.length <= LABEL_CHARS) {
|
|
204
|
+
cur = test;
|
|
205
|
+
} else {
|
|
206
|
+
if (cur) allLines.push(cur);
|
|
207
|
+
cur = tok;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (cur) allLines.push(cur);
|
|
211
|
+
if (allLines.length === 0) return [name.slice(0, LABEL_CHARS)];
|
|
212
|
+
if (allLines.length <= 3) return allLines;
|
|
213
|
+
const lines = allLines.slice(0, 3);
|
|
214
|
+
const last = lines[2];
|
|
215
|
+
lines[2] = last.length + 1 <= LABEL_CHARS ? last + '…' : last.slice(0, LABEL_CHARS - 1) + '…';
|
|
216
|
+
return lines;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function belowLabelSvg(name: string | undefined, cls: string, cx: number, belowY: number, minX = 0): string {
|
|
220
|
+
if (!name) return '';
|
|
221
|
+
const lines = wrapBelowLabel(name);
|
|
222
|
+
const halfW = Math.max(...lines.map((l) => l.length)) * 3;
|
|
223
|
+
const textX = minX > 0 ? Math.max(cx, minX + halfW + 2) : cx;
|
|
224
|
+
const startY = r(belowY + 12);
|
|
225
|
+
if (lines.length === 1) {
|
|
226
|
+
return `<text class="${cls}" x="${r(textX)}" y="${startY}">${escXml(lines[0])}</text>`;
|
|
227
|
+
}
|
|
228
|
+
const tspans = lines
|
|
229
|
+
.map((ln, i) => `<tspan x="${r(textX)}" dy="${i === 0 ? 0 : LABEL_LINE_H}">${escXml(ln)}</tspan>`)
|
|
230
|
+
.join('');
|
|
231
|
+
return `<text class="${cls}" x="${r(textX)}" y="${startY}">${tspans}</text>`;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// ---------------------------------------------------------------------------
|
|
235
|
+
// Element renderer
|
|
236
|
+
// ---------------------------------------------------------------------------
|
|
237
|
+
|
|
238
|
+
function renderElement(el: ProcessFlowElement, b: ProcessBounds, ox: number, oy: number, minLabelX = 0): string {
|
|
239
|
+
const ex = b.x + ox;
|
|
240
|
+
const ey = b.y + oy;
|
|
241
|
+
const cx = ex + b.width / 2;
|
|
242
|
+
const cy = ey + b.height / 2;
|
|
243
|
+
const halfR = Math.min(b.width, b.height) / 2;
|
|
244
|
+
|
|
245
|
+
switch (el.type) {
|
|
246
|
+
case 'startEvent':
|
|
247
|
+
return [
|
|
248
|
+
`<circle class="bpmn-event bpmn-event-start" cx="${r(cx)}" cy="${r(cy)}" r="${r(halfR)}"/>`,
|
|
249
|
+
belowLabelSvg(el.name, 'bpmn-event-label', cx, ey + b.height, minLabelX),
|
|
250
|
+
].join('\n');
|
|
251
|
+
|
|
252
|
+
case 'endEvent':
|
|
253
|
+
return [
|
|
254
|
+
`<circle class="bpmn-event bpmn-event-end" cx="${r(cx)}" cy="${r(cy)}" r="${r(halfR - 2)}"/>`,
|
|
255
|
+
belowLabelSvg(el.name, 'bpmn-event-label', cx, ey + b.height, minLabelX),
|
|
256
|
+
].join('\n');
|
|
257
|
+
|
|
258
|
+
case 'task':
|
|
259
|
+
case 'userTask':
|
|
260
|
+
case 'serviceTask':
|
|
261
|
+
return [
|
|
262
|
+
`<rect class="diagram-node bpmn-task" x="${r(ex)}" y="${r(ey)}" width="${r(b.width)}" height="${r(b.height)}" rx="4" ry="4"/>`,
|
|
263
|
+
taskNameSvg(el.name, cx, cy),
|
|
264
|
+
].join('\n');
|
|
265
|
+
|
|
266
|
+
case 'exclusiveGateway':
|
|
267
|
+
return [
|
|
268
|
+
`<path class="bpmn-gateway" d="M ${r(cx)},${r(ey)} L ${r(ex + b.width)},${r(cy)} L ${r(cx)},${r(ey + b.height)} L ${r(ex)},${r(cy)} Z"/>`,
|
|
269
|
+
`<path class="bpmn-gateway-marker" d="M ${r(cx - 10)},${r(cy - 10)} L ${r(cx + 10)},${r(cy + 10)} M ${r(cx + 10)},${r(cy - 10)} L ${r(cx - 10)},${r(cy + 10)}"/>`,
|
|
270
|
+
belowLabelSvg(el.name, 'bpmn-gateway-label', cx, ey + b.height, minLabelX),
|
|
271
|
+
].join('\n');
|
|
272
|
+
|
|
273
|
+
case 'parallelGateway':
|
|
274
|
+
return [
|
|
275
|
+
`<path class="bpmn-gateway" d="M ${r(cx)},${r(ey)} L ${r(ex + b.width)},${r(cy)} L ${r(cx)},${r(ey + b.height)} L ${r(ex)},${r(cy)} Z"/>`,
|
|
276
|
+
`<path class="bpmn-gateway-marker" d="M ${r(cx)},${r(cy - 12)} L ${r(cx)},${r(cy + 12)} M ${r(cx - 12)},${r(cy)} L ${r(cx + 12)},${r(cy)}"/>`,
|
|
277
|
+
belowLabelSvg(el.name, 'bpmn-gateway-label', cx, ey + b.height, minLabelX),
|
|
278
|
+
].join('\n');
|
|
279
|
+
|
|
280
|
+
case 'inclusiveGateway':
|
|
281
|
+
return [
|
|
282
|
+
`<path class="bpmn-gateway" d="M ${r(cx)},${r(ey)} L ${r(ex + b.width)},${r(cy)} L ${r(cx)},${r(ey + b.height)} L ${r(ex)},${r(cy)} Z"/>`,
|
|
283
|
+
`<circle class="bpmn-gateway-marker" cx="${r(cx)}" cy="${r(cy)}" r="${r(halfR * 0.4)}"/>`,
|
|
284
|
+
belowLabelSvg(el.name, 'bpmn-gateway-label', cx, ey + b.height, minLabelX),
|
|
285
|
+
].join('\n');
|
|
286
|
+
|
|
287
|
+
case 'intermediateMessageEvent': {
|
|
288
|
+
const innerR = r(halfR - 4);
|
|
289
|
+
const eHW = r(halfR * 0.45);
|
|
290
|
+
const eHH = r(halfR * 0.3);
|
|
291
|
+
return [
|
|
292
|
+
`<circle class="bpmn-event bpmn-event-start" cx="${r(cx)}" cy="${r(cy)}" r="${r(halfR)}"/>`,
|
|
293
|
+
`<circle class="bpmn-event-intermediate" cx="${r(cx)}" cy="${r(cy)}" r="${innerR}"/>`,
|
|
294
|
+
`<rect class="bpmn-event-icon" x="${r(cx - eHW)}" y="${r(cy - eHH)}" width="${r(eHW * 2)}" height="${r(eHH * 2)}"/>`,
|
|
295
|
+
`<path class="bpmn-event-icon" d="M ${r(cx - eHW)},${r(cy - eHH)} L ${r(cx)},${r(cy)} L ${r(cx + eHW)},${r(cy - eHH)}"/>`,
|
|
296
|
+
belowLabelSvg(el.name, 'bpmn-event-label', cx, ey + b.height, minLabelX),
|
|
297
|
+
].join('\n');
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
case 'intermediateTimerEvent': {
|
|
301
|
+
const innerR = r(halfR - 4);
|
|
302
|
+
const clockR = r(halfR * 0.5);
|
|
303
|
+
const handLen = r(halfR * 0.38);
|
|
304
|
+
return [
|
|
305
|
+
`<circle class="bpmn-event bpmn-event-start" cx="${r(cx)}" cy="${r(cy)}" r="${r(halfR)}"/>`,
|
|
306
|
+
`<circle class="bpmn-event-intermediate" cx="${r(cx)}" cy="${r(cy)}" r="${innerR}"/>`,
|
|
307
|
+
`<circle class="bpmn-event-icon" cx="${r(cx)}" cy="${r(cy)}" r="${clockR}"/>`,
|
|
308
|
+
`<line class="bpmn-event-icon" x1="${r(cx)}" y1="${r(cy)}" x2="${r(cx)}" y2="${r(cy - handLen)}"/>`,
|
|
309
|
+
`<line class="bpmn-event-icon" x1="${r(cx)}" y1="${r(cy)}" x2="${r(cx + r(handLen * 0.7))}" y2="${r(cy)}"/>`,
|
|
310
|
+
belowLabelSvg(el.name, 'bpmn-event-label', cx, ey + b.height, minLabelX),
|
|
311
|
+
].join('\n');
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
case 'dataObject': {
|
|
315
|
+
const fold = Math.min(8, b.width / 3, b.height / 3);
|
|
316
|
+
return [
|
|
317
|
+
`<path class="bpmn-data-obj" d="M ${r(ex)},${r(ey)} L ${r(ex + b.width - fold)},${r(ey)} L ${r(ex + b.width)},${r(ey + fold)} L ${r(ex + b.width)},${r(ey + b.height)} L ${r(ex)},${r(ey + b.height)} Z"/>`,
|
|
318
|
+
`<path class="bpmn-data-obj" fill="none" d="M ${r(ex + b.width - fold)},${r(ey)} L ${r(ex + b.width - fold)},${r(ey + fold)} L ${r(ex + b.width)},${r(ey + fold)}"/>`,
|
|
319
|
+
belowLabelSvg(el.name, 'bpmn-data-obj-label', cx, ey + b.height, minLabelX),
|
|
320
|
+
].join('\n');
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
default:
|
|
324
|
+
return [
|
|
325
|
+
`<rect class="diagram-node" x="${r(ex)}" y="${r(ey)}" width="${r(b.width)}" height="${r(b.height)}"/>`,
|
|
326
|
+
el.name
|
|
327
|
+
? `<text class="text-primary" x="${r(cx)}" y="${r(cy)}" text-anchor="middle" dominant-baseline="central">${escXml(el.name)}</text>`
|
|
328
|
+
: '',
|
|
329
|
+
].join('\n');
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// ---------------------------------------------------------------------------
|
|
334
|
+
// Pool / lane structure
|
|
335
|
+
// ---------------------------------------------------------------------------
|
|
336
|
+
|
|
337
|
+
function renderPoolLanes(layout: ProcessDiagramLayout, ox: number, oy: number): string {
|
|
338
|
+
const { process, laneBounds, poolBounds: pb } = layout;
|
|
339
|
+
const parts: string[] = [];
|
|
340
|
+
const px = r(pb.x + ox);
|
|
341
|
+
const py = r(pb.y + oy);
|
|
342
|
+
const pw = r(pb.width);
|
|
343
|
+
const ph = r(pb.height);
|
|
344
|
+
|
|
345
|
+
// Pool name band width: distance from pool left edge to first lane left edge
|
|
346
|
+
const firstLb = laneBounds.size > 0 ? [...laneBounds.values()][0] : undefined;
|
|
347
|
+
const poolNameW = firstLb ? r(firstLb.x - pb.x) : 48;
|
|
348
|
+
|
|
349
|
+
parts.push(`<rect class="bpmn-pool" x="${px}" y="${py}" width="${pw}" height="${ph}"/>`);
|
|
350
|
+
parts.push(`<rect class="bpmn-pool-name" x="${px}" y="${py}" width="${poolNameW}" height="${ph}"/>`);
|
|
351
|
+
|
|
352
|
+
const pLX = r(px + poolNameW / 2);
|
|
353
|
+
const poolLabelSpan = Math.max(ph - 2 * HEADER_LABEL_AXIS_PAD, 0);
|
|
354
|
+
const pLY = r(py + HEADER_LABEL_AXIS_PAD + poolLabelSpan / 2);
|
|
355
|
+
parts.push(
|
|
356
|
+
`<text class="bpmn-pool-label" text-anchor="middle" dominant-baseline="central"` +
|
|
357
|
+
` transform="rotate(-90,${pLX},${pLY})" x="${pLX}" y="${pLY}">${escXml(fitRotatedHeaderText(process.poolName, poolLabelSpan))}</text>`,
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
for (const lane of process.lanes) {
|
|
361
|
+
const lb = laneBounds.get(lane.id);
|
|
362
|
+
if (!lb) continue;
|
|
363
|
+
const lx = r(lb.x + ox);
|
|
364
|
+
const ly = r(lb.y + oy);
|
|
365
|
+
const lw = r(lb.width);
|
|
366
|
+
const lh = r(lb.height);
|
|
367
|
+
|
|
368
|
+
parts.push(`<rect class="bpmn-lane" x="${lx}" y="${ly}" width="${lw}" height="${lh}"/>`);
|
|
369
|
+
parts.push(`<rect class="bpmn-lane-header" x="${lx}" y="${ly}" width="${LANE_LABEL_BAND}" height="${lh}"/>`);
|
|
370
|
+
|
|
371
|
+
const lLX = r(lx + LANE_LABEL_BAND / 2);
|
|
372
|
+
const laneLabelSpan = Math.max(lh - 2 * HEADER_LABEL_AXIS_PAD, 0);
|
|
373
|
+
const lLY = r(ly + HEADER_LABEL_AXIS_PAD + laneLabelSpan / 2);
|
|
374
|
+
parts.push(
|
|
375
|
+
`<text class="bpmn-lane-label" text-anchor="middle" dominant-baseline="central"` +
|
|
376
|
+
` transform="rotate(-90,${lLX},${lLY})" x="${lLX}" y="${lLY}">${escXml(fitRotatedHeaderText(lane.name, laneLabelSpan))}</text>`,
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return parts.join('\n');
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// ---------------------------------------------------------------------------
|
|
384
|
+
// Public API
|
|
385
|
+
// ---------------------------------------------------------------------------
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Canonical body emitter, shared by every host (VS Code, JCEF, static export).
|
|
389
|
+
*
|
|
390
|
+
* Renders: pool + lane structure, all flow elements, sequence flows (with
|
|
391
|
+
* default-flow markers), and association edges. The `<defs>` block
|
|
392
|
+
* containing the arrowhead marker is included so the body is self-contained.
|
|
393
|
+
*
|
|
394
|
+
* @param layout - Positioned process layout (output of `layoutProcess`).
|
|
395
|
+
* @param ox - Horizontal canvas offset (px) applied to all coordinates.
|
|
396
|
+
* @param oy - Vertical canvas offset (px) applied to all coordinates.
|
|
397
|
+
*/
|
|
398
|
+
export function renderProcessBody(
|
|
399
|
+
layout: ProcessDiagramLayout,
|
|
400
|
+
ox: number,
|
|
401
|
+
oy: number,
|
|
402
|
+
): string {
|
|
403
|
+
const parts: string[] = [];
|
|
404
|
+
|
|
405
|
+
// Build clip-path rects for every lane so element labels can't bleed into the
|
|
406
|
+
// lane-name header strip on the left.
|
|
407
|
+
const laneClipDefs = layout.process.lanes.map((lane) => {
|
|
408
|
+
const lb = layout.laneBounds.get(lane.id);
|
|
409
|
+
if (!lb) return '';
|
|
410
|
+
const clipId = `bpmn-lc-${escXml(lane.id)}`;
|
|
411
|
+
const cx2 = r(lb.x + ox + LANE_LABEL_BAND);
|
|
412
|
+
const cy2 = r(lb.y + oy);
|
|
413
|
+
const cw = r(lb.width - LANE_LABEL_BAND);
|
|
414
|
+
const ch = r(lb.height);
|
|
415
|
+
return ` <clipPath id="${clipId}"><rect x="${cx2}" y="${cy2}" width="${cw}" height="${ch}"/></clipPath>`;
|
|
416
|
+
}).filter(Boolean).join('\n');
|
|
417
|
+
|
|
418
|
+
parts.push(
|
|
419
|
+
`<defs>\n` +
|
|
420
|
+
` <marker id="bpmn-arrow" viewBox="0 0 10 10" refX="9" refY="5"` +
|
|
421
|
+
` markerWidth="8" markerHeight="8" orient="auto">\n` +
|
|
422
|
+
` <path d="M 0 0 L 10 5 L 0 10 z" class="arrow-fill"/>\n` +
|
|
423
|
+
` </marker>\n` +
|
|
424
|
+
(laneClipDefs ? laneClipDefs + '\n' : '') +
|
|
425
|
+
`</defs>`,
|
|
426
|
+
);
|
|
427
|
+
|
|
428
|
+
parts.push(renderPoolLanes(layout, ox, oy));
|
|
429
|
+
|
|
430
|
+
for (const lane of layout.process.lanes) {
|
|
431
|
+
const lb = layout.laneBounds.get(lane.id);
|
|
432
|
+
const clipId = lb ? `bpmn-lc-${escXml(lane.id)}` : undefined;
|
|
433
|
+
const laneContentX = lb ? lb.x + ox + LANE_LABEL_BAND : 0;
|
|
434
|
+
if (clipId) parts.push(`<g clip-path="url(#${clipId})">`);
|
|
435
|
+
for (const el of lane.elements) {
|
|
436
|
+
const b = layout.elements.get(el.id);
|
|
437
|
+
if (!b) continue;
|
|
438
|
+
parts.push(renderElement(el, b, ox, oy, laneContentX));
|
|
439
|
+
}
|
|
440
|
+
if (clipId) parts.push('</g>');
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
for (const flow of layout.flows) {
|
|
444
|
+
if (flow.waypoints.length < 2) continue;
|
|
445
|
+
const pts = flow.waypoints.map((p) => `${r(p.x + ox)},${r(p.y + oy)}`).join(' ');
|
|
446
|
+
parts.push(`<polyline class="bpmn-seq-flow" points="${pts}" marker-end="url(#bpmn-arrow)"/>`);
|
|
447
|
+
if (flow.default) {
|
|
448
|
+
const p0 = flow.waypoints[0];
|
|
449
|
+
const p1 = flow.waypoints[1];
|
|
450
|
+
const dx = p1.x - p0.x;
|
|
451
|
+
const dy = p1.y - p0.y;
|
|
452
|
+
const len = Math.sqrt(dx * dx + dy * dy);
|
|
453
|
+
if (len >= 1) {
|
|
454
|
+
const nx = dx / len;
|
|
455
|
+
const ny = dy / len;
|
|
456
|
+
const HALF = 5;
|
|
457
|
+
const OFFSET = 8;
|
|
458
|
+
const cx = p0.x + ox + nx * OFFSET;
|
|
459
|
+
const cy = p0.y + oy + ny * OFFSET;
|
|
460
|
+
// Perpendicular slash: marks the default outflow per BPMN 2.0 §10.3.3
|
|
461
|
+
parts.push(
|
|
462
|
+
`<line class="bpmn-default-mark" x1="${r(cx - ny * HALF)}" y1="${r(cy + nx * HALF)}" x2="${r(cx + ny * HALF)}" y2="${r(cy - nx * HALF)}"/>`,
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
for (const assoc of layout.associations) {
|
|
469
|
+
if (assoc.waypoints.length < 2) continue;
|
|
470
|
+
const pts = assoc.waypoints.map((p) => `${r(p.x + ox)},${r(p.y + oy)}`).join(' ');
|
|
471
|
+
parts.push(`<polyline class="bpmn-assoc" points="${pts}"/>`);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
return parts.join('\n');
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Self-contained SVG for the BPMN process notation.
|
|
479
|
+
*
|
|
480
|
+
* Embeds the shared Transitrix theme CSS plus BPMN-specific rules so the
|
|
481
|
+
* output can be dropped into a static webview panel or saved as an `.svg`
|
|
482
|
+
* file. VS Code's dynamic preview (which supplies CSS separately via a
|
|
483
|
+
* webview stylesheet) should call `renderProcessBody` directly and wrap it
|
|
484
|
+
* with its own HTML shell.
|
|
485
|
+
*/
|
|
486
|
+
export function renderProcessLayoutSvg(
|
|
487
|
+
layout: ProcessDiagramLayout,
|
|
488
|
+
options: RenderProcessOptions = {},
|
|
489
|
+
): string {
|
|
490
|
+
const { title = '', topInset = title ? 32 : 0 } = options;
|
|
491
|
+
const pb = layout.poolBounds;
|
|
492
|
+
const PAD = 16;
|
|
493
|
+
|
|
494
|
+
const svgW = r(pb.x + pb.width + PAD);
|
|
495
|
+
const svgH = r(pb.y + pb.height + PAD + topInset);
|
|
496
|
+
|
|
497
|
+
const embedCss = generateSvgEmbedCss('transitrix') + BPMN_PROCESS_CSS;
|
|
498
|
+
const body = renderProcessBody(layout, 0, topInset);
|
|
499
|
+
|
|
500
|
+
return (
|
|
501
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${svgW}" height="${svgH}" viewBox="0 0 ${svgW} ${svgH}">\n` +
|
|
502
|
+
`<style>${embedCss}</style>\n` +
|
|
503
|
+
(title ? `${title}\n` : '') +
|
|
504
|
+
`${body}\n` +
|
|
505
|
+
`</svg>`
|
|
506
|
+
);
|
|
507
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Mirrors `extension/src/scenarios-preview.ts`; emits a self-contained HTML
|
|
4
4
|
* fragment for the JCEF host (Step 4 of ADR 0001).
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { DriverView, ScenarioHeader } from '../scenarios/types.js';
|
|
7
7
|
import { escHtml } from './render-util.js';
|
|
8
8
|
|
|
9
9
|
const STATUS_BADGE: Record<string, string> = {
|
|
@@ -18,7 +18,7 @@ const RELEVANCE_BADGE: Record<string, string> = {
|
|
|
18
18
|
Low: 'badge-low',
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
function
|
|
21
|
+
function buildDriversTable(factors: DriverView[] | undefined): string {
|
|
22
22
|
if (!factors || factors.length === 0) return '';
|
|
23
23
|
const rows = factors
|
|
24
24
|
.map(
|
|
@@ -63,7 +63,7 @@ export function renderScenarioHtml(scn: ScenarioHeader): string {
|
|
|
63
63
|
<p class="scn-vision-text">${escHtml(scn.vision)}</p>
|
|
64
64
|
</section>`);
|
|
65
65
|
}
|
|
66
|
-
blocks.push(
|
|
66
|
+
blocks.push(buildDriversTable(scn.factors_view));
|
|
67
67
|
blocks.push(buildRefSection('Goals', extractIds(scn.goals, 'goal_id')));
|
|
68
68
|
blocks.push(buildRefSection('Capabilities', extractIds(scn.capabilities, 'capability_id')));
|
|
69
69
|
blocks.push(buildRefSection('Activities', extractIds(scn.activities, 'activity_id')));
|
|
@@ -16,19 +16,32 @@ export function escXml(s: string): string {
|
|
|
16
16
|
/** Same encoding as `escXml`; aliased so HTML-table renderers read clearly. */
|
|
17
17
|
export const escHtml = escXml;
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Extracts standard diagram-level metadata from a raw parsed YAML document.
|
|
21
|
+
*
|
|
22
|
+
* Per CONTRACT §1.1, every notation stores its canonical metadata at the root level:
|
|
23
|
+
* name: "Human-readable diagram title" # required
|
|
24
|
+
* generated_at: "YYYY-MM-DD" # optional
|
|
25
|
+
*
|
|
26
|
+
* Backward-compat reads: `title` (legacy alias for `name`), `date` (legacy alias
|
|
27
|
+
* for `generated_at`), and `description`/`version` which are not in the standard
|
|
28
|
+
* but widely present in existing files.
|
|
29
|
+
*
|
|
30
|
+
* Host-neutral so both the VS Code preview chrome and the webview bundle share a
|
|
31
|
+
* single metadata reader (review E). Accepts `unknown` and guards internally.
|
|
32
|
+
*/
|
|
33
|
+
export function extractDiagramMeta(doc: unknown): {
|
|
34
|
+
title: string | undefined;
|
|
35
|
+
subtitle: string | undefined;
|
|
36
|
+
date: string | undefined;
|
|
37
|
+
version: string | undefined;
|
|
25
38
|
} {
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return
|
|
39
|
+
const raw = (doc && typeof doc === 'object' ? doc : {}) as Record<string, unknown>;
|
|
40
|
+
const name = typeof raw['name'] === 'string' ? raw['name'] : undefined;
|
|
41
|
+
const title = name ?? (typeof raw['title'] === 'string' ? raw['title'] : undefined);
|
|
42
|
+
const subtitle = typeof raw['description'] === 'string' ? raw['description'] : undefined;
|
|
43
|
+
const genAt = typeof raw['generated_at'] === 'string' ? raw['generated_at'] : undefined;
|
|
44
|
+
const date = genAt ?? (typeof raw['date'] === 'string' ? raw['date'] : undefined);
|
|
45
|
+
const version = raw['version'] !== undefined ? String(raw['version']) : undefined;
|
|
46
|
+
return { title, subtitle, date, version };
|
|
34
47
|
}
|