@formicoidea/labre-framework-wardley 0.40.0 → 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
@@ -4,6 +4,35 @@ import type { BlockStdScope } from '@formicoidea/labre-core/std';
4
4
  import { type GfxController } from '@formicoidea/labre-core/std/gfx';
5
5
  import { type WardleyExportBoard } from './export.js';
6
6
  import { type WardleyAreaShape, type WardleyArtefactKind } from './presets.js';
7
+ /**
8
+ * Standalone creation/activation actions for the Wardley toolbox — the
9
+ * BEHAVIOUR layer, shared by every surface. They only depend on the
10
+ * {@link GfxController}.
11
+ *
12
+ * They no longer emit telemetry: since PF3 the single emission point is the
13
+ * command registry's `runCommand` (`docs/adr/0008`), which is the only function
14
+ * every surface goes through. `WardleyActionSource` is gone with it — the
15
+ * segment/module discrimination it carried is now `CommandInvocation.surface`.
16
+ */
17
+ /**
18
+ * The three axis words a translated variant's background is seeded with —
19
+ * declared once, so the resolver below and the manifest
20
+ * (`../translations.ts`) read the very same fallback.
21
+ */
22
+ export declare const WARDLEY_AXIS_SEED: {
23
+ readonly opportunity: {
24
+ readonly key: "com.labre.wardley.seed.axis-opportunity";
25
+ readonly fallback: "Opportunity";
26
+ };
27
+ readonly benefit: {
28
+ readonly key: "com.labre.wardley.seed.axis-benefit";
29
+ readonly fallback: "Benefit";
30
+ };
31
+ readonly investment: {
32
+ readonly key: "com.labre.wardley.seed.axis-investment";
33
+ readonly fallback: "Investment";
34
+ };
35
+ };
7
36
  /**
8
37
  * The single-circle node flavours: one connectable ellipse + a label to its
9
38
  * right, grouped. The glyph itself (anchor silhouette, ecosystem hatching,
package/dist/actions.js CHANGED
@@ -11,7 +11,7 @@ import { WARDLEY_SVG_IMPORT } from './interchange.js';
11
11
  import { wardleyBoardFrom, wardleySafeFilename, } from './export.js';
12
12
  import { WARDLEY_OWM_EXPORT, WARDLEY_OWM_IMPORT } from './interchange.js';
13
13
  import { HANDLE_SIZE, INERTIA_SIZE, LABEL_GAP, LINK_GREY, LINK_STROKE_WIDTH, PORTER_DEFAULT_LETTER, WARDLEY_RED, } from './node/consts.js';
14
- import { wardleyAreaBox, wardleyAreaProps, wardleyCanonicalBox, wardleyHandleBox, wardleyHandleProps, wardleyInertiaProps, WARDLEY_LABEL_H, WARDLEY_LABEL_W, wardleyLabelProps, wardleyMarketDotBoxes, wardleyMarketDotProps, wardleyMarketLinkPairs, wardleyMarketLinkProps, WARDLEY_NODE_LABEL, WARDLEY_NODE_SIZE, wardleyNodeProps, wardleyPorterArrowProps, wardleyPorterArrows, wardleyPorterLetterProps, } from './presets.js';
14
+ import { wardleyAreaBox, wardleyAreaProps, wardleyCanonicalBox, wardleyHandleBox, wardleyHandleProps, wardleyInertiaProps, WARDLEY_LABEL_H, WARDLEY_LABEL_W, wardleyLabelProps, wardleyMarketDotBoxes, wardleyMarketDotProps, wardleyMarketLinkPairs, wardleyMarketLinkProps, WARDLEY_NODE_LABEL, wardleyNodeLabelKey, WARDLEY_NODE_SIZE, wardleyNodeProps, wardleyPorterArrowProps, wardleyPorterArrows, wardleyPorterLetterProps, } from './presets.js';
15
15
  import { WARDLEY_ROLE } from './roles.js';
16
16
  /**
17
17
  * Standalone creation/activation actions for the Wardley toolbox — the
@@ -24,44 +24,62 @@ import { WARDLEY_ROLE } from './roles.js';
24
24
  * segment/module discrimination it carried is now `CommandInvocation.surface`.
25
25
  */
26
26
  /**
27
- * Per-variant default label overrides applied at creation (all remain editable
28
- * afterwards via the inline editor / toggles). The gradient itself is driven by
29
- * `variant` in the renderer.
30
- *
31
- * TODO(PF2 follow-up): these write ENGLISH PROSE into the document. Since PF2
32
- * the ten label props default to `undefined` precisely so the declaration's
33
- * i18n keys are reachable — but a map created as `opportunity` or `benefit`
34
- * lands with "Opportunity" / "Benefit" / "Investment" already persisted as if
35
- * the user had typed them, so those three are un-localisable for the life of
36
- * the document. Only `classic` and `evolution-gradient` are fully localisable
37
- * today.
38
- *
39
- * The fix is to make the variant part of the declaration — one axis/end-label
40
- * set per variant, each naming its own `labelKey` — rather than a bag of prop
41
- * overrides applied at creation. Out of scope here (it changes what a variant
42
- * IS). This is now the ONLY copy: the four background templates are derived
43
- * from these four commands, so the table goes away in one place.
27
+ * The three axis words a translated variant's background is seeded with —
28
+ * declared once, so the resolver below and the manifest
29
+ * (`../translations.ts`) read the very same fallback.
44
30
  */
