@formicoidea/labre-framework-c4 0.36.0 → 0.37.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/index.d.ts CHANGED
@@ -14,3 +14,4 @@ export { C4_ELEMENT_MATRIX, C4_RELATIONSHIP_MATRIX, C4_RULES, } from './rules.js
14
14
  export { c4CommandIcons, c4Commands } from './commands.js';
15
15
  export { c4TranslationEntries } from './translations.js';
16
16
  export { C4_AUTO_LEGEND } from './legend.js';
17
+ export { C4_COMPONENT_READING, C4_CONTAINER_READING, C4_PERSON_READING, C4_READINGS, C4_SYSTEM_READING, } from './reading.js';
package/dist/index.js CHANGED
@@ -54,3 +54,4 @@ export { c4TranslationEntries } from './translations.js';
54
54
  // the same reason the two background declarations are: it answers "what does
55
55
  // this framework document about itself" without a canvas.
56
56
  export { C4_AUTO_LEGEND } from './legend.js';
57
+ export { C4_COMPONENT_READING, C4_CONTAINER_READING, C4_PERSON_READING, C4_READINGS, C4_SYSTEM_READING, } from './reading.js';
@@ -0,0 +1,8 @@
1
+ import type { ReadingProfile } from '@formicoidea/labre-core/blocks/surface';
2
+ export declare const C4_PERSON_READING: ReadingProfile;
3
+ export declare const C4_SYSTEM_READING: ReadingProfile;
4
+ /** Covers `c4:database`, the one specialisation in the pack. */
5
+ export declare const C4_CONTAINER_READING: ReadingProfile;
6
+ export declare const C4_COMPONENT_READING: ReadingProfile;
7
+ /** Every C4 profile, in the order the view extension registers them. */
8
+ export declare const C4_READINGS: readonly ReadingProfile[];
@@ -0,0 +1,85 @@
1
+ import { C4_ROLE, C4_ROLES } from './roles.js';
2
+ /**
3
+ * What a C4 diagram lets the tool read of an element (MF3, the reversed
4
+ * reading).
5
+ *
6
+ * DATA, like the rules and the profiles beside it: the engine
7
+ * (`@labre/affine-block-surface`) knows how to read a role and a typed edge — it
8
+ * knows nothing about C4. Everything below is already stated in `roles.ts` and
9
+ * is merely POINTED AT here.
10
+ *
11
+ * Registered from the FLAG-GATED view extension: reading a diagram is tooling,
12
+ * so a board whose C4 flag is off keeps every element it has and simply stops
13
+ * being read (ADR 0009).
14
+ *
15
+ * ## FOUR profiles, because the four levels are deliberately FLAT
16
+ *
17
+ * `roles.ts` argues it at length: the relation between the levels is
18
+ * COMPOSITION ("a container is part of a system"), not specialisation, and
19
+ * `roleIsA` means the second. Filing them in a chain to get one `appliesTo`
20
+ * would make "every rule about a system also falls on every container" true —
21
+ * the opposite of what C4 says — and minting a `c4:element` parent would be
22
+ * inventing an id the notation does not have (ADR 0007: an id is forever).
23
+ *
24
+ * So there is one profile per level, each with an id of its own (the DI keys on
25
+ * it and throws on a duplicate). `c4:database` needs none: it is the one real
26
+ * specialisation in the pack, a kind of container, and is read through the
27
+ * container's profile for free.
28
+ *
29
+ * The BOARD and the BOUNDARY (and its two children) are frames and are not read.
30
+ *
31
+ * ## The name lives on a separate element
32
+ *
33
+ * A C4 element is a composite — a shape, and three tiers of canvas text grouped
34
+ * with it — so every profile points `labelRole` at `c4:title`. Without it the
35
+ * panel would print an id at a human, and the relation lines would name the
36
+ * other end by id too.
37
+ *
38
+ * ## No nature, no phase
39
+ *
40
+ * C4 ships no type-3 tag pack: the levels ARE the roles, and the middle tier of
41
+ * the label (`c4:type-line`) already says the technology in the author's own
42
+ * words. And a board declares which of the three diagrams it draws, not a set of
43
+ * zones a position could be read against.
44
+ */
45
+ /**
46
+ * The two words a relationship is read with, from the subject's end.
47
+ *
48
+ * ADR 0010 tier 1 and this role's own `direction`: the verb is "uses", so the
49
+ * SOURCE is the user. An edge leaving the subject names what it uses; one
50
+ * arriving names what uses it.
51
+ */
52
+ const RELATIONSHIP = {
53
+ edgeRole: C4_ROLE.relationship,
54
+ sides: {
55
+ consumer: {
56
+ labelKey: 'com.labre.c4.reading.relations.consumer',
57
+ labelFallback: 'Used by',
58
+ },
59
+ supplier: {
60
+ labelKey: 'com.labre.c4.reading.relations.supplier',
61
+ labelFallback: 'Uses',
62
+ },
63
+ },
64
+ };
65
+ /** One level, as a profile. The four below differ by `id` and `appliesTo` only. */
66
+ const level = (id, appliesTo) => ({
67
+ id,
68
+ framework: 'c4',
69
+ roles: C4_ROLES,
70
+ appliesTo,
71
+ labelRole: C4_ROLE.title,
72
+ relation: RELATIONSHIP,
73
+ });
74
+ export const C4_PERSON_READING = level('c4-person', C4_ROLE.person);
75
+ export const C4_SYSTEM_READING = level('c4-system', C4_ROLE.system);
76
+ /** Covers `c4:database`, the one specialisation in the pack. */
77
+ export const C4_CONTAINER_READING = level('c4-container', C4_ROLE.container);
78
+ export const C4_COMPONENT_READING = level('c4-component', C4_ROLE.component);
79
+ /** Every C4 profile, in the order the view extension registers them. */
80
+ export const C4_READINGS = [
81
+ C4_PERSON_READING,
82
+ C4_SYSTEM_READING,
83
+ C4_CONTAINER_READING,
84
+ C4_COMPONENT_READING,
85
+ ];
@@ -3,6 +3,7 @@ import { C4_BOARD_BACKGROUND, C4_BOUNDARY_BACKGROUND } from './background.js';
3
3
  import { c4Commands } from './commands.js';
