@formicoidea/labre-framework-cynefin 0.37.0 → 0.38.1

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.js CHANGED
@@ -1,73 +1,48 @@
1
1
  import { DefaultTool } from '@formicoidea/labre-core/blocks/surface';
2
- import { ShapeStyle, TextFitMode } from '@formicoidea/labre-core/model';
3
2
  import { Bound } from '@formicoidea/labre-core/global/gfx';
4
3
  import { GfxControllerIdentifier } from '@formicoidea/labre-core/std/gfx';
5
- import { REF_H as CYN_H, REF_W as CYN_W } from './cynefin/consts.js';
6
- import { HEX_FILL, HEX_SIZE, HEX_STROKE, HEX_VERTICES, REF_H as EST_H, REF_W as EST_W, } from './estuarine/consts.js';
7
- import { ESTUARINE_ROLE } from './estuarine/roles.js';
4
+ import { CYNEFIN_H, CYNEFIN_W, cynefinBackgroundProps, ESTUARINE_MAP_H, ESTUARINE_MAP_W, estuarineHexagonBox, estuarineHexagonProps, estuarineMapProps, } from './presets.js';
8
5
  /**
9
6
  * Creation actions for the Cynefin / Estuarine toolbox — lifted out of
10
7
  * `toolbar/menu.ts` by PF3. This is also the framework that emitted NO
11
8
  * telemetry at all before the switchover: routing every surface through
12
9
  * `runCommand` fixes that for free (`docs/adr/0008`).
10
+ *
11
+ * What each artefact IS lives in `presets.ts`, which the palette reads too: the
12
+ * templates used to restate these props and drifted from them.
13
13
  */
14
- /** Estuarine map default size (REF aspect, scaled up so it reads on canvas). */
15
- const MAP_SCALE = 1.2;
16
14
  const gfxOf = (std) => std.get(GfxControllerIdentifier);
17
15
  function finish(gfx, id) {
18
16
  gfx.doc.captureSync();
19
17
  gfx.tool.setTool(DefaultTool);
20
18
  gfx.selection.set({ elements: [id], editing: false });
21
19
  }
20
+ /** The box an artefact of the given size is born in, centred on the viewport. */
21
+ function centered(gfx, width, height) {
22
+ const { centerX, centerY } = gfx.viewport;
23
+ return new Bound(centerX - width / 2, centerY - height / 2, width, height).serialize();
24
+ }
22
25
  export function createCynefin(std) {
23
26
  const gfx = gfxOf(std);
24
27
  if (!gfx.surface)
25
28
  return;
26
- const { centerX, centerY } = gfx.viewport;
27
- const id = gfx.surface.addElement({
28
- type: 'cynefin',
29
- xywh: new Bound(centerX - CYN_W / 2, centerY - CYN_H / 2, CYN_W, CYN_H).serialize(),
30
- });
29
+ const id = gfx.surface.addElement(cynefinBackgroundProps({ xywh: centered(gfx, CYNEFIN_W, CYNEFIN_H) }));
31
30
  finish(gfx, id);
32
31
  }
33
32
  export function createEstuarineMap(std) {
34
33
  const gfx = gfxOf(std);
35
34
  if (!gfx.surface)
36
35
  return;
37
- const width = EST_W * MAP_SCALE;
38
- const height = EST_H * MAP_SCALE;
39
- const { centerX, centerY } = gfx.viewport;
40
- const id = gfx.surface.addElement({
41
- type: 'estuarine',
42
- // The map is this framework's ROOT INSTANCE: the role is what makes the
43
- // Map quality checklist reachable on it (WS4). Cynefin's background gets
44
- // none, on purpose — see `estuarine/roles.ts`.
45
- role: ESTUARINE_ROLE.map,
46
- xywh: new Bound(centerX - width / 2, centerY - height / 2, width, height).serialize(),
47
- });
36
+ const id = gfx.surface.addElement(estuarineMapProps({
37
+ xywh: centered(gfx, ESTUARINE_MAP_W, ESTUARINE_MAP_H),
38
+ }));
48
39
  finish(gfx, id);
49
40
  }