45
- const BACKGROUND_VARIANT_DEFAULTS = {
46
- classic: {},
47
- // The Y axis becomes "Opportunity"; phase labels keep the classic defaults.
31
+ export const WARDLEY_AXIS_SEED = {
48
32
  opportunity: {
49
- yAxisTitle: 'Opportunity',
50
- showVisibilityLabels: false,
51
- showCornerLabels: false,
33
+ key: 'com.labre.wardley.seed.axis-opportunity',
34
+ fallback: 'Opportunity',
52
35
  },
53
- // The Y axis splits into Benefit (top) / Investment (bottom) around a zero
54
- // line drawn by the renderer.
55
36
  benefit: {
56
- yAxisTitle: '',
57
- visibilityHigh: 'Benefit',
58
- visibilityLow: 'Investment',
59
- showCornerLabels: false,
37
+ key: 'com.labre.wardley.seed.axis-benefit',
38
+ fallback: 'Benefit',
39
+ },
40
+ investment: {
41
+ key: 'com.labre.wardley.seed.axis-investment',
42
+ fallback: 'Investment',
60
43
  },
61
- // Keeps the classic labels (Value Chain / Uncharted / Industrialized…); only
62
- // the grey gradient differs.
63
- 'evolution-gradient': {},
64
44
  };
45
+ /**
46
+ * Per-variant default label overrides applied at creation (all remain editable
47
+ * afterwards via the inline editor / toggles). The gradient itself is driven by
48
+ * `variant` in the renderer.
49
+ *
50
+ * Resolved through the translation seam since the i18n pass (#278): the ten
51
+ * label props still default to `undefined` on the declaration itself, but
52
+ * `opportunity` and `benefit` are the two variants whose Y axis is PROSE the
53
+ * gesture bakes into the document at creation — `WARDLEY_AXIS_SEED` above is
54
+ * what a host's catalogue is offered for the three words, resolved HERE, once,
55
+ * exactly like every other seed in this file. `classic` and
56
+ * `evolution-gradient` keep the classic labels (Value Chain / Uncharted /
57
+ * Industrialized…), which are declaration `labelKey`s and were already fully
58
+ * localisable — this function names no override for them.
59
+ */
60
+ function backgroundVariantDefaults(gfx) {
61
+ const axis = (def) => translateKey(gfx.std, def.key, def.fallback);
62
+ return {
63
+ classic: {},
64
+ // The Y axis becomes "Opportunity"; phase labels keep the classic defaults.
65
+ opportunity: {
66
+ yAxisTitle: axis(WARDLEY_AXIS_SEED.opportunity),
67
+ showVisibilityLabels: false,
68
+ showCornerLabels: false,
69
+ },
70
+ // The Y axis splits into Benefit (top) / Investment (bottom) around a zero
71
+ // line drawn by the renderer.
72
+ benefit: {
73
+ yAxisTitle: '',
74
+ visibilityHigh: axis(WARDLEY_AXIS_SEED.benefit),
75
+ visibilityLow: axis(WARDLEY_AXIS_SEED.investment),
76
+ showCornerLabels: false,
77
+ },
78
+ // Keeps the classic labels (Value Chain / Uncharted / Industrialized…); only
79
+ // the grey gradient differs.
80
+ 'evolution-gradient': {},
81
+ };
82
+ }
65
83
  // The label box, now owned by `presets.ts` — the local names stay so the four
66
84
  // placements below keep reading as they did.
67
85
  const LABEL_H = WARDLEY_LABEL_H;
@@ -128,7 +146,7 @@ export function createWardleyBackground(gfx, variant = 'classic') {
128
146
  // declaration decides, and the toolbar toggle takes over from there.
129
147
  resizeEnabled: WARDLEY_BACKGROUND.geometry.resizable,
130
148
  variant,
131
- ...BACKGROUND_VARIANT_DEFAULTS[variant],
149
+ ...backgroundVariantDefaults(gfx)[variant],
132
150
  xywh: new Bound(centerX - width / 2, centerY - height / 2, width, height).serialize(),
133
151
  });
134
152
  finish(gfx, id);
@@ -145,7 +163,12 @@ export function createWardleyNode(gfx, kind) {
145
163
  const { w } = WARDLEY_NODE_SIZE[kind];
146
164
  const { centerX: cx, centerY: cy } = gfx.viewport;
147
165
  const nodeId = addNode(surface, kind, cx, cy);
148
- const labelId = addLabel(surface, WARDLEY_NODE_LABEL[kind], cx + w / 2 + LABEL_GAP, cy - LABEL_H / 2);
166
+ const labelId = addLabel(surface,
167
+ // Resolved HERE, once — the prompt a node nobody has named still carries,
168
+ // exactly like a BPMN node's caption. `gfx.std` is how this file reaches
169
+ // the translation seam: these creation sites take `GfxController`, not
170
+ // `BlockStdScope`, directly (`WardleyView` reads the same member).
171
+ translateKey(gfx.std, wardleyNodeLabelKey(kind), WARDLEY_NODE_LABEL[kind]), cx + w / 2 + LABEL_GAP, cy - LABEL_H / 2);
149
172
  finish(gfx, group(gfx, [nodeId, labelId]));
150
173
  }
151
174
  /** Create an inertia bar (filled black rect). */
