@formicoidea/labre-framework-uml 0.42.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/LICENSE +384 -0
- package/dist/actions.d.ts +430 -0
- package/dist/actions.js +724 -0
- package/dist/background.d.ts +153 -0
- package/dist/background.js +557 -0
- package/dist/board-hit.d.ts +137 -0
- package/dist/board-hit.js +191 -0
- package/dist/commands-manifest.d.ts +19 -0
- package/dist/commands-manifest.js +571 -0
- package/dist/commands.d.ts +4 -0
- package/dist/commands.js +983 -0
- package/dist/component.d.ts +521 -0
- package/dist/component.js +708 -0
- package/dist/consts.d.ts +365 -0
- package/dist/consts.js +463 -0
- package/dist/descriptor.d.ts +12 -0
- package/dist/descriptor.js +10 -0
- package/dist/drawio-decode.d.ts +32 -0
- package/dist/drawio-decode.js +96 -0
- package/dist/drawio-import.d.ts +133 -0
- package/dist/drawio-import.js +885 -0
- package/dist/edge-morph.d.ts +154 -0
- package/dist/edge-morph.js +153 -0
- package/dist/edge-styles.d.ts +78 -0
- package/dist/edge-styles.js +210 -0
- package/dist/effects.d.ts +9 -0
- package/dist/effects.js +6 -0
- package/dist/element-renderer.d.ts +64 -0
- package/dist/element-renderer.js +114 -0
- package/dist/element-view.d.ts +234 -0
- package/dist/element-view.js +430 -0
- package/dist/export.d.ts +61 -0
- package/dist/export.js +41 -0
- package/dist/filename.d.ts +17 -0
- package/dist/filename.js +26 -0
- package/dist/frame-tag.d.ts +70 -0
- package/dist/frame-tag.js +78 -0
- package/dist/grammar.d.ts +695 -0
- package/dist/grammar.js +1436 -0
- package/dist/import.d.ts +306 -0
- package/dist/import.js +1270 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +67 -0
- package/dist/interchange.d.ts +125 -0
- package/dist/interchange.js +372 -0
- package/dist/keywords.d.ts +204 -0
- package/dist/keywords.js +361 -0
- package/dist/kinds.d.ts +73 -0
- package/dist/kinds.js +91 -0
- package/dist/legend.d.ts +30 -0
- package/dist/legend.js +255 -0
- package/dist/model.d.ts +862 -0
- package/dist/model.js +1316 -0
- package/dist/morph.d.ts +178 -0
- package/dist/morph.js +496 -0
- package/dist/node/act-glyphs.d.ts +30 -0
- package/dist/node/act-glyphs.js +142 -0
- package/dist/node/compartment-watcher.d.ts +107 -0
- package/dist/node/compartment-watcher.js +163 -0
- package/dist/node/fit.d.ts +85 -0
- package/dist/node/fit.js +129 -0
- package/dist/node/node-renderer.d.ts +49 -0
- package/dist/node/node-renderer.js +611 -0
- package/dist/node/node-view.d.ts +51 -0
- package/dist/node/node-view.js +89 -0
- package/dist/node/paint.d.ts +84 -0
- package/dist/node/paint.js +143 -0
- package/dist/node/sd-glyphs.d.ts +36 -0
- package/dist/node/sd-glyphs.js +79 -0
- package/dist/node/stm-glyphs.d.ts +22 -0
- package/dist/node/stm-glyphs.js +111 -0
- package/dist/node/tier-metrics.d.ts +38 -0
- package/dist/node/tier-metrics.js +45 -0
- package/dist/operators.d.ts +45 -0
- package/dist/operators.js +75 -0
- package/dist/plantuml-import.d.ts +113 -0
- package/dist/plantuml-import.js +1723 -0
- package/dist/plantuml.d.ts +94 -0
- package/dist/plantuml.js +985 -0
- package/dist/presets.d.ts +149 -0
- package/dist/presets.js +302 -0
- package/dist/profiles.d.ts +2 -0
- package/dist/profiles.js +358 -0
- package/dist/reading.d.ts +160 -0
- package/dist/reading.js +648 -0
- package/dist/roles.d.ts +257 -0
- package/dist/roles.js +997 -0
- package/dist/rules.d.ts +267 -0
- package/dist/rules.js +3090 -0
- package/dist/templates.d.ts +2 -0
- package/dist/templates.js +197 -0
- package/dist/toolbar/config.d.ts +228 -0
- package/dist/toolbar/config.js +833 -0
- package/dist/toolbar/icons.d.ts +440 -0
- package/dist/toolbar/icons.js +711 -0
- package/dist/toolbar/senior-tool.d.ts +11 -0
- package/dist/toolbar/senior-tool.js +21 -0
- package/dist/toolbar/uml-menu.d.ts +17 -0
- package/dist/toolbar/uml-menu.js +20 -0
- package/dist/toolbar/uml-senior-button.d.ts +18 -0
- package/dist/toolbar/uml-senior-button.js +22 -0
- package/dist/translations.d.ts +27 -0
- package/dist/translations.js +117 -0
- package/dist/view.d.ts +33 -0
- package/dist/view.js +236 -0
- package/dist/xmi-import.d.ts +174 -0
- package/dist/xmi-import.js +2268 -0
- package/dist/xmi.d.ts +61 -0
- package/dist/xmi.js +1860 -0
- package/dist/xml-reader.d.ts +157 -0
- package/dist/xml-reader.js +430 -0
- package/dist/xml.d.ts +72 -0
- package/dist/xml.js +96 -0
- package/package.json +38 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { InterchangeNote } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
+
import type { UmlBox } from './component.js';
|
|
3
|
+
import type { UmlModel } from './model.js';
|
|
4
|
+
/**
|
|
5
|
+
* A draw.io drawing, read as a UML model — the **visual** tier of
|
|
6
|
+
* `docs/adr/0012` (see `docs/adr/0019`).
|
|
7
|
+
*
|
|
8
|
+
* ## Why this reader is `visual` where the other two are `semantic`
|
|
9
|
+
*
|
|
10
|
+
* A `.drawio` file carries no UML metamodel. What it carries is a list of
|
|
11
|
+
* boxes, each with a `style` string and a blob of HTML, so "this box is a
|
|
12
|
+
* Class" is a GUESS made out of `<hr />` separators and `endArrow=block`. It is
|
|
13
|
+
* a good guess — every UML shape library in draw.io writes the same handful of
|
|
14
|
+
* style tokens, and the corpus this was written against is draw.io's own UML
|
|
15
|
+
* class example — but it is a guess, and ADR 0012 P2 is explicit that the tier
|
|
16
|
+
* is a promise made to the user BEFORE the file is read. So: no round-trip
|
|
17
|
+
* promise, and anything this reader does not recognise becomes a `carried` note
|
|
18
|
+
* naming the cell and the style that defeated it. Nothing here throws and
|
|
19
|
+
* nothing is dropped in silence.
|
|
20
|
+
*
|
|
21
|
+
* ## Decoded XML in, and nothing else (ADR 0019, the compressed-payload split)
|
|
22
|
+
*
|
|
23
|
+
* A `.drawio` file's `<diagram>` usually holds base64 of a raw-deflate of
|
|
24
|
+
* URI-encoded XML. Inflating it needs `DecompressionStream` — a platform API,
|
|
25
|
+
* and asynchronous — so it is NOT done here. This function is pure and
|
|
26
|
+
* synchronous per P3, which is what makes it callable from labre-mcp and
|
|
27
|
+
* testable with neither an editor nor a browser; the COMMAND decodes first
|
|
28
|
+
* (`drawio-decode.ts`, `actions.ts`). What arrives here is either a plain
|
|
29
|
+
* `<mxGraphModel>` or an `<mxfile>` whose `<diagram>` already holds one, and a
|
|
30
|
+
* payload that is still compressed comes back as an empty model carrying one
|
|
31
|
+
* `warning` note rather than as an exception. {@link isCompressedDrawio} is the
|
|
32
|
+
* same test, exported so the capability can say so before it reads.
|
|
33
|
+
*
|
|
34
|
+
* ## The XML comes off the shared reader
|
|
35
|
+
*
|
|
36
|
+
* `DOMParser` is a DOM API and a pure function has no DOM, so the tree comes
|
|
37
|
+
* from `xml-reader.ts` — the same tolerant reader the XMI importer walks. One
|
|
38
|
+
* reader for the two XML formats this framework reads means one set of
|
|
39
|
+
* entity-decoding bugs rather than two.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Where the source drew every cell, in MODEL units, relative to the drawing's
|
|
43
|
+
* own top-left corner.
|
|
44
|
+
*
|
|
45
|
+
* One draw.io unit is one model unit — both are CSS-pixel-shaped, and both
|
|
46
|
+
* frameworks draw a class box at a couple of hundred of them — so the only
|
|
47
|
+
* transform is a TRANSLATION: the minimum corner of the drawing becomes
|
|
48
|
+
* `(0, 0)` here, and the materializer adds the frame's plot origin and its own
|
|
49
|
+
* margin. That way round keeps this function free of the one number it cannot
|
|
50
|
+
* know (where the frame will land) and the materializer free of the one it
|
|
51
|
+
* cannot know (how far from the origin somebody had dragged their diagram).
|
|
52
|
+
*
|
|
53
|
+
* Keyed by the SOURCE cell id, which is the id every element also carries under
|
|
54
|
+
* `interchange.drawio.id` (`docs/adr/0012` D3) — so a box is resolved the same
|
|
55
|
+
* way a connector end is.
|
|
56
|
+
*/
|
|
57
|
+
export interface UmlDrawioLayout {
|
|
58
|
+
boxes: Record<string, UmlBox>;
|
|
59
|
+
}
|
|
60
|
+
/** What {@link importDrawio} read: the model, the remarks, and the geometry. */
|
|
61
|
+
export interface UmlDrawioImport {
|
|
62
|
+
model: UmlModel;
|
|
63
|
+
notes: InterchangeNote[];
|
|
64
|
+
layout: UmlDrawioLayout;
|
|
65
|
+
}
|
|
66
|
+
/** The format id foreign draw.io matter rides under (`docs/adr/0012` D2). */
|
|
67
|
+
export declare const UML_DRAWIO_FORMAT_ID = "drawio";
|
|
68
|
+
/**
|
|
69
|
+
* Whether this text is an `<mxfile>` whose payload still needs inflating.
|
|
70
|
+
*
|
|
71
|
+
* The test is the honest one — "there is a `<diagram>` and no `<mxGraphModel>`
|
|
72
|
+
* anywhere in it" — rather than a guess at what base64 looks like: draw.io
|
|
73
|
+
* writes the uncompressed form under the very same element (File › Properties ›
|
|
74
|
+
* Compressed: off), and a reader that refused those would refuse half the files
|
|
75
|
+
* in the wild for the sake of a heuristic.
|
|
76
|
+
*/
|
|
77
|
+
export declare function isCompressedDrawio(text: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* A cell's `value` as COMPARTMENTS of lines — draw.io's UML class template,
|
|
80
|
+
* read.
|
|
81
|
+
*
|
|
82
|
+
* The template is `<p>Name</p><hr />attributes<hr />operations`, each member
|
|
83
|
+
* separated by `<br />`, and the whole of it HTML-escaped inside the `value`
|
|
84
|
+
* attribute. So: split on the rules, turn every block boundary into a newline,
|
|
85
|
+
* drop what is left of the markup, and decode what the markup was hiding.
|
|
86
|
+
*
|
|
87
|
+
* The second decode pass, after the tags come off, is deliberate rather than
|
|
88
|
+
* belt-and-braces: draw.io escapes the HTML into an XML attribute, so a `<` the
|
|
89
|
+
* author typed in a label is `&lt;` in the file and one pass would leave
|
|
90
|
+
* them looking at `<`.
|
|
91
|
+
*
|
|
92
|
+
* Blank lines and §9.2.4's elision marker are dropped, exactly as
|
|
93
|
+
* `parseCompartment` drops them for a compartment the author typed on the
|
|
94
|
+
* canvas: a file that wrote `...` back as a property named `...` would turn
|
|
95
|
+
* "there are more features, not shown" into "one of them is called dot dot
|
|
96
|
+
* dot".
|
|
97
|
+
*/
|
|
98
|
+
export declare function drawioCompartments(value: string | undefined): string[][];
|
|
99
|
+
/**
|
|
100
|
+
* The one remark this reader raises whose wording is FIXED, as a
|
|
101
|
+
* `[key, English]` pair — the same table, the same shape and the same reasons
|
|
102
|
+
* as `UML_PLANTUML_REMARKS` (`plantuml-import.ts`, where the contract is
|
|
103
|
+
* written out): one entry per SHAPE of sentence, the `{{kind}}` hole filled at
|
|
104
|
+
* the call site by `InterchangeNote.messageParams`, the English kept here as
|
|
105
|
+
* the fallback.
|
|
106
|
+
*
|
|
107
|
+
* The reader's refusals ({@link importDrawio}'s `refused`) and its two
|
|
108
|
+
* {@link carried} fragments are deliberately NOT here: a remark that names
|
|
109
|
+
* something out of the file with no sentence shape worth sharing — a raw style
|
|
110
|
+
* dump, a one-off diagnostic — carries no key and stays English, which is what
|
|
111
|
+
* `InterchangeNote.messageKey`'s own contract asks for.
|
|
112
|
+
*/
|
|
113
|
+
export declare const UML_DRAWIO_REMARKS: {
|
|
114
|
+
readonly ambiguousBlockHead: readonly ["com.labre.uml.import.drawio.ambiguous-block-head", "read as a {{kind}}, but the arrowhead is drawn filled; UML draws the generalization triangle hollow (endFill=0)."];
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* A draw.io drawing as a UML model.
|
|
118
|
+
*
|
|
119
|
+
* Never throws. A file that is not a draw.io document at all comes back as an
|
|
120
|
+
* empty model with one `warning` note, which is the same answer as for a
|
|
121
|
+
* payload that is still compressed: this is the visual tier, the tier's promise
|
|
122
|
+
* is recognition, and "I recognised nothing" is an answer rather than a
|
|
123
|
+
* failure.
|
|
124
|
+
*
|
|
125
|
+
* @param xml a decoded `<mxGraphModel>`, or an `<mxfile>` whose `<diagram>`
|
|
126
|
+
* already holds one. See the module docblock for why the compressed form is
|
|
127
|
+
* the command's problem and not this function's.
|
|
128
|
+
* @param options.name what to call the sheet when the file names nothing — the
|
|
129
|
+
* importer's context name, which is the file's own name in practice.
|
|
130
|
+
*/
|
|
131
|
+
export declare function importDrawio(xml: string, options?: {
|
|
132
|
+
name?: string;
|
|
133
|
+
}): UmlDrawioImport;
|