@formicoidea/labre-framework-cynefin 0.59.0 → 0.60.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.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { DefaultTool } from '@formicoidea/labre-core/blocks/surface';
2
- import { Bound } from '@formicoidea/labre-core/global/gfx';
3
2
  import { GfxControllerIdentifier } from '@formicoidea/labre-core/std/gfx';
4
- import { CYNEFIN_H, CYNEFIN_W, cynefinBackgroundProps, ESTUARINE_MAP_H, ESTUARINE_MAP_W, estuarineHexagonBox, estuarineHexagonProps, estuarineMapProps, } from './presets.js';
3
+ import { HEX_SIZE } from './estuarine/consts.js';
4
+ import { CYNEFIN_H, CYNEFIN_W, ESTUARINE_MAP_H, ESTUARINE_MAP_W, } from './presets.js';
5
+ import { constraintHexagonElement, cynefinElement, estuarineMapElement, } from './toolbox.js';
5
6
  /**
6
7
  * Creation actions for the Cynefin / Estuarine toolbox — lifted out of
7
8
  * `toolbar/menu.ts` by PF3. This is also the framework that emitted NO
@@ -9,7 +10,10 @@ import { CYNEFIN_H, CYNEFIN_W, cynefinBackgroundProps, ESTUARINE_MAP_H, ESTUARIN
9
10
  * `runCommand` fixes that for free (`docs/adr/0008`).
10
11
  *
11
12
  * 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
+ * templates used to restate these props and drifted from them. What the
14
+ * toolbar places comes from the ONE assembly a host with no editor also calls
15
+ * (`toolbox.ts`, `docs/adr/0045`); only the viewport centre and the selection
16
+ * stay here.
13
17
  */
14
18
  const gfxOf = (std) => std.get(GfxControllerIdentifier);