@@ -178,7 +201,7 @@ export function createWardleyPipeline(gfx) {
178
201
  // `centerAnchorOnly` so connectors attach to its center only.
179
202
  const handleId = gfx.surface.addElement(wardleyHandleProps({ xywh: wardleyHandleBox(cx, cy) }));
180
203
  // Label centered horizontally on the pipeline, sitting ABOVE the handle.
181
- const labelId = addLabel(gfx.surface, WARDLEY_NODE_LABEL.pipeline, cx - 60, top - d / 2 - LABEL_H - LABEL_GAP, 'center');
204
+ const labelId = addLabel(gfx.surface, translateKey(gfx.std, wardleyNodeLabelKey('pipeline'), WARDLEY_NODE_LABEL.pipeline), cx - 60, top - d / 2 - LABEL_H - LABEL_GAP, 'center');
182
205
  // Nested groups: (handle + label), then (body + that group).
183
206
  const innerId = group(gfx, [handleId, labelId]);
184
207
  finish(gfx, group(gfx, [bodyId, innerId]));
@@ -202,7 +225,7 @@ export function createWardleyMarket(gfx) {
202
225
  const dotIds = wardleyMarketDotBoxes(cx, cy).map(xywh => surface.addElement(wardleyMarketDotProps({ xywh })));
203
226
  // Triangle: 3 attached connectors (auto-route center-to-center, clipped).
204
227
  const connIds = wardleyMarketLinkPairs(dotIds).map(([a, b]) => surface.addElement(wardleyMarketLinkProps(a, b)));
205
- const labelId = addLabel(surface, WARDLEY_NODE_LABEL.market, cx + R + LABEL_GAP, cy - LABEL_H / 2);
228
+ const labelId = addLabel(surface, translateKey(gfx.std, wardleyNodeLabelKey('market'), WARDLEY_NODE_LABEL.market), cx + R + LABEL_GAP, cy - LABEL_H / 2);
206
229
  finish(gfx, group(gfx, [circleId, ...dotIds, ...connIds, labelId]));
207
230
  }
208
231
  /**
@@ -263,7 +286,7 @@ export function createWardleyAccelerator(gfx, kind) {
263
286
  const { centerX: cx, centerY: cy } = gfx.viewport;
264
287
  const nodeId = addNode(surface, kind, cx, cy);
265
288
  const rightwards = kind === 'accelerator';
266
- const labelId = addLabel(surface, WARDLEY_NODE_LABEL[kind],
289
+ const labelId = addLabel(surface, translateKey(gfx.std, wardleyNodeLabelKey(kind), WARDLEY_NODE_LABEL[kind]),
267
290
  // A label box is a fixed LABEL_W wide whatever it reads, so a right-aligned
268
291
  // one has to start a box-width before the edge the words must end on.
269
292
  rightwards ? cx + w / 2 + LABEL_GAP : cx - w / 2 - LABEL_GAP - LABEL_W, cy - LABEL_H / 2, rightwards ? 'left' : 'right', FontWeight.SemiBold);
package/dist/import.d.ts CHANGED
@@ -1,5 +1,33 @@
1
1
  import type { InterchangeImportContext, InterchangeImportResult } from '@formicoidea/labre-core/blocks/surface';
2
2
  import { OWM_SCOPE, WARDLEY_OWM_FORMAT_ID } from './export.js';
3
+ /**
4
+ * The OWM import remarks whose wording is FIXED, as `[key, English]` pairs.
5
+ *
6
+ * A reader is a pure function of text (mirroring `.bpmn`'s own, ADR 0012 P3)
7
+ * and has no `std`, so it cannot ask the host's catalogue for anything: it
8
+ * declares the key on the note and `reportInterchangeImport` resolves it when
9
+ * it draws the report (`InterchangeNote.messageKey`). The English string
10
+ * stays here and stays the fallback.
11
+ *
12
+ * Every remark's fallback is the whole sentence a call site builds — a
13
+ * `{{name}}` / `{{count}}` hole is filled by `messageParams`
14
+ * (`InterchangeNote.messageParams`) at the call site, never by minting a new
15
+ * key for every value the file happens to carry. Plural wording stays
16
+ * grammatically neutral in the fallback (`'{{count}} line(s)…'`) — the
17
+ * host's job, the same rule BPMN's own remarks follow
18
+ * (`gfx/bpmn/src/import.ts`).
19
+ *
20
+ * Contributed to the manifest by `./translations.ts`.
21
+ */
22
+ export declare const WARDLEY_OWM_IMPORT_REMARKS: {
23
+ readonly unreadableCoordinatesInvented: readonly ["com.labre.wardley.import.remark.unreadable-coordinates", "its coordinates were unreadable, so it was placed where a map with no coordinates places things. The file did not say where it goes."];
24
+ readonly noCoordinatesInvented: readonly ["com.labre.wardley.import.remark.no-coordinates", "the file gives it no coordinates, so it was placed where a map with no coordinates places things. The file did not say where it goes."];
25
+ readonly duplicateName: readonly ["com.labre.wardley.import.remark.duplicate-name", "this name is declared more than once. Both artefacts are on the map, and every link naming it means the first — OWM identifies a component by its name."];
26
+ readonly linkEmptyEnd: readonly ["com.labre.wardley.import.remark.link-empty-end", "a link names nothing on one of its ends, so the arrow it asks for runs to no artefact and is invisible on the canvas."];
27
+ readonly linkUndeclaredEnd: readonly ["com.labre.wardley.import.remark.link-undeclared-end", "a link names this, and no statement in the file declares it. The arrow is in the document and runs to no artefact, so it is invisible on the canvas."];
28
+ readonly unreadableCoordinatesLine: readonly ["com.labre.wardley.import.remark.unreadable-coordinates-line", "line {{line}} declares coordinates this reader cannot make a number of, so they were not used."];
29
+ readonly carriedConstruct: readonly ["com.labre.wardley.import.remark.carried-construct", "{{count}} `{{kind}}` line(s) kept verbatim on the map and written back on the next export. Nothing on this canvas draws them."];
30
+ };
3
31
  /**
4
32
  * An OnlineWardleyMaps (OWM) DSL document, read as a Wardley map — the inverse
5
33
  * of `export.ts` on the vocabulary Labre draws, and an honest accounting of
package/dist/import.js CHANGED
@@ -4,6 +4,55 @@ import { OWM_DEFAULT_MAP_HEIGHT, OWM_DEFAULT_MAP_WIDTH, OWM_LABEL_HEIGHT, OWM_LA
4
4
  import { HANDLE_SIZE, LABEL_GAP, LABEL_FONT_SIZE, LINK_GREY, LINK_STROKE_WIDTH, MARKET_DOT_RING, MARKET_DOT_SIZE, MARKET_DOT_STROKE_WIDTH, MARKET_LINK_COLOR, MARKET_LINK_WIDTH, MARKET_SIZE, ECOSYSTEM_SIZE, NODE_FILL, NODE_SIZE, NODE_STROKE, NODE_STROKE_WIDTH, PIPELINE_FILL, PIPELINE_HEIGHT, WARDLEY_RED, } from './node/consts.js';
5
5
  import { WARDLEY_NODE_SIZE, wardleyNodeProps } from './presets.js';
6
6
  import { WARDLEY_ROLE } from './roles.js';
7
+ /**
8
+ * The OWM import remarks whose wording is FIXED, as `[key, English]` pairs.
9
+ *
10
+ * A reader is a pure function of text (mirroring `.bpmn`'s own, ADR 0012 P3)
11
+ * and has no `std`, so it cannot ask the host's catalogue for anything: it
12
+ * declares the key on the note and `reportInterchangeImport` resolves it when
13
+ * it draws the report (`InterchangeNote.messageKey`). The English string
14
+ * stays here and stays the fallback.
15
+ *
16
+ * Every remark's fallback is the whole sentence a call site builds — a
17
+ * `{{name}}` / `{{count}}` hole is filled by `messageParams`
18
+ * (`InterchangeNote.messageParams`) at the call site, never by minting a new
19
+ * key for every value the file happens to carry. Plural wording stays
20
+ * grammatically neutral in the fallback (`'{{count}} line(s)…'`) — the
21
+ * host's job, the same rule BPMN's own remarks follow
22
+ * (`gfx/bpmn/src/import.ts`).
23
+ *
24
+ * Contributed to the manifest by `./translations.ts`.
25
+ */
26
+ export const WARDLEY_OWM_IMPORT_REMARKS = {
27
+ unreadableCoordinatesInvented: [
28
+ 'com.labre.wardley.import.remark.unreadable-coordinates',
29
+ 'its coordinates were unreadable, so it was placed where a map with no coordinates places things. The file did not say where it goes.',
30
+ ],
31
+ noCoordinatesInvented: [
32
+ 'com.labre.wardley.import.remark.no-coordinates',
33
+ 'the file gives it no coordinates, so it was placed where a map with no coordinates places things. The file did not say where it goes.',
34
+ ],
35
+ duplicateName: [
36
+ 'com.labre.wardley.import.remark.duplicate-name',
37
+ 'this name is declared more than once. Both artefacts are on the map, and every link naming it means the first — OWM identifies a component by its name.',
38
+ ],
39
+ linkEmptyEnd: [
40
+ 'com.labre.wardley.import.remark.link-empty-end',
41
+ 'a link names nothing on one of its ends, so the arrow it asks for runs to no artefact and is invisible on the canvas.',
42
+ ],
43
+ linkUndeclaredEnd: [
44
+ 'com.labre.wardley.import.remark.link-undeclared-end',
45
+ 'a link names this, and no statement in the file declares it. The arrow is in the document and runs to no artefact, so it is invisible on the canvas.',
46
+ ],
47
+ unreadableCoordinatesLine: [
48
+ 'com.labre.wardley.import.remark.unreadable-coordinates-line',
49
+ 'line {{line}} declares coordinates this reader cannot make a number of, so they were not used.',
50
+ ],
51
+ carriedConstruct: [
52
+ 'com.labre.wardley.import.remark.carried-construct',
53
+ '{{count}} `{{kind}}` line(s) kept verbatim on the map and written back on the next export. Nothing on this canvas draws them.',
54
+ ],
55
+ };
7
56
  /**
8
57
  * An OnlineWardleyMaps (OWM) DSL document, read as a Wardley map — the inverse
9
58
  * of `export.ts` on the vocabulary Labre draws, and an honest accounting of
@@ -261,12 +310,13 @@ export function importWardleyOwm(source, context = {}) {
261
310
  carriedLines.push(line);
262
311
  carriedKinds.set(kind, (carriedKinds.get(kind) ?? 0) + 1);
263
312
  };
264
- const inventedNote = (element, name, why) => {
313
+ const inventedNote = (element, name, why, whyKey) => {
265
314
  notes.push({
266
315
  kind: 'invented-layout',
267
316
  sourceId: name,
268
317
  element,
269
318
  message: why,
319
+ ...(whyKey ? { messageKey: whyKey } : {}),
270
320
  });
271
321
  };
272
322
  /**
@@ -297,12 +347,16 @@ export function importWardleyOwm(source, context = {}) {
297
347
  kind: 'warning',
298
348
  sourceId: name,
299
349
  element,
350
+ messageKey: WARDLEY_OWM_IMPORT_REMARKS.unreadableCoordinatesLine[0],
300
351
  message: `line ${lineIndex + 1} declares coordinates this reader cannot make a number of, so they were not used.`,
352
+ messageParams: { line: lineIndex + 1 },
301
353
  });
302
354
  }
303
355
  inventedNote(element, name, bracket.present
304
- ? 'its coordinates were unreadable, so it was placed where a map with no coordinates places things. The file did not say where it goes.'
305
- : 'the file gives it no coordinates, so it was placed where a map with no coordinates places things. The file did not say where it goes.');
356
+ ? WARDLEY_OWM_IMPORT_REMARKS.unreadableCoordinatesInvented[1]
357
+ : WARDLEY_OWM_IMPORT_REMARKS.noCoordinatesInvented[1], bracket.present
358
+ ? WARDLEY_OWM_IMPORT_REMARKS.unreadableCoordinatesInvented[0]
359
+ : WARDLEY_OWM_IMPORT_REMARKS.noCoordinatesInvented[0]);
306
360
  return { ...place, invented: true };
307
361
  }
308
362
  inventedNote(element, name, visibility === undefined
@@ -467,7 +521,9 @@ export function importWardleyOwm(source, context = {}) {
467
521
  notes.push({
468
522
  kind: 'carried',
469
523
  element: kind,
470
- message: `${count} \`${kind}\` line${count === 1 ? '' : 's'} kept verbatim on the map and written back on the next export. Nothing on this canvas draws ${count === 1 ? 'it' : 'them'}.`,
524
+ messageKey: WARDLEY_OWM_IMPORT_REMARKS.carriedConstruct[0],
525
+ message: `${count} \`${kind}\` line(s) kept verbatim on the map and written back on the next export. Nothing on this canvas draws them.`,
526
+ messageParams: { count, kind },
471
527
  });
472
528
  }
473
529
  /* ── A name declared twice ────────────────────────────────────────── */
@@ -478,7 +534,8 @@ export function importWardleyOwm(source, context = {}) {
478
534
  kind: 'warning',
479
535
  sourceId: statement.name,
480
536
  element: statement.keyword,
481
- message: 'this name is declared more than once. Both artefacts are on the map, and every link naming it means the first — OWM identifies a component by its name.',
537
+ message: WARDLEY_OWM_IMPORT_REMARKS.duplicateName[1],
538
+ messageKey: WARDLEY_OWM_IMPORT_REMARKS.duplicateName[0],
482
539
  });
