@formicoidea/labre-framework-bpmn 0.39.3 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/actions.d.ts CHANGED
@@ -79,16 +79,16 @@ export declare function bpmnPoolsForLaneEdit(std: BlockStdScope): BpmnPoolElemen
79
79
  * Before it, a single lane was indistinguishable from no lane at all, and the
80
80
  * gesture looked broken until the second click.
81
81
  *
82
- * ## `Lane N` is DOCUMENT DATA, not vocabulary
82
+ * ## `Lane N` is a SEED, resolved once at placement
83
83
  *
84
84
  * The default name is a plain persisted string, exactly like the pool's own
85
85
  * `'Pool'` default: it is written into the document by this action and is the
86
- * user's to rewrite from that moment on. It is deliberately NOT a `labelKey`
87
- * through the translation seam — a host that ships a French catalogue must not
88
- * silently retitle a lane an author named, and a name that changed language
89
- * when the reader's locale did would be a document that says different things
90
- * to different people. `N` is the count AFTER this lane, so the first is
91
- * `Lane 1`.
86
+ * user's to rewrite from that moment on. Since the i18n pass (#278) it goes
87
+ * through the translation seam exactly as `nodeLabelKey` does for a node's
88
+ * caption — resolved HERE, once, so a lane added in a translated host starts
89
+ * in that language, and never re-resolved afterwards: a lane the author has
90
+ * since renamed is document content, and nothing here revisits it. `{{n}}` is
91
+ * the count AFTER this lane, so the first is `Lane 1`.
92
92
  */
93
93
  export declare function addBpmnLane(std: BlockStdScope): void;
94
94
  /**
package/dist/actions.js CHANGED
@@ -5,8 +5,8 @@ import { NotificationProvider, translateKey, } from '@formicoidea/labre-core/sha
5
5
  import { downloadBlob } from '@formicoidea/labre-core/shared/utils';
6
6
  import { Bound } from '@formicoidea/labre-core/global/gfx';
7
7
  import { GfxControllerIdentifier } from '@formicoidea/labre-core/std/gfx';
8
- import { ASSOCIATION_STROKE, ASSOCIATION_WIDTH, MESSAGE_STROKE, MESSAGE_WIDTH, NODE_LABEL, nodeLabelKey, NODE_SIZE, SEQUENCE_STROKE, SEQUENCE_WIDTH, } from './consts.js';
9
- import { BPMN_FORMAT_ID } from './export.js';
8
+ import { ASSOCIATION_STROKE, ASSOCIATION_WIDTH, LANE_NAME_FALLBACK, LANE_NAME_KEY, MESSAGE_STROKE, MESSAGE_WIDTH, NODE_LABEL, nodeLabelKey, NODE_SIZE, POOL_NAME_FALLBACK, POOL_NAME_KEY, SEQUENCE_STROKE, SEQUENCE_WIDTH, } from './consts.js';
9
+ import { BPMN_FORMAT_ID, exportBpmnXmlWithWarnings, } from './export.js';
10
10
  import { BPMN_SVG_IMPORT, BPMN_XML_EXPORT, BPMN_XML_FORMAT, BPMN_XML_IMPORT, bpmnBoardFrom, bpmnSafeFilename, } from './interchange.js';
11
11
  import { bpmnNodeProps, bpmnPoolProps } from './presets.js';
12
12
  import { BPMN_ROLE } from './roles.js';
@@ -60,7 +60,16 @@ export function createBpmnPool(std) {
60
60
  // and for the same reason: the shipped cards build their participants from it
61
61
  // too, so a pool laid out by a template and one dropped from the toolbox
62
62
  // cannot say different things. The gesture owns the BOX and nothing else.
63
- const id = surface.addElement(bpmnPoolProps({ xywh: new Bound(cx - w / 2, cy - h / 2, w, h).serialize() }));
63
+ //
64
+ // The NAME is the one exception, and it is written HERE rather than left to
65
+ // the model's default (`BpmnPoolElementModel.name = 'Pool'`, a red-zone
66
+ // field: a document created before this key existed keeps its literal
67
+ // 'Pool' verbatim). Resolved at placement and never again — content from
68
+ // the moment it lands, exactly like a node's caption.
69
+ const id = surface.addElement(bpmnPoolProps({
70
+ xywh: new Bound(cx - w / 2, cy - h / 2, w, h).serialize(),
71
+ name: translateKey(std, POOL_NAME_KEY, POOL_NAME_FALLBACK),
72
+ }));
64
73
  finish(gfx, id);
65
74
  }
66
75
  /**
@@ -217,16 +226,16 @@ function writeLanes(std, model, lanes) {
217
226
  * Before it, a single lane was indistinguishable from no lane at all, and the
218
227
  * gesture looked broken until the second click.
219
228
  *
220
- * ## `Lane N` is DOCUMENT DATA, not vocabulary
229
+ * ## `Lane N` is a SEED, resolved once at placement
221
230
  *
222
231
  * The default name is a plain persisted string, exactly like the pool's own
223
232
  * `'Pool'` default: it is written into the document by this action and is the
224
- * user's to rewrite from that moment on. It is deliberately NOT a `labelKey`
225
- * through the translation seam — a host that ships a French catalogue must not
226
- * silently retitle a lane an author named, and a name that changed language
227
- * when the reader's locale did would be a document that says different things
228
- * to different people. `N` is the count AFTER this lane, so the first is
229
- * `Lane 1`.
233
+ * user's to rewrite from that moment on. Since the i18n pass (#278) it goes
234
+ * through the translation seam exactly as `nodeLabelKey` does for a node's
235
+ * caption — resolved HERE, once, so a lane added in a translated host starts
236
+ * in that language, and never re-resolved afterwards: a lane the author has
237
+ * since renamed is document content, and nothing here revisits it. `{{n}}` is
238
+ * the count AFTER this lane, so the first is `Lane 1`.
230
239
  */