4
4
  import { C4_BOARD_LEVEL_MENU } from './levels.js';
5
5
  import { C4_PROFILES } from './profiles.js';
6
+ import { C4_READINGS } from './reading.js';
6
7
  import { C4_ROLES } from './roles.js';
7
8
  import { C4_RULES } from './rules.js';
8
9
  /**
@@ -45,4 +46,8 @@ commandCategoryTranslationEntries(c4Commands), collectTranslationKeys('role', C4
45
46
  // declaration, so walking the rules reaches keys those two lists already
46
47
  // named. `mergeTranslationEntries` keeps the FIRST occurrence, which is what
47
48
  // makes each key report the source it actually comes from.
48
- collectTranslationKeys('rule', C4_RULES), collectTranslationKeys('profile', C4_PROFILES));
49
+ collectTranslationKeys('rule', C4_RULES), collectTranslationKeys('profile', C4_PROFILES),
50
+ // LAST, for the reason the rules are placed after the roles: a reading
51
+ // profile carries the framework's own `roles` too, so walking it reaches
52
+ // keys the lists above already named, and the first occurrence wins.
53
+ collectTranslationKeys('reading', C4_READINGS));
package/dist/view.js CHANGED
@@ -1,4 +1,4 @@
1
- import { FrameworkBackgroundInteractionExtension, InterchangeExtension, morphToolbarConfig, ValidationProfileExtension, ValidationRuleExtension, } from '@formicoidea/labre-core/blocks/surface';
1
+ import { FrameworkBackgroundInteractionExtension, InterchangeExtension, morphToolbarConfig, ReadingProfileExtension, ValidationProfileExtension, ValidationRuleExtension, } from '@formicoidea/labre-core/blocks/surface';
2
2
  import { ViewExtensionProvider, } from '@formicoidea/labre-core/ext-loader';
3
3
  import { ToolbarModuleExtension, toolbarModuleKey, } from '@formicoidea/labre-core/shared/services';
4
4
  import { BlockFlavourIdentifier, CommandExtension } from '@formicoidea/labre-core/std';
@@ -14,6 +14,7 @@ import { C4NodeRendererExtension } from './node/node-renderer.js';
14
14
  import { C4NodeView } from './node/node-view.js';
15
15
  import { C4TypeLineWatcher } from './node/type-line-watcher.js';
16
16
  import { C4_PROFILES } from './profiles.js';
17
+ import { C4_READINGS } from './reading.js';
17
18
  import { C4_ROLES } from './roles.js';
18
19
  import { C4_RULES } from './rules.js';
19
20
  import { c4BoardToolbarExtension, c4BoardToolingToolbarExtension, } from './toolbar/config.js';
@@ -99,6 +100,14 @@ export class C4ViewExtension extends ViewExtensionProvider {
99
100
  // Tooling like the rest of this class: with the flag off there is nothing
100
101
  // to export WITH, while a stored diagram keeps painting (`docs/adr/0009`).
101
102
  context.register(InterchangeExtension(C4_INTERCHANGE));
103
+ // The reversed reading (MF3): what the diagram says about an element, on
104
+ // demand. Four profiles because the four levels are deliberately FLAT —
105
+ // composition is not specialisation, and `reading.ts` says why a common
106
+ // parent would be a lie. The CLICK that triggers it is registered once by
107
+ // the surface and gated by the presence of a profile.
108
+ for (const reading of C4_READINGS) {
109
+ context.register(ReadingProfileExtension(reading));
110
+ }
102
111
  context.register(c4SeniorTool);
103
112
  context.register(CommandExtension(c4Commands, c4CommandIcons));
104
113
  // The flag-gated half of the selected BOARD's row, through the `custom:`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formicoidea/labre-framework-c4",
3
3
  "description": "Labre c4 framework for @formicoidea/labre-core.",
4
- "version": "0.36.0",
4
+ "version": "0.37.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",
@@ -31,8 +31,8 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@formicoidea/labre-core": "0.36.0",
35
- "@formicoidea/labre-ddd-shared": "0.36.0",
34
+ "@formicoidea/labre-core": "0.37.0",
35
+ "@formicoidea/labre-ddd-shared": "0.37.0",
36
36
  "lit": "^3.2.0"
37
37
  }
38
38
  }