483
540
  }
484
541
  declared.add(statement.name);
@@ -504,7 +561,8 @@ export function importWardleyOwm(source, context = {}) {
504
561
  notes.push({
505
562
  kind: 'warning',
506
563
  element: 'link',
507
- message: 'a link names nothing on one of its ends, so the arrow it asks for runs to no artefact and is invisible on the canvas.',
564
+ message: WARDLEY_OWM_IMPORT_REMARKS.linkEmptyEnd[1],
565
+ messageKey: WARDLEY_OWM_IMPORT_REMARKS.linkEmptyEnd[0],
508
566
  });
509
567
  continue;
510
568
  }
@@ -514,7 +572,8 @@ export function importWardleyOwm(source, context = {}) {
514
572
  kind: 'warning',
515
573
  sourceId: end,
516
574
  element: 'link',
517
- message: 'a link names this, and no statement in the file declares it. The arrow is in the document and runs to no artefact, so it is invisible on the canvas.',
575
+ message: WARDLEY_OWM_IMPORT_REMARKS.linkUndeclaredEnd[1],
576
+ messageKey: WARDLEY_OWM_IMPORT_REMARKS.linkUndeclaredEnd[0],
518
577
  });
519
578
  }
520
579
  }
package/dist/legend.d.ts CHANGED
@@ -1,9 +1,20 @@
1
1
  import { type WardleyBackgroundElementModel } from '@formicoidea/labre-core/model';
