@tumaet/apollon 4.2.16 → 4.2.18

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 TUM Applied Education Technologies
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # @tumaet/apollon
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@tumaet/apollon)](https://www.npmjs.com/package/@tumaet/apollon)
4
+ [![npm license](https://img.shields.io/npm/l/@tumaet/apollon)](https://github.com/ls1intum/Apollon/blob/main/LICENSE)
5
+
6
+ A UML modeling editor for React. Mount it into any DOM node. 13 diagram types, SVG/PNG/PDF/JSON export, optional real-time collaboration via Yjs.
7
+
8
+ > Replaces the deprecated [`@ls1intum/apollon`](https://www.npmjs.com/package/@ls1intum/apollon) — see that page for the migration guide.
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ npm install @tumaet/apollon
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```ts
19
+ import {
20
+ ApollonEditor,
21
+ ApollonMode,
22
+ Locale,
23
+ UMLDiagramType,
24
+ } from "@tumaet/apollon"
25
+
26
+ const container = document.getElementById("apollon")
27
+ if (!container) throw new Error("#apollon container missing")
28
+
29
+ const editor = new ApollonEditor(container, {
30
+ type: UMLDiagramType.ClassDiagram,
31
+ mode: ApollonMode.Modelling,
32
+ locale: Locale.en,
33
+ // model, theme, readonly, enablePopups, colorEnabled, scale,
34
+ // collaborationEnabled, scrollLock — see `ApollonOptions`
35
+ })
36
+
37
+ // Read / write the model
38
+ console.log(editor.model)
39
+ editor.model = nextModel
40
+
41
+ // React to edits
42
+ const subscriptionId = editor.subscribeToModelChange((model) => {
43
+ // persist / broadcast
44
+ })
45
+
46
+ // Export
47
+ const svg = await editor.exportAsSVG({ svgMode: "web" })
48
+
49
+ // Teardown
50
+ editor.unsubscribe(subscriptionId)
51
+ editor.destroy()
52
+ ```
53
+
54
+ The editor mounts into the DOM and is client-only. In SSR frameworks (Next.js, Remix), instantiate inside `useEffect` or behind a dynamic import. Call `editor.destroy()` before re-mounting on the same container.
55
+
56
+ Type definitions ship with the package (`dist/index.d.ts`).
57
+
58
+ ## Supported diagrams
59
+
60
+ `ClassDiagram`, `ObjectDiagram`, `ActivityDiagram`, `UseCaseDiagram`, `CommunicationDiagram`, `ComponentDiagram`, `DeploymentDiagram`, `PetriNet`, `ReachabilityGraph`, `SyntaxTree`, `Flowchart`, `BPMN`, `Sfc` (Sequential Function Chart).
61
+
62
+ ## Real-time collaboration
63
+
64
+ Collaboration is opt-in and transport-agnostic. Enable `collaborationEnabled` in `ApollonOptions`, then wire your transport to the editor's Yjs bridge:
65
+
66
+ ```ts
67
+ editor.sendBroadcastMessage((base64) => transport.send(base64))
68
+ transport.onMessage((base64) => editor.receiveBroadcastedMessage(base64))
69
+ ```
70
+
71
+ Use any Yjs-compatible transport (WebSocket, WebRTC, `y-websocket`, etc.).
72
+
73
+ ## Export
74
+
75
+ - `editor.exportAsSVG(options)` resolves to `{ svg, clip }` — render or serialize as-is.
76
+ - PNG and PDF use the same pipeline via `ExportOptions` (`svgMode: "web" | "compat"`); see `dist/index.d.ts`.
77
+ - `editor.model` returns the `UMLModel` as JSON.
78
+
79
+ ## Related
80
+
81
+ - Source and issue tracker: <https://github.com/ls1intum/Apollon>
82
+ - Standalone web editor, server, and mobile apps live in the same monorepo.
83
+ - Developed alongside [Artemis](https://artemis.tum.de/), TUM's interactive learning platform.
84
+
85
+ ## License
86
+
87
+ MIT — see [LICENSE](https://github.com/ls1intum/Apollon/blob/main/LICENSE).
@@ -24,10 +24,15 @@ export declare const LAYOUT: Readonly<{
24
24
  readonly LINE_WIDTH_EDGE: 2;
25
25
  readonly ICON_LINE_WIDTH: 1.5;
26
26
  }>;
27
+ export declare const INTERFACE_SIZE = 30;
28
+ export declare const INTERFACE_RADIUS: number;
29
+ export declare const INTERFACE_STROKE_WIDTH = 2;
30
+ export declare const INTERFACE_SOCKET_GAP = 4;
27
31
  export declare const INTERFACE: Readonly<{
28
32
  readonly SIZE: 30;
29
- readonly RADIUS: 15;
33
+ readonly RADIUS: number;
30
34
  readonly STROKE_WIDTH: 2;
35
+ readonly SOCKET_GAP: 4;
31
36
  }>;
32
37
  export declare const MARKER_BASE_SIZE = 18;
33
38
  export declare const BPMN_MARKER_SIZE = 11;
@@ -100,15 +105,15 @@ export declare const MARKER_CONFIGS: Readonly<{
100
105
  readonly "required-interface": {
101
106
  readonly type: "semicircle";
102
107
  readonly filled: false;
103
- readonly size: 15;
108
+ readonly size: number;
104
109
  readonly widthFactor: 1;
105
110
  readonly heightFactor: 1;
106
- readonly arcSpanDegrees: 180;
111
+ readonly arcSpanDegrees: 150;
107
112
  };
108
113
  readonly "required-interface-quarter": {
109
114
  readonly type: "semicircle";
110
115
  readonly filled: false;
111
- readonly size: 15;
116
+ readonly size: number;
112
117
  readonly widthFactor: 1;
113
118
  readonly heightFactor: 1;
114
119
  readonly arcSpanDegrees: 90;
@@ -116,7 +121,7 @@ export declare const MARKER_CONFIGS: Readonly<{
116
121
  readonly "required-interface-threequarter": {
117
122
  readonly type: "semicircle";
118
123
  readonly filled: false;
119
- readonly size: 15;
124
+ readonly size: number;
120
125
  readonly widthFactor: 1;
121
126
  readonly heightFactor: 1;
122
127
  readonly arcSpanDegrees: 270;
@@ -107,16 +107,16 @@ export declare const edgeConfig: {
107
107
  readonly allowMidpointDragging: true;
108
108
  };
109
109
  readonly ComponentProvidedInterface: {
110
- readonly allowMidpointDragging: false;
110
+ readonly allowMidpointDragging: true;
111
111
  };
112
112
  readonly ComponentRequiredInterface: {
113
- readonly allowMidpointDragging: false;
113
+ readonly allowMidpointDragging: true;
114
114
  };
115
115
  readonly ComponentRequiredThreeQuarterInterface: {
116
- readonly allowMidpointDragging: false;
116
+ readonly allowMidpointDragging: true;
117
117
  };
118
118
  readonly ComponentRequiredQuarterInterface: {
119
- readonly allowMidpointDragging: false;
119
+ readonly allowMidpointDragging: true;
120
120
  };
121
121
  readonly DeploymentAssociation: {
122
122
  readonly allowMidpointDragging: true;
@@ -53,13 +53,13 @@ export declare const useEdgeConfig: (edgeType: DiagramEdgeType) => {
53
53
  } | {
54
54
  readonly allowMidpointDragging: true;
55
55
  } | {
56
- readonly allowMidpointDragging: false;
56
+ readonly allowMidpointDragging: true;
57
57
  } | {
58
- readonly allowMidpointDragging: false;
58
+ readonly allowMidpointDragging: true;
59
59
  } | {
60
- readonly allowMidpointDragging: false;
60
+ readonly allowMidpointDragging: true;
61
61
  } | {
62
- readonly allowMidpointDragging: false;
62
+ readonly allowMidpointDragging: true;
63
63
  } | {
64
64
  readonly allowMidpointDragging: true;
65
65
  readonly showRelationshipLabels: true;