umlimator 0.19.0 → 0.21.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/README.md +77 -24
- package/lib/umlimator-all.js +3527 -189
- package/lib/umlimator-element.js +2 -5
- package/lib/umlimator.d.ts +71 -21
- package/lib/umlimator.js +108 -154
- package/lib/umlimator.schema.json +190 -35
- package/package.json +2 -2
package/lib/umlimator-element.js
CHANGED
|
@@ -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'
|
|
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',
|
|
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;
|
package/lib/umlimator.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
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
|
|
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,8 +44,8 @@ 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); other types draw as plain cards.
|
|
52
|
-
* From 0.19.0
|
|
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); other types draw as plain cards.
|
|
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 {
|
|
55
51
|
id: string; type: string; label?: string; parent?: string; props?: Record<string, unknown>; members?: Element[];
|
|
@@ -98,7 +94,69 @@ 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 }
|
|
98
|
+
/** The sequence diagram's vocabulary (a view with `diagram: 'uml.sequence'`, umlimator/all from 0.20.0;
|
|
99
|
+
* docs/conformance/uml-sequence.md). Lifelines are model nodes the view lists in `nodeIds`, left to right. Messages and
|
|
100
|
+
* interaction uses are inline in the view's `edges`, in time order; a fragment's content is one run there, operand by
|
|
101
|
+
* operand. Combined fragments are in the view's `fragments`, each with its operands as `members`; an occurrence's or a
|
|
102
|
+
* fragment's `parent` is the operand that holds it. Activations and message numbers are derived, never stored. */
|
|
103
|
+
export type UmlSequenceElementType = 'uml.Lifeline' | 'uml.InteractionUse' | 'uml.CombinedFragment';
|
|
104
|
+
export type UmlSequenceMemberType = 'uml.InteractionOperand';
|
|
105
|
+
export type UmlSequenceLineType = 'uml.Message';
|
|
106
|
+
/** A lifeline's props: what it represents, by name, as text (drawn `name : Type`); stereotype `actor` draws «actor». */
|
|
107
|
+
export interface UmlLifelineProps { represents?: string; stereotypes?: string[]; [key: string]: unknown }
|
|
108
|
+
/** A message's kind: a call (filled arrow, the default), async (open arrow), reply (dashed, open), create (dashed, open;
|
|
109
|
+
* the receiver's head is lowered to it) or delete (the receiver's stem ends in a cross). */
|
|
110
|
+
export type UmlMessageSort = 'call' | 'async' | 'reply' | 'create' | 'delete';
|
|
111
|
+
/** A message's props: its sort; a reply's `replyTo`, the id of the earlier call it answers. */
|
|
112
|
+
export interface UmlMessageProps { sort?: UmlMessageSort; replyTo?: string; stereotypes?: string[]; [key: string]: unknown }
|
|
113
|
+
/** An interaction use's props: the lifelines it covers (next to each other in `nodeIds`), and the view it refers to. */
|
|
114
|
+
export interface UmlInteractionUseProps { covers?: string[]; refersTo?: string; [key: string]: unknown }
|
|
115
|
+
/** A combined fragment's operator; any other is drawn by its name, with a warning. opt, loop and break have one operand,
|
|
116
|
+
* whose `label` is its guard. */
|
|
117
|
+
export type UmlInteractionOperator = 'alt' | 'opt' | 'loop' | 'par' | 'break';
|
|
118
|
+
export interface UmlCombinedFragmentProps { operator?: UmlInteractionOperator; [key: string]: unknown }
|
|
119
|
+
/** The communication diagram's vocabulary (a view with `diagram: 'uml.communication'`, umlimator/all from 0.20.0;
|
|
120
|
+
* docs/conformance/uml-communication.md): lifelines; connectors and messages are model edges the view's `edges` lists,
|
|
121
|
+
* connectors first. Only the messages' order means anything; their numbers (1, 1.1, 1.1.2) are derived. A message's
|
|
122
|
+
* props are UmlMessageProps; a message needs a connector between its two lifelines. */
|
|
123
|
+
export type UmlCommunicationElementType = 'uml.Lifeline';
|
|
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';
|
|
102
160
|
/** What a line means, drawn as its colour: calls (the default), feeds (hands work on), triggers (suggests, offers, fires),
|
|
103
161
|
* state (reads or writes a file, board or config: a thinner line, a muted label, no flow) and guard (a hook steps in).
|
|
104
162
|
* Colours are --um-w-<kind>. An edge's `style` (emphasis, dashed, security) wins over its kind's colour. */
|
|
@@ -139,7 +197,8 @@ export interface MapEdge {
|
|
|
139
197
|
}
|
|
140
198
|
export interface MapView {
|
|
141
199
|
id: string; parent?: string | null; title?: string; nodeIds: string[];
|
|
142
|
-
|
|
200
|
+
/** Model line ids or lines of its own; in a sequence view (0.20.0) its messages and interaction uses (Elements), in time order. */
|
|
201
|
+
edges?: (string | MapEdge | Element)[]; layout?: Record<string, [number, number]>; repair?: boolean;
|
|
143
202
|
/** Cards 80 px tall that show their sub-line and then their chips (`verbs`) on a third line. Default: 64 px, and a card's
|
|
144
203
|
* chips take its sub-line's place. A script card (no kind) shows no sub-line either way. */
|
|
145
204
|
subAndChips?: boolean;
|
|
@@ -149,8 +208,6 @@ export interface MapView {
|
|
|
149
208
|
/** Boxes: badges are tabs on the box's border; tone, a palette name as a badge's (--um-<tone>), tints the region behind the
|
|
150
209
|
* box (as deep as --um-tint makes the cards), with its border dashed and its title in the tone. */
|
|
151
210
|
containers?: { id: string; label?: string; nodeIds?: string[]; parent?: string; badges?: Badge[]; tone?: string }[];
|
|
152
|
-
/** The notation this view's cards are drawn in (0.15.0): it wins over the model's. */
|
|
153
|
-
shapes?: Notation;
|
|
154
211
|
[key: string]: unknown;
|
|
155
212
|
}
|
|
156
213
|
|
|
@@ -205,7 +262,6 @@ export interface MapState {
|
|
|
205
262
|
paused: boolean;
|
|
206
263
|
camera: { x: number; y: number; zoom: number }; // the centre in map units, and the zoom (1: actual size); a state event's: at rest
|
|
207
264
|
flow: boolean;
|
|
208
|
-
shapes: Notation; // the notation the view shown is drawn in (0.15.0)
|
|
209
265
|
motion: 'full' | 'reduced' | 'instant';
|
|
210
266
|
gesture: 'idle' | 'dragging' | 'connecting' | 'naming'; // an edit in progress (editable maps)
|
|
211
267
|
destroyed: boolean;
|
|
@@ -234,8 +290,6 @@ export interface RenderOptions {
|
|
|
234
290
|
wheel?: 'zoom' | 'ctrl';
|
|
235
291
|
minimap?: boolean; // default false
|
|
236
292
|
flow?: boolean; // animated flow along lines (default: on unless prefers-reduced-motion)
|
|
237
|
-
/** The notation every view is drawn in (0.15.0), over each view's and the model's own. */
|
|
238
|
-
shapes?: Notation;
|
|
239
293
|
/** Text widths: default the host's font (--um-sans, measured on a canvas); false: a font-independent estimate. */
|
|
240
294
|
measure?: false | ((text: string, px: number) => number);
|
|
241
295
|
/** Edit gestures that emit `change` events: all of them, or only those set true. Off by default. */
|
|
@@ -308,10 +362,6 @@ export interface Handle {
|
|
|
308
362
|
readonly destroyed: boolean;
|
|
309
363
|
/** The animated flow along lines (the ≋ button and F), to read or set. */
|
|
310
364
|
flow: boolean;
|
|
311
|
-
/** 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
|
|
312
|
-
* cards are drawn again from the geometry they have, with the camera, selection, lens and marks; nothing is laid out. */
|
|
313
|
-
get shapes(): Notation;
|
|
314
|
-
set shapes(notation: Notation | null);
|
|
315
365
|
/** How this map moves: 'instant' (drawn without animation, as the page's #check, #still and #shot are), 'reduced' (the
|
|
316
366
|
* reader's setting), else 'full'. */
|
|
317
367
|
readonly motion: 'full' | 'reduced' | 'instant';
|