2
+ import { type ChromeWording } from '@formicoidea/labre-core/shared/services';
2
3
  import type { BlockStdScope } from '@formicoidea/labre-core/std';
3
- /** A box in the panel, relative to the panel's top-left, plus its words. */
4
+ /** Every {@link LEGEND_DESC} wording, for `translations.ts`'s manifest. */
5
+ export declare const WARDLEY_LEGEND_DESC_WORDINGS: readonly ChromeWording[];
6
+ /** Every {@link LEGEND_GRADIENT} caption, for `translations.ts`'s manifest. */
7
+ export declare const WARDLEY_LEGEND_GRADIENT_WORDINGS: readonly ChromeWording[];
8
+ /** The legend box's own title. */
9
+ export declare const WARDLEY_LEGEND_TITLE: ChromeWording;
10
+ /** The five-forces panel's own title. */
11
+ export declare const WARDLEY_LEGEND_PORTER_TITLE: ChromeWording;
12
+ /** Every {@link PORTER_FORCES} wording, plus the caption, for the manifest. */
13
+ export declare const WARDLEY_LEGEND_PORTER_WORDINGS: readonly ChromeWording[];
14
+ /** A box in the panel, relative to the panel's top-left, plus its wording. */
4
15
  interface PorterPanelBox {
5
16
  xywh: [number, number, number, number];
6
- label: string;
17
+ label: ChromeWording;
7
18
  }
