@formicoidea/labre-framework-uml 0.42.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.
Files changed (114) hide show
  1. package/LICENSE +384 -0
  2. package/dist/actions.d.ts +430 -0
  3. package/dist/actions.js +724 -0
  4. package/dist/background.d.ts +153 -0
  5. package/dist/background.js +557 -0
  6. package/dist/board-hit.d.ts +137 -0
  7. package/dist/board-hit.js +191 -0
  8. package/dist/commands-manifest.d.ts +19 -0
  9. package/dist/commands-manifest.js +571 -0
  10. package/dist/commands.d.ts +4 -0
  11. package/dist/commands.js +983 -0
  12. package/dist/component.d.ts +521 -0
  13. package/dist/component.js +708 -0
  14. package/dist/consts.d.ts +365 -0
  15. package/dist/consts.js +463 -0
  16. package/dist/descriptor.d.ts +12 -0
  17. package/dist/descriptor.js +10 -0
  18. package/dist/drawio-decode.d.ts +32 -0
  19. package/dist/drawio-decode.js +96 -0
  20. package/dist/drawio-import.d.ts +133 -0
  21. package/dist/drawio-import.js +885 -0
  22. package/dist/edge-morph.d.ts +154 -0
  23. package/dist/edge-morph.js +153 -0
  24. package/dist/edge-styles.d.ts +78 -0
  25. package/dist/edge-styles.js +210 -0
  26. package/dist/effects.d.ts +9 -0
  27. package/dist/effects.js +6 -0
  28. package/dist/element-renderer.d.ts +64 -0
  29. package/dist/element-renderer.js +114 -0
  30. package/dist/element-view.d.ts +234 -0
  31. package/dist/element-view.js +430 -0
  32. package/dist/export.d.ts +61 -0
  33. package/dist/export.js +41 -0
  34. package/dist/filename.d.ts +17 -0
  35. package/dist/filename.js +26 -0
  36. package/dist/frame-tag.d.ts +70 -0
  37. package/dist/frame-tag.js +78 -0
  38. package/dist/grammar.d.ts +695 -0
  39. package/dist/grammar.js +1436 -0
  40. package/dist/import.d.ts +306 -0
  41. package/dist/import.js +1270 -0
  42. package/dist/index.d.ts +47 -0
  43. package/dist/index.js +67 -0
  44. package/dist/interchange.d.ts +125 -0
  45. package/dist/interchange.js +372 -0
  46. package/dist/keywords.d.ts +204 -0
  47. package/dist/keywords.js +361 -0
  48. package/dist/kinds.d.ts +73 -0
  49. package/dist/kinds.js +91 -0
  50. package/dist/legend.d.ts +30 -0
  51. package/dist/legend.js +255 -0
  52. package/dist/model.d.ts +862 -0
  53. package/dist/model.js +1316 -0
  54. package/dist/morph.d.ts +178 -0
  55. package/dist/morph.js +496 -0
  56. package/dist/node/act-glyphs.d.ts +30 -0
  57. package/dist/node/act-glyphs.js +142 -0
  58. package/dist/node/compartment-watcher.d.ts +107 -0
  59. package/dist/node/compartment-watcher.js +163 -0
  60. package/dist/node/fit.d.ts +85 -0
  61. package/dist/node/fit.js +129 -0
  62. package/dist/node/node-renderer.d.ts +49 -0
  63. package/dist/node/node-renderer.js +611 -0
  64. package/dist/node/node-view.d.ts +51 -0
  65. package/dist/node/node-view.js +89 -0
  66. package/dist/node/paint.d.ts +84 -0
  67. package/dist/node/paint.js +143 -0
  68. package/dist/node/sd-glyphs.d.ts +36 -0
  69. package/dist/node/sd-glyphs.js +79 -0
  70. package/dist/node/stm-glyphs.d.ts +22 -0
  71. package/dist/node/stm-glyphs.js +111 -0
  72. package/dist/node/tier-metrics.d.ts +38 -0
  73. package/dist/node/tier-metrics.js +45 -0
  74. package/dist/operators.d.ts +45 -0
  75. package/dist/operators.js +75 -0
  76. package/dist/plantuml-import.d.ts +113 -0
  77. package/dist/plantuml-import.js +1723 -0
  78. package/dist/plantuml.d.ts +94 -0
  79. package/dist/plantuml.js +985 -0
  80. package/dist/presets.d.ts +149 -0
  81. package/dist/presets.js +302 -0
  82. package/dist/profiles.d.ts +2 -0
  83. package/dist/profiles.js +358 -0
  84. package/dist/reading.d.ts +160 -0
  85. package/dist/reading.js +648 -0
  86. package/dist/roles.d.ts +257 -0
  87. package/dist/roles.js +997 -0
  88. package/dist/rules.d.ts +267 -0
  89. package/dist/rules.js +3090 -0
  90. package/dist/templates.d.ts +2 -0
  91. package/dist/templates.js +197 -0
  92. package/dist/toolbar/config.d.ts +228 -0
  93. package/dist/toolbar/config.js +833 -0
  94. package/dist/toolbar/icons.d.ts +440 -0
  95. package/dist/toolbar/icons.js +711 -0
  96. package/dist/toolbar/senior-tool.d.ts +11 -0
  97. package/dist/toolbar/senior-tool.js +21 -0
  98. package/dist/toolbar/uml-menu.d.ts +17 -0
  99. package/dist/toolbar/uml-menu.js +20 -0
  100. package/dist/toolbar/uml-senior-button.d.ts +18 -0
  101. package/dist/toolbar/uml-senior-button.js +22 -0
  102. package/dist/translations.d.ts +27 -0
  103. package/dist/translations.js +117 -0
  104. package/dist/view.d.ts +33 -0
  105. package/dist/view.js +236 -0
  106. package/dist/xmi-import.d.ts +174 -0
  107. package/dist/xmi-import.js +2268 -0
  108. package/dist/xmi.d.ts +61 -0
  109. package/dist/xmi.js +1860 -0
  110. package/dist/xml-reader.d.ts +157 -0
  111. package/dist/xml-reader.js +430 -0
  112. package/dist/xml.d.ts +72 -0
  113. package/dist/xml.js +96 -0
  114. package/package.json +38 -0
