@formicoidea/labre-framework-ddd-core-domain 0.30.1 → 0.32.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.
@@ -0,0 +1,4 @@
1
+ import type { CommandDescriptor } from '@formicoidea/labre-core/std';
2
+ import { type TemplateResult } from 'lit';
3
+ export declare const coreDomainCommands: CommandDescriptor[];
4
+ export declare const coreDomainCommandIcons: Record<string, TemplateResult>;
@@ -0,0 +1,76 @@
1
+ import { addConnector, addDot, addMarker, CD_SUBDOMAINS, MOVEMENT_COLOR, placeDddElement, TEAM_TOPOLOGIES, } from '@formicoidea/labre-ddd-shared';
2
+ import { Bound } from '@formicoidea/labre-core/global/gfx';
3
+ import { svg } from 'lit';
4
+ import { REF_H, REF_W } from './core-domain/consts.js';
5
+ /**
6
+ * The Core Domain Chart palette as commands: the background, the five
7
+ * sub-domain dots, the three Team Topologies markers and the movement arrow.
8
+ * The notation legend stays in the map-background context menu (toolbar
9
+ * config) — the element toolbar is out of scope for `docs/adr/0008`.
10
+ */
11
+ const chartSwatch = svg `<svg viewBox="0 0 24 24" fill="none"><rect x="4" y="3" width="17" height="17" fill="#4d9900" fill-opacity="0.5"/><rect x="4" y="3" width="6" height="17" fill="#9933ff" fill-opacity="0.5"/><path d="M4 20 V3 M4 20 H21" stroke="currentColor" stroke-width="1.8"/></svg>`;
12
+ const dotSwatch = (color) => svg `<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="7" fill="${color}" stroke="#1f2328" stroke-width="1.2"/></svg>`;
13
+ const movementSwatch = svg `<svg viewBox="0 0 24 24" fill="none"><path d="M3 18 L16 7" stroke="${MOVEMENT_COLOR}" stroke-width="2" stroke-dasharray="3 3"/><path d="M12 6 L18 5 L17 11" stroke="${MOVEMENT_COLOR}" stroke-width="2" fill="none"/></svg>`;
14
+ const markerSwatch = (fill, letter) => svg `<svg viewBox="0 0 24 24"><rect x="4" y="4" width="16" height="16" rx="3" fill="${fill}" stroke="#1f2328" stroke-width="1.2"/><text x="12" y="16" text-anchor="middle" font-size="11" font-family="sans-serif" fill="#1f2328">${letter}</text></svg>`;
15
+ const SPECS = [
16
+ {
17
+ id: 'addChart',
18
+ label: 'Core Domain Chart',
19
+ iconKey: 'ddd-core-domain.chart',
20
+ element: 'background',
21
+ icon: chartSwatch,
22
+ run: std => placeDddElement(std, (surface, cx, cy) => surface.addElement({
23
+ type: 'coreDomain',
24
+ xywh: new Bound(cx - REF_W / 2, cy - REF_H / 2, REF_W, REF_H).serialize(),
25
+ })),
26
+ },
27
+ ...CD_SUBDOMAINS.map((preset) => ({
28
+ id: `add${preset.kind[0].toUpperCase()}${preset.kind.slice(1)}`,
29
+ label: preset.label,
30
+ iconKey: `ddd-core-domain.subdomain.${preset.kind}`,
31
+ element: `subdomain:${preset.kind}`,
32
+ icon: dotSwatch(preset.fill),
33
+ run: std => placeDddElement(std, (surface, cx, cy) => addDot(surface, std, cx, cy, preset.fill, preset.label)),
34
+ })),
35
+ ...TEAM_TOPOLOGIES.map((preset) => ({
36
+ id: `add${preset.kind[0].toUpperCase()}${preset.kind.slice(1)}`,
37
+ label: preset.label,
38
+ iconKey: `ddd-core-domain.team-topology.${preset.kind}`,
39
+ element: `team-topology:${preset.kind}`,
40
+ icon: markerSwatch(preset.fill, preset.letter),
41
+ run: std => placeDddElement(std, (surface, cx, cy) => addMarker(surface, std, cx, cy, {
42
+ fill: preset.fill,
43
+ letter: preset.letter,
44
+ label: preset.label,
45
+ })),
46
+ })),
47
+ {
48
+ id: 'addMovement',
49
+ label: 'Movement over time',
50
+ iconKey: 'ddd-core-domain.movement',
51
+ element: 'movement',
52
+ icon: movementSwatch,
53
+ run: std => placeDddElement(std, (surface, cx, cy) => addConnector(surface, cx - 80, cy + 60, cx + 80, cy - 60, {
54
+ rearArrow: true,
55
+ dashed: true,
56
+ stroke: MOVEMENT_COLOR,
57
+ })),
58
+ },
59
+ ];
60
+ export const coreDomainCommands = SPECS.map((spec, order) => ({
61
+ id: `ddd-core-domain.${spec.id}`,
62
+ owner: 'ddd-core-domain',
63
+ kind: 'artefact',
64
+ labelKey: `com.labre.commands.ddd-core-domain.${spec.id}`,
65
+ labelFallback: spec.label,
66
+ category: 'chart',
67
+ iconKey: spec.iconKey,
68
+ surfaces: ['senior-menu', 'catalogue', 'palette', 'agent'],
69
+ order,
70
+ scope: 'edgeless',
71
+ defaultKeys: { mac: [], other: [] },
72
+ availability: 'always',
73
+ run: spec.run,
74
+ telemetry: { framework: 'ddd-core-domain', element: spec.element },
75
+ }));
76
+ export const coreDomainCommandIcons = Object.fromEntries(SPECS.map(spec => [spec.iconKey, spec.icon]));
@@ -1,6 +1,6 @@
1
1
  import { ElementRendererExtension, } from '@formicoidea/labre-core/blocks/surface';
