umlimator 0.20.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 +52 -25
- package/lib/umlimator-all.js +3520 -184
- package/lib/umlimator-element.js +2 -5
- package/lib/umlimator.d.ts +41 -19
- package/lib/umlimator.js +104 -152
- package/lib/umlimator.schema.json +81 -31
- 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,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); 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,41 @@ 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';
|
|
129
160
|
/** What a line means, drawn as its colour: calls (the default), feeds (hands work on), triggers (suggests, offers, fires),
|
|
130
161
|
* state (reads or writes a file, board or config: a thinner line, a muted label, no flow) and guard (a hook steps in).
|
|
131
162
|
* Colours are --um-w-<kind>. An edge's `style` (emphasis, dashed, security) wins over its kind's colour. */
|
|
@@ -177,8 +208,6 @@ export interface MapView {
|
|
|
177
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
|
|
178
209
|
* box (as deep as --um-tint makes the cards), with its border dashed and its title in the tone. */
|
|
179
210
|
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
211
|
[key: string]: unknown;
|
|
183
212
|
}
|
|
184
213
|
|
|
@@ -233,7 +262,6 @@ export interface MapState {
|
|
|
233
262
|
paused: boolean;
|
|
234
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
|
|
235
264
|
flow: boolean;
|
|
236
|
-
shapes: Notation; // the notation the view shown is drawn in (0.15.0)
|
|
237
265
|
motion: 'full' | 'reduced' | 'instant';
|
|
238
266
|
gesture: 'idle' | 'dragging' | 'connecting' | 'naming'; // an edit in progress (editable maps)
|
|
239
267
|
destroyed: boolean;
|
|
@@ -262,8 +290,6 @@ export interface RenderOptions {
|
|
|
262
290
|
wheel?: 'zoom' | 'ctrl';
|
|
263
291
|
minimap?: boolean; // default false
|
|
264
292
|
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
293
|
/** Text widths: default the host's font (--um-sans, measured on a canvas); false: a font-independent estimate. */
|
|
268
294
|
measure?: false | ((text: string, px: number) => number);
|
|
269
295
|
/** Edit gestures that emit `change` events: all of them, or only those set true. Off by default. */
|
|
@@ -336,10 +362,6 @@ export interface Handle {
|
|
|
336
362
|
readonly destroyed: boolean;
|
|
337
363
|
/** The animated flow along lines (the ≋ button and F), to read or set. */
|
|
338
364
|
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
365
|
/** How this map moves: 'instant' (drawn without animation, as the page's #check, #still and #shot are), 'reduced' (the
|
|
344
366
|
* reader's setting), else 'full'. */
|
|
345
367
|
readonly motion: 'full' | 'reduced' | 'instant';
|