@formicoidea/labre-framework-cynefin 0.23.0 → 0.23.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.
Files changed (57) hide show
  1. package/dist/cynefin/consts.d.ts +80 -0
  2. package/dist/cynefin/consts.js +142 -0
  3. package/dist/cynefin/element-renderer.d.ts +15 -0
  4. package/dist/cynefin/element-renderer.js +115 -0
  5. package/dist/cynefin/element-view.d.ts +15 -0
  6. package/dist/cynefin/element-view.js +24 -0
  7. package/dist/cynefin/toolbar/config.d.ts +32 -0
  8. package/dist/cynefin/toolbar/config.js +44 -0
  9. package/dist/descriptor.d.ts +7 -0
  10. package/{src/descriptor.ts → dist/descriptor.js} +1 -1
  11. package/dist/effects.d.ts +10 -0
  12. package/dist/effects.js +7 -0
  13. package/dist/estuarine/consts.d.ts +85 -0
  14. package/dist/estuarine/consts.js +55 -0
  15. package/dist/estuarine/element-renderer.d.ts +14 -0
  16. package/dist/estuarine/element-renderer.js +84 -0
  17. package/dist/estuarine/element-view.d.ts +15 -0
  18. package/dist/estuarine/element-view.js +24 -0
  19. package/dist/estuarine/toolbar/config.d.ts +38 -0
  20. package/dist/estuarine/toolbar/config.js +48 -0
  21. package/dist/index.d.ts +2 -0
  22. package/dist/index.js +2 -0
  23. package/dist/templates/index.d.ts +4 -0
  24. package/dist/templates/index.js +95 -0
  25. package/dist/toolbar/cynefin-menu.d.ts +12 -0
  26. package/dist/toolbar/cynefin-menu.js +66 -0
  27. package/dist/toolbar/cynefin-senior-button.d.ts +13 -0
  28. package/dist/toolbar/cynefin-senior-button.js +90 -0
  29. package/dist/toolbar/estuarine-menu.d.ts +14 -0
  30. package/dist/toolbar/estuarine-menu.js +113 -0
  31. package/dist/toolbar/estuarine-senior-button.d.ts +13 -0
  32. package/dist/toolbar/estuarine-senior-button.js +90 -0
  33. package/dist/toolbar/icons.d.ts +9 -0
  34. package/{src/toolbar/icons.ts → dist/toolbar/icons.js} +14 -17
  35. package/dist/toolbar/menu.d.ts +18 -0
  36. package/{src/toolbar/menu.ts → dist/toolbar/menu.js} +68 -91
  37. package/dist/toolbar/senior-button.d.ts +13 -0
  38. package/{src/toolbar/senior-button.ts → dist/toolbar/senior-button.js} +33 -38
  39. package/dist/toolbar/senior-tool.d.ts +3 -0
  40. package/{src/toolbar/senior-tool.ts → dist/toolbar/senior-tool.js} +5 -8
  41. package/dist/utils.d.ts +12 -0
  42. package/{src/utils.ts → dist/utils.js} +11 -11
  43. package/dist/view.d.ts +7 -0
  44. package/dist/view.js +38 -0
  45. package/package.json +15 -6
  46. package/src/cynefin/consts.ts +0 -188
  47. package/src/cynefin/element-renderer.ts +0 -156
  48. package/src/cynefin/element-view.ts +0 -32
  49. package/src/cynefin/toolbar/config.ts +0 -60
  50. package/src/effects.ts +0 -20
  51. package/src/estuarine/consts.ts +0 -69
  52. package/src/estuarine/element-renderer.ts +0 -122
  53. package/src/estuarine/element-view.ts +0 -32
  54. package/src/estuarine/toolbar/config.ts +0 -65
  55. package/src/index.ts +0 -1
  56. package/src/templates/index.ts +0 -130
  57. package/src/view.ts +0 -44
