diff options
Diffstat (limited to 'subprojects/frontend/src/index.tsx')
-rw-r--r-- | subprojects/frontend/src/index.tsx | 127 |
1 files changed, 97 insertions, 30 deletions
diff --git a/subprojects/frontend/src/index.tsx b/subprojects/frontend/src/index.tsx index cb11e6c3..60debd6b 100644 --- a/subprojects/frontend/src/index.tsx +++ b/subprojects/frontend/src/index.tsx | |||
@@ -4,46 +4,113 @@ | |||
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
6 | 6 | ||
7 | import { styled } from '@mui/material/styles'; | ||
7 | import { configure } from 'mobx'; | 8 | import { configure } from 'mobx'; |
8 | import { type Root, createRoot } from 'react-dom/client'; | 9 | import { type Root, createRoot } from 'react-dom/client'; |
9 | 10 | ||
10 | import App from './App'; | 11 | import App from './App'; |
11 | import RootStore from './RootStore'; | 12 | import RootStore from './RootStore'; |
12 | 13 | ||
13 | const initialValue = `// Metamodel | 14 | // Make sure `styled` ends up in the entry chunk. |
14 | class Person { | 15 | // https://github.com/mui/material-ui/issues/32727#issuecomment-1659945548 |
15 | Person[] friend opposite friend | 16 | (window as unknown as { fixViteIssue: unknown }).fixViteIssue = styled; |
17 | |||
18 | const initialValue = `% Metamodel | ||
19 | |||
20 | abstract class CompositeElement { | ||
21 | contains Region[] regions | ||
16 | } | 22 | } |
17 | 23 | ||
18 | class Post { | 24 | class Region { |
19 | Person author | 25 | contains Vertex[] vertices opposite region |
20 | Post[0..1] replyTo | ||
21 | } | 26 | } |
22 | 27 | ||
23 | // Constraints | 28 | abstract class Vertex { |
24 | error replyToNotFriend(Post x, Post y) <-> | 29 | container Region region opposite vertices |
25 | replyTo(x, y), | 30 | contains Transition[] outgoingTransition opposite source |
26 | author(x, xAuthor), | 31 | Transition[] incomingTransition opposite target |
27 | author(y, yAuthor), | 32 | } |
28 | !friend(xAuthor, yAuthor). | 33 | |
29 | 34 | class Transition { | |
30 | error replyToCycle(Post x) <-> replyTo+(x,x). | 35 | container Vertex source opposite outgoingTransition |
31 | 36 | Vertex[1] target opposite incomingTransition | |
32 | // Instance model | 37 | } |
33 | Person(a). | 38 | |
34 | Person(b). | 39 | abstract class Pseudostate extends Vertex. |
35 | friend(a, b). | 40 | |
36 | friend(b, a). | 41 | abstract class RegularState extends Vertex. |
37 | Post(p1). | 42 | |
38 | author(p1, a). | 43 | class Entry extends Pseudostate. |
39 | Post(p2). | 44 | |
40 | author(p2, b). | 45 | class Exit extends Pseudostate. |
41 | replyTo(p2, p1). | 46 | |
42 | 47 | class Choice extends Pseudostate. | |
43 | !author(Post::new, a). // Automatically inferred: author(Post::new, b). | 48 | |
44 | 49 | class FinalState extends RegularState. | |
45 | // Scope | 50 | |
46 | scope Post = 10..15, Person += 0. | 51 | class State extends RegularState, CompositeElement. |
52 | |||
53 | class Statechart extends CompositeElement. | ||
54 | |||
55 | % Constraints | ||
56 | |||
57 | %% Entry | ||
58 | |||
59 | pred entryInRegion(Region r, Entry e) <-> | ||
60 | vertices(r, e). | ||
61 | |||
62 | error noEntryInRegion(Region r) <-> | ||
63 | !entryInRegion(r, _). | ||
64 | |||
65 | error multipleEntryInRegion(Region r) <-> | ||
66 | entryInRegion(r, e1), | ||
67 | entryInRegion(r, e2), | ||
68 | e1 != e2. | ||
69 | |||
70 | error incomingToEntry(Transition t, Entry e) <-> | ||
71 | target(t, e). | ||
72 | |||
73 | error noOutgoingTransitionFromEntry(Entry e) <-> | ||
74 | !source(_, e). | ||
75 | |||
76 | error multipleTransitionFromEntry(Entry e, Transition t1, Transition t2) <-> | ||
77 | outgoingTransition(e, t1), | ||
78 | outgoingTransition(e, t2), | ||
79 | t1 != t2. | ||
80 | |||
81 | %% Exit | ||
82 | |||
83 | error outgoingFromExit(Transition t, Exit e) <-> | ||
84 | source(t, e). | ||
85 | |||
86 | %% Final | ||
87 | |||
88 | error outgoingFromFinal(Transition t, FinalState e) <-> | ||
89 | source(t, e). | ||
90 | |||
91 | %% State vs Region | ||
92 | |||
93 | pred stateInRegion(Region r, State s) <-> | ||
94 | vertices(r, s). | ||
95 | |||
96 | error noStateInRegion(Region r) <-> | ||
97 | !stateInRegion(r, _). | ||
98 | |||
99 | %% Choice | ||
100 | |||
101 | error choiceHasNoOutgoing(Choice c) <-> | ||
102 | !source(_, c). | ||
103 | |||
104 | error choiceHasNoIncoming(Choice c) <-> | ||
105 | !target(_, c). | ||
106 | |||
107 | % Instance model | ||
108 | |||
109 | Statechart(sct). | ||
110 | |||
111 | % Scope | ||
112 | |||
113 | scope node = 20..30, Region = 2..*, Choice = 1..*, Statechart += 0. | ||
47 | `; | 114 | `; |
48 | 115 | ||
49 | configure({ | 116 | configure({ |