15
19
  function finish(gfx, id) {
@@ -17,32 +21,28 @@ function finish(gfx, id) {
17
21
  gfx.tool.setTool(DefaultTool);
18
22
  gfx.selection.set({ elements: [id], editing: false });
19
23
  }
20
- /** The box an artefact of the given size is born in, centred on the viewport. */
24
+ /** The top-left an artefact of the given size is born at, centred on the viewport. */
21
25
  function centered(gfx, width, height) {
22
26
  const { centerX, centerY } = gfx.viewport;
23
- return new Bound(centerX - width / 2, centerY - height / 2, width, height).serialize();
27
+ return { x: centerX - width / 2, y: centerY - height / 2 };
28
+ }
29
+ /** Write one built element; the builder's local id is the editor's to mint. */
30
+ function place(gfx, element) {
31
+ const surface = gfx.surface;
32
+ if (!surface)
33
+ return;
34
+ const { id: _local, ...props } = element;
35
+ finish(gfx, surface.addElement(props));
24
36
  }
25
37
  export function createCynefin(std) {
26
38
  const gfx = gfxOf(std);
27
- if (!gfx.surface)
28
- return;
29
- const id = gfx.surface.addElement(cynefinBackgroundProps({ xywh: centered(gfx, CYNEFIN_W, CYNEFIN_H) }));
30
- finish(gfx, id);
39
+ place(gfx, cynefinElement(centered(gfx, CYNEFIN_W, CYNEFIN_H)));
31
40
  }
32
41
  export function createEstuarineMap(std) {
33
42
  const gfx = gfxOf(std);
34
- if (!gfx.surface)
35
- return;
36
- const id = gfx.surface.addElement(estuarineMapProps({
37
- xywh: centered(gfx, ESTUARINE_MAP_W, ESTUARINE_MAP_H),
38
- }));
39
- finish(gfx, id);
43
+ place(gfx, estuarineMapElement(centered(gfx, ESTUARINE_MAP_W, ESTUARINE_MAP_H)));
40
44
  }
41
45
  export function createConstraintHexagon(std) {
42
46
  const gfx = gfxOf(std);
43
- if (!gfx.surface)
44
- return;
45
- const { centerX, centerY } = gfx.viewport;
46
- const id = gfx.surface.addElement(estuarineHexagonProps({ xywh: estuarineHexagonBox(centerX, centerY) }));
47
- finish(gfx, id);
47
+ place(gfx, constraintHexagonElement(centered(gfx, HEX_SIZE, HEX_SIZE)));
48
48
  }
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export { cynefinEstuarineCommandIcons, cynefinEstuarineCommands, } from './comma
2
2
  export { cynefinEstuarineTranslationEntries } from './translations.js';
3
3
  export { ESTUARINE_ROLE, ESTUARINE_ROLES, type EstuarineRoleId, } from './estuarine/roles.js';
4
4
  export { ESTUARINE_READING } from './estuarine/reading.js';
5
+ export { constraintHexagonElement, CYNEFIN_ESTUARINE_TOOLBOX, cynefinElement, estuarineMapElement, } from './toolbox.js';
package/dist/index.js CHANGED
@@ -5,3 +5,5 @@ export { cynefinEstuarineTranslationEntries } from './translations.js';
5
5
  // Cynefin contributes neither, having no role of its own (ADR 0013).
6
6
  export { ESTUARINE_ROLE, ESTUARINE_ROLES, } from './estuarine/roles.js';
7
7
  export { ESTUARINE_READING } from './estuarine/reading.js';
8
+ // The toolbar as pure builders (`docs/adr/0045`), also on `./interchange`.
9
+ export { constraintHexagonElement, CYNEFIN_ESTUARINE_TOOLBOX, cynefinElement, estuarineMapElement, } from './toolbox.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `@labre/affine-gfx-cynefin-estuarine/interchange` — Cynefin and estuarine
3
+ * mapping with no editor behind them.
4
+ *
5
+ * The framework declares no file format. What a host without an editor uses
6
+ * is its toolbar as pure builders (`docs/adr/0045`): the elements a user
7
+ * places from the toolbar, for a server or an MCP tool to place the same ones.
8
+ *
9
+ * Held by `interchange-headless.unit.spec.ts` in `packages/affine/all`.
10
+ */
11
+ export { constraintHexagonElement, CYNEFIN_ESTUARINE_TOOLBOX, cynefinElement, estuarineMapElement, } from './toolbox.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `@labre/affine-gfx-cynefin-estuarine/interchange` — Cynefin and estuarine
3
+ * mapping with no editor behind them.
4
+ *
5
+ * The framework declares no file format. What a host without an editor uses
6
+ * is its toolbar as pure builders (`docs/adr/0045`): the elements a user
7
+ * places from the toolbar, for a server or an MCP tool to place the same ones.
8
+ *
9
+ * Held by `interchange-headless.unit.spec.ts` in `packages/affine/all`.
10
+ */
11
+ export { constraintHexagonElement, CYNEFIN_ESTUARINE_TOOLBOX, cynefinElement, estuarineMapElement, } from './toolbox.js';
package/dist/presets.js CHANGED
@@ -1,4 +1,7 @@
1
- import { ShapeStyle, TextFitMode } from '@formicoidea/labre-core/model';
1
+ // Values from the headless entry, never the model index: the toolbox
2
+ // (`toolbox.ts`, `docs/adr/0045`) builds on these presets from the
3
+ // editor-free `./interchange` entry.
4
+ import { ShapeStyle, TextFitMode } from '@formicoidea/labre-core/model/headless';
2
5
  import { REF_H as CYN_H, REF_W as CYN_W } from './cynefin/consts.js';
3
6
  import { HEX_FILL, HEX_SIZE, HEX_STROKE, HEX_VERTICES, REF_H as EST_H, REF_W as EST_W, } from './estuarine/consts.js';
4
7
  import { ESTUARINE_ROLE } from './estuarine/roles.js';
@@ -0,0 +1,19 @@
1
+ import type { FrameworkToolbox, SerializedElementProps, ToolboxPoint } from '@formicoidea/labre-core/interchange';
2
+ /**
3
+ * The Cynefin and estuarine toolbar as pure builders (`docs/adr/0045`): what
4
+ * `createCynefin`, `createEstuarineMap` and `createConstraintHexagon` place,
5
+ * with no editor behind them. The actions call these, so an element built
6
+ * here and one placed from the toolbar are the same element. The framework
7
+ * has no relation style: there is no link.
8
+ */
9
+ /** The Cynefin framework background at `at`, its top-left. */
10
+ export declare function cynefinElement(at: ToolboxPoint, local?: string): SerializedElementProps;
11
+ /** The estuarine map background at `at`, its top-left. */
12
+ export declare function estuarineMapElement(at: ToolboxPoint, local?: string): SerializedElementProps;
13
+ /**
14
+ * A constraint hexagon at `at`, its top-left. The toolbar places it empty; a
15
+ * `name` is written as the shape's own inner text, where a user types it.
16
+ */
17
+ export declare function constraintHexagonElement(at: ToolboxPoint, name?: string, local?: string): SerializedElementProps;
18
+ /** Every item of the Cynefin and estuarine toolbar, in the toolbar's order. */
19
+ export declare const CYNEFIN_ESTUARINE_TOOLBOX: FrameworkToolbox;
@@ -0,0 +1,82 @@
1
+ import { Bound } from '@formicoidea/labre-core/global/gfx';
2
+ import { cynefinEstuarineCommandsManifest } from './commands-manifest.js';
3
+ import { HEX_SIZE } from './estuarine/consts.js';
4
+ import { CYNEFIN_H, CYNEFIN_W, cynefinBackgroundProps, ESTUARINE_MAP_H, ESTUARINE_MAP_W, estuarineHexagonProps, estuarineMapProps, } from './presets.js';
5
+ /**
6
+ * The Cynefin and estuarine toolbar as pure builders (`docs/adr/0045`): what
7
+ * `createCynefin`, `createEstuarineMap` and `createConstraintHexagon` place,
8
+ * with no editor behind them. The actions call these, so an element built
9
+ * here and one placed from the toolbar are the same element. The framework
10
+ * has no relation style: there is no link.
11
+ */
12
+ /** The Cynefin framework background at `at`, its top-left. */
13
+ export function cynefinElement(at, local = 'cynefin') {
14
+ return {
15
+ ...cynefinBackgroundProps({
16
+ xywh: new Bound(at.x, at.y, CYNEFIN_W, CYNEFIN_H).serialize(),
17
+ }),
18
+ id: local,
19
+ };
20
+ }
21
+ /** The estuarine map background at `at`, its top-left. */
22
+ export function estuarineMapElement(at, local = 'estuarine-map') {
23
+ return {
24
+ ...estuarineMapProps({
25
+ xywh: new Bound(at.x, at.y, ESTUARINE_MAP_W, ESTUARINE_MAP_H).serialize(),
26
+ }),
27
+ id: local,
28
+ };
29
+ }
30
+ /**
31
+ * A constraint hexagon at `at`, its top-left. The toolbar places it empty; a
32
+ * `name` is written as the shape's own inner text, where a user types it.
33
+ */
34
+ export function constraintHexagonElement(at, name, local = 'constraint-hexagon') {
35
+ const text = name?.trim();
36
+ return {
37
+ ...estuarineHexagonProps({
38
+ xywh: new Bound(at.x, at.y, HEX_SIZE, HEX_SIZE).serialize(),
39
+ }),
40
+ ...(text ? { text } : {}),
41
+ id: local,
42
+ };
43
+ }
44
+ /** The toolbar command's label, so a host names an item as the toolbar does. */
45
+ function label(commandId) {
46
+ const row = cynefinEstuarineCommandsManifest.find(r => r.id === commandId);
47
+ return {
48
+ labelKey: row?.labelKey ?? commandId,
49
+ labelFallback: row?.labelFallback ?? commandId,
50
+ };
51
+ }
52
+ const items = [
53
+ {
54
+ id: 'cynefin',
55
+ ...label('cynefin-estuarine.addCynefin'),
56
+ texts: [],
57
+ size: { w: CYNEFIN_W, h: CYNEFIN_H },
58
+ build: (at, _texts, local) => [cynefinElement(at, local)],
59
+ },
60
+ {
61
+ id: 'estuarine-map',
62
+ ...label('cynefin-estuarine.addEstuarineMap'),
63
+ texts: [],
64
+ size: { w: ESTUARINE_MAP_W, h: ESTUARINE_MAP_H },
65
+ build: (at, _texts, local) => [estuarineMapElement(at, local)],
66
+ },
67
+ {
68
+ id: 'constraint-hexagon',
69
+ ...label('cynefin-estuarine.addConstraintHexagon'),
70
+ texts: ['name'],
71
+ size: { w: HEX_SIZE, h: HEX_SIZE },
72
+ build: (at, texts, local) => [
73
+ constraintHexagonElement(at, texts?.name, local),
74
+ ],
75
+ },
76
+ ];
77
+ /** Every item of the Cynefin and estuarine toolbar, in the toolbar's order. */
78
+ export const CYNEFIN_ESTUARINE_TOOLBOX = {
79
+ framework: 'cynefin-estuarine',
80
+ items,
81
+ links: [],
82
+ };
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.59.0",
4
+ "version": "0.60.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",
@@ -25,13 +25,17 @@
25
25
  "./commands-manifest": {
26
26
  "types": "./dist/commands-manifest.d.ts",
27
27
  "import": "./dist/commands-manifest.js"
28
+ },
29
+ "./interchange": {
30
+ "types": "./dist/interchange-headless.d.ts",
31
+ "import": "./dist/interchange-headless.js"
28
32
  }
29
33
  },
30
34
  "files": [
31
35
  "dist"
32
36
  ],
33
37
  "dependencies": {
34
- "@formicoidea/labre-core": "0.59.0",
38
+ "@formicoidea/labre-core": "0.60.0",
35
39
  "@preact/signals-core": "^1.8.0",
36
40
  "lit": "^3.2.0"
37
41
  }