@formicoidea/labre-framework-bpmn 3.0.0 → 3.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.
@@ -118,6 +118,9 @@ export const BPMN_POOL_BACKGROUND = {
118
118
  // whole, and the rename editor shows it in full.
119
119
  fit: 'wrap',
120
120
  maxLines: 2,
121
+ // The author's size for every lane title of this pool, when they picked
122
+ // one in the toolbar; the declared size below otherwise (ADR 0049).
123
+ sizeProp: 'laneFontSize',
121
124
  style: {
122
125
  size: POOL_LANE_NAME_FONT_SIZE,
123
126
  color: '@name',
@@ -161,6 +164,9 @@ export const BPMN_POOL_BACKGROUND = {
161
164
  // `x: 0` is the inner edge of the band; half a band width back from
162
165
  // it is the middle of the strip.
163
166
  anchor: { x: 0, y: 0.5, dx: -POOL_BAND_WIDTH / 2 },
167
+ // The author's size, when they picked one in the toolbar; the band
168
+ // thickens to hold it like it does a second line (ADR 0049).
169
+ sizeProp: 'nameFontSize',
164
170
  style: {
165
171
  size: POOL_NAME_FONT_SIZE,
166
172
  weight: 600,
package/dist/consts.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { BpmnNodeKind } from '@formicoidea/labre-core/model';
2
2
  import { PointStyle, StrokeStyle } from '@formicoidea/labre-core/model/headless';
3
+ import type { ChromeWording } from '@formicoidea/labre-core/shared/services';
3
4
  /**
4
5
  * Visual constants for the BPMN basics. Style "C" (hybrid): spec-accurate
5
6
  * shapes and line weights, with accent colour only on the event rings — the
@@ -233,6 +234,17 @@ export declare const POOL_FONT_FAMILY = "Inter, sans-serif";
233
234
  * zoomed out, which is the size the distinction has to hold at.
234
235
  */
235
236
  export declare const POOL_LANE_NAME_FONT_SIZE = 13;
237
+ /**
238
+ * The sizes the pool toolbar offers for the participant name and for the lane
239
+ * titles (ADR 0049) — the default of each among them, and the lane steps two
240
+ * units under the title's, the distance the default sizes keep. A pool stores
241
+ * a size only once the author picks one (`nameFontSize` / `laneFontSize`).
242
+ */
243
+ export declare const POOL_NAME_FONT_SIZES: readonly [13, 15, 18, 24, 32];
244
+ export declare const POOL_LANE_NAME_FONT_SIZES: readonly [11, 13, 15, 18, 24];
245
+ /** The two size dropdowns' own labels — toolbar chrome, never stored. */
246
+ export declare const BPMN_POOL_TITLE_SIZE: ChromeWording;
247
+ export declare const BPMN_LANE_TITLE_SIZE: ChromeWording;
236
248
  /**
237
249
  * The two band widths live in `@labre/affine-model`, beside the pool model that
238
250
  * hit-tests against them (a pool is clickable by its title bands as well as by
package/dist/consts.js CHANGED
@@ -289,6 +289,23 @@ export const POOL_FONT_FAMILY = 'Inter, sans-serif';
289
289
  * zoomed out, which is the size the distinction has to hold at.
290
290
  */
291
291
  export const POOL_LANE_NAME_FONT_SIZE = 13;
292
+ /**
293
+ * The sizes the pool toolbar offers for the participant name and for the lane
294
+ * titles (ADR 0049) — the default of each among them, and the lane steps two
295
+ * units under the title's, the distance the default sizes keep. A pool stores
296
+ * a size only once the author picks one (`nameFontSize` / `laneFontSize`).
297
+ */
298
+ export const POOL_NAME_FONT_SIZES = [13, 15, 18, 24, 32];
299
+ export const POOL_LANE_NAME_FONT_SIZES = [11, 13, 15, 18, 24];
300
+ /** The two size dropdowns' own labels — toolbar chrome, never stored. */
301
+ export const BPMN_POOL_TITLE_SIZE = [
302
+ 'com.labre.bpmn.toolbar.poolTitleSize',
303
+ 'Pool title size',
304
+ ];
305
+ export const BPMN_LANE_TITLE_SIZE = [
306
+ 'com.labre.bpmn.toolbar.laneTitleSize',
307
+ 'Lane title size',
308
+ ];
292
309
  /**
293
310
  * The two band widths live in `@labre/affine-model`, beside the pool model that
294
311
  * hit-tests against them (a pool is clickable by its title bands as well as by
@@ -5,11 +5,18 @@ import { bpmnLanesOf, renameBpmnLane, } from './actions.js';
5
5
  import { POOL_LANE_MIN_HEIGHT } from './consts.js';
6
6
  import { bpmnLaneBoundaryAt, bpmnPoolBands, bpmnPoolMeasuredLayout, bpmnPoolTargetAt, cachePaintedBands, } from './pool-hit.js';
7
7
  /**
8
- * The props whose change moves a title band: the names it is sized by, and the
9
- * box whose height a name wraps along. `paintedBands` itself is NOT here — the
8
+ * The props whose change moves a title band: the names it is sized by, the
9
+ * font sizes the author picked for them (ADR 0049), and the box whose height a
10
+ * name wraps along. `paintedBands` itself is NOT here — the
10
11
  * cache's own write must never re-enter the code that writes it.
11
12
  */
12
- const BAND_PROPS = new Set(['name', 'lanes', 'xywh']);
13
+ const BAND_PROPS = new Set([
14
+ 'name',
15
+ 'lanes',
16
+ 'nameFontSize',
17
+ 'laneFontSize',
18
+ 'xywh',
19
+ ]);
13
20
  /**
14
21
  * View for a BPMN pool. Three direct gestures live here:
15
22
  *
package/dist/export.d.ts CHANGED
@@ -229,6 +229,23 @@ export interface BpmnExportBoard {
229
229
  * inscribed kind, and an event drawn before its name gravitated.
230
230
  */
231
231
  labels?: ReadonlyMap<string, string>;
232
+ /**
233
+ * Where each of those names is drawn, keyed like {@link labels}: the bound
234
+ * of the grouped `bpmn:label` text, written as the shape's
235
+ * `bpmndi:BPMNLabel` so a tool puts the name where the author left it rather
236
+ * than where it would have chosen (ADR 0029, amendment of 2026-11-04).
237
+ *
238
+ * A map of its own beside `labels` rather than a richer value inside it, so
239
+ * that a host which builds or reads `labels` as plain strings keeps
240
+ * compiling. A node with a name and no entry here gets no `BPMNLabel` of
241
+ * Labre's, and whatever an import carried is written back as before.
242
+ */
243
+ labelBounds?: ReadonlyMap<string, {
244
+ x: number;
245
+ y: number;
246
+ w: number;
247
+ h: number;
248
+ }>;
232
249
  /**
233
250
  * How many things drawn INSIDE a pool the picking left behind because they
234
251
  * carry no BPMN role — a free shape, a text, an artefact drawn before roles
package/dist/export.js CHANGED
@@ -568,6 +568,17 @@ class Carried {
568
568
  function isFragment(value) {
569
569
  return typeof value === 'string' && value.trimStart().startsWith('<');
570
570
  }
571
+ /**
572
+ * Whether a carried shape child is a `BPMNLabel`, under whatever prefix the
573
+ * source file bound DI to: matches `<bpmndi:BPMNLabel>` and `<BPMNLabel/>`,
574
+ * rejects `<bpmndi:BPMNLabelStyle>`. By local name, because the fragment is a
575
+ * string and its prefix is the file's; under a `BPMNShape`, the one child of
576
+ * that name the schema allows IS the label.
577
+ */
578
+ function isCarriedBpmnLabel(node) {
579
+ return ('fragment' in node &&
580
+ /^\s*<(?:[A-Za-z_][\w.-]*:)?BPMNLabel(?=[\s/>])/.test(node.fragment));
581
+ }
571
582
  /** The carried child fragments of one or more scopes, in the stored order. */
572
583
  function carriedFragments(bag, ...scopes) {
573
584
  const out = [];
@@ -1130,13 +1141,19 @@ export function exportBpmnXmlWithWarnings(board, options = {}) {
1130
1141
  : orphanProcessIndex();
1131
1142
  // The grouped label first, then the shape's own text: a legacy event kept
1132
1143
  // its inner text and must still export the same name.
1133
- const name = labelOf(board.labels?.get(model.id)) || labelOf(model.text);
1144
+ const label = labelOf(board.labels?.get(model.id));
1145
+ const name = label || labelOf(model.text);
1146
+ // A box only for a name its LABEL gave: a legacy event whose name is its
1147
+ // own inner text has no drawn label to place, and an empty label text in
1148
+ // the group names nothing a reader could draw in it.
1149
+ const labelBound = label ? board.labelBounds?.get(model.id) : undefined;
1134
1150
  const node = {
1135
1151
  model,
1136
1152
  mapping,
1137
1153
  id: minter.given(carriedBpmnId(model), '', model.id),
1138
1154
  name,
1139
1155
  bound,
1156
+ ...(labelBound ? { labelBound } : {}),
1140
1157
  scope,
1141
1158
  lane: pool ? bpmnLaneOf(pool, bound) : null,
1142
1159
  payload: carriedOf(model),
@@ -1228,6 +1245,12 @@ export function exportBpmnXmlWithWarnings(board, options = {}) {
1228
1245
  const bound = process.pool.elementBound;
1229
1246
  observe(bound.x, bound.y);
1230
1247
  }
1248
+ // The labels are offset with the shapes but do not MOVE the origin: a name
1249
+ // hangs wider than a narrow event, so letting it count would shift the whole
1250
+ // plane the first time a board's names gravitate into labels, and the
1251
+ // export → import → export fixed point would no longer hold. A name hung
1252
+ // past the leftmost or topmost shape keeps a small negative coordinate,
1253
+ // which BPMN DI allows (ADR 0029, amendment of 2026-11-04).
1231
1254
  for (const node of planned)
1232
1255
  observe(node.bound.x, node.bound.y);
1233
1256
  for (const edge of edges) {
@@ -1447,9 +1470,24 @@ export function exportBpmnXmlWithWarnings(board, options = {}) {
1447
1470
  attrs.isMarkerVisible = 'true';
1448
1471
  }
1449
1472
  Object.assign(attrs, carried.attrs(node.payload, BPMN_SCOPE.shape));
1473
+ const extras = carriedFragments(node.payload?.di, BPMN_SCOPE.shape);
1474
+ // `tBPMNShape` is `Bounds → BPMNLabel?`: ONE label, after the bounds. When
1475
+ // the name has a label of its own on the board, that label's box is the
1476
+ // `BPMNLabel`, offset with everything else, and any label an import carried
1477
+ // (a document imported before 2026-11-04 holds one) gives way to it.
1478
+ const label = node.labelBound
1479
+ ? [
1480
+ el('bpmndi:BPMNLabel', {}, [
1481
+ el('dc:Bounds', boundsAttrs(node.labelBound, dx, dy)),
1482
+ ]),
1483
+ ]
1484
+ : [];
1450
1485
  planeElements.push(el('bpmndi:BPMNShape', attrs, [
1451
1486
  el('dc:Bounds', boundsAttrs(node.bound, dx, dy)),
1452
- ...carried.keep(carriedFragments(node.payload?.di, BPMN_SCOPE.shape)),
1487
+ ...label,
1488
+ ...carried.keep(node.labelBound
1489
+ ? extras.filter(extra => !isCarriedBpmnLabel(extra))
1490
+ : extras),
1453
1491
  ]));
1454
1492
  }
1455
1493
  for (const edge of edges) {
package/dist/import.js CHANGED
@@ -530,6 +530,38 @@ function boundsOf(shape) {
530
530
  return null;
531
531
  return { x: numbers[0], y: numbers[1], w: numbers[2], h: numbers[3] };
532
532
  }
533
+ /** Whether a DI child is the shape's `bpmndi:BPMNLabel`. */
534
+ function isBpmnLabel(child) {
535
+ return (child.namespaceURI === BPMN_NS.bpmndi && child.localName === 'BPMNLabel');
536
+ }
537
+ /**
538
+ * Beyond this, a coordinate or a size is not a drawing but a file trying to
539
+ * push a name somewhere nobody will ever scroll to (or overflow a renderer
540
+ * on the way): a million units is two orders of magnitude past the widest
541
+ * process bpmn.io's own examples draw.
542
+ */
543
+ const MAX_LABEL_EXTENT = 1_000_000;
544
+ /**
545
+ * The box a shape's `BPMNLabel` places its name in — `null` when it has none,
546
+ * or one this reader refuses: not finite, empty or negative, or absurdly far
547
+ * (ADR 0029, amendment of 2026-11-04). A refused box is no box, and the label
548
+ * falls back to the pack's own place under the symbol; it is never clamped,
549
+ * because a clamped box would be a position nobody drew.
550
+ */
551
+ function labelBoundsOf(shape) {
552
+ const label = childrenOf(shape).find(isBpmnLabel);
553
+ if (!label)
554
+ return null;
555
+ const box = boundsOf(label);
556
+ if (!box)
557
+ return null;
558
+ if (box.w <= 0 || box.h <= 0)
559
+ return null;
560
+ if ([box.x, box.y, box.w, box.h].some(value => Math.abs(value) > MAX_LABEL_EXTENT)) {
561
+ return null;
562
+ }
563
+ return box;
564
+ }
533
565
  /**
534
566
  * Every `BPMNShape` and `BPMNEdge` of the document, keyed by what it draws.
535
567
  *
@@ -902,19 +934,24 @@ export function importBpmnXml(source, context = {}) {
902
934
  }
903
935
  };
904
936
  /** The DI element's own extras: colours quarantined, the rest kept as `di`. */
905
- const sortShapeExtras = (shape, payload, sourceId) => {
937
+ const sortShapeExtras = (shape, payload, sourceId, labelRead = false) => {
906
938
  if (!shape)
907
939
  return;
908
940
  sortAttributes(shape, payload, BPMN_SCOPE.shape, sourceId, READ_SHAPE_ATTRS);
909
941
  for (const child of childrenOf(shape)) {
910
942
  // The bounds and the waypoints ARE the drawing, and the drawing is what
911
- // was mapped. A `BPMNLabel` and anything else is kept as diagram matter.
943
+ // was mapped. A `BPMNLabel` is too once its bounds placed a gravitating
944
+ // label (`labelRead`): the exporter writes it back from that label, so
945
+ // carrying it as well would hand the shape two. Anything else — and a
946
+ // label the reader did not use — is kept as diagram matter.
912
947
  if (child.namespaceURI === BPMN_NS.dc && child.localName === 'Bounds') {
913
948
  continue;
914
949
  }
915
950
  if (child.namespaceURI === BPMN_NS.di && child.localName === 'waypoint') {
916
951
  continue;
917
952
  }
953
+ if (labelRead && isBpmnLabel(child))
954
+ continue;
918
955
  carryDi(payload, BPMN_SCOPE.shape, fragmentOf(child));
919
956
  }
920
957
  };
@@ -1271,7 +1308,6 @@ export function importBpmnXml(source, context = {}) {
1271
1308
  const shape = sourceId === undefined ? undefined : shapes.get(sourceId);
1272
1309
  const bounds = shape?.bounds ?? null;
1273
1310
  sortAttributes(element, payload, BPMN_SCOPE.self, sourceId);
1274
- sortShapeExtras(shape?.element, payload, sourceId);
1275
1311
  // The label, from wherever this kind keeps it: an annotation's is a child
1276
1312
  // element, a group's is the value of the category it points at, everything
1277
1313
  // else's is its own `name`.
@@ -1283,6 +1319,15 @@ export function importBpmnXml(source, context = {}) {
1283
1319
  const ref = attrOf(element, 'categoryValueRef');
1284
1320
  text = (ref !== undefined ? categoryValues.get(ref) : undefined) ?? '';
1285
1321
  }
1322
+ // An external kind's name is not the shape's to hold (R38): it goes to a
1323
+ // grouped label, and the node is drawn bare. Where the label goes is the
1324
+ // file's `BPMNLabel` when it drew one this reader accepts — bpmn.io puts a
1325
+ // gateway's name above it and an event's beside it — and the pack's own
1326
+ // place under the symbol otherwise. Only for a shape the file placed: a
1327
+ // swept shape's label follows it under, wherever the file thought it was.
1328
+ const gravitating = text !== '' && bpmnLabelMode(kind) === 'external';
1329
+ const labelBox = gravitating && bounds && shape ? labelBoundsOf(shape.element) : null;
1330
+ sortShapeExtras(shape?.element, payload, sourceId, labelBox !== null);
1286
1331
  // D5 case 2: an activity the DIAGRAM says is expanded holds a flow drawn
1287
1332
  // inside it, and the pack draws the collapsed form only.
1288
1333
  const expanded = shape !== undefined && attrOf(shape.element, 'isExpanded') === 'true';
@@ -1325,9 +1370,6 @@ export function importBpmnXml(source, context = {}) {
1325
1370
  const box = bounds
1326
1371
  ? new Bound(bounds.x, bounds.y, bounds.w, bounds.h)
1327
1372
  : new Bound(0, 0, size.w, size.h);
1328
- // An external kind's name is not the shape's to hold (R38): it goes to a
1329
- // grouped label under the symbol, and the node is drawn bare.
1330
- const gravitating = text !== '' && bpmnLabelMode(kind) === 'external';
1331
1373
  const order = shape?.index ?? Number.POSITIVE_INFINITY;
1332
1374
  const nodeDraft = {
1333
1375
  props: bpmnNodeProps(kind, {
@@ -1351,19 +1393,21 @@ export function importBpmnXml(source, context = {}) {
1351
1393
  };
1352
1394
  drafts.push(nodeDraft);
1353
1395
  if (gravitating) {
1354
- // ponytail: the label is always placed centred under the symbol, and a
1355
- // `BPMNLabel`'s own bounds are ignored for placement (they are still
1356
- // carried verbatim as DI, so the file gets them back). Ceiling: a file
1357
- // that set its label beside an event lands it under. Upgrade: read the
1358
- // `dc:Bounds` of the shape's `BPMNLabel` and place the text there.
1359
1396
  const nodeId = mint();
1360
1397
  const labelId = mint();
1361
1398
  nodeDraft.props.id = nodeId;
1399
+ // The file's box whole — position, width AND height — rather than a
1400
+ // height re-measured from the text: this reader is pure and has no font
1401
+ // metrics, and the box it was handed is the one the exporter must hand
1402
+ // back for the round trip to be a fixed point.
1362
1403
  const under = bpmnLabelBoxUnder(box.x + box.w / 2, box.y + box.h);
1404
+ const labelProps = labelBox
1405
+ ? bpmnLabelProps(text, labelBox.x, labelBox.y, labelBox)
1406
+ : bpmnLabelProps(text, under.x, under.y);
1363
1407
  // Same order as the node, pushed after it: the stable sort keeps the
1364
1408
  // node, then its label, then the group that holds both.
1365
1409
  drafts.push({
1366
- props: { ...bpmnLabelProps(text, under.x, under.y), id: labelId },
1410
+ props: { ...labelProps, id: labelId },
1367
1411
  payload: {},
1368
1412
  order,
1369
1413
  kind: 'label',
@@ -76,11 +76,16 @@ function legendMemberIds(elements) {
76
76
  * left-out count does not report a name that IS written. An unbound
77
77
  * `bpmn:label` stays counted: its words are in no file.
78
78
  *
79
+ * `labelBounds` is where each bound label is drawn, the box the exporter writes
80
+ * as the shape's `BPMNLabel` (ADR 0029, amendment of 2026-11-04): a label the
81
+ * user dragged beside its event goes out beside it.
82
+ *
79
83
  * Direct children only, read defensively: they came out of a Y.Map.
80
84
  */
81
85
  function gravitatingLabels(elements, picked) {
82
86
  const byId = new Map(elements.map(element => [element.id, element]));
83
87
  const labels = new Map();
88
+ const labelBounds = new Map();
84
89
  const consumed = new Set();
85
90
  const isLabel = (element) => element instanceof TextElementModel && element.role === BPMN_ROLE.label;
86
91
  for (const group of elements) {
@@ -94,6 +99,7 @@ function gravitatingLabels(elements, picked) {
94
99
  const texts = members.filter((member) => isLabel(member));
95
100
  if (nodes.length === 1 && texts.length === 1) {
96
101
  labels.set(nodes[0].id, texts[0].text?.toString() ?? '');
102
+ labelBounds.set(nodes[0].id, texts[0].elementBound);
97
103
  consumed.add(texts[0].id);
98
104
  }
99
105
  if (members.length > 0 &&
@@ -101,7 +107,7 @@ function gravitatingLabels(elements, picked) {
101
107
  consumed.add(group.id);
102
108
  }
103
109
  }
104
- return { labels, consumed };
110
+ return { labels, labelBounds, consumed };
105
111
  }
106
112
  /**
107
113
  * The artefacts the exporter speaks about, picked out of a surface's elements
@@ -179,7 +185,7 @@ export function bpmnBoardFrom(elements) {
179
185
  // audit and the serializer use, so what is reported left out is what the rest
180
186
  // of the framework agrees is in there.
181
187
  const legend = legendMemberIds(elements);
182
- const { labels, consumed } = gravitatingLabels(elements, new Set(nodes.map(node => node.id)));
188
+ const { labels, labelBounds, consumed } = gravitatingLabels(elements, new Set(nodes.map(node => node.id)));
183
189
  const leftOut = roleless.filter(element => !legend.has(element.id) &&
184
190
  !consumed.has(element.id) &&
185
191
  bpmnPoolOf(pools, element.elementBound) !== null).length;
@@ -187,7 +193,7 @@ export function bpmnBoardFrom(elements) {
187
193
  pools,
188
194
  nodes,
189
195
  connectors,
190
- ...(labels.size > 0 ? { labels } : {}),
196
+ ...(labels.size > 0 ? { labels, labelBounds } : {}),
191
197
  ...(leftOut > 0 ? { leftOut } : {}),
192
198
  };
193
199
  }
package/dist/presets.d.ts CHANGED
@@ -151,9 +151,15 @@ export declare function bpmnLabelBoxUnder(cx: number, bottom: number): {
151
151
  * centred, carrying the role that makes it a NAME rather than a note.
152
152
  *
153
153
  * Mirrors `wardleyLabelProps`; one builder so the palette, the scenes and the
154
- * importer write the same element.
154
+ * importer write the same element. `size` is the pack's own box unless a file
155
+ * drew the label somewhere else: an imported `BPMNLabel` keeps its own width
156
+ * and height, so the name wraps where the author's tool wrapped it and goes
157
+ * back out in the very box it came in (ADR 0029, amendment of 2026-11-04).
155
158
  */
156
- export declare function bpmnLabelProps(text: string, x: number, y: number): Record<string, unknown> & {
159
+ export declare function bpmnLabelProps(text: string, x: number, y: number, size?: {
160
+ w: number;
161
+ h: number;
162
+ }): Record<string, unknown> & {
157
163
  type: string;
158
164
  };
159
165
  /**
package/dist/presets.js CHANGED
@@ -283,9 +283,12 @@ export function bpmnLabelBoxUnder(cx, bottom) {
283
283
  * centred, carrying the role that makes it a NAME rather than a note.
284
284
  *
285
285
  * Mirrors `wardleyLabelProps`; one builder so the palette, the scenes and the
286
- * importer write the same element.
286
+ * importer write the same element. `size` is the pack's own box unless a file
287
+ * drew the label somewhere else: an imported `BPMNLabel` keeps its own width
288
+ * and height, so the name wraps where the author's tool wrapped it and goes
289
+ * back out in the very box it came in (ADR 0029, amendment of 2026-11-04).
287
290
  */
288
- export function bpmnLabelProps(text, x, y) {
291
+ export function bpmnLabelProps(text, x, y, size = { w: BPMN_LABEL_W, h: BPMN_LABEL_H }) {
289
292
  return {
290
293
  type: 'text',
291
294
  text,
@@ -294,7 +297,7 @@ export function bpmnLabelProps(text, x, y) {
294
297
  fontSize: LABEL_FONT_SIZE,
295
298
  color: NEUTRAL_STROKE,
296
299
  textAlign: TextAlign.Center,
297
- xywh: new Bound(x, y, BPMN_LABEL_W, BPMN_LABEL_H).serialize(),
300
+ xywh: new Bound(x, y, size.w, size.h).serialize(),
298
301
  };
299
302
  }
300
303
  /**
package/dist/rules.d.ts CHANGED
@@ -145,12 +145,11 @@ import type { EndpointTriplet, ValidationRule } from '@formicoidea/labre-core/bl
145
145
  * - `forbidPattern` carries its OWN {@link RuleMessage} inside the pattern
146
146
  * rather than in a slot beside the other bounds, because a forbidden zone is
147
147
  * not a bound that failed and its sentence never reads like one;
148
- * - `label-presence` reads the subject's OWN `text`. A framework whose artefacts
149
- * are named by a separate element beside them is asking a different question,
150
- * and this family cannot answer it. BPMN names its ACTIVITIES in place, so it
151
- * can ask it of them; since R38 its events, gateways and data shapes are
152
- * named by a grouped `bpmn:label` instead, and are not asked (see
153
- * {@link unlabeledStep}).
148
+ * - `label-presence` reads the subject's OWN `text`, then — when the rule
149
+ * declares a `labelRole` — the text of the GROUPED sibling carrying it. BPMN
150
+ * names its activities in place and, since R38, its events and gateways by a
151
+ * grouped `bpmn:label`; {@link unlabeledStep} declares that role and asks all
152
+ * three. A text merely sitting beside a node is still not this question.
154
153
  */
155
154
  /**
156
155
  * `eitherMin` was also shipped, and this pack deliberately does not use it.
package/dist/rules.js CHANGED
@@ -146,12 +146,11 @@ import { BPMN_ROLE, BPMN_ROLES } from './roles.js';
146
146
  * - `forbidPattern` carries its OWN {@link RuleMessage} inside the pattern
147
147
  * rather than in a slot beside the other bounds, because a forbidden zone is
148
148
  * not a bound that failed and its sentence never reads like one;
149
- * - `label-presence` reads the subject's OWN `text`. A framework whose artefacts
150
- * are named by a separate element beside them is asking a different question,
151
- * and this family cannot answer it. BPMN names its ACTIVITIES in place, so it
152
- * can ask it of them; since R38 its events, gateways and data shapes are
153
- * named by a grouped `bpmn:label` instead, and are not asked (see
154
- * {@link unlabeledStep}).
149
+ * - `label-presence` reads the subject's OWN `text`, then — when the rule
150
+ * declares a `labelRole` — the text of the GROUPED sibling carrying it. BPMN
151
+ * names its activities in place and, since R38, its events and gateways by a
152
+ * grouped `bpmn:label`; {@link unlabeledStep} declares that role and asks all
153
+ * three. A text merely sitting beside a node is still not this question.
155
154
  */
156
155
  /**
157
156
  * `eitherMin` was also shipped, and this pack deliberately does not use it.
@@ -1455,37 +1454,37 @@ const singleBlankStart = {
1455
1454
  * **`audit`**, because an unnamed step is a diagram that is not done rather than
1456
1455
  * a diagram that is wrong, and the panel is where "not done" belongs.
1457
1456
  *
1458
- * Written on `bpmn:activity`, and only there. The `label-presence` family
1459
- * reads the subject's OWN `text`, and since R38 (`docs/adr/0029`) only an
1460
- * activity keeps its name there: an event, a gateway or a data shape is named
1461
- * by a free `bpmn:label` text grouped with it, which the family cannot see
1462
- * (`packages/affine/blocks/surface/src/extensions/validation.ts`, the
1463
- * label-presence evaluator). Left on `bpmn:flow-object`, the rule would report
1464
- * every NAMED event and gateway as unnamed.
1465
- *
1466
- * Losing them costs little: BPMN practice commonly leaves an event or a
1467
- * converging gateway unnamed, while an activity is a box whose whole content is
1468
- * its name — an empty one says nothing at all. The rule id is kept (ids are
1469
- * forever); it was shipped as "step", and an activity is the step par
1470
- * excellence.
1471
- *
1472
- * ponytail: the ceiling is "a gateway that asks no question is not reported".
1473
- * The upgrade path is a label-presence mode that also reads the `labelRole`
1474
- * member of the subject's group, the way `readName` does for the reading
1475
- * panel — an engine change, not a pack one.
1457
+ * Written on `bpmn:flow-object`: every activity, event and gateway. Since R38
1458
+ * (`docs/adr/0029`) only an activity keeps its name in its own `text`; an event
1459
+ * or a gateway is named by a free `bpmn:label` text GROUPED with it. The rule
1460
+ * therefore declares `labelRole: BPMN_ROLE.label`, and the `label-presence`
1461
+ * family reads that sibling when the subject's own text is empty — the same
1462
+ * reading as the panel's `readName` (ADR 0021, amendment of 2026-11-04). A
1463
+ * legacy event still carrying inner text is named by it, as before.
1464
+ *
1465
+ * Version 2: version 1 was written on `bpmn:activity` alone, because the
1466
+ * family could not see the grouped label and would have reported every NAMED
1467
+ * event and gateway. A gateway that asks no question, or an event nobody
1468
+ * named, is now reported too — in strict profiles, at the same `audit`
1469
+ * severity. Data shapes are not flow objects and stay out of it. The rule id is
1470
+ * kept (ids are forever); it was shipped as "step".
1471
+ *
1472
+ * The incremental limit of a sibling read (editing only the label does not
1473
+ * re-judge the subject on the real-time path) costs nothing here: the rule is
1474
+ * on-demand, and a check-up is a full pass.
1476
1475
  */
1477
1476
  const unlabeledStep = {
1478
1477
  id: 'bpmn.unlabeled-step',
1479
1478
  framework: 'bpmn',
1480
1479
  family: 'label-presence',
1481
1480
  severity: 'audit',
1482
- appliesTo: BPMN_ROLE.activity,
1481
+ appliesTo: BPMN_ROLE.flowObject,
1483
1482
  roles: BPMN_ROLES,
1484
1483
  messageKey: 'com.labre.bpmn.validation.unlabeled-step',
1485
1484
  messageFallback: 'This step has no name.',
1486
1485
  suggestionKey: 'com.labre.bpmn.validation.unlabeled-step.suggestion',
1487
1486
  suggestionFallback: 'Name it in a verb phrase a reader outside the room would understand — "Check the credit limit" rather than "Step 3".',
1488
- version: 1,
1487
+ version: 2,
1489
1488
  // A name is nowhere required by the specification: an unnamed step is a
1490
1489
  // diagram that is not done, never one that is wrong.
1491
1490
  provenance: {
@@ -1499,7 +1498,7 @@ const unlabeledStep = {
1499
1498
  // second moment exists to refuse.
1500
1499
  moment: 'on-demand',
1501
1500
  backgroundRole: BPMN_ROLE.pool,
1502
- label: { present: true },
1501
+ label: { present: true, labelRole: BPMN_ROLE.label },
1503
1502
  };
1504
1503
  /**
1505
1504
  * The pack, whole: twenty-two rules, all registered, all live.
@@ -1,5 +1,18 @@
1
+ import { BpmnPoolElementModel } from '@formicoidea/labre-core/model';
1
2
  import { type ChromeWording, type ToolbarContext, type ToolbarModuleConfig } from '@formicoidea/labre-core/shared/services';
2
3
  import { type TemplateResult } from 'lit';
4
+ type BpmnPoolSizeProp = 'nameFontSize' | 'laneFontSize';
5
+ /**
6
+ * Write a picked title size onto every selected pool: one gesture, one undo
7
+ * step (`captureSync` first), nothing written on a readonly store, and a pool
8
+ * already showing that size left alone, since an unchanged write still pushes
9
+ * an undo entry. A pool that stores no size shows the declared one, so picking
10
+ * the declared size on it writes nothing: the key stays absent until the
11
+ * author changes what is painted.
12
+ *
13
+ * Exported for the spec, which drives it without a toolbar.
14
+ */
15
+ export declare function setBpmnPoolTitleSize(ctx: Pick<ToolbarContext, 'std'>, models: readonly BpmnPoolElementModel[], prop: BpmnPoolSizeProp, size: number): void;
3
16
  export declare const bpmnPoolToolbarConfig: {
4
17
  readonly actions: [{
5
18
  id: string;
@@ -40,6 +53,12 @@ export declare const bpmnPoolToolbarConfig: {
40
53
  tooltip: string;
41
54
  run: (runCtx: ToolbarContext) => void;
42
55
  };
56
+ }, {
57
+ id: string;
58
+ content(ctx: ToolbarContext): TemplateResult<1> | null;
59
+ }, {
60
+ id: string;
61
+ content(ctx: ToolbarContext): TemplateResult<1> | null;
43
62
  }, import("@formicoidea/labre-core/shared/services").ToolbarActionGenerator];
44
63
  readonly when: (ctx: ToolbarContext) => boolean;
45
64
  };
@@ -64,3 +83,4 @@ export declare const bpmnPoolToolbarExtension: import("@formicoidea/labre-core/_
64
83
  */
65
84
  export declare const bpmnPoolToolingToolbarConfig: ToolbarModuleConfig;
66
85
  export declare const bpmnPoolToolingToolbarExtension: import("@formicoidea/labre-core/_pkgs/store/index.js").ExtensionType;
86
+ export {};
@@ -1,8 +1,11 @@
1
1
  import { EdgelessCRUDIdentifier, legendToolbarAction, validationToolbarConfig, } from '@formicoidea/labre-core/blocks/surface';
2
2
  import { BpmnPoolElementModel } from '@formicoidea/labre-core/model';
3
3
  import { BOARD_RESIZE_TOGGLE, commandMoreAction, ToolbarModuleExtension, translateKey, } from '@formicoidea/labre-core/shared/services';
4
+ import { getMostCommonValue } from '@formicoidea/labre-core/shared/utils';
4
5
  import { BlockFlavourIdentifier, getRegisteredCommands, runCommand, } from '@formicoidea/labre-core/std';
6
+ import { signal } from '@preact/signals-core';
5
7
  import { html } from 'lit';
8
+ import { BPMN_LANE_TITLE_SIZE, BPMN_POOL_TITLE_SIZE, POOL_LANE_NAME_FONT_SIZE, POOL_LANE_NAME_FONT_SIZES, POOL_NAME_FONT_SIZE, POOL_NAME_FONT_SIZES, } from '../consts.js';
6
9
  import { bpmnExportXmlIcon, bpmnLaneAddIcon, bpmnLaneDownIcon, bpmnLaneRemoveIcon, bpmnLaneUpIcon, } from './icons.js';
7
10
  const ResizeIcon = html `<svg
8
11
  width="24"
@@ -85,6 +88,68 @@ function commandAction(id, commandId, labelKey, labelFallback, icon) {
85
88
  };
86
89
  }
87
90
  const findCommand = (ctx, id) => getRegisteredCommands(ctx.std).find(candidate => candidate.id === id);
91
+ /** What a pool that stores no size paints, per prop. */
92
+ const DECLARED_SIZE = {
93
+ nameFontSize: POOL_NAME_FONT_SIZE,
94
+ laneFontSize: POOL_LANE_NAME_FONT_SIZE,
95
+ };
96
+ /**
97
+ * Write a picked title size onto every selected pool: one gesture, one undo
98
+ * step (`captureSync` first), nothing written on a readonly store, and a pool
99
+ * already showing that size left alone, since an unchanged write still pushes
100
+ * an undo entry. A pool that stores no size shows the declared one, so picking
101
+ * the declared size on it writes nothing: the key stays absent until the
102
+ * author changes what is painted.
103
+ *
104
+ * Exported for the spec, which drives it without a toolbar.
105
+ */
106
+ export function setBpmnPoolTitleSize(ctx, models, prop, size) {
107
+ const store = ctx.std.store;
108
+ if (store.readonly)
109
+ return;
110
+ const changed = models.filter(model => (model[prop] ?? DECLARED_SIZE[prop]) !== size);
111
+ if (!changed.length)
112
+ return;
113
+ store.captureSync();
114
+ const crud = ctx.std.get(EdgelessCRUDIdentifier);
115
+ changed.forEach(model => crud.updateElement(model.id, { [prop]: size }));
116
+ }
117
+ /**
118
+ * A title-size dropdown, the shape of the text toolbar's `d.font-size`
119
+ * (`gfx/text/src/toolbar/actions.ts`) with the pool's own steps: a title band
120
+ * is not a free text, and the text list's 16 to 128 would let one name eat the
121
+ * flow area. The free input is clamped to the same range.
122
+ */
123
+ function titleSizeAction(id, prop, label, sizes, when) {
124
+ const items = sizes.map(value => ({ value }));
125
+ return {
126
+ id,
127
+ content(ctx) {
128
+ const models = ctx.getSurfaceModelsByType(BpmnPoolElementModel);
129
+ if (!models.length)
130
+ return null;
131
+ if (when && !when(models))
132
+ return null;
133
+ const shown = models.map(model => ({
134
+ size: model[prop] ?? DECLARED_SIZE[prop],
135
+ }));
136
+ const size$ = signal(getMostCommonValue(shown, 'size') ?? DECLARED_SIZE[prop]);
137
+ const onPick = (e) => {
138
+ e.stopPropagation();
139
+ setBpmnPoolTitleSize(ctx, models, prop, e.detail);
140
+ };
141
+ return html `<affine-size-dropdown-menu
142
+ @select=${onPick}
143
+ .label=${translateKey(ctx.std, ...label)}
144
+ .sizes=${items}
145
+ .minSize=${sizes[0]}
146
+ .maxSize=${sizes[sizes.length - 1]}
147
+ .size$=${size$}
148
+ ></affine-size-dropdown-menu>`;
149
+ },
150
+ };
151
+ }
152
+ const hasLanes = (models) => models.some(model => (model.lanes?.length ?? 0) > 0);
88
153
  export const bpmnPoolToolbarConfig = {
89
154
  actions: [
90
155
  booleanToggle('a.toggle-resize', BOARD_RESIZE_TOGGLE, ResizeIcon, 'resizeEnabled'),
@@ -98,6 +163,11 @@ export const bpmnPoolToolbarConfig = {
98
163
  // its title strip) and only show while one is focused and can move.
99
164
  commandAction('b.lane-2-up', 'bpmn.moveLaneUp', 'com.labre.commands.bpmn.moveLaneUp', 'Move lane up', bpmnLaneUpIcon),
100
165
  commandAction('b.lane-3-down', 'bpmn.moveLaneDown', 'com.labre.commands.bpmn.moveLaneDown', 'Move lane down', bpmnLaneDownIcon),
166
+ // The author's title sizes (ADR 0049), after the lane gestures: they are
167
+ // about how the pool reads rather than how it is cut. `b.size-*` sorts
168
+ // after `b.lane-*` and before the gated row's `c.legend`.
169
+ titleSizeAction('b.size-1-title', 'nameFontSize', BPMN_POOL_TITLE_SIZE, POOL_NAME_FONT_SIZES),
170
+ titleSizeAction('b.size-2-lanes', 'laneFontSize', BPMN_LANE_TITLE_SIZE, POOL_LANE_NAME_FONT_SIZES, hasLanes),
101
171
  // …and, in the "⋮", the one thing you do to a finished process rather than
102
172
  // to the shape of a pool: take it away as a file.
103
173
  commandMoreAction('z.export-xml', 'bpmn.exportXml', 'com.labre.commands.bpmn.exportXml', 'Export BPMN XML', bpmnExportXmlIcon),
@@ -1,6 +1,6 @@
1
1
  import { collectTranslationKeys, commandCategoryTranslationEntries, commandTranslationEntries, mergeTranslationEntries, } from '@formicoidea/labre-core/std';
2
2
  import { bpmnCommands } from './commands.js';
3
- import { LANE_NAME_FALLBACK, LANE_NAME_KEY, NODE_LABEL, nodeLabelKey, POOL_NAME_FALLBACK, POOL_NAME_KEY, } from './consts.js';
3
+ import { BPMN_LANE_TITLE_SIZE, BPMN_POOL_TITLE_SIZE, LANE_NAME_FALLBACK, LANE_NAME_KEY, NODE_LABEL, nodeLabelKey, POOL_NAME_FALLBACK, POOL_NAME_KEY, } from './consts.js';
4
4
  import { BPMN_EXPORT_WARNING_KEYS } from './export.js';
5
5
  import { BPMN_IMPORT_ERRORS, BPMN_IMPORT_REMARKS, BPMN_QUARANTINE_REASON, BPMN_QUARANTINE_REASON_KEY, } from './import.js';
6
6
  import { BPMN_PROFILES } from './profiles.js';
@@ -101,6 +101,15 @@ const paletteEntries = () => BPMN_PALETTE_WORDINGS.map(([key, fallback]) => ({
101
101
  fallback,
102
102
  source: 'chrome',
103
103
  }));
104
+ /**
105
+ * The pool toolbar's two title-size dropdown labels (ADR 0049) — chrome,
106
+ * re-resolved every time the toolbar renders, never written into a document.
107
+ */
108
+ const poolToolbarEntries = () => [BPMN_POOL_TITLE_SIZE, BPMN_LANE_TITLE_SIZE].map(([key, fallback]) => ({
109
+ key,
110
+ fallback,
111
+ source: 'chrome',
112
+ }));
104
113
  /**
105
114
  * THIS framework's contribution to the translation-key manifest — every
106
115
  * `com.labre.*` key BPMN can hand to `TranslationProvider.t`, derived from the
@@ -121,7 +130,7 @@ export const bpmnTranslationEntries = mergeTranslationEntries(commandTranslation
121
130
  // registry names no framework category in the bundled distribution, so a
122
131
  // host that composed core's manifest alone drew translated entries under
123
132
  // English headers (#183).
124
- commandCategoryTranslationEntries(bpmnCommands), collectTranslationKeys('role', BPMN_ROLES), collectTranslationKeys('rule', BPMN_RULES), collectTranslationKeys('profile', BPMN_PROFILES), seedEntries(), furnitureSeedEntries(), exampleSeedEntries(), templateNameEntries(), paletteEntries(), importRemarkEntries(), importErrorEntries(), quarantineReasonEntries(), exportWarningEntries(),
133
+ commandCategoryTranslationEntries(bpmnCommands), collectTranslationKeys('role', BPMN_ROLES), collectTranslationKeys('rule', BPMN_RULES), collectTranslationKeys('profile', BPMN_PROFILES), seedEntries(), furnitureSeedEntries(), exampleSeedEntries(), templateNameEntries(), paletteEntries(), poolToolbarEntries(), importRemarkEntries(), importErrorEntries(), quarantineReasonEntries(), exportWarningEntries(),
125
134
  // LAST, and the order is load-bearing: a reading profile carries the
126
135
  // framework's own `roles`, so walking it reaches every role key the `role`
127
136
  // line above already named. `mergeTranslationEntries` keeps the FIRST
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formicoidea/labre-framework-bpmn",
3
3
  "description": "Labre bpmn framework for @formicoidea/labre-core.",
4
- "version": "3.0.0",
4
+ "version": "3.1.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",
@@ -35,7 +35,8 @@
35
35
  "dist"
36
36
  ],
37
37
  "dependencies": {
38
- "@formicoidea/labre-core": "3.0.0",
38
+ "@formicoidea/labre-core": "3.1.0",
39
+ "@preact/signals-core": "^1.8.0",
39
40
  "lit": "^3.2.0"
40
41
  }
41
42
  }