umlimator 0.20.0 → 0.22.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.
@@ -15,8 +15,6 @@
15
15
  Events: the map's select, open and viewchange as umlimator:select, umlimator:open and umlimator:viewchange, the map's
16
16
  event as `detail` (preventDefault() on umlimator:open keeps the view); load each time the map is drawn, error (an
17
17
  ErrorEvent, whose message says why) when it can't be, a model with no view to draw too (its children show again).
18
- shapes: "box", "c4" or "uml", the notation every view is drawn in (0.15.0; without it each view's own); changing it
19
- draws the cards again in the map drawn, with nothing laid out again.
20
18
  `el.map` is render()'s handle once drawn (toSVG(), highlight(), setView(), state ...), else null; `el.loading` is true
21
19
  while a draw waits for its model, when el.map is still the map drawn last. An attribute set to the value it has draws
22
20
  nothing again. */
@@ -25,7 +23,7 @@ import { render } from './umlimator.js';
25
23
  const Base = globalThis.HTMLElement || class {}; // importable where there is no DOM (a docs site's server render)
26
24
 
27
25
  export class UmlimatorMap extends Base {
28
- static observedAttributes = ['src', 'view', 'minimap', 'controls', 'wheel', 'height', 'shapes'];
26
+ static observedAttributes = ['src', 'view', 'minimap', 'controls', 'wheel', 'height'];
29
27
  map = null;
30
28
  #drawn = 0; #due = false; #src = null; #model = null; #loading = false;
31
29
 
@@ -40,7 +38,6 @@ export class UmlimatorMap extends Base {
40
38
  attributeChangedCallback(name, was, now) {
41
39
  if (was === now) return; // set to the value it has: nothing to draw again (0.14.0)
42
40
  if (name === 'height') this.style.height = now == null ? '' : /^\d+(\.\d+)?$/.test(now) ? now + 'px' : now;
43
- else if (name === 'shapes' && this.map && !this.#loading) this.map.shapes = now || null; // the map drawn, in another notation: no new draw
44
41
  else this.#soon();
45
42
  }
46
43
  #soon() { // attributes set together draw once
@@ -81,7 +78,7 @@ export class UmlimatorMap extends Base {
81
78
  if (!this.dispatchEvent(new CustomEvent('umlimator:' + t, { detail: e, bubbles: true, composed: true, cancelable: t === 'open' }))) e.preventDefault();
82
79
  }]));
83
80
  try {
84
- this.map = render(box, model, { view: get('view') || undefined, minimap: this.hasAttribute('minimap') && get('minimap') !== 'false', controls: get('controls') !== 'false', wheel: get('wheel') === 'ctrl' ? 'ctrl' : 'zoom', shapes: get('shapes') || undefined, on });
81
+ this.map = render(box, model, { view: get('view') || undefined, minimap: this.hasAttribute('minimap') && get('minimap') !== 'false', controls: get('controls') !== 'false', wheel: get('wheel') === 'ctrl' ? 'ctrl' : 'zoom', on });
85
82
  } catch (err) { return this.#fail(err); }
86
83
  if (this.map.view == null) return this.#fail(new Error(`${src || 'the inline model'}: the model has no view to draw`)); // drawn, with nothing to see: an error, not a load (0.14.0)
87
84
  this.#loading = false;
@@ -18,15 +18,11 @@ export interface MapModel {
18
18
  stories?: Story[];
19
19
  /** Saved ways to look at the map (#94): handle.lens(id), the standalone page's Lenses menu and #lens=<id>. */
20
20
  lenses?: Lens[];
21
- /** The notation every view's cards are drawn in (0.15.0; a view's own `shapes` wins). Default 'box'. */
22
- shapes?: Notation;
23
21
  [key: string]: unknown;
24
22
  }
25
- /** How cards are drawn (0.15.0): box (every card a rounded box, the default), c4 (people, browser apps, phones, databases,
26
- * queues and files as the C4 model's tools draw them) or uml (UML 2.5's actor, node, artifact, package and data store,
27
- * and the component icon on a box). Each shape keeps to its card's box: the layout is the same in every notation. */
28
- export type Notation = 'box' | 'c4' | 'uml';
29
- /** A card's shape (0.15.0). */
23
+ /** A card's shape (0.15.0). A map draws each card in one style (0.21.0; the box/c4/uml choice and `shapes` are gone):
24
+ * by its kind (people, browser apps, phones, terminals, queues, packages, hosts, robots, data stores, files and hooks),
25
+ * a rounded box where no shape says more. Each shape keeps to its card's box: the layout is the same as a box's. */
30
26
  export type Shape = 'box' | 'person' | 'browser' | 'mobile' | 'cylinder' | 'pipe' | 'document' | 'hexagon' | 'robot' | 'terminal' | 'window' | 'folder' | 'node';
31
27
  /** A badge: its text, and optionally a palette name for its colour (green, amber, rose, accent, violet ... : --um-<tone>). */
32
28
  export type Badge = string | { text: string; tone?: string };
@@ -40,7 +36,7 @@ export interface MapNode {
40
36
  opensCount?: number;
41
37
  /** Who owns the card (a team, say): selectors pick by it, and a lens with color 'owner' rings the card in its owner's tone. */
42
38
  owner?: string;
43
- /** The card's own shape, in every notation (0.15.0); without it, the notation draws the card by its kind. */
39
+ /** The card's own shape (0.15.0); without it, a map draws the card by its kind. */
44
40
  shape?: Shape;
45
41
  /** In schema version 2 (0.17.0) a node may also be a typed Element: type, parent, props, members. */
46
42
  [key: string]: unknown;
@@ -48,7 +44,7 @@ export interface MapNode {
48
44
  /** A typed element in schema version 2's envelope (docs/diagrams/model.md §1): a node, a member, a typed edge, a
49
45
  * fragment. Nodes, edges, members and fragments share one id space; an id never contains "->". A typed edge is an
50
46
  * Element with `from` and `to`, which may name a member. A typed view is a MapView with `diagram` (uml.class), and may
51
- * have `subject`, `direction` ('right' | 'down'), `notation`, `present`, `fragments` and `timeline`. umlimator/all draws `uml.class` (0.18.0), `uml.object` and `uml.package` (0.19.0), `uml.sequence` and `uml.communication` (0.20.0); other types draw as plain cards.
47
+ * have `subject`, `direction` ('right' | 'down'), `notation`, `present`, `fragments` and `timeline`. umlimator/all draws `uml.class` (0.18.0), `uml.object` and `uml.package` (0.19.0), `uml.sequence` and `uml.communication` (0.20.0), `uml.use-case`, `uml.activity`, `uml.state-machine` and `uml.interaction-overview` (0.21.0), `uml.component`, `uml.deployment` and `uml.composite-structure` (0.22.0); other types draw as plain cards.
52
48
  * From 0.19.0 the class, object and package types draw a shown package that owns something the view shows as a box holding it (`parent`), and
53
49
  * qualify names (`sales::Order`) from the nearest shown owner, the view's `subject`, or the top. */
54
50
  export interface Element {
@@ -98,7 +94,7 @@ export type UmlPackageLineType = 'uml.PackageImport' | 'uml.PackageMerge' | 'uml
98
94
  export interface UmlPackageImportProps { visibility?: 'public' | 'private'; stereotypes?: string[]; [key: string]: unknown }
99
95
  /** What a typed view shows of one element, in its `present` by the element's id: compartments not drawn, divider and
100
96
  * all, and at most `rows` rows in each, then "+k more". */
101
- export interface UmlPresent { collapsed?: ('attributes' | 'operations' | 'literals')[]; rows?: number }
97
+ export interface UmlPresent { collapsed?: ('attributes' | 'operations' | 'literals' | 'activities')[]; rows?: number }
102
98
  /** The sequence diagram's vocabulary (a view with `diagram: 'uml.sequence'`, umlimator/all from 0.20.0;
103
99
  * docs/conformance/uml-sequence.md). Lifelines are model nodes the view lists in `nodeIds`, left to right. Messages and
104
100
  * interaction uses are inline in the view's `edges`, in time order; a fragment's content is one run there, operand by
@@ -126,6 +122,78 @@ export interface UmlCombinedFragmentProps { operator?: UmlInteractionOperator; [
126
122
  * props are UmlMessageProps; a message needs a connector between its two lifelines. */
127
123
  export type UmlCommunicationElementType = 'uml.Lifeline';
128
124
  export type UmlCommunicationLineType = 'uml.Connector' | 'uml.Message';
125
+ /** The use case diagram's vocabulary (a view with `diagram: 'uml.use-case'`, umlimator/all from 0.21.0;
126
+ * docs/conformance/uml-use-case.md). A use case's `parent` is a subject (drawn as a box holding it) or a package. An
127
+ * extend runs from the extending use case to the one it extends; an include from the including one. */
128
+ export type UmlUseCaseElementType = 'uml.Actor' | 'uml.UseCase' | 'uml.Subject' | 'uml.Comment';
129
+ export type UmlUseCaseMemberType = 'uml.ExtensionPoint';
130
+ export type UmlUseCaseLineType = 'uml.Association' | 'uml.Include' | 'uml.Extend' | 'uml.Generalization' | 'uml.CommentLink';
131
+ /** An extend's props: the ids of the extended use case's extension points (one at least), and its condition, as text. */
132
+ export interface UmlExtendProps { extensionPoints?: string[]; condition?: string; stereotypes?: string[]; [key: string]: unknown }
133
+ /** The activity diagram's vocabulary (a view with `diagram: 'uml.activity'`, umlimator/all from 0.21.0;
134
+ * docs/conformance/uml-activity.md). A node's `parent` is its partition, drawn as a lane; a partition's is the
135
+ * partition it is nested in. A call behaviour action's `opensView` names an activity view. */
136
+ export type UmlActivityElementType = 'uml.InitialNode' | 'uml.ActivityFinalNode' | 'uml.FlowFinalNode' | 'uml.Action' | 'uml.CallBehaviorAction'
137
+ | 'uml.SendSignalAction' | 'uml.AcceptEventAction' | 'uml.DecisionNode' | 'uml.MergeNode' | 'uml.ForkNode' | 'uml.JoinNode'
138
+ | 'uml.ObjectNode' | 'uml.DataStoreNode' | 'uml.ActivityPartition' | 'uml.Comment';
139
+ export type UmlActivityLineType = 'uml.ControlFlow' | 'uml.ObjectFlow' | 'uml.CommentLink';
140
+ /** A flow's props (activity and interaction overview): its guard, as text, drawn `name [guard]`; its label is its name. */
141
+ export interface UmlFlowProps { guard?: string; stereotypes?: string[]; [key: string]: unknown }
142
+ /** The state machine diagram's vocabulary (a view with `diagram: 'uml.state-machine'`, umlimator/all from 0.21.0;
143
+ * docs/conformance/uml-state-machine.md). A substate's or pseudostate's `parent` is a state, or a region (a member) of
144
+ * one; a state with shown substates is drawn as a box, each region that holds something shown as a box inside it. */
145
+ export type UmlStateMachineElementType = 'uml.State' | 'uml.Pseudostate' | 'uml.FinalState' | 'uml.Comment';
146
+ export type UmlStateMachineMemberType = 'uml.Region' | 'uml.InternalTransition';
147
+ export type UmlStateMachineLineType = 'uml.Transition' | 'uml.CommentLink';
148
+ export interface UmlStateProps { entry?: string; do?: string; exit?: string; stereotypes?: string[]; [key: string]: unknown }
149
+ export type UmlPseudostateKind = 'initial' | 'choice' | 'junction' | 'fork' | 'join' | 'shallowHistory' | 'deepHistory' | 'terminate';
150
+ export interface UmlPseudostateProps { kind?: UmlPseudostateKind; stereotypes?: string[]; [key: string]: unknown }
151
+ /** A transition's or an internal transition's props, each text, drawn `trigger [guard] / effect`. */
152
+ export interface UmlTransitionProps { trigger?: string; guard?: string; effect?: string; stereotypes?: string[]; [key: string]: unknown }
153
+ /** The interaction overview diagram's vocabulary (a view with `diagram: 'uml.interaction-overview'`, umlimator/all from
154
+ * 0.21.0; docs/conformance/uml-interaction-overview.md): the activity's control nodes and flows (UmlFlowProps), and
155
+ * interaction uses (drawn `ref`) and inline interactions (drawn `sd` with their content), whose `opensView` names a
156
+ * `uml.sequence` view of the same model. */
157
+ export type UmlInteractionOverviewElementType = 'uml.InitialNode' | 'uml.ActivityFinalNode' | 'uml.FlowFinalNode' | 'uml.DecisionNode'
158
+ | 'uml.MergeNode' | 'uml.ForkNode' | 'uml.JoinNode' | 'uml.InteractionUse' | 'uml.Interaction' | 'uml.Comment';
159
+ export type UmlInteractionOverviewLineType = 'uml.ControlFlow' | 'uml.CommentLink';
160
+ /** The component diagram's vocabulary (a view with `diagram: 'uml.component'`, umlimator/all from 0.22.0;
161
+ * docs/conformance/uml-component.md). A component's `parent` is a component (drawn nested, a box) or a package; its
162
+ * ports (a class's too) are members, drawn on its border. A provided interface is always an `uml.Interface` node, joined
163
+ * to its provider (a component, a class or a port) by a realization and to its requirers by usages; `present.<id>.as:
164
+ * 'ball'` draws it as a ball, a usage to it ending in a socket. */
165
+ export type UmlComponentElementType = 'uml.Component' | 'uml.Interface' | 'uml.Artifact' | 'uml.Package' | 'uml.Comment';
166
+ export type UmlComponentMemberType = 'uml.Port';
167
+ export type UmlComponentLineType = 'uml.InterfaceRealization' | 'uml.ComponentRealization' | 'uml.Usage' | 'uml.Connector' | 'uml.Dependency'
168
+ | 'uml.Manifestation' | 'uml.CommentLink';
169
+ /** A port's props: its type, drawn `name : Type` beside it. */
170
+ export interface UmlPortProps { valueType?: string; stereotypes?: string[]; [key: string]: unknown }
171
+ /** A connector's props: in a component view its kind (an assembly when left out); in a composite structure view, an end
172
+ * through a part (UML's partWithPort): `ends.from.part` or `ends.to.part` names the part, `from` or `to` the port of its type. */
173
+ export interface UmlConnectorProps { kind?: 'assembly' | 'delegation'; ends?: { from?: { part?: string }; to?: { part?: string } }; stereotypes?: string[]; [key: string]: unknown }
174
+ /** What a component or composite structure view shows of one element, beside UmlPresent: an interface as a ball; a port's
175
+ * side; on a part, each of its type's ports' sides. */
176
+ export interface UmlStructurePresent { as?: 'ball'; side?: 'left' | 'right' | 'top' | 'bottom'; ports?: Record<string, { side?: 'left' | 'right' | 'top' | 'bottom' }> }
177
+ /** The deployment diagram's vocabulary (a view with `diagram: 'uml.deployment'`, umlimator/all from 0.22.0;
178
+ * docs/conformance/uml-deployment.md). A node, device or execution environment that holds something shown is a box drawn
179
+ * as a cube; an artifact or deployment specification whose `parent` is one is deployed on it, a `uml.Deployment` line
180
+ * from it to one is the other form. */
181
+ export type UmlDeploymentElementType = 'uml.Node' | 'uml.Device' | 'uml.ExecutionEnvironment' | 'uml.Artifact' | 'uml.DeploymentSpecification'
182
+ | 'uml.Component' | 'uml.Comment';
183
+ export type UmlDeploymentLineType = 'uml.Deployment' | 'uml.Manifestation' | 'uml.CommunicationPath' | 'uml.Dependency' | 'uml.CommentLink';
184
+ /** The composite structure diagram's vocabulary (a view with `diagram: 'uml.composite-structure'`, umlimator/all from
185
+ * 0.22.0; docs/conformance/uml-composite-structure.md). The view's `subject` (a class, component or collaboration, listed
186
+ * in `nodeIds`) is drawn as a box holding its parts (`uml.Property` members) and collaboration uses (`parent` the
187
+ * subject); a part shows the ports of the class or component its `valueType` names by label, each drawn under the id
188
+ * `<part>-><port>`. An open collaboration (listed in `nodeIds`) is a dashed ellipse round its roles. A role binding runs
189
+ * from a part to a collaboration use, its `label` the role. */
190
+ export type UmlCompositeStructureElementType = 'uml.Class' | 'uml.Component' | 'uml.Collaboration' | 'uml.CollaborationUse' | 'uml.Comment';
191
+ export type UmlCompositeStructureMemberType = 'uml.Property' | 'uml.Port';
192
+ export type UmlCompositeStructureLineType = 'uml.Connector' | 'uml.RoleBinding' | 'uml.CommentLink';
193
+ /** A part's (or role's) props: the class or component it is, by label; its multiplicity; shared parts are drawn dashed. */
194
+ export interface UmlPartProps { valueType?: string; multiplicity?: string; aggregation?: 'composite' | 'shared'; stereotypes?: string[]; [key: string]: unknown }
195
+ /** A collaboration use's props: the collaboration it uses, by label. */
196
+ export interface UmlCollaborationUseProps { collaboration?: string; stereotypes?: string[]; [key: string]: unknown }
129
197
  /** What a line means, drawn as its colour: calls (the default), feeds (hands work on), triggers (suggests, offers, fires),
130
198
  * state (reads or writes a file, board or config: a thinner line, a muted label, no flow) and guard (a hook steps in).
131
199
  * Colours are --um-w-<kind>. An edge's `style` (emphasis, dashed, security) wins over its kind's colour. */
@@ -177,8 +245,6 @@ export interface MapView {
177
245
  /** Boxes: badges are tabs on the box's border; tone, a palette name as a badge's (--um-<tone>), tints the region behind the
178
246
  * box (as deep as --um-tint makes the cards), with its border dashed and its title in the tone. */
179
247
  containers?: { id: string; label?: string; nodeIds?: string[]; parent?: string; badges?: Badge[]; tone?: string }[];
180
- /** The notation this view's cards are drawn in (0.15.0): it wins over the model's. */
181
- shapes?: Notation;
182
248
  [key: string]: unknown;
183
249
  }
184
250
 
@@ -233,7 +299,6 @@ export interface MapState {
233
299
  paused: boolean;
234
300
  camera: { x: number; y: number; zoom: number }; // the centre in map units, and the zoom (1: actual size); a state event's: at rest
235
301
  flow: boolean;
236
- shapes: Notation; // the notation the view shown is drawn in (0.15.0)
237
302
  motion: 'full' | 'reduced' | 'instant';
238
303
  gesture: 'idle' | 'dragging' | 'connecting' | 'naming'; // an edit in progress (editable maps)
239
304
  destroyed: boolean;
@@ -262,8 +327,6 @@ export interface RenderOptions {
262
327
  wheel?: 'zoom' | 'ctrl';
263
328
  minimap?: boolean; // default false
264
329
  flow?: boolean; // animated flow along lines (default: on unless prefers-reduced-motion)
265
- /** The notation every view is drawn in (0.15.0), over each view's and the model's own. */
266
- shapes?: Notation;
267
330
  /** Text widths: default the host's font (--um-sans, measured on a canvas); false: a font-independent estimate. */
268
331
  measure?: false | ((text: string, px: number) => number);
269
332
  /** Edit gestures that emit `change` events: all of them, or only those set true. Off by default. */
@@ -336,10 +399,6 @@ export interface Handle {
336
399
  readonly destroyed: boolean;
337
400
  /** The animated flow along lines (the ≋ button and F), to read or set. */
338
401
  flow: boolean;
339
- /** The notation the view shown is drawn in (0.15.0). Set it to draw every view in one (null: each view's own): the
340
- * cards are drawn again from the geometry they have, with the camera, selection, lens and marks; nothing is laid out. */
341
- get shapes(): Notation;
342
- set shapes(notation: Notation | null);
343
402
  /** How this map moves: 'instant' (drawn without animation, as the page's #check, #still and #shot are), 'reduced' (the
344
403
  * reader's setting), else 'full'. */
345
404
  readonly motion: 'full' | 'reduced' | 'instant';