50
41
  export function createConstraintHexagon(std) {
51
42
  const gfx = gfxOf(std);
52
43
  if (!gfx.surface)
53
44
  return;
54
- const { centerX: cx, centerY: cy } = gfx.viewport;
55
- const id = gfx.surface.addElement({
56
- type: 'shape',
57
- // A hexagon is a plain polygon on the canvas: nothing about its geometry
58
- // says "constraint". The role is the only place that does.
59
- role: ESTUARINE_ROLE.constraint,
60
- shapeType: 'polygon',
61
- vertices: HEX_VERTICES,
62
- filled: true,
63
- fillColor: HEX_FILL,
64
- strokeColor: HEX_STROKE,
65
- strokeWidth: 2,
66
- shapeStyle: ShapeStyle.General,
67
- roughness: 0,
68
- // hexi constraints behave like post-its: fixed hex, text shrinks
69
- textFitMode: TextFitMode.Contained,
70
- xywh: new Bound(cx - HEX_SIZE / 2, cy - HEX_SIZE / 2, HEX_SIZE, HEX_SIZE).serialize(),
71
- });
45
+ const { centerX, centerY } = gfx.viewport;
46
+ const id = gfx.surface.addElement(estuarineHexagonProps({ xywh: estuarineHexagonBox(centerX, centerY) }));
72
47
  finish(gfx, id);
73
48
  }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * What a Cynefin / Estuarine artefact IS, as props — the ONE description the
