@formicoidea/labre-framework-ddd-context-map 0.25.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,7 @@
1
+ import { DddContextMapViewExtension } from './view.js';
2
+ /** Host wiring for the ddd-context-map framework. */
3
+ export declare const dddContextMapFramework: {
4
+ readonly flag: "ddd-context-map";
5
+ readonly telemetry: "ddd-context-map";
6
+ readonly viewExtension: typeof DddContextMapViewExtension;
7
+ };
@@ -0,0 +1,7 @@
1
+ import { DddContextMapViewExtension } from './view.js';
2
+ /** Host wiring for the ddd-context-map framework. */
3
+ export const dddContextMapFramework = {
4
+ flag: 'ddd-context-map',
5
+ telemetry: 'ddd-context-map',
6
+ viewExtension: DddContextMapViewExtension,
7
+ };
@@ -0,0 +1,9 @@
1
+ import { EdgelessDddContextMapMenu } from './toolbar/context-map-menu';
2
+ import { EdgelessDddContextMapSeniorButton } from './toolbar/senior-button';
3
+ export declare function contextMapEffects(): void;
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ 'edgeless-ddd-context-map-menu': EdgelessDddContextMapMenu;
7
+ 'edgeless-ddd-context-map-senior-button': EdgelessDddContextMapSeniorButton;
8
+ }
9
+ }
@@ -0,0 +1,11 @@
1
+ import { EdgelessDddContextMapMenu } from './toolbar/context-map-menu';
2
+ import { EdgelessDddContextMapSeniorButton } from './toolbar/senior-button';
3
+ /** Define a custom element once (each tool's effect may run more than once). */
4
+ function define(tag, ctor) {
5
+ if (!customElements.get(tag))
6
+ customElements.define(tag, ctor);
7
+ }
8
+ export function contextMapEffects() {
9
+ define('edgeless-ddd-context-map-menu', EdgelessDddContextMapMenu);
10
+ define('edgeless-ddd-context-map-senior-button', EdgelessDddContextMapSeniorButton);
11
+ }
@@ -0,0 +1,4 @@
1
+ export { contextMapTemplateCategory } from './templates.js';
2
+ export { contextMapSeniorTool } from './toolbar/senior-tool.js';
3
+ export { EdgelessDddContextMapSeniorButton } from './toolbar/senior-button.js';
4
+ export { DddContextMapViewExtension } from './view.js';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { contextMapTemplateCategory } from './templates.js';
2
+ export { contextMapSeniorTool } from './toolbar/senior-tool.js';
3
+ export { EdgelessDddContextMapSeniorButton } from './toolbar/senior-button.js';
4
+ export { DddContextMapViewExtension } from './view.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Context Map Templates-panel category. The builder lives in the shared package
3
+ * so the aggregate package can register all DDD categories under the single
4
+ * `ddd-templates` flag; re-exported here for a stable per-package API.
5
+ */
6
+ export { contextMapTemplateCategory } from '@formicoidea/labre-ddd-shared';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Context Map Templates-panel category. The builder lives in the shared package
3
+ * so the aggregate package can register all DDD categories under the single
4
+ * `ddd-templates` flag; re-exported here for a stable per-package API.
5
+ */
6
+ export { contextMapTemplateCategory } from '@formicoidea/labre-ddd-shared';
@@ -0,0 +1,10 @@
1
+ import { DddMenuBase } from '@formicoidea/labre-ddd-shared';
2
+ /** Context Map palette: bounded-context bubble, the cloud, the nine relationship patterns. */
3
+ export declare class EdgelessDddContextMapMenu extends DddMenuBase {
4
+ protected framework: "context-map";
5
+ private _createBubble;
6
+ private _createCloud;
7
+ private _createRelationship;
8
+ private _createLegend;
9
+ render(): import("lit-html").TemplateResult<1>;
10
+ }
@@ -0,0 +1,107 @@
1
+ import { addBubble, addCloud, addLegend, addRelationship, CLOUD, CM_BUBBLE, CM_RELATIONSHIPS, DddMenuBase, } from '@formicoidea/labre-ddd-shared';
2
+ import { html, svg } from 'lit';
3
+ const bubbleSwatch = svg `<svg viewBox="0 0 24 24" fill="none"><rect x="2" y="7" width="20" height="10" rx="5" fill="#e6f0fa" stroke="#2f6fb0" stroke-width="1.6"/></svg>`;
4
+ const cloudSwatch = svg `<svg viewBox="0 0 24 24" fill="none"><path d="M6 17 C3 17 2 14 4.5 12.5 C4 9 8 8 9.5 10 C11 6.5 16 7.5 16 11 C19 10.5 20.5 14 18 16 C18 17 16.5 17 15 17 Z" fill="#f0eef6" stroke="#6d6e71" stroke-width="1.4"/></svg>`;
5
+ const legendSwatch = svg `<svg viewBox="0 0 24 24" fill="none"><rect x="3" y="4" width="18" height="16" rx="2" stroke="currentColor" stroke-width="1.6"/><circle cx="7" cy="9" r="1.6" fill="currentColor"/><circle cx="7" cy="14" r="1.6" fill="currentColor"/><path d="M11 9 H18 M11 14 H18" stroke="currentColor" stroke-width="1.4"/></svg>`;
6
+ const relationSwatch = (dashed, arrow) => svg `<svg viewBox="0 0 24 24" fill="none"><path d="M3 12 H${arrow ? 17 : 21}" stroke="currentColor" stroke-width="2" stroke-dasharray="${dashed ? '3 3' : '0'}"/>${arrow ? svg `<path d="M15 8 L21 12 L15 16" stroke="currentColor" stroke-width="2" fill="none"/>` : ''}</svg>`;
7
+ /** Context Map palette: bounded-context bubble, the cloud, the nine relationship patterns. */
8
+ export class EdgelessDddContextMapMenu extends DddMenuBase {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.framework = 'context-map';
12
+ }
13
+ _createBubble() {
14
+ const surface = this.surface;
15
+ if (!surface)
16
+ return;
17
+ const { cx, cy } = this.center;
18
+ const id = addBubble(surface, this.edgeless.std, cx, cy, 'Bounded Context');
19
+ this.track('FrameworkElementAdded', 'bounded-context');
20
+ this.finish(id);
21
+ }
22
+ _createCloud() {
23
+ const surface = this.surface;
24
+ if (!surface)
25
+ return;
26
+ const { cx, cy } = this.center;
27
+ const id = addCloud(surface, this.edgeless.std, cx, cy, 'System');
28
+ this.track('FrameworkElementAdded', 'cloud');
29
+ this.finish(id);
30
+ }
31
+ _createRelationship(preset) {
32
+ const surface = this.surface;
33
+ if (!surface)
34
+ return;
35
+ const { cx, cy } = this.center;
36
+ const id = addRelationship(surface, this.edgeless.std, cx, cy, preset);
37
+ this.track('FrameworkElementAdded', `relationship:${preset.kind}`);
38
+ this.finish(id);
39
+ }
40
+ _createLegend() {
41
+ const surface = this.surface;
42
+ if (!surface)
43
+ return;
44
+ const { cx, cy } = this.center;
45
+ const patRows = (kinds) => CM_RELATIONSHIPS.filter(r => kinds.includes(r.kind)).map((r) => ({
46
+ swatch: 'line',
47
+ color: '#1f2328',
48
+ label: `${r.abbrev} — ${r.label}`,
49
+ }));
50
+ const sections = [
51
+ {
52
+ title: 'Boundaries',
53
+ rows: [
54
+ { swatch: 'square', color: CM_BUBBLE.fill, label: 'Bounded Context' },
55
+ { swatch: 'square', color: CLOUD.fill, label: 'System / Big Ball of Mud' },
56
+ ],
57
+ },
58
+ { title: 'Mutually dependent', rows: patRows(['partnership', 'sharedKernel']) },
59
+ {
60
+ title: 'Upstream → Downstream (U/D)',
61
+ rows: patRows(['customerSupplier', 'conformist', 'acl', 'ohs', 'publishedLanguage']),
62
+ },
63
+ { title: 'Separate / no integration', rows: patRows(['separateWays', 'bbom']) },
64
+ ];
65
+ const id = addLegend(surface, this.edgeless.std, cx - 140, cy - 210, {
66
+ title: 'Légende',
67
+ sections,
68
+ width: 290,
69
+ });
70
+ this.track('FrameworkElementAdded', 'legend');
71
+ this.finish(id);
72
+ }
73
+ render() {
74
+ return html `
75
+ <edgeless-slide-menu>
76
+ <div class="menu-content">
77
+ <div class="button-group-container">
78
+ <edgeless-tool-icon-button
79
+ .tooltip=${'Bounded Context'}
80
+ @click=${() => this._createBubble()}
81
+ >
82
+ ${bubbleSwatch}
83
+ </edgeless-tool-icon-button>
84
+ <edgeless-tool-icon-button
85
+ .tooltip=${'Cloud / System (Big Ball of Mud)'}
86
+ @click=${() => this._createCloud()}
87
+ >
88
+ ${cloudSwatch}
89
+ </edgeless-tool-icon-button>
90
+ ${CM_RELATIONSHIPS.map(preset => html `<edgeless-tool-icon-button
91
+ .tooltip=${preset.label}
92
+ @click=${() => this._createRelationship(preset)}
93
+ >
94
+ ${relationSwatch(preset.dashed, preset.upDown)}
95
+ </edgeless-tool-icon-button>`)}
96
+ <edgeless-tool-icon-button
97
+ .tooltip=${'Legend'}
98
+ @click=${() => this._createLegend()}
99
+ >
100
+ ${legendSwatch}
101
+ </edgeless-tool-icon-button>
102
+ </div>
103
+ </div>
104
+ </edgeless-slide-menu>
105
+ `;
106
+ }
107
+ }
@@ -0,0 +1,6 @@
1
+ import { DddSeniorButtonBase } from '@formicoidea/labre-ddd-shared';
2
+ export declare class EdgelessDddContextMapSeniorButton extends DddSeniorButtonBase {
3
+ protected menuTag: "edgeless-ddd-context-map-menu";
4
+ protected label: string;
5
+ protected icon: import("lit-html").TemplateResult<2>;
6
+ }
@@ -0,0 +1,9 @@
1
+ import { contextMapToolbarIcon, DddSeniorButtonBase, } from '@formicoidea/labre-ddd-shared';
2
+ export class EdgelessDddContextMapSeniorButton extends DddSeniorButtonBase {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.menuTag = 'edgeless-ddd-context-map-menu';
6
+ this.label = 'Context Map';
7
+ this.icon = contextMapToolbarIcon;
8
+ }
9
+ }
@@ -0,0 +1,2 @@
1
+ /** Independent senior tool — Context Map. */
2
+ export declare const contextMapSeniorTool: import("@formicoidea/labre-core/store").ExtensionType;
@@ -0,0 +1,9 @@
1
+ import { SeniorToolExtension } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
2
+ import { html } from 'lit';
3
+ /** Independent senior tool — Context Map. */
4
+ export const contextMapSeniorTool = SeniorToolExtension('ddd-context-map', ({ block }) => ({
5
+ name: 'Context Map',
6
+ content: html `<edgeless-ddd-context-map-senior-button
7
+ .edgeless=${block}
8
+ ></edgeless-ddd-context-map-senior-button>`,
9
+ }));
package/dist/view.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { type ViewExtensionContext, ViewExtensionProvider } from '@formicoidea/labre-core/ext-loader';
2
+ /**
3
+ * Context Map — independently flag-gated (`ddd-context-map`).
4
+ *
5
+ * Note: its Templates-panel category is registered by the aggregate package's
6
+ * {@link DddTemplatesViewExtension} (gated by `ddd-templates`), so templates
7
+ * stay available even when this senior button is disabled.
8
+ */
9
+ export declare class DddContextMapViewExtension extends ViewExtensionProvider {
10
+ name: string;
11
+ effect(): void;
12
+ setup(context: ViewExtensionContext): void;
13
+ }
package/dist/view.js ADDED
@@ -0,0 +1,26 @@
1
+ import { ViewExtensionProvider, } from '@formicoidea/labre-core/ext-loader';
2
+ import { contextMapEffects } from './effects';
3
+ import { contextMapSeniorTool } from './toolbar/senior-tool';
4
+ /**
5
+ * Context Map — independently flag-gated (`ddd-context-map`).
6
+ *
7
+ * Note: its Templates-panel category is registered by the aggregate package's
8
+ * {@link DddTemplatesViewExtension} (gated by `ddd-templates`), so templates
9
+ * stay available even when this senior button is disabled.
10
+ */
11
+ export class DddContextMapViewExtension extends ViewExtensionProvider {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.name = 'affine-ddd-context-map-gfx';
15
+ }
16
+ effect() {
17
+ super.effect();
18
+ contextMapEffects();
19
+ }
20
+ setup(context) {
21
+ super.setup(context);
22
+ if (this.isEdgeless(context.scope)) {
23
+ context.register(contextMapSeniorTool);
24
+ }
25
+ }
26
+ }
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@formicoidea/labre-framework-ddd-context-map",
3
+ "description": "Labre ddd-context-map framework for @formicoidea/labre-core.",
4
+ "version": "0.25.0",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "author": "lajola",
8
+ "contributors": [
9
+ "toeverything"
10
+ ],
11
+ "license": "MPL-2.0",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ },
17
+ "./view": {
18
+ "types": "./dist/view.d.ts",
19
+ "import": "./dist/view.js"
20
+ },
21
+ "./descriptor": {
22
+ "types": "./dist/descriptor.d.ts",
23
+ "import": "./dist/descriptor.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "dependencies": {
30
+ "@formicoidea/labre-core": "0.25.0",
31
+ "@formicoidea/labre-ddd-shared": "0.25.0",
32
+ "lit": "^3.2.0"
33
+ }
34
+ }