2
2
  import { FONT_FAMILY, refScale } from '@formicoidea/labre-ddd-shared';
3
- import { AXIS, COLORS, REF_H, REF_W, ZONE_LABELS, ZONES } from './consts';
3
+ import { AXIS, COLORS, REF_H, REF_W, ZONE_LABELS, ZONES } from './consts.js';
4
4
  /**
5
5
  * Canvas renderer for the Core Domain Chart background — the translucent
6
6
  * Generic / Supporting / Core zone bands, the two axes with arrow heads and the
@@ -2,7 +2,7 @@ import { CoreDomainChartElementModel } from '@formicoidea/labre-core/model';
2
2
  import { TelemetryProvider, ToolbarModuleExtension, } from '@formicoidea/labre-core/shared/services';
3
3
  import { BlockFlavourIdentifier } from '@formicoidea/labre-core/std';
4
4
  import { html } from 'lit';
5
- import { createCoreDomainLegend } from './legend';
5
+ import { createCoreDomainLegend } from './legend.js';
6
6
  const legendIcon = html `<svg
7
7
  width="24"
8
8
  height="24"
@@ -1,7 +1,8 @@
1
1
  import { DddCoreDomainRenderViewExtension, DddCoreDomainViewExtension } from './view.js';
2
2
  /** Host wiring for the ddd-core-domain framework. */