3
+ * creation actions and the templates both read.
4
+ *
5
+ * Split out of `actions.ts` for the reason Wardley's and BPMN's `presets.ts`
6
+ * give: the palette used to restate these props by hand and drifted the moment
7
+ * the toolbox moved. The hexagon lost the `textFitMode` that #52 gave it, and
8
+ * the estuarine background was drawn at scale 1 while the button drew it at
9
+ * 1.2. Derived from one table, neither can happen again.
10
+ */
11
+ /** Estuarine map default scale (REF aspect, scaled up so it reads on canvas). */
12
+ export declare const MAP_SCALE = 1.2;
13
+ /** The box an estuarine map is born in — the size the toolbox draws. */
14
+ export declare const ESTUARINE_MAP_W: number;
15
+ export declare const ESTUARINE_MAP_H: number;
16
+ /** The box a Cynefin frame is born in. */
17
+ export declare const CYNEFIN_W = 1080;
18
+ export declare const CYNEFIN_H = 777;
19
+ /**
20
+ * The Cynefin frame, as props.
21
+ *
22
+ * NO role, deliberately and for good: the framework is out of the validation
23
+ * perimeter (PO, 26/08/2026 — see `estuarine/roles.ts`). Stated here once so
24
+ * the neutrality is a decision rather than an omission on either side.
25
+ */
26
+ export declare function cynefinBackgroundProps(box: {
27
+ xywh: string;
28
+ }): Record<string, unknown> & {
29
+ type: string;
30
+ };
31
+ /**
32
+ * The estuarine map, as props.
33
+ *
34
+ * The map is this framework's ROOT INSTANCE: the role is what makes the Map
35
+ * quality checklist reachable on it (WS4).
36
+ */
37
+ export declare function estuarineMapProps(box: {
38
+ xywh: string;
39
+ }): Record<string, unknown> & {
40
+ type: string;
41
+ };
42
+ /**
43
+ * A hexi constraint, as props.
44
+ *
45
+ * A hexagon is a plain polygon on the canvas: nothing about its geometry says
46
+ * "constraint". The role is the only place that does. The fit mode is the other
47
+ * half of the notation — a constraint behaves like a post-it, fixed hex, text
48
+ * shrinks — and it is exactly what the palette had lost.
49
+ */
50
+ export declare function estuarineHexagonProps(box: {
51
+ xywh: string;
52
+ }): Record<string, unknown> & {
53
+ type: string;
54
+ };
55
+ /** The box a hexagon is born in, centred on a point. */
56
+ export declare function estuarineHexagonBox(cx: number, cy: number): string;
@@ -0,0 +1,71 @@
1
+ import { ShapeStyle, TextFitMode } from '@formicoidea/labre-core/model';
2
+ import { REF_H as CYN_H, REF_W as CYN_W } from './cynefin/consts.js';
3
+ import { HEX_FILL, HEX_SIZE, HEX_STROKE, HEX_VERTICES, REF_H as EST_H, REF_W as EST_W, } from './estuarine/consts.js';
4
+ import { ESTUARINE_ROLE } from './estuarine/roles.js';
5
+ /**
6
+ * What a Cynefin / Estuarine artefact IS, as props — the ONE description the
7
+ * creation actions and the templates both read.
8
+ *
9
+ * Split out of `actions.ts` for the reason Wardley's and BPMN's `presets.ts`
10
+ * give: the palette used to restate these props by hand and drifted the moment
11
+ * the toolbox moved. The hexagon lost the `textFitMode` that #52 gave it, and
12
+ * the estuarine background was drawn at scale 1 while the button drew it at
13
+ * 1.2. Derived from one table, neither can happen again.
14
+ */
15
+ /** Estuarine map default scale (REF aspect, scaled up so it reads on canvas). */
16
+ export const MAP_SCALE = 1.2;
17
+ /** The box an estuarine map is born in — the size the toolbox draws. */
18
+ export const ESTUARINE_MAP_W = EST_W * MAP_SCALE;
19
+ export const ESTUARINE_MAP_H = EST_H * MAP_SCALE;
20
+ /** The box a Cynefin frame is born in. */
21
+ export const CYNEFIN_W = CYN_W;
22
+ export const CYNEFIN_H = CYN_H;
23
+ /**
24
+ * The Cynefin frame, as props.
25
+ *
26
+ * NO role, deliberately and for good: the framework is out of the validation
27
+ * perimeter (PO, 26/08/2026 — see `estuarine/roles.ts`). Stated here once so
28
+ * the neutrality is a decision rather than an omission on either side.
29
+ */
30
+ export function cynefinBackgroundProps(box) {
31
+ return { type: 'cynefin', xywh: box.xywh };
32
+ }
33
+ /**
34
+ * The estuarine map, as props.
35
+ *
36
+ * The map is this framework's ROOT INSTANCE: the role is what makes the Map
37
+ * quality checklist reachable on it (WS4).
38
+ */
39
+ export function estuarineMapProps(box) {
40
+ return { type: 'estuarine', role: ESTUARINE_ROLE.map, xywh: box.xywh };
41
+ }
42
+ /**
43
+ * A hexi constraint, as props.
44
+ *
45
+ * A hexagon is a plain polygon on the canvas: nothing about its geometry says
46
+ * "constraint". The role is the only place that does. The fit mode is the other
47
+ * half of the notation — a constraint behaves like a post-it, fixed hex, text
48
+ * shrinks — and it is exactly what the palette had lost.
49
+ */
50
+ export function estuarineHexagonProps(box) {
51
+ return {
52
+ type: 'shape',
53
+ role: ESTUARINE_ROLE.constraint,
54
+ shapeType: 'polygon',
55
+ // A fresh array of fresh pairs: this goes into a document, and two hexagons
56
+ // sharing one literal would be two elements sharing one array.
57
+ vertices: HEX_VERTICES.map(([x, y]) => [x, y]),
58
+ filled: true,
59
+ fillColor: HEX_FILL,
60
+ strokeColor: HEX_STROKE,
61
+ strokeWidth: 2,
62
+ shapeStyle: ShapeStyle.General,
63
+ roughness: 0,
64
+ textFitMode: TextFitMode.Contained,
65
+ xywh: box.xywh,
66
+ };
67
+ }
68
+ /** The box a hexagon is born in, centred on a point. */
69
+ export function estuarineHexagonBox(cx, cy) {
70
+ return `[${cx - HEX_SIZE / 2},${cy - HEX_SIZE / 2},${HEX_SIZE},${HEX_SIZE}]`;
71
+ }
@@ -1,8 +1,30 @@
1
- import { makeTemplateSnapshot, surfaceText, } from '@formicoidea/labre-core/gfx/template';
1
+ import { makeTemplateSnapshot, surfaceText, templateFromCommand, } from '@formicoidea/labre-core/gfx/template';
2
2
  import { FontFamily, ShapeStyle, TextAlign } from '@formicoidea/labre-core/model';
