umlimator 0.16.0 → 0.17.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 +10 -4
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/lib/umlimator-all.js +5917 -0
- package/lib/umlimator.d.ts +41 -1
- package/lib/umlimator.js +4610 -3910
- package/lib/umlimator.schema.json +45 -0
- package/package.json +3 -2
package/lib/umlimator.d.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
/** A map model: engine/references/schema.md § Map model, plus the README's umlimator fields. Never mutated. */
|
|
4
4
|
export interface MapModel {
|
|
5
|
+
/** 1 (or none): a map, read as always. 2: it may hold typed elements and typed views (docs/diagrams/model.md). A newer
|
|
6
|
+
* version is an error: validate() says so and migrate() throws (0.17.0). */
|
|
7
|
+
schemaVersion?: number;
|
|
5
8
|
title?: string;
|
|
6
9
|
root?: string;
|
|
7
10
|
nodes: MapNode[];
|
|
@@ -39,6 +42,15 @@ export interface MapNode {
|
|
|
39
42
|
owner?: string;
|
|
40
43
|
/** The card's own shape, in every notation (0.15.0); without it, the notation draws the card by its kind. */
|
|
41
44
|
shape?: Shape;
|
|
45
|
+
/** In schema version 2 (0.17.0) a node may also be a typed Element: type, parent, props, members. */
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
/** A typed element in schema version 2's envelope (docs/diagrams/model.md §1): a node, a member, a typed edge, a
|
|
49
|
+
* fragment. Nodes, edges, members and fragments share one id space; an id never contains "->". A typed edge is an
|
|
50
|
+
* 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`. None is drawn yet. */
|
|
52
|
+
export interface Element {
|
|
53
|
+
id: string; type: string; label?: string; parent?: string; props?: Record<string, unknown>; members?: Element[];
|
|
42
54
|
[key: string]: unknown;
|
|
43
55
|
}
|
|
44
56
|
/** What a line means, drawn as its colour: calls (the default), feeds (hands work on), triggers (suggests, offers, fires),
|
|
@@ -111,6 +123,10 @@ export interface Events {
|
|
|
111
123
|
open: { target: Ref; view: string; preventDefault(): void }; // view: the one the card opens, which may not be in the model yet
|
|
112
124
|
viewchange: { view: string; from: string };
|
|
113
125
|
change: Change; // only with `editable`
|
|
126
|
+
/** A gesture on a typed view (a schema version 2 view whose `diagram` is set and is not 'map'), with `editable`
|
|
127
|
+
* (0.17.0): a transaction for the host to apply with apply(model, commands) and hand back with update(). Nothing is
|
|
128
|
+
* drawn before. Map views emit `change`, never this. */
|
|
129
|
+
edit: { view: string; commands: Command[] };
|
|
114
130
|
/** E or Alt + click on a stacked card, or the ⤡ tab of the box it unfolded into (#71): before the card unfolds in place
|
|
115
131
|
* (expanded: true) or folds back (false). view: the card's inner view, which may not be in the model yet; the card
|
|
116
132
|
* unfolds once it is: the update() that brings it unfolds the card (here or later), or expand(). preventDefault(): no change. */
|
|
@@ -344,9 +360,33 @@ export function history(model: MapModel, limit?: number): History;
|
|
|
344
360
|
export function layout(model: MapModel, viewId: string, options?: { repair?: boolean; measure?: (text: string, px: number) => number; expand?: string[] }): Geometry & { unfolded?: string[] };
|
|
345
361
|
/** A model's own problem. path says where: "views[2].nodeIds[4]". Errors draw as holes or not at all (missing,
|
|
346
362
|
* repeated or dangling ids, a box inside itself); warnings draw other than they say (an unknown kind, weight or side,
|
|
347
|
-
* a view a card opens that the host has not loaded yet). The JSON Schema is umlimator/schema.json. */
|
|
363
|
+
* a view a card opens that the host has not loaded yet, a line from a card or box to itself, which is not drawn). The JSON Schema is umlimator/schema.json. */
|
|
348
364
|
export interface Problem { level: 'error' | 'warning'; path: string; message: string }
|
|
349
365
|
export function validate(model: MapModel): Problem[];
|
|
366
|
+
/** The model at the schema version this release reads (0.17.0). Versions 1 and 2 come back unchanged; lines with no id
|
|
367
|
+
* keep their positional names. Throws on a newer version (a whole number above 2). */
|
|
368
|
+
export function migrate<M extends MapModel>(model: M): M;
|
|
369
|
+
/** A command on the model (0.17.0). `path` is a dotted path, or a list of keys when a key holds a dot; `value`
|
|
370
|
+
* undefined removes the field. `id`, `members`, `parent`, `from` and `to` change by their own commands, not by set. */
|
|
371
|
+
export type Command =
|
|
372
|
+
| { op: 'set'; id: string; path: string | string[]; value: unknown }
|
|
373
|
+
| { op: 'set'; view: string; path: string | string[]; value: unknown }
|
|
374
|
+
| { op: 'add'; element: { id: string; [key: string]: unknown }; owner?: string; index?: number; view?: string }
|
|
375
|
+
| { op: 'move'; id: string; index: number; owner?: string; view?: never }
|
|
376
|
+
| { op: 'move'; id: string; view: string; index: number; owner?: never }
|
|
377
|
+
| { op: 'hide'; id: string; view: string }
|
|
378
|
+
| { op: 'delete'; id: string }
|
|
379
|
+
| { op: 'reparent'; id: string; parent: string | null };
|
|
380
|
+
/** The model after a transaction: one command, or a list run in order, on a copy (0.17.0). A command that cannot run
|
|
381
|
+
* throws, and none of the transaction is applied. `delete` takes with it the element's members, what it owns, the lines
|
|
382
|
+
* to them and every place that names them (references()); one already gone in the same transaction is passed over.
|
|
383
|
+
* `hide` takes it out of one view with all the view says of it. Undo is the model before: keep it with history(). */
|
|
384
|
+
export function apply<M extends MapModel>(model: M, commands: Command | Command[]): M;
|
|
385
|
+
/** Where a model names an element, other than the element itself (0.17.0): the keys from the model down to the place
|
|
386
|
+
* (['views', 0, 'nodeIds', 2]) and what it is: 'end', 'parent', 'part', 'view', 'pin', 'present', 'override',
|
|
387
|
+
* 'subject', 'story', 'lens' or 'rule'; later releases may add kinds. */
|
|
388
|
+
export interface Reference { path: (string | number)[]; kind: string }
|
|
389
|
+
export function references(model: MapModel, id: string): Reference[];
|
|
350
390
|
/** One issue of the layout check: its message, as the page's check words it, and the cards, lines and boxes it is about
|
|
351
391
|
* (exactly those, even where two cards share a label). */
|
|
352
392
|
export interface CheckIssue { message: string; targets: Ref[] }
|