231
240
  export function addBpmnLane(std) {
232
241
  const pools = bpmnPoolsForLaneEdit(std);
@@ -245,9 +254,14 @@ export function addBpmnLane(std) {
245
254
  const size = lanes.length
246
255
  ? lanes.reduce((sum, lane) => sum + lane.size, 0) / lanes.length
247
256
  : 1;
257
+ const n = lanes.length + 1;
248
258
  writeLanes(std, model, [
249
259
  ...lanes,
250
- { id: generateElementId(), name: `Lane ${lanes.length + 1}`, size },
260
+ {
261
+ id: generateElementId(),
262
+ name: translateKey(std, LANE_NAME_KEY, LANE_NAME_FALLBACK, { n }),
263
+ size,
264
+ },
251
265
  ]);
252
266
  }
253
267
  }
@@ -335,9 +349,8 @@ export function bpmnExportFilename(std) {
335
349
  */
336
350
  export function exportBpmnXmlFile(std) {
337
351
  const elements = gfxOf(std).surface?.elementModels ?? [];
338
- const { text, filename, mime, warnings } = BPMN_XML_EXPORT.run(elements, {
339
- name: bpmnExportFilename(std),
340
- });
352
+ const name = bpmnExportFilename(std);
353
+ const { text, filename, mime } = BPMN_XML_EXPORT.run(elements, { name });
341
354
  // The charset is the browser's business, not the format's: `mime` is what
342
355
  // `.bpmn` IS, and this is how a blob is told to carry it.
343
356
  downloadBlob(new Blob([text], { type: `${mime};charset=utf-8` }), filename);
@@ -347,11 +360,25 @@ export function exportBpmnXmlFile(std) {
347
360
  // Export is the one person entitled to be told" false in the only place a
348
361
  // user stands. A warning is never an error: the file downloaded, and it is
349
362
  // valid; what it could not say is what this names.
350
- if (!warnings || warnings.length === 0)
363
+ //
364
+ // Read straight from the PURE exporter rather than through
365
+ // `BPMN_XML_EXPORT.run` above: the interchange capability's `warnings` is
366
+ // `readonly string[]` (a seam shared with every other format, resolved to
367
+ // its English fallback with no `std` to ask), while the STRUCTURED
368
+ // `BpmnExportWarning[]` — key, fallback, params — is what `translateKey`
369
+ // needs. Calling the exporter a second time costs nothing beyond CPU (it is
370
+ // pure and deterministic on the same `elements`/`name`), and keeps the
371
+ // downloaded bytes on the one door `BPMN_XML_EXPORT.run` already is.
372
+ const { warnings } = exportBpmnXmlWithWarnings(bpmnBoardFrom(elements), {
373
+ name,
374
+ });
375
+ if (warnings.length === 0)
351
376
  return;
352
377
  notifyBpmn(std, {
353
378
  title: translateKey(std, EXPORT_WARNINGS_KEY, EXPORT_WARNINGS_FALLBACK),
354
- message: warnings.join('\n'),
379
+ message: warnings
380
+ .map(w => translateKey(std, w.key, w.fallback, w.params))
381
+ .join('\n'),
355
382
  accent: 'warning',
356
383
  });
357
384
  }
package/dist/consts.d.ts CHANGED
@@ -4,15 +4,20 @@ import type { BpmnNodeKind } from '@formicoidea/labre-core/model';
4
4
  * shapes and line weights, with accent colour only on the event rings — the
5
5
  * task and gateway stay neutral. All of these are just the creation-time
6
6
  * defaults; every value is an editable shape property afterwards.
7
+ *
8
+ * The neutrals come from the shared notation scale (`NOTATION_NEUTRALS`);
9
+ * only the event hues are BPMN's own. A node, flow or group created before the
10
+ * scale was adopted keeps the `#262626` / `#8e8d91` it was written with — a
11
+ * creation default is copied into the element, never re-read from here.
7
12
  */
8
13
  /** Accent stroke for the start event (thin green ring). */
9
14
  export declare const EVENT_START = "#43a06b";
10
15
  /** Accent stroke for the end event (thick red ring). */
11
16
  export declare const EVENT_END = "#cf5648";
12
- /** Neutral stroke for task / gateway (matches the EDGY base shapes). */
13
- export declare const NEUTRAL_STROKE = "#262626";
17
+ /** Neutral stroke for task / gateway — the shared artefact ink. */
18
+ export declare const NEUTRAL_STROKE: string;
14
19
  /** Default fill for events / task / gateway. */
15
- export declare const NODE_FILL = "#ffffff";
20
+ export declare const NODE_FILL: string;
16
21
  /** BPMN line weights: thin start ring, thick end ring, regular elsewhere. */
17
22
  export declare const START_WIDTH = 2;
18
23
  export declare const END_WIDTH = 4;
@@ -40,9 +45,9 @@ export declare const GROUP_RADIUS = 20;
40
45
  * several others. At the neutral stroke it out-shouts everything it encloses,
41
46
  * which is the exact opposite of what a lasso is for. Every tool that draws
42
47
  * BPMN makes the same call; the spec prescribes the dash and says nothing about
43
- * the colour.
48
+ * the colour. The shared scale's divider grey is exactly that role.
44
49
  */
45
- export declare const GROUP_STROKE = "#8e8d91";
50
+ export declare const GROUP_STROKE: string;
46
51
  /** Inner-text font for the task label. */
47
52
  export declare const INNER_FONT_SIZE = 18;
48
53
  /**
@@ -130,22 +135,47 @@ export declare const NODE_LABEL: Record<BpmnNodeKind, string>;
130
135
  * no word to translate, and BPMN puts an event's name outside its glyph anyway.
131
136
  */
132
137
  export declare const nodeLabelKey: (kind: BpmnNodeKind) => string;
138
+ /**
139
+ * The pool's own default name, at creation — a plain seed like {@link
140
+ * NODE_LABEL}, and never restated: `packages/affine/model/src/elements/bpmn/pool.ts`
141
+ * still defaults `name` to the English literal `'Pool'` (a document created
142
+ * before this key existed, or without a host catalogue, keeps that exact
143
+ * text), but `createBpmnPool` writes the resolved value explicitly so a pool
144
+ * dropped in a translated host starts in that language.
145
+ *
146
+ * "Pool" is the PO's glossary term for BPMN: the French proposal IS the
147
+ * English word.
148
+ */
149
+ export declare const POOL_NAME_KEY = "com.labre.bpmn.seed.pool";
150
+ export declare const POOL_NAME_FALLBACK = "Pool";
151
+ /**
152
+ * A fresh lane's name — `Lane 1`, `Lane 2`… — resolved AT PLACEMENT
153
+ * (`addBpmnLane`) like every other seed here. `{{n}}` is the count AFTER the
154
+ * lane being added, so the first is `Lane 1`.
155
+ */
156
+ export declare const LANE_NAME_KEY = "com.labre.bpmn.seed.lane";
157
+ export declare const LANE_NAME_FALLBACK = "Lane {{n}}";
133
158
  /**
134
159
  * Pool (background container) defaults — read by the `BPMN_POOL_BACKGROUND`
135
160
  * declaration (`background.ts`), which is the only thing that draws a pool.
136
161
  */
137
- export declare const POOL_FRAME_COLOR = "#262626";
162
+ export declare const POOL_FRAME_COLOR: string;
138
163
  /**
139
164
  * The card. The same white every framework background paints — it is what
140
165
  * `DEFAULT_BACKGROUND_SURFACE` gives a declaration that names no fill, and what
141
166
  * the Wardley map, the Core Domain Chart and the Context Map board all declare.
142
167
  */
143
- export declare const POOL_CARD_FILL = "#ffffff";
144
- export declare const POOL_BAND_FILL = "#f4f4f5";
168
+ export declare const POOL_CARD_FILL: string;
169
+ /**
170
+ * The participant and lane title bands: plain card white, painted at render
171
+ * time (a pool stores no colour of its own). The strip reads through the frame
172
+ * divider beside it, not through a tint (PO, 11/09/2026: no tinted bands).
173
+ */
174
+ export declare const POOL_BAND_FILL: string;
145
175
  export declare const POOL_FRAME_WIDTH = 1.5;
146
176
  export declare const POOL_CORNER_RADIUS = 6;
147
177
  export declare const POOL_NAME_FONT_SIZE = 15;
148
- export declare const POOL_NAME_COLOR = "#262626";
178
+ export declare const POOL_NAME_COLOR: string;
149
179
  export declare const POOL_FONT_FAMILY = "Inter, sans-serif";
150
180
  /**
151
181
  * Lane (couloir) name size — two units under the participant's own.
@@ -197,7 +227,7 @@ export declare const POOL_LANE_MIN_HEIGHT = 24;
197
227
  export declare const POOL_REF_WIDTH = 560;
198
228
  export declare const POOL_REF_HEIGHT = 200;
199
229
  /** Sequence-flow connector preset. */
200
- export declare const SEQUENCE_STROKE = "#262626";
230
+ export declare const SEQUENCE_STROKE: string;
201
231
  export declare const SEQUENCE_WIDTH = 2;
202
232
  /**
203
233
  * Message-flow connector preset — the dashed line that crosses between pools.
@@ -206,7 +236,7 @@ export declare const SEQUENCE_WIDTH = 2;
206
236
  * the DASH and the endpoints (an open circle where the message leaves, an open
207
237
  * arrowhead where it lands), which is exactly the distinction BPMN draws.
208
238
  */
209
- export declare const MESSAGE_STROKE = "#262626";
239
+ export declare const MESSAGE_STROKE: string;
210
240
  export declare const MESSAGE_WIDTH = 2;
211
241
  /**
212
242
  * Association connector preset — the line that ties a note or a data object to
@@ -228,5 +258,5 @@ export declare const MESSAGE_WIDTH = 2;
228
258
  * dot pattern, it is one the notation itself means — an association has no
229
259
  * direction to point in. A rule reads the `role`, which is exact either way.
230
260
  */
231
- export declare const ASSOCIATION_STROKE = "#262626";
261
+ export declare const ASSOCIATION_STROKE: string;
232
262
  export declare const ASSOCIATION_WIDTH = 2;
package/dist/consts.js CHANGED
@@ -1,17 +1,23 @@
1
+ import { NOTATION_NEUTRALS } from '@formicoidea/labre-core/shared/consts';
1
2
  /**
2
3
  * Visual constants for the BPMN basics. Style "C" (hybrid): spec-accurate
3
4
  * shapes and line weights, with accent colour only on the event rings — the
4
5
  * task and gateway stay neutral. All of these are just the creation-time
5
6
  * defaults; every value is an editable shape property afterwards.
7
+ *
8
+ * The neutrals come from the shared notation scale (`NOTATION_NEUTRALS`);
9
+ * only the event hues are BPMN's own. A node, flow or group created before the
10
+ * scale was adopted keeps the `#262626` / `#8e8d91` it was written with — a
11
+ * creation default is copied into the element, never re-read from here.
6
12
  */
7
13
  /** Accent stroke for the start event (thin green ring). */
8
14
  export const EVENT_START = '#43a06b';
9
15
  /** Accent stroke for the end event (thick red ring). */
10
16
  export const EVENT_END = '#cf5648';
11
- /** Neutral stroke for task / gateway (matches the EDGY base shapes). */
12
- export const NEUTRAL_STROKE = '#262626';
17
+ /** Neutral stroke for task / gateway — the shared artefact ink. */
18
+ export const NEUTRAL_STROKE = NOTATION_NEUTRALS.ink;
13
19
  /** Default fill for events / task / gateway. */
14
- export const NODE_FILL = '#ffffff';
20
+ export const NODE_FILL = NOTATION_NEUTRALS.cardFill;
15
21
  /** BPMN line weights: thin start ring, thick end ring, regular elsewhere. */
16
22
  export const START_WIDTH = 2;
17
23
  export const END_WIDTH = 4;
@@ -39,9 +45,9 @@ export const GROUP_RADIUS = 20;
39
45
  * several others. At the neutral stroke it out-shouts everything it encloses,
40
46
  * which is the exact opposite of what a lasso is for. Every tool that draws
41
47
  * BPMN makes the same call; the spec prescribes the dash and says nothing about
42
- * the colour.
48
+ * the colour. The shared scale's divider grey is exactly that role.
43
49
  */
44
- export const GROUP_STROKE = '#8e8d91';
50
+ export const GROUP_STROKE = NOTATION_NEUTRALS.divider;
45
51
  /** Inner-text font for the task label. */
46
52
  export const INNER_FONT_SIZE = 18;
47
53
  /**
@@ -166,22 +172,47 @@ export const NODE_LABEL = {
166
172
  * no word to translate, and BPMN puts an event's name outside its glyph anyway.
167
173
  */
168
174
  export const nodeLabelKey = (kind) => `com.labre.bpmn.seed.${kind}`;
175
+ /**
176
+ * The pool's own default name, at creation — a plain seed like {@link
177
+ * NODE_LABEL}, and never restated: `packages/affine/model/src/elements/bpmn/pool.ts`
178
+ * still defaults `name` to the English literal `'Pool'` (a document created
179
+ * before this key existed, or without a host catalogue, keeps that exact
180
+ * text), but `createBpmnPool` writes the resolved value explicitly so a pool
181
+ * dropped in a translated host starts in that language.
182
+ *
183
+ * "Pool" is the PO's glossary term for BPMN: the French proposal IS the
184
+ * English word.
185
+ */
186
+ export const POOL_NAME_KEY = 'com.labre.bpmn.seed.pool';
187
+ export const POOL_NAME_FALLBACK = 'Pool';
188
+ /**
189
+ * A fresh lane's name — `Lane 1`, `Lane 2`… — resolved AT PLACEMENT
190
+ * (`addBpmnLane`) like every other seed here. `{{n}}` is the count AFTER the
191
+ * lane being added, so the first is `Lane 1`.
192
+ */
193
+ export const LANE_NAME_KEY = 'com.labre.bpmn.seed.lane';
194
+ export const LANE_NAME_FALLBACK = 'Lane {{n}}';
169
195
  /**
170
196
  * Pool (background container) defaults — read by the `BPMN_POOL_BACKGROUND`
171
197
  * declaration (`background.ts`), which is the only thing that draws a pool.
172
198
  */
173
- export const POOL_FRAME_COLOR = '#262626';
199
+ export const POOL_FRAME_COLOR = NOTATION_NEUTRALS.frameInk;
174
200
  /**
175
201
  * The card. The same white every framework background paints — it is what
176
202
  * `DEFAULT_BACKGROUND_SURFACE` gives a declaration that names no fill, and what
177
203
  * the Wardley map, the Core Domain Chart and the Context Map board all declare.
178
204
  */
179
- export const POOL_CARD_FILL = '#ffffff';
180
- export const POOL_BAND_FILL = '#f4f4f5';
205
+ export const POOL_CARD_FILL = NOTATION_NEUTRALS.cardFill;
206
+ /**
207
+ * The participant and lane title bands: plain card white, painted at render
208
+ * time (a pool stores no colour of its own). The strip reads through the frame
209
+ * divider beside it, not through a tint (PO, 11/09/2026: no tinted bands).
210
+ */
211
+ export const POOL_BAND_FILL = NOTATION_NEUTRALS.cardFill;
181
212
  export const POOL_FRAME_WIDTH = 1.5;
182
213
  export const POOL_CORNER_RADIUS = 6;
183
214
  export const POOL_NAME_FONT_SIZE = 15;
184
- export const POOL_NAME_COLOR = '#262626';
215
+ export const POOL_NAME_COLOR = NOTATION_NEUTRALS.frameInk;
185
216
  export const POOL_FONT_FAMILY = 'Inter, sans-serif';
186
217
  /**
187
218
  * Lane (couloir) name size — two units under the participant's own.
@@ -238,7 +269,7 @@ export const POOL_LANE_MIN_HEIGHT = 24;
238
269
  export const POOL_REF_WIDTH = 560;
239
270
  export const POOL_REF_HEIGHT = 200;
240
271
  /** Sequence-flow connector preset. */
241
- export const SEQUENCE_STROKE = '#262626';
272
+ export const SEQUENCE_STROKE = NOTATION_NEUTRALS.ink;
242
273
  export const SEQUENCE_WIDTH = 2;
243
274
  /**
244
275
  * Message-flow connector preset — the dashed line that crosses between pools.
@@ -247,7 +278,7 @@ export const SEQUENCE_WIDTH = 2;
247
278
  * the DASH and the endpoints (an open circle where the message leaves, an open
248
279
  * arrowhead where it lands), which is exactly the distinction BPMN draws.
249
280
  */
250
- export const MESSAGE_STROKE = '#262626';
281
+ export const MESSAGE_STROKE = NOTATION_NEUTRALS.ink;
251
282
  export const MESSAGE_WIDTH = 2;
252
283
  /**
253
284
  * Association connector preset — the line that ties a note or a data object to
@@ -269,5 +300,5 @@ export const MESSAGE_WIDTH = 2;
269
300
  * dot pattern, it is one the notation itself means — an association has no
270
301
  * direction to point in. A rule reads the `role`, which is exact either way.
271
302
  */
272
- export const ASSOCIATION_STROKE = '#262626';
303
+ export const ASSOCIATION_STROKE = NOTATION_NEUTRALS.ink;
273
304
  export const ASSOCIATION_WIDTH = 2;
package/dist/export.d.ts CHANGED
@@ -222,6 +222,23 @@ export interface BpmnExportOptions {
222
222
  /** Names the `collaboration` / lone `process` and the `BPMNDiagram`. */
223
223
  name?: string;
224
224
  }
225
+ /**
226
+ * One warning, KEYED rather than a resolved string — see
227
+ * {@link BpmnExportOutcome}. `exportBpmnXmlWithWarnings` is pure and has no
228
+ * `std` to ask a host's catalogue, so it hands back the key, the English
229
+ * fallback (with `{{name}}` placeholders) and the params to fill them; the
230
+ * caller that DOES have `std` (`exportBpmnXmlFile`, `actions.ts`) is the one
231
+ * that calls `translateKey`.
232
+ */
233
+ export interface BpmnExportWarning {
234
+ key: string;
235
+ /** The English default, `{{name}}` placeholders included. */
236
+ fallback: string;
237
+ /** Values for the fallback's placeholders — a count, a list of names. */
238
+ params?: Record<string, string | number>;
239
+ }
240
+ /** All nine, for `translations.ts`'s manifest contribution. */
241
+ export declare const BPMN_EXPORT_WARNING_KEYS: readonly (readonly [string, string])[];
225
242
  /**
226
243
  * The document, plus what writing it could not say.
227
244
  *
@@ -235,7 +252,7 @@ export interface BpmnExportOptions {
235
252
  export interface BpmnExportOutcome {
236
253
  text: string;
237
254
  /** Empty when the board came out whole, which is the usual case. */
238
- warnings: string[];
255
+ warnings: BpmnExportWarning[];
239
256
  }
240
257
  /**
241
258
  * Serialize a board as a BPMN 2.0 XML interchange document.
package/dist/export.js CHANGED
@@ -763,6 +763,67 @@ class IdMinter {
763
763
  return unique;
764
764
  }
765
765
  }
766
+ /**
767
+ * The nine export-warning keys, each paired with its English fallback
768
+ * (`{{name}}` placeholders included) — declared ONCE, here, and read both by
769
+ * the `if` blocks below (which add the live `params`) and by
770
+ * `translations.ts`'s manifest (which needs the pair with no board to run
771
+ * against).
772
+ */
773
+ // Each fallback below is ONE unbroken literal rather than the `+`-joined
774
+ // pieces an earlier draft used: `manifest.unit.spec.ts`'s drift check reads a
775
+ // key/fallback PAIR as two adjacent literals in one argument list, and a
776
+ // concatenation left it seeing only the first piece — a drift the check
777
+ // itself then (correctly) flagged. A long line is the trade for a fallback
778
+ // the check can actually confirm against the manifest.
779
+ const UNDRAWN_ARTEFACTS_WARNING = [
780
+ 'com.labre.bpmn.export.warning.undrawn',
781
+ '{{count}} artefact(s) are drawn outside every pool. They are in the file, but most BPMN tools will not draw them: only a pool has a shape to hold them. Draw them inside a pool to make them visible.',
782
+ ];
783
+ const DROPPED_MESSAGE_FLOWS_WARNING = [
784
+ 'com.labre.bpmn.export.warning.dropped-message-flows',
785
+ '{{count}} message flow(s) were left out: a message flow runs between participants, and this board has no pool. Draw the pools it runs between, or say "is followed by" instead.',
786
+ ];
787
+ const SUBSTITUTED_IDS_WARNING = [
788
+ 'com.labre.bpmn.export.warning.substituted-ids',
789
+ '{{count}} element(s) imported from a BPMN file could not keep their original id: it was already taken in this file. A new id was written instead; nothing else changed.',
790
+ ];
791
+ const DISPLACED_SHAPES_WARNING = [
792
+ 'com.labre.bpmn.export.warning.displaced-shapes',
793
+ '{{count}} shape(s) imported from a BPMN file are kept exactly as the file drew them, and the rest of this drawing has moved since. They will open beside the process rather than inside it. Nothing was lost: they are in the file, at the position the original gave them.',
794
+ ];
795
+ const CONTRADICTING_DECLARATIONS_WARNING = [
796
+ 'com.labre.bpmn.export.warning.contradicting-declarations',
797
+ "This board came from a BPMN file that used {{names}} for something other than what BPMN means by them. Labre writes its own, so the file's declarations were left out rather than allowed to redefine the diagram's own namespaces. They are still in the document. Anything the file wrote under those prefixes is still in the export and will now be read under Labre's meaning of them, which is not the meaning the original had.",
798
+ ];
799
+ const DISAGREEING_DECLARATIONS_WARNING = [
800
+ 'com.labre.bpmn.export.warning.disagreeing-declarations',
801
+ "Two pools on this board disagree about {{names}}: they came from BPMN files that gave the same name two different values. The last was written and the other left out, so matter carried from the first file is now read under the second's meaning. Both are still in the document.",
802
+ ];
803
+ const CONFLICTING_IDS_WARNING = [
804
+ 'com.labre.bpmn.export.warning.conflicting-ids',
805
+ '{{count}} element(s) imported from a BPMN file could not be written back: {{names}} name(s) an id another imported element had already claimed, and a BPMN id must be unique across a document. The first was kept. The other(s) are still in the document; they are not in this file.',
806
+ ];
807
+ const REFUSED_ATTRIBUTE_NAMES_WARNING = [
808
+ 'com.labre.bpmn.export.warning.refused-attribute-names',
809
+ '{{count}} carried attribute(s) could not be written back, because their name(s) are not a valid XML name. They are still in the document. This is a sign the payload was edited by something other than a BPMN import.',
810
+ ];
811
+ const UNWRITABLE_EDGES_WARNING = [
812
+ 'com.labre.bpmn.export.warning.unwritable-edges',
813
+ '{{count}} arrow(s) were left out: BPMN requires both ends of a flow to be named, and they have an end that is loose or attached to something that is not a BPMN artefact.',
814
+ ];
815
+ /** All nine, for `translations.ts`'s manifest contribution. */
816
+ export const BPMN_EXPORT_WARNING_KEYS = [
817
+ UNDRAWN_ARTEFACTS_WARNING,
818
+ DROPPED_MESSAGE_FLOWS_WARNING,
819
+ SUBSTITUTED_IDS_WARNING,
820
+ DISPLACED_SHAPES_WARNING,
821
+ CONTRADICTING_DECLARATIONS_WARNING,
822
+ DISAGREEING_DECLARATIONS_WARNING,
823
+ CONFLICTING_IDS_WARNING,
824
+ REFUSED_ATTRIBUTE_NAMES_WARNING,
825
+ UNWRITABLE_EDGES_WARNING,
826
+ ];
766
827
  /* ── The plan ─────────────────────────────────────────────────────────── */
767
828
  /**
768
829
  * Which element an artefact is written INSIDE.
@@ -1465,6 +1526,14 @@ export function exportBpmnXmlWithWarnings(board, options = {}) {
1465
1526
  ...slot(document, 'relationship'),
1466
1527
  ]);
1467
1528
  /* ── What the format refused to carry ────────────────────────────── */
1529
+ //
1530
+ // Each warning is a KEY plus its English fallback and params — see
1531
+ // `BpmnExportWarning`. This function stays `std`-free (like every other
1532
+ // pure exporter in the pack), so it cannot ask a host's catalogue itself;
1533
+ // `exportBpmnXmlFile` (`actions.ts`) resolves every one of these through
1534
+ // `translateKey` before showing them. The fallback is deliberately NEUTRAL
1535
+ // on number ("{{count}} element(s)") rather than branching singular/plural
1536
+ // English by hand: pluralisation is the host's, off `count`.
1468
1537
  const warnings = [];
1469
1538
  // Flow objects drawn beside the pools. They are in the file and correct for
1470
1539
  // any tool that reads the MODEL, and a collaboration plane has no shape to
@@ -1478,18 +1547,12 @@ export function exportBpmnXmlWithWarnings(board, options = {}) {
1478
1547
  ? planned.filter(node => node.scope === orphanProcess).length
1479
1548
  : 0;
1480
1549
  if (undrawn > 0) {
1481
- warnings.push(`${undrawn} ${undrawn === 1 ? 'artefact is' : 'artefacts are'} drawn ` +
1482
- `outside every pool. ${undrawn === 1 ? 'It is' : 'They are'} in the ` +
1483
- `file, but most BPMN tools will not draw ${undrawn === 1 ? 'it' : 'them'}: ` +
1484
- `only a pool has a shape to hold ${undrawn === 1 ? 'it' : 'them'}. ` +
1485
- `Draw ${undrawn === 1 ? 'it' : 'them'} inside a pool to make ` +
1486
- `${undrawn === 1 ? 'it' : 'them'} visible.`);
1550
+ const [key, fallback] = UNDRAWN_ARTEFACTS_WARNING;
1551
+ warnings.push({ key, fallback, params: { count: undrawn } });
1487
1552
  }
1488
1553
  if (droppedMessageFlows > 0) {
1489
- warnings.push(`${droppedMessageFlows} message ${droppedMessageFlows === 1 ? 'flow was' : 'flows were'} ` +
1490
- `left out: a message flow runs between participants, and this board ` +
1491
- `has no pool. Draw the pools it runs between, or say "is followed by" ` +
1492
- `instead.`);
1554
+ const [key, fallback] = DROPPED_MESSAGE_FLOWS_WARNING;
1555
+ warnings.push({ key, fallback, params: { count: droppedMessageFlows } });
1493
1556
  }
1494
1557
  // An id a file gave us that we could not give back (ADR 0012 D3). It happens
1495
1558
  // when two elements carry the same recorded id — a merged document, an
@@ -1497,11 +1560,8 @@ export function exportBpmnXmlWithWarnings(board, options = {}) {
1497
1560
  // file is correct either way; what the author loses is the continuity of one
1498
1561
  // name between the document they imported and the one they are exporting.
1499
1562
  if (minter.substituted > 0) {
1500
- warnings.push(`${minter.substituted} ${minter.substituted === 1 ? 'element' : 'elements'} ` +
1501
- `imported from a BPMN file could not keep ` +
1502
- `${minter.substituted === 1 ? 'its' : 'their'} original id: ` +
1503
- `${minter.substituted === 1 ? 'it was' : 'they were'} already taken in ` +
1504
- `this file. A new id was written instead; nothing else changed.`);
1563
+ const [key, fallback] = SUBSTITUTED_IDS_WARNING;
1564
+ warnings.push({ key, fallback, params: { count: minter.substituted } });
1505
1565
  }
1506
1566
  // A carried diagram element keeps the source file's own coordinates, and the
1507
1567
  // rest of the drawing has just been translated to the plane origin (§12.3).
@@ -1510,44 +1570,28 @@ export function exportBpmnXmlWithWarnings(board, options = {}) {
1510
1570
  // once anything has been dragged. Nothing is lost; something is displaced,
1511
1571
  // and the person who clicked Export is the one entitled to hear about it.
1512
1572
  if (carriedPlane.length > 0 && (dx !== 0 || dy !== 0)) {
1513
- const count = carriedPlane.length;
1514
- warnings.push(`${count} ${count === 1 ? 'shape' : 'shapes'} imported from a BPMN file ` +
1515
- `${count === 1 ? 'is' : 'are'} kept exactly as the file drew ` +
1516
- `${count === 1 ? 'it' : 'them'}, and the rest of this drawing has ` +
1517
- `moved since. ${count === 1 ? 'It' : 'They'} will open beside the ` +
1518
- `process rather than inside it. Nothing was lost: ` +
1519
- `${count === 1 ? 'it is' : 'they are'} in the file, at the position ` +
1520
- `the original gave ${count === 1 ? 'it' : 'them'}.`);
1573
+ const [key, fallback] = DISPLACED_SHAPES_WARNING;
1574
+ warnings.push({ key, fallback, params: { count: carriedPlane.length } });
1521
1575
  }
1522
1576
  if (contradictingDeclarations.length > 0) {
1523
- const one = contradictingDeclarations.length === 1;
1524
- warnings.push(`This board came from a BPMN file that used ` +
1525
- `${contradictingDeclarations.join(' and ')} for something other than ` +
1526
- `what BPMN means by ${one ? 'it' : 'them'}. ` +
1527
- `Labre writes its own, so the file's ` +
1528
- `${one ? 'declaration was' : 'declarations were'} ` +
1529
- `left out rather than allowed to redefine the diagram's own namespaces. ` +
1530
- `${one ? 'It is' : 'They are'} still in the document. ` +
1531
- // The half a reader would otherwise have to work out: the DECLARATION
1532
- // is what was dropped, and the matter written under it was not — so it
1533
- // is now read under Labre's binding of the same prefix, which means
1534
- // something else. That is the larger of the two changes and it was the
1535
- // silent one.
1536
- `Anything the file wrote under ` +
1537
- `${one ? 'that prefix' : 'those prefixes'} is still in the export and ` +
1538
- `will now be read under Labre's meaning of ` +
1539
- `${one ? 'it' : 'them'}, which is not the meaning the original had.`);
1577
+ const [key, fallback] = CONTRADICTING_DECLARATIONS_WARNING;
1578
+ warnings.push({
1579
+ key,
1580
+ fallback,
1581
+ params: { names: contradictingDeclarations.join(' and ') },
1582
+ });
1540
1583
  }
1541
1584
  // Two pools, two source files, one prefix bound two ways. Last one wins —
1542
1585
  // there is one attribute of each name on `definitions` and something has to
1543
1586
  // be written — but a rebinding nobody was told about is how a fragment comes
1544
1587
  // to mean something else with no trace of when.
1545
1588
  if (disagreeingDeclarations.length > 0) {
1546
- warnings.push(`Two pools on this board disagree about ` +
1547
- `${disagreeingDeclarations.join(' and ')}: they came from BPMN files ` +
1548
- `that gave the same name two different values. The last was written ` +
1549
- `and the other left out, so matter carried from the first file is now ` +
1550
- `read under the second's meaning. Both are still in the document.`);
1589
+ const [key, fallback] = DISAGREEING_DECLARATIONS_WARNING;
1590
+ warnings.push({
1591
+ key,
1592
+ fallback,
1593
+ params: { names: disagreeingDeclarations.join(' and ') },
1594
+ });
1551
1595
  }
1552
1596
  // A carried element claiming an id another has already written back. The
1553
1597
  // duplicate-by-paste case is silent on purpose — one thing carried twice is
@@ -1555,32 +1599,27 @@ export function exportBpmnXmlWithWarnings(board, options = {}) {
1555
1599
  // fragments claiming one id, which is a file that cannot hold both.
1556
1600
  const conflicting = [...new Set(carried.conflictingIds)];
1557
1601
  if (conflicting.length > 0) {
1558
- const one = conflicting.length === 1;
1559
- warnings.push(`${conflicting.length} ${one ? 'element' : 'elements'} imported from a ` +
1560
- `BPMN file could not be written back: ` +
1561
- `${conflicting.map(id => `"${id}"`).join(', ')} ` +
1562
- `${one ? 'names an id' : 'name ids'} another imported element had ` +
1563
- `already claimed, and a BPMN id must be unique across a document. The ` +
1564
- `first was kept. ${one ? 'The other is' : 'The others are'} still in ` +
1565
- `the document; ${one ? 'it is' : 'they are'} not in this file.`);
1602
+ const [key, fallback] = CONFLICTING_IDS_WARNING;
1603
+ warnings.push({
1604
+ key,
1605
+ fallback,
1606
+ params: {
1607
+ count: conflicting.length,
1608
+ names: conflicting.map(id => `"${id}"`).join(', '),
1609
+ },
1610
+ });
1566
1611
  }
1567
1612
  // An attribute NAME that is not a name. It cannot be written without
1568
1613
  // unbalancing the document — the serializer interpolates a name and escapes
1569
1614
  // only a value — so it is dropped rather than allowed to corrupt the file.
1570
1615
  const refusedNames = [...new Set(carried.refusedNames)];
1571
1616
  if (refusedNames.length > 0) {
1572
- const one = refusedNames.length === 1;
1573
- warnings.push(`${refusedNames.length} carried ${one ? 'attribute' : 'attributes'} ` +
1574
- `could not be written back, because ` +
1575
- `${one ? 'its name is not' : 'their names are not'} a valid XML name. ` +
1576
- `${one ? 'It is' : 'They are'} still in the document. This is a sign ` +
1577
- `the payload was edited by something other than a BPMN import.`);
1617
+ const [key, fallback] = REFUSED_ATTRIBUTE_NAMES_WARNING;
1618
+ warnings.push({ key, fallback, params: { count: refusedNames.length } });
1578
1619
  }
1579
1620
  if (unwritableEdges > 0) {
1580
- warnings.push(`${unwritableEdges} ${unwritableEdges === 1 ? 'arrow was' : 'arrows were'} ` +
1581
- `left out: BPMN requires both ends of a flow to be named, and ` +
1582
- `${unwritableEdges === 1 ? 'this one has' : 'these have'} an end that ` +
1583
- `is loose or attached to something that is not a BPMN artefact.`);
1621
+ const [key, fallback] = UNWRITABLE_EDGES_WARNING;
1622
+ warnings.push({ key, fallback, params: { count: unwritableEdges } });
1584
1623
  }
1585
1624
  return {
1586
1625
  text: `<?xml version="1.0" encoding="UTF-8"?>\n${serializeElement(definitions, '')}\n`,