3
- import { REF_H as CYN_H, REF_W as CYN_W } from '../cynefin/consts.js';
4
- import { HEX_FILL, HEX_SIZE, HEX_STROKE, HEX_VERTICES, REF_H as EST_H, REF_W as EST_W, } from '../estuarine/consts.js';
5
- import { ESTUARINE_ROLE } from '../estuarine/roles.js';
3
+ import { cynefinEstuarineCommands } from '../commands.js';
4
+ import { HEX_SIZE } from '../estuarine/consts.js';
5
+ import { CYNEFIN_H, CYNEFIN_W, cynefinBackgroundProps, ESTUARINE_MAP_H, ESTUARINE_MAP_W, estuarineHexagonBox, estuarineHexagonProps, estuarineMapProps, MAP_SCALE, } from '../presets.js';
6
+ /**
7
+ * The Cynefin / Estuarine palettes — DERIVED from the toolbox, one template per
8
+ * command.
9
+ *
10
+ * Every single-artefact entry below is what its command actually draws, run
11
+ * once against a recording surface. Hand-written, they had drifted exactly as
12
+ * far as a copy drifts: the hexagons had lost the `textFitMode` #52 gave them,
13
+ * and the estuarine background was drawn at scale 1 (690×801) where the button
14
+ * draws it at 1.2 (828×961). Derived, neither can happen again — and
15
+ * `templates-parity.unit.spec.ts` re-runs each command and compares.
16
+ *
17
+ * The two COMPOSITIONS stay hand-written: a sorting board and a constraint map
18
+ * are arrangements no single command draws. They are built on the same presets,
19
+ * and the same test checks their composition.
20
+ */
21
+ /** The command a derived template is the picture of. Throws rather than skips. */
22
+ function byId(id) {
23
+ const command = cynefinEstuarineCommands.find(entry => entry.id === id);
24
+ if (!command)
25
+ throw new Error(`[cynefin-estuarine] templates: no "${id}"`);
26
+ return command;
27
+ }
6
28
  function sticky(x, y, text) {
7
29
  return {
8
30
  type: 'shape',
@@ -22,24 +44,31 @@ function sticky(x, y, text) {
22
44
  xywh: `[${x},${y},200,70]`,
23
45
  };
24
46
  }
25
- function hexagon(x, y) {
26
- return {
27
- type: 'shape',
28
- // Same role the toolbox stamps (`actions.ts`): a template must produce the
29
- // map a user would have drawn by hand, roles included.
30
- role: ESTUARINE_ROLE.constraint,
31
- shapeType: 'polygon',
32
- vertices: HEX_VERTICES,
33
- filled: true,
34
- fillColor: HEX_FILL,
35
- strokeColor: HEX_STROKE,
36
- strokeWidth: 2,
37
- shapeStyle: ShapeStyle.General,
38
- roughness: 0,
39
- xywh: `[${x},${y},${HEX_SIZE},${HEX_SIZE}]`,
40
- };
41
- }
42
- function caption(x, y, str) {
47
+ /**
48
+ * A constraint on the shipped map, placed by its CENTRE in the map's reference
49
+ * space (690×801) — the frame the drawing was laid out in — carried onto the
50
+ * box the map is actually born at.
51
+ */
52
+ const hexAt = (cx, cy) => estuarineHexagonProps({
53
+ xywh: estuarineHexagonBox(cx * MAP_SCALE, cy * MAP_SCALE),
54
+ });
55
+ const CAPTION_W = 120;
56
+ const CAPTION_H = 24;
57
+ /** Room between a hexagon's bottom edge and the name under it. */
58
+ const CAPTION_GAP = 8;
59
+ /**
60
+ * The name UNDER the hexagon centred on the same point.
61
+ *
62
+ * The offset is `HEX_SIZE`, never a literal: this used to be a `+64` computed
63
+ * for a 60-wide hexagon, and #55 doubled the hexagon to 120 without touching
64
+ * it — so every caption ended up drawn INSIDE the shape it names. Derived, the
65
+ * caption follows the hexagon whatever size it is given next.
66
+ *
67
+ * Neutral, and staying so: a name is nobody's artefact.
68
+ */
69
+ function caption(cx, cy, str) {
70
+ const x = cx * MAP_SCALE - CAPTION_W / 2;
71
+ const y = cy * MAP_SCALE + HEX_SIZE / 2 + CAPTION_GAP;
43
72
  return {
44
73
  type: 'text',
45
74
  text: surfaceText(str),
@@ -47,9 +76,10 @@ function caption(x, y, str) {
47
76
  fontFamily: FontFamily.Inter,
48
77
  fontSize: 16,
49
78
  textAlign: TextAlign.Center,
50
- xywh: `[${x},${y},120,24]`,
79
+ xywh: `[${x},${y},${CAPTION_W},${CAPTION_H}]`,
51
80
  };
52
81
  }
82
+ /** A hand-composed template — what is left once the artefacts are derived. */
53
83
  function tpl(name, preview, elements) {
54
84
  return {
55
85
  name,
@@ -59,41 +89,36 @@ function tpl(name, preview, elements) {
59
89
  };
60
90
  }
61
91
  const ATTRS = 'width="100%" height="100%" viewBox="0 0 135 80" xmlns="http://www.w3.org/2000/svg"';
62
- // Cynefin's background carries NO role, deliberately and for good: the
63
- // framework is out of the validation perimeter (PO, 26/08/2026). See
64
- // `estuarine/roles.ts`.
65
- const cynefinBg = (xywh) => ({ type: 'cynefin', xywh });
66
- const estuarineBg = (xywh) => ({
67
- type: 'estuarine',
68
- role: ESTUARINE_ROLE.map,
69
- xywh,
70
- });
71
92
  export const cynefinTemplateCategory = {
72
93
  name: 'Cynefin',
73
94
  templates: [
74
95
  tpl('Decision sorting', `<svg ${ATTRS} fill="none"><rect x="8" y="10" width="119" height="60" rx="4" stroke="#2a9d99" stroke-width="1.5"/><path d="M67 10 V70 M8 40 H127" stroke="#9aa0a6"/><rect x="18" y="18" width="34" height="14" rx="2" fill="#fff3b0"/><rect x="83" y="18" width="34" height="14" rx="2" fill="#fff3b0"/><rect x="18" y="48" width="34" height="14" rx="2" fill="#fff3b0"/><rect x="83" y="48" width="34" height="14" rx="2" fill="#fff3b0"/></svg>`, {
75
- bg: cynefinBg(`[0,0,${CYN_W},${CYN_H}]`),
96
+ bg: cynefinBackgroundProps({
97
+ xywh: `[0,0,${CYNEFIN_W},${CYNEFIN_H}]`,
98
+ }),
76
99
  s1: sticky(190, 175, 'Probe & learn'),
77
100
  s2: sticky(690, 175, 'Expert analysis'),
78
101
  s3: sticky(190, 505, 'Act now'),
79
102
  s4: sticky(690, 505, 'Known issue'),
80
103
  }),
81
- tpl('Cynefin framework', `<svg ${ATTRS} fill="none"><rect x="14" y="12" width="107" height="56" rx="4" stroke="#2a9d99" stroke-width="1.6"/><path d="M67 12 V68 M14 40 H121" stroke="#9aa0a6"/></svg>`, { bg: cynefinBg(`[0,0,${CYN_W},${CYN_H}]`) }),
104
+ templateFromCommand(byId('cynefin-estuarine.addCynefin'), `<svg ${ATTRS} fill="none"><rect x="14" y="12" width="107" height="56" rx="4" stroke="#2a9d99" stroke-width="1.6"/><path d="M67 12 V68 M14 40 H121" stroke="#9aa0a6"/></svg>`, 'Cynefin framework'),
82
105
  ],
83
106
  };
84
107
  export const estuarineTemplateCategory = {
85
108
  name: 'Estuarine',
86
109
  templates: [
87
110
  tpl('Constraint map', `<svg ${ATTRS} fill="none"><path d="M20 12 V70 M20 70 H120" stroke="#941253" stroke-width="2"/><g fill="#34c724" stroke="#1f1f1f"><path d="M44 28 l6 4 l0 8 l-6 4 l-6 -4 l0 -8 z"/><path d="M74 40 l6 4 l0 8 l-6 4 l-6 -4 l0 -8 z"/><path d="M56 52 l6 4 l0 8 l-6 4 l-6 -4 l0 -8 z"/></g></svg>`, {
88
- bg: estuarineBg(`[0,0,${EST_W},${EST_H}]`),
89
- h1: hexagon(150, 220),
90
- c1: caption(120, 284, 'Policy'),
91
- h2: hexagon(330, 360),
92
- c2: caption(300, 424, 'Habit'),
93
- h3: hexagon(230, 520),
94
- c3: caption(200, 584, 'Budget'),
111
+ bg: estuarineMapProps({
112
+ xywh: `[0,0,${ESTUARINE_MAP_W},${ESTUARINE_MAP_H}]`,
113
+ }),
114
+ h1: hexAt(210, 280),
115
+ c1: caption(210, 280, 'Policy'),
116
+ h2: hexAt(390, 420),
117
+ c2: caption(390, 420, 'Habit'),
118
+ h3: hexAt(290, 580),
119
+ c3: caption(290, 580, 'Budget'),
95
120
  }),
96
- tpl('Estuarine map', `<svg ${ATTRS} fill="none"><path d="M24 10 V70 M24 70 H120" stroke="#941253" stroke-width="2.4"/><path d="M30 52 q40 -30 84 -34" stroke="#5ecc44" stroke-width="2" fill="none"/></svg>`, { bg: estuarineBg(`[0,0,${EST_W},${EST_H}]`) }),
97
- tpl('Hexagon constraint', `<svg ${ATTRS} fill="none"><path d="M67 24 l18 11 l0 22 l-18 11 l-18 -11 l0 -22 z" fill="#34c724" stroke="#1f1f1f" stroke-width="2"/></svg>`, { hex: hexagon(0, 0) }),
121
+ templateFromCommand(byId('cynefin-estuarine.addEstuarineMap'), `<svg ${ATTRS} fill="none"><path d="M24 10 V70 M24 70 H120" stroke="#941253" stroke-width="2.4"/><path d="M30 52 q40 -30 84 -34" stroke="#5ecc44" stroke-width="2" fill="none"/></svg>`, 'Estuarine map'),
122
+ templateFromCommand(byId('cynefin-estuarine.addConstraintHexagon'), `<svg ${ATTRS} fill="none"><path d="M67 24 l18 11 l0 22 l-18 11 l-18 -11 l0 -22 z" fill="#34c724" stroke="#1f1f1f" stroke-width="2"/></svg>`, 'Hexagon constraint'),
98
123
  ],
99
124
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formicoidea/labre-framework-cynefin",
3
3
  "description": "Labre cynefin-estuarine framework for @formicoidea/labre-core.",
4
- "version": "0.37.0",
4
+ "version": "0.38.1",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",
@@ -31,7 +31,7 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@formicoidea/labre-core": "0.37.0",
34
+ "@formicoidea/labre-core": "0.38.1",
35
35
  "@preact/signals-core": "^1.8.0",
36
36
  "lit": "^3.2.0"
37
37
  }