@formicoidea/labre-framework-wardley 0.40.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,42 +1,28 @@
1
+ import type { EditableBackgroundLabel, FrameworkBackgroundDef } from '@formicoidea/labre-core/blocks/surface';
2
+ import { DeclaredBackgroundView } from '@formicoidea/labre-core/blocks/surface';
1
3
  import type { WardleyBackgroundElementModel } from '@formicoidea/labre-core/model';
2
- import type { EditorHost } from '@formicoidea/labre-core/std';
3
- import type { PointTestOptions } from '@formicoidea/labre-core/std/gfx';
4
- import { GfxElementModelView } from '@formicoidea/labre-core/std/gfx';
5
- export declare class WardleyView extends GfxElementModelView<WardleyBackgroundElementModel> {
4
+ /**
5
+ * The Wardley map's view: the shared background gesture, aimed by the
6
+ * `WARDLEY_BACKGROUND` declaration.
7
+ *
8
+ * The in-place rename shipped here first and has moved to
9
+ * `DeclaredBackgroundView` (`@labre/affine-block-surface`) so that every
10
+ * framework background gets it rather than the two that got round to copying
11
+ * it — see issue #355. Nothing about the map's behaviour changed: the hit test
12
+ * reads the same declaration, through the same catalogue, and the guard below
13
+ * is the one thing this framework adds to it.
14
+ */
15
+ export declare class WardleyView extends DeclaredBackgroundView<WardleyBackgroundElementModel> {
6
16
  static type: string;
7
- /** The in-place `<input>` used to edit a label, or null when idle. */
8
- private _labelEditor;
9
- onCreated(): void;
10
- onDestroyed(): void;
17
+ protected get def(): FrameworkBackgroundDef;
11
18
  /**
12
- * The editable label under a MODEL-space point, or null.
19
+ * The declaration names the prop; this decides whether it may be WRITTEN.
13
20
  *
14
- * Which labels exist, where they sit, what they SAY and which are editable
15
- * all come from the declaration the renderer paints — one source, resolved
16
- * through the same catalogue, so a label can never be drawn in one place
17
- * and clicked in another, nor read one thing and open on another.
18
- */
19
- private _labelAt;
20
- /**
21
- * The map is SELECTED by its border (`WardleyBackgroundElementModel`), but
22
- * its axis labels must still receive the double-click that renames them.
23
- *
24
- * So the two areas differ, and this is where they are allowed to: the pointer
25
- * router asks the VIEW (`GfxViewEventManager`), and the view adds the zones
26
- * the declaration draws its labels in. Picking is unaffected —
27
- * `getElementByPoint` still asks the model, so a click in the middle of the
28
- * map still goes to whatever the user put there.
29
- */
30
- includesPoint(x: number, y: number, options: PointTestOptions, host: EditorHost): boolean;
31
- /** Double-click on a label → edit its text in place. */
32
- private _onDblClick;
33
- /**
34
- * @param current the words currently DRAWN — which is the vocabulary, not
35
- * `model[field]`, for a label the user has never renamed. Opening on the raw
36
- * prop would show an empty box for a label that plainly reads "Evolution".
21
+ * A closed list, because since #73 an element preserves keys it does not
22
+ * declare: a typo in the declaration would otherwise persist a junk key onto
23
+ * every map it was double-clicked on.
37
24
  */
38
- private _openLabelEditor;
39
- private _closeLabelEditor;
25
+ protected labelAt(lx: number, ly: number, w: number, h: number): EditableBackgroundLabel | null;
40
26
  }
41
27
  /**
42
28
  * Resize gating, from the primitive: the handles stay hidden until
@@ -1,147 +1,31 @@
1
- import { backgroundLabelHits, EdgelessCRUDIdentifier, FrameworkBackgroundInteractionExtension, hitTestBackgroundLabel, } from '@formicoidea/labre-core/blocks/surface';
2
- import { TranslationProvider } from '@formicoidea/labre-core/shared/services';
3
- import { rotatePoint } from '@formicoidea/labre-core/global/gfx';
4
- import { GfxElementModelView } from '@formicoidea/labre-core/std/gfx';
5
- import { isWardleyLabelProp, WARDLEY_BACKGROUND, } from './background.js';
6
- export class WardleyView extends GfxElementModelView {
7
- constructor() {
8
- super(...arguments);
9
- /** The in-place `<input>` used to edit a label, or null when idle. */
10
- this._labelEditor = null;
11
- }
1
+ import { DeclaredBackgroundView, FrameworkBackgroundInteractionExtension, } from '@formicoidea/labre-core/blocks/surface';
2
+ import { isWardleyLabelProp, WARDLEY_BACKGROUND } from './background.js';
3
+ /**
4
+ * The Wardley map's view: the shared background gesture, aimed by the
5
+ * `WARDLEY_BACKGROUND` declaration.
6
+ *
7
+ * The in-place rename shipped here first and has moved to
8
+ * `DeclaredBackgroundView` (`@labre/affine-block-surface`) so that every
9
+ * framework background gets it rather than the two that got round to copying
10
+ * it — see issue #355. Nothing about the map's behaviour changed: the hit test
11
+ * reads the same declaration, through the same catalogue, and the guard below
12
+ * is the one thing this framework adds to it.
13
+ */
14
+ export class WardleyView extends DeclaredBackgroundView {
12
15
  static { this.type = 'wardley'; }
13
- onCreated() {
14
- super.onCreated();
15
- this.on('dblclick', e => this._onDblClick(e));
16
- }
17
- onDestroyed() {
18
- this._closeLabelEditor();
19
- super.onDestroyed();
16
+ get def() {
17
+ return WARDLEY_BACKGROUND;
20
18
  }
21
19
  /**
22
- * The editable label under a MODEL-space point, or null.
20
+ * The declaration names the prop; this decides whether it may be WRITTEN.
23
21
  *
24
- * Which labels exist, where they sit, what they SAY and which are editable
25
- * all come from the declaration the renderer paints — one source, resolved
26
- * through the same catalogue, so a label can never be drawn in one place
27
- * and clicked in another, nor read one thing and open on another.
22
+ * A closed list, because since #73 an element preserves keys it does not
23
+ * declare: a typo in the declaration would otherwise persist a junk key onto
24
+ * every map it was double-clicked on.
28
25
  */
29
- _labelAt(mx, my) {
30
- const [bx, by, w, h] = this.model.deserializedXYWH;
31
- // Convert the model-space point into element-local coordinates, undoing the
32
- // element rotation around its center.
33
- let lx = mx - bx;
34
- let ly = my - by;
35
- const rot = this.model.rotate ?? 0;
36
- if (rot) {
37
- const center = [bx + w / 2, by + h / 2];
38
- const [ux, uy] = rotatePoint([mx, my], center, -rot);
39
- lx = ux - bx;
40
- ly = uy - by;
41
- }
42
- const hit = hitTestBackgroundLabel(backgroundLabelHits(WARDLEY_BACKGROUND, this.model, w, h, this.gfx.std.getOptional(TranslationProvider)), lx, ly);
43
- // The declaration names the prop; this decides whether it may be written.
44
- if (!hit || !isWardleyLabelProp(hit.prop))
45
- return null;
46
- return { prop: hit.prop, text: hit.text };
47
- }
48
- /**
49
- * The map is SELECTED by its border (`WardleyBackgroundElementModel`), but
50
- * its axis labels must still receive the double-click that renames them.
51
- *
52
- * So the two areas differ, and this is where they are allowed to: the pointer
53
- * router asks the VIEW (`GfxViewEventManager`), and the view adds the zones
54
- * the declaration draws its labels in. Picking is unaffected —
55
- * `getElementByPoint` still asks the model, so a click in the middle of the
56
- * map still goes to whatever the user put there.
57
- */
58
- includesPoint(x, y, options, host) {
59
- if (super.includesPoint(x, y, options, host))
60
- return true;
61
- return this._labelAt(x, y) !== null;
62
- }
63
- /** Double-click on a label → edit its text in place. */
64
- _onDblClick(e) {
65
- if (this.model.isLocked())
66
- return;
67
- const [mx, my] = this.gfx.viewport.toModelCoord(e.x, e.y);
68
- const hit = this._labelAt(mx, my);
69
- if (!hit)
70
- return;
71
- this._openLabelEditor(hit.prop, hit.text, e);
72
- }
73
- /**
74
- * @param current the words currently DRAWN — which is the vocabulary, not
75
- * `model[field]`, for a label the user has never renamed. Opening on the raw
76
- * prop would show an empty box for a label that plainly reads "Evolution".
77
- */
78
- _openLabelEditor(field, current, e) {
79
- this._closeLabelEditor();
80
- const input = document.createElement('input');
81
- input.value = current;
82
- Object.assign(input.style, {
83
- position: 'fixed',
84
- left: `${e.raw.clientX}px`,
85
- top: `${e.raw.clientY}px`,
86
- transform: 'translate(-50%, -50%)',
87
- zIndex: '10000',
88
- minWidth: '140px',
89
- padding: '3px 8px',
90
- font: '14px Inter, sans-serif',
91
- color: 'var(--affine-text-primary-color, #1f2328)',
92
- background: 'var(--affine-background-overlay-panel-color, #ffffff)',
93
- border: '1px solid var(--affine-primary-color, #1e96eb)',
94
- borderRadius: '6px',
95
- boxShadow: 'var(--affine-shadow-2, 0 2px 8px rgba(0,0,0,0.18))',
96
- outline: 'none',
97
- });
98
- document.body.append(input);
99
- this._labelEditor = input;
100
- // Mark the element as "editing" so the global edgeless key handlers
101
- // (delete, escape, etc.) don't act on it while the user types.
102
- this.gfx.selection.set({ elements: [this.model.id], editing: true });
103
- input.focus();
104
- input.select();
105
- const commit = () => {
106
- // Guard against re-entrancy: removing the input fires `blur`, which would
107
- // otherwise call `commit` a second time.
108
- if (this._labelEditor !== input)
109
- return;
110
- const value = input.value;
111
- this._closeLabelEditor();
112
- // Opening an editor is not renaming. Writing back an untouched value
113
- // would persist the resolved VOCABULARY as the user's own text, freezing
114
- // the label in whatever language it was read in and putting it beyond
115
- // any catalogue for good — and it would push an empty entry onto undo.
116
- if (value === current)
117
- return;
118
- this.gfx.std.store.captureSync();
119
- this.gfx.std
120
- .get(EdgelessCRUDIdentifier)
121
- .updateElement(this.model.id, { [field]: value });
122
- };
123
- input.addEventListener('keydown', ev => {
124
- ev.stopPropagation();
125
- if (ev.key === 'Enter') {
126
- ev.preventDefault();
127
- commit();
128
- }
129
- else if (ev.key === 'Escape') {
130
- ev.preventDefault();
131
- this._closeLabelEditor();
132
- }
133
- });
134
- input.addEventListener('blur', commit);
135
- }
136
- _closeLabelEditor() {
137
- if (!this._labelEditor)
138
- return;
139
- const input = this._labelEditor;
140
- this._labelEditor = null;
141
- input.remove();
142
- if (this.isConnected) {
143
- this.gfx.selection.set({ elements: [this.model.id], editing: false });
144
- }
26
+ labelAt(lx, ly, w, h) {
27
+ const hit = super.labelAt(lx, ly, w, h);
28
+ return hit && isWardleyLabelProp(hit.prop) ? hit : null;
145
29
  }
146
30
  }
147
31
  /**
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/index.d.ts CHANGED
@@ -27,4 +27,5 @@ export { WARDLEY_BACKGROUND } from './background.js';
27
27
  */
28
28
  export { exportWardleyOwm, exportWardleyOwmWithWarnings, OWM_SCOPE, type OwmPlot, owmCoordsOf, owmPlotOf, owmPointOf, WARDLEY_OWM_FORMAT_ID, type WardleyExportBoard, wardleyBoardFrom, wardleySafeFilename, } from './export.js';
29
29
  export { importWardleyOwm } from './import.js';
30
+ export { wardleyBoardOf, wardleyExportElementsOf, wardleyMapsSelected, } from './actions.js';
30
31
  export { WARDLEY_INTERCHANGE, WARDLEY_OWM_EXPORT, WARDLEY_OWM_EXTENSION, WARDLEY_OWM_FORMAT, WARDLEY_OWM_IMPORT, WARDLEY_OWM_MIME, WARDLEY_SVG_FORMAT, WARDLEY_SVG_IMPORT, } from './interchange.js';
package/dist/index.js CHANGED
@@ -39,6 +39,10 @@ export { WARDLEY_BACKGROUND } from './background.js';
39
39
  */
40
40
  export { exportWardleyOwm, exportWardleyOwmWithWarnings, OWM_SCOPE, owmCoordsOf, owmPlotOf, owmPointOf, WARDLEY_OWM_FORMAT_ID, wardleyBoardFrom, wardleySafeFilename, } from './export.js';
41
41
  export { importWardleyOwm } from './import.js';
42
+ // The half of the export that needs an editor, kept apart from the half that
43
+ // does not — the same split C4's and BPMN's indexes make for the same reason:
44
+ // what the selection scopes the file to lives here, the serializer next door.
45
+ export { wardleyBoardOf, wardleyExportElementsOf, wardleyMapsSelected, } from './actions.js';
42
46
  // Wardley's entries in the interchange registry (`docs/adr/0012`) — the OWM
43
47
  // DSL both ways, and the visual-tier SVG fallback. Exported whole so a host can
44
48
  // ask what Wardley can read and write without mounting an editor, and call it
package/dist/legend.d.ts CHANGED
@@ -1,9 +1,101 @@
1
- import { type WardleyBackgroundElementModel } from '@formicoidea/labre-core/model';
2
- import type { BlockStdScope } from '@formicoidea/labre-core/std';
3
- /** A box in the panel, relative to the panel's top-left, plus its words. */
1
+ import { type ChromeWording } from '@formicoidea/labre-core/shared/services';
2
+ import type { BlockStdScope, CommandLegendBox, CommandLegendEntry, CommandLegendRow, CommandLegendSurface } from '@formicoidea/labre-core/std';
3
+ /** The legend box's own title. */
4
+ export declare const WARDLEY_LEGEND_TITLE: ChromeWording;
5
+ /**
6
+ * The market: a circle, three neutral dots and the triangle wiring them.
7
+ *
8
+ * A `custom` swatch and not a `glyph`, for the reason the pipeline and the
9
+ * porter below give: the drawing is SEVERAL elements, and the three connectors
10
+ * are anchored by id so the triangle follows its dots.
11
+ */
12
+ declare function drawMarket(surface: CommandLegendSurface, box: {
13
+ x: number;
14
+ y: number;
15
+ w: number;
16
+ h: number;
17
+ }): string[];
18
+ /** The pipeline: the body, and the handle astride its top edge. */
19
+ declare function drawPipeline(surface: CommandLegendSurface, box: {
20
+ x: number;
21
+ y: number;
22
+ w: number;
23
+ h: number;
24
+ }): string[];
25
+ /**
26
+ * The Porter rose at the row's scale: the circle, the four DERIVED arrows and
27
+ * the notation letter.
28
+ *
29
+ * Radius 6 and not the 8 the other circles get, because this glyph is the only
30
+ * one wider than its own circle: arrows included it spans
31
+ * `2 * (R + (gap + length) * R / 30)`, which at 8 would overrun a 30-unit row.
32
+ * It is a RATIO, so the PO's doubling of the map glyph left this row where it
33
+ * was.
34
+ *
35
+ * The letter is a SEPARATE text and not the circle's inner text (recette v2): a
36
+ * shape lays its text out inside a padding larger than this 12-unit box, so at
37
+ * font size 8 the character was pushed out under the circle.
38
+ */
39
+ declare function drawPorter(surface: CommandLegendSurface, box: {
40
+ x: number;
41
+ y: number;
42
+ w: number;
43
+ h: number;
44
+ }, std: BlockStdScope): string[];
45
+ /**
46
+ * The swatch each of the thirteen rows is pictured by, keyed by the ROLE it
47
+ * stands for — eight real artefacts at their notation size, and five samples
48
+ * the framework draws itself: the two typed connectors, at the endpoints that
49
+ * tell them apart, and the three composites that are several elements.
50
+ */
51
+ export declare const WARDLEY_LEGEND_ROWS: {
52
+ "wardley:component": CommandLegendRow;
53
+ "wardley:anchor": CommandLegendRow;
54
+ "wardley:market": {
55
+ swatch: "custom";
56
+ color: string;
57
+ draw: typeof drawMarket;
58
+ };
59
+ "wardley:ecosystem": CommandLegendRow;
60
+ "wardley:method": CommandLegendRow;
61
+ "wardley:pipeline": {
62
+ swatch: "custom";
63
+ color: string;
64
+ draw: typeof drawPipeline;
65
+ };
66
+ "wardley:dependency": CommandLegendRow;
67
+ "wardley:change-arrow": CommandLegendRow;
68
+ "wardley:inertia": CommandLegendRow;
69
+ "wardley:porter": {
70
+ swatch: "custom";
71
+ color: string;
72
+ draw: typeof drawPorter;
73
+ };
74
+ "wardley:accelerator": CommandLegendRow;
75
+ "wardley:decelerator": CommandLegendRow;
76
+ "wardley:area": CommandLegendRow;
77
+ };
78
+ /** A role Wardley pictures in its legend. */
79
+ export type WardleyLegendRole = keyof typeof WARDLEY_LEGEND_ROWS;
80
+ /** Every {@link LEGEND_DESC} wording, for `translations.ts`'s manifest. */
81
+ export declare const WARDLEY_LEGEND_DESC_WORDINGS: readonly ChromeWording[];
82
+ /**
83
+ * The legend line one command subscribes — the swatch of the role it stamps,
84
+ * and the sentence that explains it. Its sub-title comes from the command's own
85
+ * catalogue category (Nodes, Connectors, Areas), so a section is declared by
86
+ * filing a command rather than by a second list.
87
+ */
88
+ export declare function wardleyLegendEntry(role: WardleyLegendRole): CommandLegendEntry;
89
+ /** Every {@link LEGEND_GRADIENT} caption, for `translations.ts`'s manifest. */
90
+ export declare const WARDLEY_LEGEND_GRADIENT_WORDINGS: readonly ChromeWording[];
91
+ /** The five-forces panel's own title. */
92
+ export declare const WARDLEY_LEGEND_PORTER_TITLE: ChromeWording;
93
+ /** Every {@link PORTER_FORCES} wording, plus the caption, for the manifest. */
94
+ export declare const WARDLEY_LEGEND_PORTER_WORDINGS: readonly ChromeWording[];
95
+ /** A box in the panel, relative to the panel's top-left, plus its wording. */
4
96
  interface PorterPanelBox {
5
97
  xywh: [number, number, number, number];
6
- label: string;
98
+ label: ChromeWording;
7
99
  }
8
100
  interface PorterPanelLayout {
9
101
  w: number;
@@ -25,13 +117,16 @@ interface PorterPanelLayout {
25
117
  */
26
118
  export declare function porterPanelLayout(w: number): PorterPanelLayout;
27
119
  /**
28
- * Build a "Legend" group from real, editable elements (white rect frame +
29
- * "Legend" text + one row of [real component glyph + description text] per
30
- * Wardley component TYPE present inside the background's perimeter + a
31
- * gradient-meaning block when the background is a gradient variant + the
32
- * five-forces panel when a Porter's-forces glyph is on the map). A snapshot
33
- * is created on each call; everything is grouped so it can be moved / resized /
34
- * edited and is dropped bottom-left of the background.
120
+ * How a Wardley map's legend box is laid out, and the two blocks it adds under
121
+ * the rows. Declared on the FIRST background command (`commands.ts`), which is
122
+ * the sheet the legend is drawn on.
123
+ */
124
+ export declare const WARDLEY_LEGEND_BOX: CommandLegendBox;
125
+ /**
126
+ * Every wording this file writes onto the canvas, for `translations.ts`'s
127
+ * manifest contribution — the box's own title, its rows' captions, the gradient
128
+ * blocks and the Porter panel, all as `seed` (written into the document once,
129
+ * at the moment a legend is generated).
35
130
  */
36
- export declare function createWardleyLegend(std: BlockStdScope, bg: WardleyBackgroundElementModel): void;
131
+ export declare const WARDLEY_LEGEND_WORDINGS: readonly ChromeWording[];
37
132
  export {};