@@ -1,188 +0,0 @@
1
- /**
2
- * Visual constants for the Liminal Cynefin diagram, reproduced from the official
3
- * SVG (viewBox 0 0 1080 777). All geometry is authored in that fixed reference
4
- * space and scaled uniformly to the element bounds by the renderer.
5
- */
6
-
7
- export const REF_W = 1080;
8
- export const REF_H = 777;
9
-
10
- export const COLORS = {
11
- boundary: '#333333',
12
- teal: '#2a9d99',
13
- /** Domain headings + subheadings (h1 / h2). */
14
- heading: '#6d6e71',
15
- /** Body, small annotations and the big A / C glyphs. */
16
- body: '#231f20',
17
- } as const;
18
-
19
- /**
20
- * Dark boundary strokes drawn *behind* the teal "iterate" curve:
21
- * [svg path, lineWidth, miterJoin].
22
- */
23
- export const DARK_BACK_PATHS: ReadonlyArray<readonly [string, number, boolean]> = [
24
- // Main arc: top segment (Complex|Complicated) then left segment (Complex|Chaotic)
25
- ['M 550.1 17 A 296 296 0 0 1 338 328.5 A 448.7 448.7 0 0 1 26 331', 15.5, false],
26
- // Thin "Confusion" arc sweeping down towards the cliff
27
- ['M 649 294 C 644 382, 588 462, 440 506', 5, false],
28
- ];
29
-
30
- /** Teal "iterate" curve, drawn *over* the back arcs and the dashed paving. */
31
- export const TEAL_PATH =
32
- 'M 475.1 9.1 C 477.5 13.3, 484.4 26.1, 489.3 34.6 C 494.2 43.1, 499.7 51.7, 504.4 60.2 C 509.1 68.7, 513.4 77.2, 517.6 85.7 C 521.8 94.2, 525.7 102.7, 529.7 111.2 C 533.7 119.7, 538.1 128.3, 541.8 136.8 C 545.5 145.3, 549.0 153.8, 551.9 162.3 C 554.8 170.8, 557.1 179.3, 559.0 187.8 C 560.9 196.3, 562.0 204.8, 563.0 213.3 C 564.0 221.8, 564.8 230.4, 565.0 238.9 C 565.2 247.4, 565.0 255.9, 564.0 264.4 C 563.0 272.9, 561.2 281.4, 559.0 289.9 C 556.8 298.4, 554.6 307.0, 550.9 315.5 C 547.2 324.0, 542.3 332.5, 536.8 341.0 C 531.2 349.5, 524.9 358.3, 517.6 366.5 C 510.4 374.7, 501.6 383.0, 493.3 390.0 C 485.0 397.0, 476.4 403.1, 468.0 408.4 C 459.6 413.7, 451.2 418.0, 442.8 421.7 C 434.4 425.4, 425.9 427.4, 417.5 430.8 C 409.1 434.2, 400.3 437.5, 392.2 442.1 C 384.1 446.7, 377.1 455.5, 369.0 458.4 C 360.9 461.3, 352.1 459.4, 343.7 459.4 C 335.3 459.4, 326.9 459.1, 318.5 458.4 C 310.1 457.7, 301.6 456.8, 293.2 455.4 C 284.8 454.0, 276.4 452.2, 268.0 450.3 C 259.6 448.4, 251.1 446.2, 242.7 444.1 C 234.3 442.1, 225.8 440.0, 217.4 438.0 C 209.0 436.0, 200.6 434.4, 192.2 431.9 C 183.8 429.3, 175.3 426.1, 166.9 422.7 C 158.5 419.3, 150.0 415.5, 141.6 411.4 C 133.2 407.3, 124.8 403.3, 116.4 398.2 C 108.0 393.1, 99.5 386.9, 91.1 380.8 C 82.7 374.7, 74.3 368.7, 65.9 361.4 C 57.5 354.1, 45.7 342.8, 40.6 336.9 C 35.5 330.9, 36.4 327.6, 35.5 325.7';
33
- export const TEAL_WIDTH = 10.5;
34
-
35
- /**
36
- * Dark boundary strokes drawn *over* the teal curve:
37
- * [svg path, lineWidth, miterJoin].
38
- */
39
- export const DARK_FRONT_PATHS: ReadonlyArray<readonly [string, number, boolean]> = [
40
- // Thick descending branch with the bottom elbow (right edge of the cliff)
41
- ['M 340 332 C 390 440, 437 525, 472 632 Q 479 658, 453 700', 15.5, true],
42
- // Thin left line (left edge of the cliff)
43
- ['M 345 356 C 372 440, 408 540, 413 655 C 414 685, 412 710, 412 738', 4, false],
44
- ];
45
-
46
- /** Cliff hatching: [x1,y1,x2,y2], lineWidth 3. */
47
- export const HATCHES: ReadonlyArray<readonly [number, number, number, number]> = [
48
- [375, 420, 371, 431],
49
- [386, 443, 380, 461],
50
- [395, 462, 386, 483],
51
- [402, 477, 392, 506],
52
- [412, 497, 400, 539],
53
- [417, 511, 403, 558],
54
- [427, 533, 409, 591],
55
- [435, 551, 411, 612],
56
- [444, 573, 415, 659],
57
- [455, 603, 415, 700],
58
- ];
59
-
60
- /** Dashed Complicated↔Clear boundary, as oriented square pavings: [x,y,size,rotateDeg]. */
61
- export const DASH_RECTS: ReadonlyArray<readonly [number, number, number, number]> = [
62
- [511, 245, 13.8, 206.8], [530, 255.5, 13.7, 205.2], [549.5, 265.5, 13.6, 203.5],
63
- [569.5, 274.5, 13.5, 201.9], [590, 282.5, 13.5, 200.2], [610.5, 289.5, 13.4, 198.6],
64
- [631, 296, 13.3, 196.9], [673.5, 307, 13.2, 193.6], [695, 311.5, 13.1, 192.0],
65
- [716, 315.5, 13.0, 190.3], [738, 319, 12.9, 188.7], [759.5, 322, 12.8, 187.0],
66
- [781, 324.5, 12.8, 185.4], [803, 325.5, 12.7, 183.7], [824.5, 326.5, 12.6, 182.1],
67
- [846, 327.5, 12.5, 180.5], [868, 327.5, 12.4, 178.8], [889.5, 326.5, 12.3, 177.2],
68
- [912, 325.5, 12.2, 175.5], [933, 323.5, 12.1, 173.9], [954.5, 321.5, 12.1, 172.2],
69
- [976, 318, 12.0, 170.6], [998, 314, 11.9, 168.9], [1019, 310, 11.8, 167.3],
70
- ];
71
-
72
- /**
73
- * The four domain blocks. Each has a heading (h1) and, when descriptions are
74
- * shown, a subheading (h2) and three decision lines whose lead word is bold.
75
- * All three text levels share the block's left `x`.
76
- */
77
- export interface DomainBlock {
78
- heading: string;
79
- /** Left edge shared by heading, subheading and body lines. */
80
- x: number;
81
- /** Heading (h1) baseline. */
82
- hy: number;
83
- subheading: string;
84
- /** Subheading (h2) baseline. */
85
- sy: number;
86
- /** Decision lines: bold lead word + remainder, with their baseline. */
87
- lines: ReadonlyArray<{ lead: string; rest: string; y: number }>;
88
- }
89
-
90
- export const DOMAINS: ReadonlyArray<DomainBlock> = [
91
- {
92
- heading: 'Complex',
93
- x: 37,
94
- hy: 31,
95
- subheading: 'Adaptive system',
96
- sy: 53,
97
- lines: [
98
- { lead: 'Probe', rest: ' the context with parallel experiments', y: 71 },
99
- { lead: 'Sense', rest: ' how the context reacts', y: 90 },
100
- { lead: 'Respond', rest: ' by amplifying positive experiments', y: 109 },
101
- ],
102
- },
103
- {
104
- heading: 'Complicated',
105
- x: 779,
106
- hy: 31,
107
- subheading: 'Ordered system',
108
- sy: 53,
109
- lines: [
110
- { lead: 'Sense', rest: ' the context with analytical methods', y: 71 },
111
- { lead: 'Analyse', rest: ' observations', y: 90 },
112
- { lead: 'Respond', rest: ' by applying one of many good solutions', y: 109 },
113
- ],
114
- },
115
- {
116
- heading: 'Chaotic',
117
- x: 37,
118
- hy: 587,
119
- subheading: 'Un-ordered system',
120
- sy: 609,
121
- lines: [
122
- { lead: 'Act', rest: ' on the context to stabilize (it or yourself)', y: 627 },
123
- { lead: 'Sense', rest: ' how the context reacts', y: 646 },
124
- { lead: 'Respond', rest: ' by re-acting', y: 665 },
125
- ],
126
- },
127
- {
128
- heading: 'Clear',
129
- x: 779,
130
- hy: 587,
131
- subheading: 'Ordered system',
132
- sy: 609,
133
- lines: [
134
- { lead: 'Sense', rest: ' the context with analytical methods', y: 627 },
135
- { lead: 'Categorize', rest: ' observations', y: 646 },
136
- { lead: 'Respond', rest: ' by applying tried and true practices', y: 665 },
137
- ],
138
- },
139
- ];
140
-
141
- /** Teal annotation labels (centered): [text, x, y]. */
142
- export const TEAL_LABELS: ReadonlyArray<readonly [string, number, number]> = [
143
- ['iterate', 510, 16],
144
- ['iterate', 533, 230],
145
- ['strategy by design', 257, 225],
146
- ['radical innovation', 268, 390],
147
- ['by design', 268, 406],
148
- ['extreme repurposing', 217, 496],
149
- ['good practice', 814, 196],
150
- ['best practice', 751, 459],
151
- ];
152
-
153
- /** Small exaptation sub-labels (centered): [text, x, y]. */
154
- export const SMALL_LABELS: ReadonlyArray<readonly [string, number, number]> = [
155
- ['dispositional exaptation', 257, 239],
156
- ['stimulated exaptation', 268, 419],
157
- ['stress-based exaptation', 217, 510],
158
- ];
159
-
160
- /**
161
- * The two central markers — Aporia (A) and Confusion (C) — each a big glyph and
162
- * a name, with an optional teal note ("prepare to exit"). All centered.
163
- */
164
- export interface Marker {
165
- letter: string;
166
- /** Big glyph position. */
167
- lx: number;
168
- ly: number;
169
- name: string;
170
- /** Name (body) position. */
171
- nx: number;
172
- ny: number;
173
- /** Optional teal note position + text. */
174
- note?: { text: string; x: number; y: number };
175
- }
176
-
177
- export const MARKERS: ReadonlyArray<Marker> = [
178
- {
179
- letter: 'A',
180
- lx: 444,
181
- ly: 334,
182
- name: 'Aporia',
183
- nx: 447,
184
- ny: 349,
185
- note: { text: 'prepare to exit', x: 449, y: 366 },
186
- },
187
- { letter: 'C', lx: 531, ly: 419, name: 'Confusion', nx: 529, ny: 436 },
188
- ];
@@ -1,156 +0,0 @@
1
- import {
2
- type ElementRenderer,
3
- ElementRendererExtension,
4
- } from '@formicoidea/labre-core/blocks/surface';
5
- import type { CynefinElementModel } from '@formicoidea/labre-core/model';
6
-
7
- import { FONT_FAMILY, refScale } from '../utils';
8
- import {
9
- COLORS,
10
- DARK_BACK_PATHS,
11
- DARK_FRONT_PATHS,
12
- DASH_RECTS,
13
- DOMAINS,
14
- HATCHES,
15
- MARKERS,
16
- REF_H,
17
- REF_W,
18
- SMALL_LABELS,
19
- TEAL_LABELS,
20
- TEAL_PATH,
21
- TEAL_WIDTH,
22
- } from './consts';
23
-
24
- /**
25
- * Canvas renderer for the Liminal Cynefin diagram — reproduces the official SVG:
26
- * the dark hand-drawn boundary, the teal "iterate" curve, the dashed
27
- * Complicated↔Clear paving and the hatched cliff, plus the four domain blocks
28
- * (heading + Probe/Sense/Respond decisions), the teal annotation labels and the
29
- * central Aporia (A) / Confusion (C) markers. Drawn in the fixed reference space
30
- * and scaled uniformly to the element bounds.
31
- */
32
- export const cynefin: ElementRenderer<CynefinElementModel> = (
33
- model,
34
- ctx,
35
- matrix
36
- ) => {
37
- const [, , w, h] = model.deserializedXYWH;
38
- const cx = w / 2;
39
- const cy = h / 2;
40
- ctx.setTransform(
41
- matrix.translateSelf(cx, cy).rotateSelf(model.rotate).translateSelf(-cx, -cy)
42
- );
43
-
44
- const { s, ox, oy } = refScale(w, h, REF_W, REF_H);
45
- ctx.translate(ox, oy);
46
- ctx.scale(s, s);
47
-
48
- ctx.lineCap = 'butt';
49
-
50
- // ── Dark boundary strokes (behind the teal curve) ───────────────────
51
- ctx.strokeStyle = COLORS.boundary;
52
- for (const [d, lw, miter] of DARK_BACK_PATHS) {
53
- ctx.lineJoin = miter ? 'miter' : 'round';
54
- ctx.lineWidth = lw;
55
- ctx.stroke(new Path2D(d));
56
- }
57
- ctx.lineJoin = 'round';
58
-
59
- // ── Dashed boundary (oriented square pavings) ───────────────────────
60
- ctx.fillStyle = COLORS.boundary;
61
- for (const [x, y, sz, rot] of DASH_RECTS) {
62
- ctx.save();
63
- ctx.translate(x, y);
64
- ctx.rotate((rot * Math.PI) / 180);
65
- ctx.fillRect(-sz / 2, -sz / 2, sz, sz);
66
- ctx.restore();
67
- }
68
-
69
- // ── Teal "iterate" liminal curve ────────────────────────────────────
70
- if (model.showLiminalLine) {
71
- ctx.strokeStyle = COLORS.teal;
72
- ctx.lineWidth = TEAL_WIDTH;
73
- ctx.stroke(new Path2D(TEAL_PATH));
74
- }
75
-
76
- // ── Dark boundary strokes (over the teal curve) ─────────────────────
77
- ctx.strokeStyle = COLORS.boundary;
78
- for (const [d, lw, miter] of DARK_FRONT_PATHS) {
79
- ctx.lineJoin = miter ? 'miter' : 'round';
80
- ctx.lineWidth = lw;
81
- ctx.stroke(new Path2D(d));
82
- }
83
- ctx.lineJoin = 'round';
84
-
85
- // ── Cliff hatching ──────────────────────────────────────────────────
86
- ctx.lineWidth = 3;
87
- for (const [x1, y1, x2, y2] of HATCHES) {
88
- ctx.beginPath();
89
- ctx.moveTo(x1, y1);
90
- ctx.lineTo(x2, y2);
91
- ctx.stroke();
92
- }
93
-
94
- ctx.textBaseline = 'alphabetic';
95
-
96
- // ── Titles: domain headings + A / C marker glyphs and names ─────────
97
- if (model.showTitles) {
98
- ctx.textAlign = 'left';
99
- ctx.fillStyle = COLORS.heading;
100
- ctx.font = `700 30px ${FONT_FAMILY}`;
101
- for (const d of DOMAINS) ctx.fillText(d.heading, d.x, d.hy);
102
-
103
- ctx.textAlign = 'center';
104
- for (const m of MARKERS) {
105
- ctx.fillStyle = COLORS.body;
106
- ctx.font = `700 38px ${FONT_FAMILY}`;
107
- ctx.fillText(m.letter, m.lx, m.ly);
108
- ctx.font = `13.5px ${FONT_FAMILY}`;
109
- ctx.fillText(m.name, m.nx, m.ny);
110
- }
111
- }
112
-
113
- // ── Explanatory text: subheadings, decisions, annotations, notes ────
114
- if (model.showDescriptions) {
115
- // Subheadings (h2) + bold-lead decision lines
116
- ctx.textAlign = 'left';
117
- for (const d of DOMAINS) {
118
- ctx.fillStyle = COLORS.heading;
119
- ctx.font = `700 15px ${FONT_FAMILY}`;
120
- ctx.fillText(d.subheading, d.x, d.sy);
121
-
122
- ctx.fillStyle = COLORS.body;
123
- for (const { lead, rest, y } of d.lines) {
124
- ctx.font = `700 13.5px ${FONT_FAMILY}`;
125
- ctx.fillText(lead, d.x, y);
126
- const leadW = ctx.measureText(lead).width;
127
- ctx.font = `13.5px ${FONT_FAMILY}`;
128
- ctx.fillText(rest, d.x + leadW, y);
129
- }
130
- }
131
-
132
- ctx.textAlign = 'center';
133
-
134
- // Teal annotation labels
135
- ctx.fillStyle = COLORS.teal;
136
- ctx.font = `700 15px ${FONT_FAMILY}`;
137
- for (const [t, x, y] of TEAL_LABELS) ctx.fillText(t, x, y);
138
-
139
- // Small exaptation sub-labels
140
- ctx.fillStyle = COLORS.body;
141
- ctx.font = `10.5px ${FONT_FAMILY}`;
142
- for (const [t, x, y] of SMALL_LABELS) ctx.fillText(t, x, y);
143
-
144
- // Marker notes ("prepare to exit")
145
- ctx.fillStyle = COLORS.teal;
146
- ctx.font = `700 15px ${FONT_FAMILY}`;
147
- for (const m of MARKERS) {
148
- if (m.note) ctx.fillText(m.note.text, m.note.x, m.note.y);
149
- }
150
- }
151
- };
152
-
153
- export const CynefinRendererExtension = ElementRendererExtension(
154
- 'cynefin',
155
- cynefin
156
- );
@@ -1,32 +0,0 @@
1
- import type { CynefinElementModel } from '@formicoidea/labre-core/model';
2
- import {
3
- GfxElementModelView,
4
- GfxViewInteractionExtension,
5
- } from '@formicoidea/labre-core/std/gfx';
6
-
7
- /**
8
- * View for the Cynefin background. Registering it ensures `gfx.view.get(model)`
9
- * returns a view (required so move / select interactions work).
10
- */
11
- export class CynefinView extends GfxElementModelView<CynefinElementModel> {
12
- static override type: string = 'cynefin';
13
- }
14
-
15
- /**
16
- * Resize gating: the resize handles are hidden unless `model.resizeEnabled` is
17
- * true (toggled from the toolbar). Moving / selecting stays available.
18
- */
19
- export const CynefinInteraction = GfxViewInteractionExtension<CynefinView>(
20
- CynefinView.type,
21
- {
22
- handleResize({ model }) {
23
- return {
24
- beforeResize({ set }) {
25
- if (!model.resizeEnabled) {
26
- set({ allowedHandlers: [] });
27
- }
28
- },
29
- };
30
- },
31
- }
32
- );
@@ -1,60 +0,0 @@
1
- import { EdgelessCRUDIdentifier } from '@formicoidea/labre-core/blocks/surface';
2
- import { CynefinElementModel } from '@formicoidea/labre-core/model';
3
- import {
4
- type ToolbarContext,
5
- type ToolbarModuleConfig,
6
- ToolbarModuleExtension,
7
- } from '@formicoidea/labre-core/shared/services';
8
- import { BlockFlavourIdentifier } from '@formicoidea/labre-core/std';
9
- import { html, type TemplateResult } from 'lit';
10
-
11
- const ResizeIcon = html`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M9 5H5v4M15 19h4v-4" /><path d="M5 5l6 6M19 19l-6-6" /></svg>`;
12
- const TitlesIcon = html`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7h14M9 7v11" /></svg>`;
13
- const DescIcon = html`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M5 8h14M5 12h14M5 16h9" /></svg>`;
14
- const LiminalIcon = html`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M5 17 C9 6 15 6 19 7" /></svg>`;
15
-
16
- type CynefinToggleProp =
17
- | 'resizeEnabled'
18
- | 'showTitles'
19
- | 'showDescriptions'
20
- | 'showLiminalLine';
21
-
22
- function booleanToggle(
23
- id: string,
24
- tooltip: string,
25
- icon: TemplateResult,
26
- prop: CynefinToggleProp
27
- ) {
28
- return {
29
- id,
30
- tooltip,
31
- icon,
32
- active(ctx: ToolbarContext) {
33
- const models = ctx.getSurfaceModelsByType(CynefinElementModel);
34
- return models.length > 0 && models.every(model => model[prop]);
35
- },
36
- run(ctx: ToolbarContext) {
37
- const models = ctx.getSurfaceModelsByType(CynefinElementModel);
38
- if (!models.length) return;
39
- const enable = !models.every(model => model[prop]);
40
- ctx.std.store.captureSync();
41
- const crud = ctx.std.get(EdgelessCRUDIdentifier);
42
- for (const model of models) crud.updateElement(model.id, { [prop]: enable });
43
- },
44
- };
45
- }
46
-
47
- export const cynefinToolbarConfig = {
48
- actions: [
49
- booleanToggle('a.toggle-resize', 'Enable / lock resizing', ResizeIcon, 'resizeEnabled'),
50
- booleanToggle('b.toggle-titles', 'Show / hide titles', TitlesIcon, 'showTitles'),
51
- booleanToggle('c.toggle-descriptions', 'Show / hide explanatory text', DescIcon, 'showDescriptions'),
52
- booleanToggle('d.toggle-liminal', 'Show / hide liminal line', LiminalIcon, 'showLiminalLine'),
53
- ],
54
- when: ctx => ctx.getSurfaceModelsByType(CynefinElementModel).length > 0,
55
- } as const satisfies ToolbarModuleConfig;
56
-
57
- export const cynefinToolbarExtension = ToolbarModuleExtension({
58
- id: BlockFlavourIdentifier('affine:surface:cynefin'),
59
- config: cynefinToolbarConfig,
60
- });
package/src/effects.ts DELETED
@@ -1,20 +0,0 @@
1
- import { EdgelessCynefinEstuarineMenu } from './toolbar/menu';
2
- import { EdgelessCynefinEstuarineSeniorButton } from './toolbar/senior-button';
3
-
4
- export function effects() {
5
- customElements.define(
6
- 'edgeless-cynefin-estuarine-menu',
7
- EdgelessCynefinEstuarineMenu
8
- );
9
- customElements.define(
10
- 'edgeless-cynefin-estuarine-senior-button',
11
- EdgelessCynefinEstuarineSeniorButton
12
- );
13
- }
14
-
15
- declare global {
16
- interface HTMLElementTagNameMap {
17
- 'edgeless-cynefin-estuarine-menu': EdgelessCynefinEstuarineMenu;
18
- 'edgeless-cynefin-estuarine-senior-button': EdgelessCynefinEstuarineSeniorButton;
19
- }
20
- }
@@ -1,69 +0,0 @@
1
- /**
2
- * Visual constants for the Estuarine framework map, reproduced from the official
3
- * SVG (viewBox 0 0 690 801). All geometry is authored in that fixed reference
4
- * space and scaled uniformly to the element bounds by the renderer. The e axis
5
- * is vertical & double-headed (energy), the t axis horizontal & single-headed
6
- * (time only flows one way).
7
- */
8
-
9
- export const REF_W = 690;
10
- export const REF_H = 801;
11
-
12
- export const COLORS = {
13
- axis: '#941253',
14
- /** Italic e / t axis letters. */
15
- axisLabel: '#c0392b',
16
- liminal: '#5ecc44',
17
- /** LIMINAL legend (darker than the curve). */
18
- liminalLabel: '#2e7d32',
19
- volatile: '#e63322',
20
- counterfactual: '#1a1a1a',
21
- /** VOLATILE + COUNTER FACTUAL legends. */
22
- label: '#1a1a1a',
23
- } as const;
24
-
25
- /** e axis (vertical, double-headed): x, top y, bottom y. */
26
- export const E_AXIS = { x: 43.5, y1: 97, y2: 763 } as const;
27
- /** t axis (horizontal, single-headed → right): y, left x, right x. */
28
- export const T_AXIS = { y: 649, x1: 28, x2: 616 } as const;
29
- export const AXIS_WIDTH = 8;
30
-
31
- /** Filled arrowhead triangles: [[tipX,tipY],[baseAX,baseAY],[baseBX,baseBY]]. */
32
- export const ARROWHEADS: ReadonlyArray<
33
- readonly [readonly [number, number], readonly [number, number], readonly [number, number]]
34
- > = [
35
- [[43.5, 72], [30, 100], [57, 100]], // e — top
36
- [[43.5, 785], [30, 758], [57, 758]], // e — bottom
37
- [[643, 649], [613, 636], [613, 662]], // t — right
38
- ];
39
-
40
- /** Liminal: green boundary rising gently then dipping at the right end. */
41
- export const LIMINAL_PATH =
42
- 'M 63 193 C 67 192, 78 189, 85 188 C 92 187, 100 186, 107 185 C 114 184, 122 183, 129 183 C 136 183, 144 183, 151 183 C 158 183, 166 183, 173 183 C 180 183, 188 184, 195 185 C 202 186, 210 188, 217 189 C 224 190, 232 192, 239 194 C 246 196, 254 198, 261 201 C 268 204, 276 207, 283 210 C 290 213, 298 217, 305 220 C 312 223, 320 226, 327 230 C 334 234, 342 238, 349 242 C 356 246, 364 250, 371 255 C 378 260, 386 264, 393 269 C 400 274, 408 278, 415 283 C 422 288, 430 292, 437 297 C 444 302, 451 306, 458 310 C 465 314, 473 319, 480 323 C 487 327, 495 332, 502 335 C 509 338, 517 341, 524 343 C 531 345, 539 348, 546 349 C 553 350, 561 350, 568 350 C 575 350, 583 348, 590 346 C 597 344, 605 340, 612 336 C 619 332, 626 325, 633 319 C 640 313, 648 302, 651 298 C 654 294, 654 295, 654 294';
43
- export const LIMINAL_WIDTH = 4.5;
44
-
45
- /** Counter-factual: dark boundary sweeping from the top down to the right. */
46
- export const COUNTERFACTUAL_PATH =
47
- 'M 422 30 C 420 33, 414 41, 411 47 C 408 53, 405 59, 402 65 C 399 71, 397 77, 395 83 C 393 89, 392 95, 391 101 C 390 107, 389 113, 389 119 C 389 125, 389 131, 390 137 C 391 143, 392 149, 394 155 C 396 161, 399 167, 402 173 C 405 179, 408 185, 412 191 C 416 197, 421 203, 426 209 C 431 215, 436 221, 442 226 C 448 231, 454 237, 460 241 C 466 245, 472 249, 478 252 C 484 255, 490 258, 496 260 C 502 262, 508 264, 514 266 C 520 268, 526 270, 532 271 C 538 272, 544 274, 550 275 C 556 276, 562 277, 568 278 C 574 279, 580 279, 586 279 C 592 279, 598 280, 604 280 C 610 280, 616 281, 622 281 C 628 281, 634 280, 640 280 C 646 280, 655 279, 658 279';
48
- export const COUNTERFACTUAL_WIDTH = 5.5;
49
-
50
- /** Volatile: red boundary descending along the left, bulging right. */
51
- export const VOLATILE_PATH =
52
- 'M 58 446 C 61 447, 70 451, 76 454 C 82 457, 88 462, 94 466 C 100 470, 107 476, 112 481 C 117 486, 122 492, 126 498 C 130 504, 135 509, 139 515 C 143 521, 145 526, 148 532 C 151 538, 153 544, 155 550 C 157 556, 159 562, 160 568 C 161 574, 162 580, 163 586 C 164 592, 164 598, 164 604 C 164 610, 166 616, 166 622 C 166 628, 166 634, 165 640 C 164 646, 164 652, 163 658 C 162 664, 162 670, 161 676 C 160 682, 160 688, 159 694 C 158 700, 155 706, 154 712 C 153 718, 152 724, 151 730 C 150 736, 148 746, 147 749';
53
- export const VOLATILE_WIDTH = 5;
54
-
55
- /** Uppercase legends: anchored centre, alphabetic baseline, with letter-spacing. */
56
- export const LABELS = {
57
- counterfactual: { text: 'COUNTER FACTUAL', x: 422, y: 25, size: 20, color: COLORS.label },
58
- liminal: { text: 'LIMINAL', x: 316, y: 192, size: 18, color: COLORS.liminalLabel },
59
- volatile: { text: 'VOLATILE', x: 219, y: 783, size: 20, color: COLORS.volatile },
60
- } as const;
61
-
62
- /** Italic Georgia axis letters (left-anchored, alphabetic baseline). */
63
- export const AXIS_LABELS = {
64
- e: { text: 'e', x: 14, y: 138 },
65
- t: { text: 't', x: 580, y: 685 },
66
- size: 34,
67
- } as const;
68
-
69
- export const LABEL_LETTER_SPACING = 4;
@@ -1,122 +0,0 @@
1
- import {
2
- type ElementRenderer,
3
- ElementRendererExtension,
4
- } from '@formicoidea/labre-core/blocks/surface';
5
- import type { EstuarineElementModel } from '@formicoidea/labre-core/model';
6
-
7
- import { FONT_FAMILY, refScale } from '../utils';
8
- import {
9
- ARROWHEADS,
10
- AXIS_LABELS,
11
- AXIS_WIDTH,
12
- COLORS,
13
- COUNTERFACTUAL_PATH,
14
- COUNTERFACTUAL_WIDTH,
15
- E_AXIS,
16
- LABEL_LETTER_SPACING,
17
- LABELS,
18
- LIMINAL_PATH,
19
- LIMINAL_WIDTH,
20
- REF_H,
21
- REF_W,
22
- T_AXIS,
23
- VOLATILE_PATH,
24
- VOLATILE_WIDTH,
25
- } from './consts';
26
-
27
- /**
28
- * Canvas renderer for the Estuarine framework map — reproduces the official SVG:
29
- * the e (vertical, double-headed) / t (horizontal, single-headed) axes and the
30
- * three reference curves (Liminal / Volatile / Counter-factual), each with its
31
- * legend and individually hideable. Drawn in the fixed reference space and
32
- * scaled uniformly to the element bounds.
33
- */
34
- export const estuarine: ElementRenderer<EstuarineElementModel> = (
35
- model,
36
- ctx,
37
- matrix
38
- ) => {
39
- const [, , w, h] = model.deserializedXYWH;
40
- const cx = w / 2;
41
- const cy = h / 2;
42
- ctx.setTransform(
43
- matrix.translateSelf(cx, cy).rotateSelf(model.rotate).translateSelf(-cx, -cy)
44
- );
45
-
46
- const { s, ox, oy } = refScale(w, h, REF_W, REF_H);
47
- ctx.translate(ox, oy);
48
- ctx.scale(s, s);
49
-
50
- ctx.lineCap = 'round';
51
- ctx.lineJoin = 'round';
52
-
53
- // ── Axes ────────────────────────────────────────────────────────────
54
- ctx.strokeStyle = COLORS.axis;
55
- ctx.fillStyle = COLORS.axis;
56
- ctx.lineWidth = AXIS_WIDTH;
57
- ctx.beginPath();
58
- ctx.moveTo(E_AXIS.x, E_AXIS.y1);
59
- ctx.lineTo(E_AXIS.x, E_AXIS.y2);
60
- ctx.moveTo(T_AXIS.x1, T_AXIS.y);
61
- ctx.lineTo(T_AXIS.x2, T_AXIS.y);
62
- ctx.stroke();
63
- for (const [[tx, ty], [ax, ay], [bx, by]] of ARROWHEADS) {
64
- ctx.beginPath();
65
- ctx.moveTo(tx, ty);
66
- ctx.lineTo(ax, ay);
67
- ctx.lineTo(bx, by);
68
- ctx.closePath();
69
- ctx.fill();
70
- }
71
-
72
- // Uppercase legend (centre-anchored, alphabetic baseline, letter-spaced).
73
- const hasSpacing = 'letterSpacing' in ctx;
74
- const legend = (l: { text: string; x: number; y: number; size: number; color: string }) => {
75
- ctx.fillStyle = l.color;
76
- ctx.font = `600 ${l.size}px ${FONT_FAMILY}`;
77
- ctx.textAlign = 'center';
78
- ctx.textBaseline = 'alphabetic';
79
- if (hasSpacing) ctx.letterSpacing = `${LABEL_LETTER_SPACING}px`;
80
- ctx.fillText(l.text, l.x, l.y);
81
- if (hasSpacing) ctx.letterSpacing = '0px';
82
- };
83
-
84
- // ── Liminal (green) ─────────────────────────────────────────────────
85
- if (model.showLiminal) {
86
- ctx.strokeStyle = COLORS.liminal;
87
- ctx.lineWidth = LIMINAL_WIDTH;
88
- ctx.stroke(new Path2D(LIMINAL_PATH));
89
- legend(LABELS.liminal);
90
- }
91
-
92
- // ── Volatile (red) ──────────────────────────────────────────────────
93
- if (model.showVolatile) {
94
- ctx.strokeStyle = COLORS.volatile;
95
- ctx.lineWidth = VOLATILE_WIDTH;
96
- ctx.stroke(new Path2D(VOLATILE_PATH));
97
- legend(LABELS.volatile);
98
- }
99
-
100
- // ── Counter-factual (dark) ──────────────────────────────────────────
101
- if (model.showCounterfactual) {
102
- ctx.strokeStyle = COLORS.counterfactual;
103
- ctx.lineWidth = COUNTERFACTUAL_WIDTH;
104
- ctx.stroke(new Path2D(COUNTERFACTUAL_PATH));
105
- legend(LABELS.counterfactual);
106
- }
107
-
108
- // ── Italic e / t axis letters ───────────────────────────────────────
109
- if (model.showAxisLabels) {
110
- ctx.fillStyle = COLORS.axisLabel;
111
- ctx.font = `italic 700 ${AXIS_LABELS.size}px Georgia, serif`;
112
- ctx.textAlign = 'left';
113
- ctx.textBaseline = 'alphabetic';
114
- ctx.fillText(AXIS_LABELS.e.text, AXIS_LABELS.e.x, AXIS_LABELS.e.y);
115
- ctx.fillText(AXIS_LABELS.t.text, AXIS_LABELS.t.x, AXIS_LABELS.t.y);
116
- }
117
- };
118
-
119
- export const EstuarineRendererExtension = ElementRendererExtension(
120
- 'estuarine',
121
- estuarine
122
- );
@@ -1,32 +0,0 @@
1
- import type { EstuarineElementModel } from '@formicoidea/labre-core/model';
2
- import {
3
- GfxElementModelView,
4
- GfxViewInteractionExtension,
5
- } from '@formicoidea/labre-core/std/gfx';
6
-
7
- /**
8
- * View for the Estuarine background. Registering it ensures `gfx.view.get(model)`
9
- * returns a view (required so move / select interactions work).
10
- */
11
- export class EstuarineView extends GfxElementModelView<EstuarineElementModel> {
12
- static override type: string = 'estuarine';
13
- }
14
-
15
- /**
16
- * Resize gating: the resize handles are hidden unless `model.resizeEnabled` is
17
- * true (toggled from the toolbar). Moving / selecting stays available.
18
- */
19
- export const EstuarineInteraction = GfxViewInteractionExtension<EstuarineView>(
20
- EstuarineView.type,
21
- {
22
- handleResize({ model }) {
23
- return {
24
- beforeResize({ set }) {
25
- if (!model.resizeEnabled) {
26
- set({ allowedHandlers: [] });
27
- }
28
- },
29
- };
30
- },
31
- }
32
- );