@@ -0,0 +1,137 @@
1
+ import type { BackgroundRect } from '@formicoidea/labre-core/blocks/surface';
2
+ import { backgroundPlot } from '@formicoidea/labre-core/blocks/surface';
3
+ import type { UmlPartitionOrientation } from '@formicoidea/labre-core/model';
4
+ /**
5
+ * Where the UML diagram frame's heading band is, in ELEMENT-LOCAL model units.
6
+ *
7
+ * Pure, and kept out of `element-view.ts` so the answer can be asserted without
8
+ * an editor, a viewport or a canvas around it — the same split `board-hit.ts`
9
+ * makes for the C4 board and `pool-hit.ts` for the BPMN pool.
10
+ *
11
+ * The rectangle is derived from `backgroundPlot`, the very function the renderer
12
+ * lays the heading out from: nothing here restates a coordinate, so the strip a
13
+ * user aims at cannot drift away from the strip the frame reserves.
14
+ *
15
+ * ponytail: a ROTATED frame is not accounted for — the caller converts by
16
+ * subtraction (and, for the rename zones, the shared `FrameworkBackgroundView`
17
+ * de-rotates about the centre first), so every box here assumes an upright
18
+ * frame. Same reserve `board-hit.ts` and `pool-hit.ts` both document.
19
+ */
20
+ /** What this file needs of a frame: its box. */
21
+ export interface UmlDiagramGeometry {
22
+ deserializedXYWH: readonly number[];
23
+ }
24
+ /**
25
+ * The frame's heading band, or `null` when there is no room for one.
26
+ *
27
+ * The band IS the top margin, full width, clamped to a frame shorter than its
28
+ * own heading — the degenerate case the model's own carve-out clamps too.
29
+ */
30
+ export declare function umlDiagramBand(model: UmlDiagramGeometry): BackgroundRect | null;
31
+ /**
32
+ * Whether an element-local point is in the frame's heading band.
33
+ *
34
+ * The WHOLE band, not the tight box of the cut-corner tag. The strip is part of
35
+ * the sheet — nothing is ever dropped there by convention, and the drawing goes
36
+ * below it — so a click anywhere along it belongs to the frame, and this is the
37
+ * same answer `UmlDiagramElementModel.includesPoint` gives: what is picked is
38
+ * what is renamed.
39
+ *
40
+ * No zoom-grown target, unlike the BPMN pool's 28-unit strip: growing this one
41
+ * would put the rename zone outside the band the MODEL lets a click select, and
42
+ * the two agreeing is worth more than the pixels it would gain at 0.2 zoom.
43
+ */
44
+ export declare function umlInDiagramBand(model: UmlDiagramGeometry, local: readonly [number, number]): boolean;
45
+ /**
46
+ * What these functions need of a partition: its box and which way it runs.
47
+ *
48
+ * `orientation` is the MODEL's own union rather than a `string`, so a caller
49
+ * cannot hand this a lane running some third way the renderer has no band for —
50
+ * the structural type is what lets a unit test pass a plain object, and the
51
+ * union is what keeps that object honest.
52
+ */
53
+ export interface UmlPartitionGeometry {
54
+ deserializedXYWH: readonly number[];
55
+ orientation?: UmlPartitionOrientation;
56
+ }
57
+ /**
58
+ * A partition's NAME BAND, or `null` when there is no room for one.
59
+ *
60
+ * The band is the deep margin — the top of a vertical lane, the left edge of a
61
+ * horizontal one — read off whichever of the two declarations the element's
62
+ * `orientation` selects, so the strip a user aims at is the strip the renderer
63
+ * reserved. Clamped to a lane dragged smaller than its own header, the
64
+ * degenerate case the model's carve-out clamps too.
65
+ */
66
+ export declare function umlPartitionBand(model: UmlPartitionGeometry): BackgroundRect | null;
67
+ /**
68
+ * The composite state's name band, or `null` when there is no room for one.
69
+ *
70
+ * Always the top margin: unlike a partition, a composite state has no
71
+ * orientation to turn (§14.2.4 writes its name across the top and nowhere
72
+ * else), so this is the diagram frame's own arithmetic against a second
73
+ * declaration.
74
+ */
75
+ export declare function umlRegionBand(model: UmlDiagramGeometry): BackgroundRect | null;
76
+ /**
77
+ * Whether an element-local point is in a partition's name band.
78
+ *
79
+ * The WHOLE band, exactly as {@link umlInDiagramBand} claims the whole heading
80
+ * strip and for the same reason: the header is part of the LANE — nothing is
81
+ * ever dropped there by convention, and the flow goes below or beside it — so a
82
+ * click anywhere along it belongs to the partition, and this is the same answer
83
+ * `UmlPartitionElementModel.includesPoint` gives. What is picked is what is
84
+ * renamed.
85
+ */
86
+ export declare function umlInPartitionBand(model: UmlPartitionGeometry, local: readonly [number, number]): boolean;
87
+ /** The same question of a composite state's name band. */
88
+ export declare function umlInRegionBand(model: UmlDiagramGeometry, local: readonly [number, number]): boolean;
89
+ /** What these functions need of a fragment: its box and its operands. */
90
+ export interface UmlFragmentGeometry {
91
+ deserializedXYWH: readonly number[];
92
+ operands?: unknown;
93
+ }
94
+ /** One operand band of a fragment: where it starts, and how tall it is. */
95
+ export interface UmlOperandBand {
96
+ top: number;
97
+ height: number;
98
+ }
99
+ export interface UmlFragmentOperands {
100
+ plot: ReturnType<typeof backgroundPlot>;
101
+ bands: UmlOperandBand[];
102
+ }
103
+ /**
104
+ * The operand bands of this fragment, or `null` when it carries no usable
105
+ * partition — which is every `opt`, every `loop` and every `ref`.
106
+ *
107
+ * Derived from `backgroundInstanceZones`, the very function the renderer paints
108
+ * the separators from and the audit reports the zones from, so a grab zone
109
+ * cannot drift away from the line it is a grab zone for. The BPMN pool's
110
+ * `bpmnPoolBands` with one thing missing: an operand has no title strip,
111
+ * because §17.6.4 writes its guard in a corner rather than down a band.
112
+ */
113
+ export declare function umlFragmentOperands(model: UmlFragmentGeometry): UmlFragmentOperands | null;
114
+ /**
115
+ * The INTERNAL operand separator the point is on, as the index of the operand
116
+ * BELOW it — so `i` separates operand `i - 1` from operand `i`. `null` for
117
+ * anywhere else.
118
+ *
119
+ * Internal only, exactly as the pool's is: the outer edges belong to the plot,
120
+ * and dragging one would be a resize of the fragment, which the handles do.
121
+ */
122
+ export declare function umlOperandBoundaryAt(model: UmlFragmentGeometry, local: readonly [number, number]): number | null;
123
+ /**
124
+ * The operand whose GUARD CORNER the point is in, or `null`.
125
+ *
126
+ * A corner box and not a whole band, which is the opposite call the BPMN pool
127
+ * makes about its lane names — and the notation is the difference. A lane's
128
+ * name is a TITLE written down a strip that belongs to nothing else; an
129
+ * operand's guard is a condition written over the messages it governs, and a
130
+ * rename zone covering the whole operand would swallow every double-click meant
131
+ * for the conversation inside it.
132
+ *
133
+ * The box is the guard's own line: as wide as {@link UML_OPERAND_GUARD_WIDTH}
134
+ * from the plot's left edge, as tall as the line the declaration writes it on,
135
+ * anchored at the same inset the renderer uses.
136
+ */
137
+ export declare function umlOperandGuardAt(model: UmlFragmentGeometry, local: readonly [number, number]): number | null;
@@ -0,0 +1,191 @@
1
+ import { backgroundInstanceZones, backgroundPlot, } from '@formicoidea/labre-core/blocks/surface';
2
+ import { UML_DIAGRAM_FRAME, UML_FRAGMENT_FRAME, UML_REGION_FRAME, umlPartitionFrame, } from './background.js';
3
+ import { UML_OPERAND_GRAB, UML_OPERAND_GUARD_HEIGHT, UML_OPERAND_GUARD_WIDTH, } from './consts.js';
4
+ /**
5
+ * The frame's heading band, or `null` when there is no room for one.
6
+ *
7
+ * The band IS the top margin, full width, clamped to a frame shorter than its
8
+ * own heading — the degenerate case the model's own carve-out clamps too.
9
+ */
10
+ export function umlDiagramBand(model) {
11
+ const [, , w, h] = model.deserializedXYWH;
12
+ if (!(w > 0) || !(h > 0))
13
+ return null;
14
+ const plot = backgroundPlot(UML_DIAGRAM_FRAME, w, h);
15
+ const height = Math.min(plot.y0, h);
16
+ if (!(height > 0))
17
+ return null;
18
+ return { x: 0, y: 0, w, h: height };
19
+ }
20
+ /**
21
+ * Whether an element-local point is in the frame's heading band.
22
+ *
23
+ * The WHOLE band, not the tight box of the cut-corner tag. The strip is part of
24
+ * the sheet — nothing is ever dropped there by convention, and the drawing goes
25
+ * below it — so a click anywhere along it belongs to the frame, and this is the
26
+ * same answer `UmlDiagramElementModel.includesPoint` gives: what is picked is
27
+ * what is renamed.
28
+ *
29
+ * No zoom-grown target, unlike the BPMN pool's 28-unit strip: growing this one
30
+ * would put the rename zone outside the band the MODEL lets a click select, and
31
+ * the two agreeing is worth more than the pixels it would gain at 0.2 zoom.
32
+ */
33
+ export function umlInDiagramBand(model, local) {
34
+ const band = umlDiagramBand(model);
35
+ if (!band)
36
+ return false;
37
+ const [lx, ly] = local;
38
+ return (lx >= band.x &&
39
+ lx <= band.x + band.w &&
40
+ ly >= band.y &&
41
+ ly <= band.y + band.h);
42
+ }
43
+ /**
44
+ * A partition's NAME BAND, or `null` when there is no room for one.
45
+ *
46
+ * The band is the deep margin — the top of a vertical lane, the left edge of a
47
+ * horizontal one — read off whichever of the two declarations the element's
48
+ * `orientation` selects, so the strip a user aims at is the strip the renderer
49
+ * reserved. Clamped to a lane dragged smaller than its own header, the
50
+ * degenerate case the model's carve-out clamps too.
51
+ */
52
+ export function umlPartitionBand(model) {
53
+ const [, , w, h] = model.deserializedXYWH;
54
+ if (!(w > 0) || !(h > 0))
55
+ return null;
56
+ const def = umlPartitionFrame(model);
57
+ const plot = backgroundPlot(def, w, h);
58
+ if (model.orientation === 'horizontal') {
59
+ const width = Math.min(plot.x0, w);
60
+ if (!(width > 0))
61
+ return null;
62
+ return { x: 0, y: 0, w: width, h };
63
+ }
64
+ const height = Math.min(plot.y0, h);
65
+ if (!(height > 0))
66
+ return null;
67
+ return { x: 0, y: 0, w, h: height };
68
+ }
69
+ /**
70
+ * The composite state's name band, or `null` when there is no room for one.
71
+ *
72
+ * Always the top margin: unlike a partition, a composite state has no
73
+ * orientation to turn (§14.2.4 writes its name across the top and nowhere
74
+ * else), so this is the diagram frame's own arithmetic against a second
75
+ * declaration.
76
+ */
77
+ export function umlRegionBand(model) {
78
+ const [, , w, h] = model.deserializedXYWH;
79
+ if (!(w > 0) || !(h > 0))
80
+ return null;
81
+ const plot = backgroundPlot(UML_REGION_FRAME, w, h);
82
+ const height = Math.min(plot.y0, h);
83
+ if (!(height > 0))
84
+ return null;
85
+ return { x: 0, y: 0, w, h: height };
86
+ }
87
+ /** Whether an element-local point is inside a {@link BackgroundRect}. */
88
+ function inRect(rect, local) {
89
+ if (!rect)
90
+ return false;
91
+ const [lx, ly] = local;
92
+ return (lx >= rect.x &&
93
+ lx <= rect.x + rect.w &&
94
+ ly >= rect.y &&
95
+ ly <= rect.y + rect.h);
96
+ }
97
+ /**
98
+ * Whether an element-local point is in a partition's name band.
99
+ *
100
+ * The WHOLE band, exactly as {@link umlInDiagramBand} claims the whole heading
101
+ * strip and for the same reason: the header is part of the LANE — nothing is
102
+ * ever dropped there by convention, and the flow goes below or beside it — so a
103
+ * click anywhere along it belongs to the partition, and this is the same answer
104
+ * `UmlPartitionElementModel.includesPoint` gives. What is picked is what is
105
+ * renamed.
106
+ */
107
+ export function umlInPartitionBand(model, local) {
108
+ return inRect(umlPartitionBand(model), local);
109
+ }
110
+ /** The same question of a composite state's name band. */
111
+ export function umlInRegionBand(model, local) {
112
+ return inRect(umlRegionBand(model), local);
113
+ }
114
+ /**
115
+ * The operand bands of this fragment, or `null` when it carries no usable
116
+ * partition — which is every `opt`, every `loop` and every `ref`.
117
+ *
118
+ * Derived from `backgroundInstanceZones`, the very function the renderer paints
119
+ * the separators from and the audit reports the zones from, so a grab zone
120
+ * cannot drift away from the line it is a grab zone for. The BPMN pool's
121
+ * `bpmnPoolBands` with one thing missing: an operand has no title strip,
122
+ * because §17.6.4 writes its guard in a corner rather than down a band.
123
+ */
124
+ export function umlFragmentOperands(model) {
125
+ const [, , w, h] = model.deserializedXYWH;
126
+ const plot = backgroundPlot(UML_FRAGMENT_FRAME, w, h);
127
+ if (!(plot.width > 0) || !(plot.height > 0))
128
+ return null;
129
+ const zones = backgroundInstanceZones(UML_FRAGMENT_FRAME, model);
130
+ if (zones.length === 0)
131
+ return null;
132
+ return {
133
+ plot,
134
+ bands: zones.map(zone => ({
135
+ top: plot.y0 + zone.rect.y * plot.height,
136
+ height: zone.rect.h * plot.height,
137
+ })),
138
+ };
139
+ }
140
+ /**
141
+ * The INTERNAL operand separator the point is on, as the index of the operand
142
+ * BELOW it — so `i` separates operand `i - 1` from operand `i`. `null` for
143
+ * anywhere else.
144
+ *
145
+ * Internal only, exactly as the pool's is: the outer edges belong to the plot,
146
+ * and dragging one would be a resize of the fragment, which the handles do.
147
+ */
148
+ export function umlOperandBoundaryAt(model, local) {
149
+ const geometry = umlFragmentOperands(model);
150
+ if (!geometry)
151
+ return null;
152
+ const { plot, bands } = geometry;
153
+ if (local[0] < plot.x0 || local[0] > plot.x1)
154
+ return null;
155
+ for (let i = 1; i < bands.length; i++) {
156
+ if (Math.abs(local[1] - bands[i].top) <= UML_OPERAND_GRAB)
157
+ return i;
158
+ }
159
+ return null;
160
+ }
161
+ /**
162
+ * The operand whose GUARD CORNER the point is in, or `null`.
163
+ *
164
+ * A corner box and not a whole band, which is the opposite call the BPMN pool
165
+ * makes about its lane names — and the notation is the difference. A lane's
166
+ * name is a TITLE written down a strip that belongs to nothing else; an
167
+ * operand's guard is a condition written over the messages it governs, and a
168
+ * rename zone covering the whole operand would swallow every double-click meant
169
+ * for the conversation inside it.
170
+ *
171
+ * The box is the guard's own line: as wide as {@link UML_OPERAND_GUARD_WIDTH}
172
+ * from the plot's left edge, as tall as the line the declaration writes it on,
173
+ * anchored at the same inset the renderer uses.
174
+ */
175
+ export function umlOperandGuardAt(model, local) {
176
+ const geometry = umlFragmentOperands(model);
177
+ if (!geometry)
178
+ return null;
179
+ const { plot, bands } = geometry;
180
+ for (let i = 0; i < bands.length; i++) {
181
+ const top = bands[i].top;
182
+ const height = Math.min(UML_OPERAND_GUARD_HEIGHT, bands[i].height);
183
+ if (local[0] >= plot.x0 &&
184
+ local[0] <= plot.x0 + Math.min(UML_OPERAND_GUARD_WIDTH, plot.width) &&
185
+ local[1] >= top &&
186
+ local[1] <= top + height) {
187
+ return i;
188
+ }
189
+ }
190
+ return null;
191
+ }
@@ -0,0 +1,19 @@
1
+ import type { ShortcutManifestEntry } from '@formicoidea/labre-core/std';
2
+ /**
3
+ * The UML commands as SHORTCUT-MANIFEST rows — id, label, chord, scope,
4
+ * owner — and nothing else.
5
+ *
6
+ * DATA ONLY, and that is the whole point (`docs/adr/0008` § Packaging). A
7
+ * `CommandDescriptor` carries its `run`, so a host settings pane that imported
8
+ * the package entry to list names and chords would drag the entire action graph
9
+ * — the grammar, the XMI and PlantUML writers, the surface and gfx deep paths —
10
+ * into its chunk. This module has type-only imports, so the published bundle
11
+ * exposes it as `./commands-manifest`: a few hundred bytes that reference
12
+ * nothing.
13
+ *
14
+ * GENERATED-SHAPED, hand-committed: `commands-manifest.unit.spec.ts` asserts
15
+ * row-for-row equality with `toShortcutManifestEntry` over `umlCommands`, so
16
+ * this file cannot drift from the commands it projects. Add a command and the
17
+ * test says exactly what to add here.
18
+ */
19
+ export declare const umlCommandsManifest: ShortcutManifestEntry[];