8
19
  interface PorterPanelLayout {
9
20
  w: number;
@@ -24,6 +35,13 @@ interface PorterPanelLayout {
24
35
  * they surround — is checkable rather than eyeballed.
25
36
  */
26
37
  export declare function porterPanelLayout(w: number): PorterPanelLayout;
38
+ /**
39
+ * Every wording this file writes onto the canvas, for `translations.ts`'s
40
+ * manifest contribution — the auto-legend's own title, its rows' captions,
41
+ * the gradient blocks and the Porter panel, all as `seed` (written into the
42
+ * document once, at the moment a legend is generated).
43
+ */
44
+ export declare const WARDLEY_LEGEND_WORDINGS: readonly ChromeWording[];
27
45
  /**
28
46
  * Build a "Legend" group from real, editable elements (white rect frame +
29
47
  * "Legend" text + one row of [real component glyph + description text] per
package/dist/legend.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createGroupCommand } from '@formicoidea/labre-core/gfx/group';
2
2
  import { ConnectorElementModel, ConnectorMode, FontFamily, PointStyle, ShapeElementModel, ShapeStyle, StrokeStyle, WardleyNodeElementModel, } from '@formicoidea/labre-core/model';
3
3
  import { NOTATION_NEUTRALS } from '@formicoidea/labre-core/shared/consts';
4
+ import { translateKey, } from '@formicoidea/labre-core/shared/services';
4
5
  import { Bound } from '@formicoidea/labre-core/global/gfx';
5
6
  import { GfxControllerIdentifier } from '@formicoidea/labre-core/std/gfx';
6
7
  import { GRADIENT_GREEN, GRADIENT_RED } from './gradient.js';
@@ -21,37 +22,82 @@ const LEGEND_ORDER = [
21
22
  'decelerator',
22
23
  'area',
23
24
  ];
24
- /** Default (editable) descriptions for each legend row. */
25
+ /**
26
+ * Default (editable) descriptions for each legend row — a `ChromeWording` per
27
+ * row so the seed a legend writes into the document is resolved through the
28
+ * host at BUILD time, like every other text `createWardleyLegend` creates.
29
+ * The fallback is the literal that shipped before these keys existed.
30
+ */
25
31
  const LEGEND_DESC = {
26
- component: 'Need / capability (activity, practice, data…)',
27
- anchor: 'Stakeholder (customer, user…)',
28
- market: 'Market (set of actors)',
29
- ecosystem: 'Ecosystem',
30
- method: 'Component + method (color = phase)',
31
- pipeline: 'Pipeline (possible choices for a capability)',
32
- link: 'Need relation (parent → child)',
33
- arrow: 'Evolution / movement (red = future)',
34
- inertia: 'Inertia to change',
35
- porter: "Porter's forces (external competition: R relative, L survival, E establish)",
36
- accelerator: 'Accelerator (speeds evolution up)',
37
- decelerator: 'Decelerator (slows evolution down)',
38
- area: 'Area (zone of the map)',
32
+ component: [
33
+ 'com.labre.wardley.legend.desc.component',
34
+ 'Need / capability (activity, practice, data…)',
35
+ ],
36
+ anchor: [
37
+ 'com.labre.wardley.legend.desc.anchor',
38
+ 'Stakeholder (customer, user…)',
39
+ ],
40
+ market: ['com.labre.wardley.legend.desc.market', 'Market (set of actors)'],
41
+ ecosystem: ['com.labre.wardley.legend.desc.ecosystem', 'Ecosystem'],
42
+ method: [
43
+ 'com.labre.wardley.legend.desc.method',
44
+ 'Component + method (color = phase)',
45
+ ],
46
+ pipeline: [
47
+ 'com.labre.wardley.legend.desc.pipeline',
48
+ 'Pipeline (possible choices for a capability)',
49
+ ],
50
+ link: [
51
+ 'com.labre.wardley.legend.desc.link',
52
+ 'Need relation (parent → child)',
53
+ ],
54
+ arrow: [
55
+ 'com.labre.wardley.legend.desc.arrow',
56
+ 'Evolution / movement (red = future)',
57
+ ],
58
+ inertia: ['com.labre.wardley.legend.desc.inertia', 'Inertia to change'],
59
+ porter: [
60
+ 'com.labre.wardley.legend.desc.porter',
61
+ "Porter's forces (external competition: R relative, L survival, E establish)",
62
+ ],
63
+ accelerator: [
64
+ 'com.labre.wardley.legend.desc.accelerator',
65
+ 'Accelerator (speeds evolution up)',
66
+ ],
67
+ decelerator: [
68
+ 'com.labre.wardley.legend.desc.decelerator',
69
+ 'Decelerator (slows evolution down)',
70
+ ],
71
+ area: ['com.labre.wardley.legend.desc.area', 'Area (zone of the map)'],
39
72
  };
73
+ /** Every {@link LEGEND_DESC} wording, for `translations.ts`'s manifest. */
74
+ export const WARDLEY_LEGEND_DESC_WORDINGS = Object.values(LEGEND_DESC);
40
75
  /** Gradient-meaning block, keyed by variant (caption + 2-colour swatch). */
41
76
  const LEGEND_GRADIENT = {
42
77
  opportunity: {
43
- caption: 'Opportunity gradient: differential value (green) vs operational value (red).',
78
+ caption: [
79
+ 'com.labre.wardley.legend.gradient.opportunity',
80
+ 'Opportunity gradient: differential value (green) vs operational value (red).',
81
+ ],
44
82
  swatch: [GRADIENT_GREEN, GRADIENT_RED],
45
83
  },
46
84
  benefit: {
47
- caption: 'Gradient: investment (red) then benefit (green).',
85
+ caption: [
86
+ 'com.labre.wardley.legend.gradient.benefit',
87
+ 'Gradient: investment (red) then benefit (green).',
88
+ ],
48
89
  swatch: [GRADIENT_RED, GRADIENT_GREEN],
49
90
  },
50
91
  'evolution-gradient': {
51
- caption: "Gradient representing the growth of Wardley's evolution function.",
92
+ caption: [
93
+ 'com.labre.wardley.legend.gradient.evolution',
94
+ "Gradient representing the growth of Wardley's evolution function.",
95
+ ],
52
96
  swatch: [NOTATION_NEUTRALS.divider, NOTATION_NEUTRALS.legendBorder],
53
97
  },
54
98
  };
99
+ /** Every {@link LEGEND_GRADIENT} caption, for `translations.ts`'s manifest. */
100
+ export const WARDLEY_LEGEND_GRADIENT_WORDINGS = Object.values(LEGEND_GRADIENT).map(g => g.caption);
55
101
  /* ── Porter's five forces: the panel under the rows ───────────────────── */
56
102
  /** The panel's own numbers. Model units, like every other measure here. */
57
103
  const PORTER_PANEL = {
@@ -79,15 +125,46 @@ const PORTER_PANEL = {
79
125
  };
80
126
  /** The four forces the boxes name, north first and then clockwise. */
81
127
  const PORTER_FORCES = [
82
- 'Threat of new entrants',
83
- 'Bargaining power of customers',
84
- 'Threat of substitutes',
85
- 'Bargaining power of suppliers',
128
+ [
129
+ 'com.labre.wardley.legend.porter.force.new-entrants',
130
+ 'Threat of new entrants',
131
+ ],
132
+ [
133
+ 'com.labre.wardley.legend.porter.force.customers',
134
+ 'Bargaining power of customers',
135
+ ],
136
+ [
137
+ 'com.labre.wardley.legend.porter.force.substitutes',
138
+ 'Threat of substitutes',
139
+ ],
140
+ [
141
+ 'com.labre.wardley.legend.porter.force.suppliers',
142
+ 'Bargaining power of suppliers',
143
+ ],
86
144
  ];
87
- /** What the panel's own glyph reads: the notation, not one force. */
145
+ /** What the panel's own glyph reads: the notation, not one force — untouched, like the Cynefin A/C letters. */
88
146
  const PORTER_PANEL_LETTERS = 'R/L/E';
89
147
  /** What the letters mean, spelled out under the diagram. */
90
- const PORTER_CAPTION = 'R/L/E = Relative competition, or struggLe for survival, or struggle to Establish';
148
+ const PORTER_CAPTION = [
149
+ 'com.labre.wardley.legend.porter.caption',
150
+ 'R/L/E = Relative competition, or struggLe for survival, or struggle to Establish',
151
+ ];
152
+ /** The legend box's own title. */
153
+ export const WARDLEY_LEGEND_TITLE = [
154
+ 'com.labre.wardley.legend.title',
155
+ 'Legend',
156
+ ];
157
+ /** The five-forces panel's own title. */
158
+ export const WARDLEY_LEGEND_PORTER_TITLE = [
159
+ 'com.labre.wardley.legend.porter.title',
160
+ "Porter's five forces",
161
+ ];
162
+ /** Every {@link PORTER_FORCES} wording, plus the caption, for the manifest. */
163
+ export const WARDLEY_LEGEND_PORTER_WORDINGS = [
164
+ WARDLEY_LEGEND_PORTER_TITLE,
165
+ ...PORTER_FORCES,
166
+ PORTER_CAPTION,
167
+ ];
91
168
  /**
92
169
  * How far a porter glyph of the given radius reaches, arrow tips included.
93
170
  *
@@ -145,6 +222,18 @@ export function porterPanelLayout(w) {
145
222
  caption: [p.pad, captionY, inner, p.captionH],
146
223
  };
147
224
  }
225
+ /**
226
+ * Every wording this file writes onto the canvas, for `translations.ts`'s
227
+ * manifest contribution — the auto-legend's own title, its rows' captions,
228
+ * the gradient blocks and the Porter panel, all as `seed` (written into the
229
+ * document once, at the moment a legend is generated).
230
+ */
231
+ export const WARDLEY_LEGEND_WORDINGS = [
232
+ WARDLEY_LEGEND_TITLE,
233
+ ...WARDLEY_LEGEND_DESC_WORDINGS,
234
+ ...WARDLEY_LEGEND_GRADIENT_WORDINGS,
235
+ ...WARDLEY_LEGEND_PORTER_WORDINGS,
236
+ ];
148
237
  /**
149
238
  * Build a "Legend" group from real, editable elements (white rect frame +
150
239
  * "Legend" text + one row of [real component glyph + description text] per
@@ -492,13 +581,13 @@ export function createWardleyLegend(std, bg) {
492
581
  xywh: new Bound(x0, y0, W, H).serialize(),
493
582
  }));
494
583
  // Title.
495
- ids.push(text('Legend', x0 + PAD, y0 + PAD, W - PAD * 2, TITLE_FS + 6, TITLE_FS));
584
+ ids.push(text(translateKey(std, ...WARDLEY_LEGEND_TITLE), x0 + PAD, y0 + PAD, W - PAD * 2, TITLE_FS + 6, TITLE_FS));
496
585
  // Rows.
497
586
  let ry = y0 + PAD + TITLE_H;
498
587
  for (const t of rows) {
499
588
  const cyRow = ry + ROW_H / 2;
500
589
  ids.push(...glyph(t, x0 + PAD + GLYPH_W / 2, cyRow));
501
- ids.push(text(LEGEND_DESC[t], x0 + PAD + GLYPH_W + GAP, cyRow - (TEXT_FS + 8) / 2, TEXT_W, TEXT_FS + 8, TEXT_FS));
590
+ ids.push(text(translateKey(std, ...LEGEND_DESC[t]), x0 + PAD + GLYPH_W + GAP, cyRow - (TEXT_FS + 8) / 2, TEXT_W, TEXT_FS + 8, TEXT_FS));
502
591
  ry += ROW_H;
503
592
  }
504
593
  // Gradient meaning block: a separator, then [2-colour swatch | caption].
@@ -534,7 +623,7 @@ export function createWardleyLegend(std, bg) {
534
623
  xywh: new Bound(sx + i * (sw + sgap), cyRow - sw / 2, sw, sw).serialize(),
535
624
  }));
536
625
  });
537
- ids.push(text(grad.caption, x0 + PAD + GLYPH_W + GAP, cyRow - GRAD_ROW_H / 2, TEXT_W, GRAD_ROW_H, TEXT_FS));
626
+ ids.push(text(translateKey(std, ...grad.caption), x0 + PAD + GLYPH_W + GAP, cyRow - GRAD_ROW_H / 2, TEXT_W, GRAD_ROW_H, TEXT_FS));
538
627
  }
539
628
  // Porter's five forces: the panel the PO's reference draws, under everything
540
629
  // else. It is not a row — a row says what a glyph IS, and this says what the
@@ -560,7 +649,7 @@ export function createWardleyLegend(std, bg) {
560
649
  xywh: new Bound(px, py, panel.w, panel.h).serialize(),
561
650
  }));
562
651
  const [tx, ty, tw, th] = panel.title;
563
- ids.push(text("Porter's five forces", px + tx, py + ty, tw, th, p.titleFs));
652
+ ids.push(text(translateKey(std, ...WARDLEY_LEGEND_PORTER_TITLE), px + tx, py + ty, tw, th, p.titleFs));
564
653
  const [cx, cy] = panel.center;
565
654
  ids.push(surface.addElement({
566
655
  type: 'wardleyNode',
@@ -601,10 +690,10 @@ export function createWardleyLegend(std, bg) {
601
690
  radius: 0,
602
691
  xywh: new Bound(px + bx, py + by, bw, bh).serialize(),
603
692
  }));
604
- ids.push(text(box.label, px + bx + 4, py + by + 3, bw - 8, bh - 6, p.boxFs, 'center'));
693
+ ids.push(text(translateKey(std, ...box.label), px + bx + 4, py + by + 3, bw - 8, bh - 6, p.boxFs, 'center'));
605
694
  }
606
695
  const [capX, capY, capW, capH] = panel.caption;
607
- ids.push(text(PORTER_CAPTION, px + capX, py + capY, capW, capH, p.captionFs, 'center'));
696
+ ids.push(text(translateKey(std, ...PORTER_CAPTION), px + capX, py + capY, capW, capH, p.captionFs, 'center'));
608
697
  }
609
698
  // 4. Group everything and select it.
610
699
  const [, result] = std.command.exec(createGroupCommand, { elements: ids });
package/dist/morph.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type MorphSpec } from '@formicoidea/labre-core/blocks/surface';
2
2
  import { WardleyNodeElementModel } from '@formicoidea/labre-core/model';
3
+ import type { BlockStdScope } from '@formicoidea/labre-core/std';
3
4
  import type { GfxPrimitiveElementModel } from '@formicoidea/labre-core/std/gfx';
4
5
  /**
5
6
  * What a Wardley artefact may BECOME — the declaration behind the "Change type"
@@ -81,8 +82,17 @@ export declare function wardleyNodeOfComponent(model: GfxPrimitiveElementModel):
81
82
  *
82
83
  * Pure and total over every string: the input is a canvas text element somebody
83
84
  * may have typed anything into.
85
+ *
86
+ * `std` is OPTIONAL: "untouched" means equal to the English prompt OR to the
87
+ * host's own resolved wording for `from`'s kind, and the target's prompt is
88
+ * likewise resolved through the host when one is given — mirroring
89
+ * `c4MorphedTypeLine`'s fix for the identical class of gap. With no `std`
90
+ * this behaves exactly as it always has (English only). The morph toolbar's
91
+ * `afterMorph` callback (`MorphSpec`, `packages/affine/blocks/surface`) now
92
+ * hands its callee the inserting editor's `std`, so `rewriteLabel` below
93
+ * passes it straight through.
84
94
  */
85
- export declare function wardleyMorphedLabel(from: WardleyMorphKind, to: WardleyMorphKind, rawText: string | null | undefined): string | null;
95
+ export declare function wardleyMorphedLabel(from: WardleyMorphKind, to: WardleyMorphKind, rawText: string | null | undefined, std?: BlockStdScope): string | null;
86
96
  /**
87
97
  * Everything the morph owes a Wardley composite beyond the props patch — the
88
98
  * `afterMorph` half of the spec, run inside the generic module's one
@@ -110,7 +120,7 @@ export declare function wardleyMorphedLabel(from: WardleyMorphKind, to: WardleyM
110
120
  * LEAVING comes apart before the one it is arriving at is built, so a
111
121
  * market → pipeline never has three dots and a handle at once.
112
122
  */
113
- export declare function wardleyMorphComposite(selected: GfxPrimitiveElementModel, from: WardleyMorphKind, to: WardleyMorphKind): void;
123
+ export declare function wardleyMorphComposite(selected: GfxPrimitiveElementModel, from: WardleyMorphKind, to: WardleyMorphKind, std?: BlockStdScope): void;
114
124
  /**
115
125
  * Wardley's morph declaration, handed to the generic `morphToolbarConfig`.
116
126
  *