3
3
  export declare const dddCoreDomainFramework: {
4
- readonly telemetry: "ddd-core-domain";
4
+ readonly flag: "ddd-core-domain";
5
+ readonly telemetryKey: "core-domain";
5
6
  readonly extensions: readonly [{
6
7
  readonly viewExtension: typeof DddCoreDomainRenderViewExtension;
7
8
  }, {
@@ -1,7 +1,8 @@
1
1
  import { DddCoreDomainRenderViewExtension, DddCoreDomainViewExtension } from './view.js';
2
2
  /** Host wiring for the ddd-core-domain framework. */
3
3
  export const dddCoreDomainFramework = {
4
- telemetry: 'ddd-core-domain',
4
+ flag: 'ddd-core-domain',
5
+ telemetryKey: 'core-domain',
5
6
  extensions: [
6
7
  { viewExtension: DddCoreDomainRenderViewExtension },
7
8
  { flag: 'ddd-core-domain', viewExtension: DddCoreDomainViewExtension },
package/dist/effects.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { EdgelessDddCoreDomainMenu } from './toolbar/core-domain-menu';
2
- import { EdgelessDddCoreDomainSeniorButton } from './toolbar/senior-button';
1
+ import { EdgelessDddCoreDomainMenu } from './toolbar/core-domain-menu.js';
2
+ import { EdgelessDddCoreDomainSeniorButton } from './toolbar/senior-button.js';
3
3
  export declare function coreDomainEffects(): void;
4
4
  declare global {
5
5
  interface HTMLElementTagNameMap {
package/dist/effects.js CHANGED
@@ -1,5 +1,5 @@
1
- import { EdgelessDddCoreDomainMenu } from './toolbar/core-domain-menu';
2
- import { EdgelessDddCoreDomainSeniorButton } from './toolbar/senior-button';
1
+ import { EdgelessDddCoreDomainMenu } from './toolbar/core-domain-menu.js';
2
+ import { EdgelessDddCoreDomainSeniorButton } from './toolbar/senior-button.js';
3
3
  /** Define a custom element once (each tool's effect may run more than once). */
4
4
  function define(tag, ctor) {
5
5
  if (!customElements.get(tag))
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export { coreDomainCommandIcons, coreDomainCommands } from './commands.js';
2
+ export { coreDomainTranslationEntries } from './translations.js';
1
3
  export { coreDomain } from './core-domain/element-renderer.js';
2
4
  export { coreDomainTemplateCategory } from './templates.js';
3
5
  export { coreDomainSeniorTool } from './toolbar/senior-tool.js';
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ export { coreDomainCommandIcons, coreDomainCommands } from './commands.js';
2
+ export { coreDomainTranslationEntries } from './translations.js';
1
3
  export { coreDomain } from './core-domain/element-renderer.js';
2
4
  export { coreDomainTemplateCategory } from './templates.js';
3
5
  export { coreDomainSeniorTool } from './toolbar/senior-tool.js';
@@ -1,14 +1,11 @@
1
- import { DddMenuBase } from '@formicoidea/labre-ddd-shared';
1
+ import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
2
+ import { EdgelessCommandMenu } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
2
3
  /**
3
- * Core Domain Chart palette: the background, sub-domain dots, movement arrow.
4
- * The notation legend lives in the map-background context menu (toolbar-config),
5
- * not here, to avoid a duplicate entry.
4
+ * Core Domain Chart palette, rendered from `coreDomainCommands` for the
5
+ * `senior-menu` surface (`docs/adr/0008`). Keeps the DDD palettes' tighter gap.
6
6
  */
7
- export declare class EdgelessDddCoreDomainMenu extends DddMenuBase {
8
- protected framework: "core-domain";
9
- private _createBackground;
10
- private _createDot;
11
- private _createMarker;
12
- private _createMovement;
13
- render(): import("lit-html").TemplateResult<1>;
7
+ export declare class EdgelessDddCoreDomainMenu extends EdgelessCommandMenu {
8
+ static styles: import("lit").CSSResultGroup[];
9
+ protected owner: "ddd-core-domain";
10
+ type: typeof EmptyTool;
14
11
  }
@@ -1,100 +1,22 @@
1
- import { addConnector, addDot, addMarker, CD_SUBDOMAINS, DddMenuBase, MOVEMENT_COLOR, TEAM_TOPOLOGIES, } from '@formicoidea/labre-ddd-shared';
2
- import { Bound } from '@formicoidea/labre-core/global/gfx';
3
- import { html, svg } from 'lit';
4
- import { REF_H, REF_W } from '../core-domain/consts';
5
- const chartSwatch = svg `<svg viewBox="0 0 24 24" fill="none"><rect x="4" y="3" width="17" height="17" fill="#4d9900" fill-opacity="0.5"/><rect x="4" y="3" width="6" height="17" fill="#9933ff" fill-opacity="0.5"/><path d="M4 20 V3 M4 20 H21" stroke="currentColor" stroke-width="1.8"/></svg>`;
6
- const dotSwatch = (color) => svg `<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="7" fill="${color}" stroke="#1f2328" stroke-width="1.2"/></svg>`;
7
- const movementSwatch = svg `<svg viewBox="0 0 24 24" fill="none"><path d="M3 18 L16 7" stroke="${MOVEMENT_COLOR}" stroke-width="2" stroke-dasharray="3 3"/><path d="M12 6 L18 5 L17 11" stroke="${MOVEMENT_COLOR}" stroke-width="2" fill="none"/></svg>`;
8
- const markerSwatch = (fill, letter) => svg `<svg viewBox="0 0 24 24"><rect x="4" y="4" width="16" height="16" rx="3" fill="${fill}" stroke="#1f2328" stroke-width="1.2"/><text x="12" y="16" text-anchor="middle" font-size="11" font-family="sans-serif" fill="#1f2328">${letter}</text></svg>`;
1
+ import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
2
+ import { EdgelessCommandMenu } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
3
+ import { css } from 'lit';
9
4
  /**
10
- * Core Domain Chart palette: the background, sub-domain dots, movement arrow.
11
- * The notation legend lives in the map-background context menu (toolbar-config),
12
- * not here, to avoid a duplicate entry.
5
+ * Core Domain Chart palette, rendered from `coreDomainCommands` for the
6
+ * `senior-menu` surface (`docs/adr/0008`). Keeps the DDD palettes' tighter gap.
13
7
  */
14
- export class EdgelessDddCoreDomainMenu extends DddMenuBase {
8
+ export class EdgelessDddCoreDomainMenu extends EdgelessCommandMenu {
15
9
  constructor() {
16
10
  super(...arguments);
17
- this.framework = 'core-domain';
18
- }
19
- _createBackground() {
20
- const surface = this.surface;
21
- if (!surface)
22
- return;
23
- const { cx, cy } = this.center;
24
- const id = surface.addElement({
25
- type: 'coreDomain',
26
- xywh: new Bound(cx - REF_W / 2, cy - REF_H / 2, REF_W, REF_H).serialize(),
27
- });
28
- this.track('FrameworkElementAdded', 'background');
29
- this.finish(id);
30
- }
31
- _createDot(preset) {
32
- const surface = this.surface;
33
- if (!surface)
34
- return;
35
- const { cx, cy } = this.center;
36
- const id = addDot(surface, this.edgeless.std, cx, cy, preset.fill, preset.label);
37
- this.track('FrameworkElementAdded', `subdomain:${preset.kind}`);
38
- this.finish(id);
39
- }
40
- _createMarker(preset) {
41
- const surface = this.surface;
42
- if (!surface)
43
- return;
44
- const { cx, cy } = this.center;
45
- const id = addMarker(surface, this.edgeless.std, cx, cy, {
46
- fill: preset.fill,
47
- letter: preset.letter,
48
- label: preset.label,
49
- });
50
- this.track('FrameworkElementAdded', `team-topology:${preset.kind}`);
51
- this.finish(id);
52
- }
53
- _createMovement() {
54
- const surface = this.surface;
55
- if (!surface)
56
- return;
57
- const { cx, cy } = this.center;
58
- const id = addConnector(surface, cx - 80, cy + 60, cx + 80, cy - 60, {
59
- rearArrow: true,
60
- dashed: true,
61
- stroke: MOVEMENT_COLOR,
62
- });
63
- this.track('FrameworkElementAdded', 'movement');
64
- this.finish(id);
65
- }
66
- render() {
67
- return html `
68
- <edgeless-slide-menu>
69
- <div class="menu-content">
70
- <div class="button-group-container">
71
- <edgeless-tool-icon-button
72
- .tooltip=${'Core Domain Chart'}
73
- @click=${() => this._createBackground()}
74
- >
75
- ${chartSwatch}
76
- </edgeless-tool-icon-button>
77
- ${CD_SUBDOMAINS.map(preset => html `<edgeless-tool-icon-button
78
- .tooltip=${preset.label}
79
- @click=${() => this._createDot(preset)}
80
- >
81
- ${dotSwatch(preset.fill)}
82
- </edgeless-tool-icon-button>`)}
83
- ${TEAM_TOPOLOGIES.map(preset => html `<edgeless-tool-icon-button
84
- .tooltip=${preset.label}
85
- @click=${() => this._createMarker(preset)}
86
- >
87
- ${markerSwatch(preset.fill, preset.letter)}
88
- </edgeless-tool-icon-button>`)}
89
- <edgeless-tool-icon-button
90
- .tooltip=${'Movement over time'}
91
- @click=${() => this._createMovement()}
92
- >
93
- ${movementSwatch}
94
- </edgeless-tool-icon-button>
95
- </div>
96
- </div>
97
- </edgeless-slide-menu>
98
- `;
11
+ this.owner = 'ddd-core-domain';
12
+ this.type = EmptyTool;
99
13
  }
14
+ static { this.styles = [
15
+ EdgelessCommandMenu.styles,
16
+ css `
17
+ :host {
18
+ --labre-command-menu-gap: 10px;
19
+ }
20
+ `,
21
+ ]; }
100
22
  }
@@ -0,0 +1,14 @@
1
+ import { type TranslationKeyManifestEntry } from '@formicoidea/labre-core/std';
2
+ /**
3
+ * THIS framework's contribution to the translation-key manifest.
4
+ *
5
+ * Its command labels and descriptions are built from a TEMPLATE, so the
6
+ * concrete keys exist nowhere but in the declarations themselves and the
7
+ * core manifest could not restate them even if it wanted to. The
8
+ * contribution therefore ships WITH the framework: in the bundled
9
+ * distribution `@formicoidea/labre-framework-ddd-core-domain` carries it, and a host
10
+ * composes it into its catalogue exactly as it already composes
11
+ * `coreDomainCommands` into the command registry. See
12
+ * `packages/affine/all/src/translations.ts`.
13
+ */
14
+ export declare const coreDomainTranslationEntries: TranslationKeyManifestEntry[];
@@ -0,0 +1,15 @@
1
+ import { commandTranslationEntries, } from '@formicoidea/labre-core/std';
2
+ import { coreDomainCommands } from './commands.js';
3
+ /**
4
+ * THIS framework's contribution to the translation-key manifest.
5
+ *
6
+ * Its command labels and descriptions are built from a TEMPLATE, so the
7
+ * concrete keys exist nowhere but in the declarations themselves and the
8
+ * core manifest could not restate them even if it wanted to. The
9
+ * contribution therefore ships WITH the framework: in the bundled
10
+ * distribution `@formicoidea/labre-framework-ddd-core-domain` carries it, and a host
11
+ * composes it into its catalogue exactly as it already composes
12
+ * `coreDomainCommands` into the command registry. See
13
+ * `packages/affine/all/src/translations.ts`.
14
+ */
15
+ export const coreDomainTranslationEntries = commandTranslationEntries(coreDomainCommands);
package/dist/view.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import { ViewExtensionProvider, } from '@formicoidea/labre-core/ext-loader';
2
- import { CoreDomainRendererExtension } from './core-domain/element-renderer';
3
- import { CoreDomainInteraction, CoreDomainView } from './core-domain/element-view';
4
- import { coreDomainToolbarExtension } from './core-domain/toolbar-config';
5
- import { coreDomainEffects } from './effects';
6
- import { coreDomainSeniorTool } from './toolbar/senior-tool';
2
+ import { CommandExtension } from '@formicoidea/labre-core/std';
3
+ import { coreDomainCommandIcons, coreDomainCommands } from './commands.js';
4
+ import { CoreDomainRendererExtension } from './core-domain/element-renderer.js';
5
+ import { CoreDomainInteraction, CoreDomainView } from './core-domain/element-view.js';
6
+ import { coreDomainToolbarExtension } from './core-domain/toolbar-config.js';
7
+ import { coreDomainEffects } from './effects.js';
8
+ import { coreDomainSeniorTool } from './toolbar/senior-tool.js';
7
9
  /**
8
10
  * Core Domain Chart rendering — ALWAYS registered, independent of any flag.
9
11
  * Disabling `ddd-core-domain` hides only the senior toolbar button (see
@@ -46,6 +48,7 @@ export class DddCoreDomainViewExtension extends ViewExtensionProvider {
46
48
  super.setup(context);
47
49
  if (this.isEdgeless(context.scope)) {
48
50
  context.register(coreDomainSeniorTool);
51
+ context.register(CommandExtension(coreDomainCommands, coreDomainCommandIcons));
49
52
  }
50
53
  }
51
54
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formicoidea/labre-framework-ddd-core-domain",
3
3
  "description": "Labre ddd-core-domain framework for @formicoidea/labre-core.",
4
- "version": "0.30.1",
4
+ "version": "0.32.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",
@@ -27,8 +27,8 @@
27
27
  "dist"
28
28
  ],
29
29
  "dependencies": {
30
- "@formicoidea/labre-core": "0.30.1",
31
- "@formicoidea/labre-ddd-shared": "0.30.1",
30
+ "@formicoidea/labre-core": "0.32.0",
31
+ "@formicoidea/labre-ddd-shared": "0.32.0",
32
32
  "lit": "^3.2.0"
33
33
  }
34
34
  }