@zenuml/core 2.0.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.
Files changed (97) hide show
  1. package/Integration/vanilla-js/index.html +31 -0
  2. package/LICENSE +21 -0
  3. package/README.md +81 -0
  4. package/README_CN.md +15 -0
  5. package/antlr/antlr-4.8-complete.jar +0 -0
  6. package/coverage/clover.xml +6 -0
  7. package/coverage/coverage-final.json +1 -0
  8. package/coverage/lcov-report/Interaction.vue.html +532 -0
  9. package/coverage/lcov-report/Owner.js.html +175 -0
  10. package/coverage/lcov-report/base.css +224 -0
  11. package/coverage/lcov-report/block-navigation.js +79 -0
  12. package/coverage/lcov-report/components/interaction/Interaction.vue.html +544 -0
  13. package/coverage/lcov-report/components/interaction/index.html +110 -0
  14. package/coverage/lcov-report/index.html +95 -0
  15. package/coverage/lcov-report/positioning/david/DavidEisenstat2.ts.html +196 -0
  16. package/coverage/lcov-report/positioning/david/index.html +110 -0
  17. package/coverage/lcov-report/prettify.css +1 -0
  18. package/coverage/lcov-report/prettify.js +2 -0
  19. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  20. package/coverage/lcov-report/sorter.js +170 -0
  21. package/coverage/lcov.info +0 -0
  22. package/cypress/fixtures/example.json +5 -0
  23. package/cypress/fixtures/profile.json +5 -0
  24. package/cypress/fixtures/users.json +232 -0
  25. package/cypress/integration/__image_snapshots__/Smoke test creation #0.png +0 -0
  26. package/cypress/integration/__image_snapshots__/Smoke test fragment #0.png +0 -0
  27. package/cypress/integration/__image_snapshots__/Smoke test fragmentIssue #0.png +0 -0
  28. package/cypress/integration/__image_snapshots__/Smoke test interaction #0.png +0 -0
  29. package/cypress/integration/__image_snapshots__/Smoke test return #0.png +0 -0
  30. package/cypress/integration/__image_snapshots__/Smoke test return #1.png +0 -0
  31. package/cypress/integration/__image_snapshots__/Smoke test should load the home page #0.png +0 -0
  32. package/cypress/integration/smoke.spec.js +64 -0
  33. package/cypress/plugins/index.js +30 -0
  34. package/cypress/support/commands.js +25 -0
  35. package/cypress/support/index.js +20 -0
  36. package/cypress/videos/smoke.spec.js.mp4 +0 -0
  37. package/cypress.json +7 -0
  38. package/dist/fonts/kalam-v15-latin-300.00bd845e.woff2 +0 -0
  39. package/dist/fonts/kalam-v15-latin-300.1c36b0ad.woff +0 -0
  40. package/dist/fonts/kalam-v15-latin-700.2a87f463.woff2 +0 -0
  41. package/dist/fonts/kalam-v15-latin-700.9ec0bbf1.woff +0 -0
  42. package/dist/fonts/kalam-v15-latin-regular.4c0c4df4.woff +0 -0
  43. package/dist/fonts/kalam-v15-latin-regular.e4d4907f.woff2 +0 -0
  44. package/dist/vue-sequence.css +7 -0
  45. package/dist/vue-sequence.umd.min.js +12 -0
  46. package/docs/asciidoc/contributor.adoc +79 -0
  47. package/docs/asciidoc/create-my-own-theme.adoc +25 -0
  48. package/docs/asciidoc/images/creation-component.png +0 -0
  49. package/docs/asciidoc/images/creation-rtl.png +0 -0
  50. package/docs/asciidoc/images/message-arrow-rtl.png +0 -0
  51. package/docs/asciidoc/images/occurrence.png +0 -0
  52. package/docs/asciidoc/images/return-message-conflict.png +0 -0
  53. package/docs/asciidoc/images/shift-up-half-the-height.png +0 -0
  54. package/docs/asciidoc/images/vertical-alignment.svg +1 -0
  55. package/docs/asciidoc/images/vertically-aligning.png +0 -0
  56. package/docs/asciidoc/index.adoc +277 -0
  57. package/docs/asciidoc/integration-guide.adoc +121 -0
  58. package/docs/asciidoc/tutorial.adoc +22 -0
  59. package/docs/async-vs-sync-parser-rules.md +78 -0
  60. package/docs/handling-starter.png +0 -0
  61. package/docs/highlighting-messages.md +47 -0
  62. package/docs/inherited-vs-provided-from.md +59 -0
  63. package/docs/invalid-host-header-error.md +20 -0
  64. package/docs/osx-unsupported-arm64-node12.md +13 -0
  65. package/docs/participants-function.md +27 -0
  66. package/docs/responsive-participant-margin.md +52 -0
  67. package/docs/starter.md +8 -0
  68. package/docs/testing-minified-lib.md +29 -0
  69. package/docs/watch.md +1 -0
  70. package/docs/why-we-publish-embed-view-to-github-pages.md +15 -0
  71. package/docs/width-translate-and-offsets.md +54 -0
  72. package/gen/css3.interp +214 -0
  73. package/gen/css3.tokens +92 -0
  74. package/gen/css3BaseListener.java +1106 -0
  75. package/gen/css3BaseVisitor.java +636 -0
  76. package/gen/css3Lexer.interp +251 -0
  77. package/gen/css3Lexer.java +672 -0
  78. package/gen/css3Lexer.tokens +92 -0
  79. package/gen/css3Listener.java +939 -0
  80. package/gen/css3Parser.java +8113 -0
  81. package/gen/css3Visitor.java +566 -0
  82. package/gen/sequenceLexer.interp +206 -0
  83. package/gen/sequenceLexer.java +419 -0
  84. package/gen/sequenceLexer.tokens +104 -0
  85. package/gen/sequenceParser.interp +180 -0
  86. package/gen/sequenceParser.java +4659 -0
  87. package/gen/sequenceParser.tokens +101 -0
  88. package/gen/sequenceParserBaseListener.java +830 -0
  89. package/gen/sequenceParserBaseVisitor.java +475 -0
  90. package/gen/sequenceParserListener.java +703 -0
  91. package/gen/sequenceParserVisitor.java +425 -0
  92. package/package.json +133 -0
  93. package/playground/creation.html +32 -0
  94. package/playground/message.html +39 -0
  95. package/tailwind.config.js +15 -0
  96. package/types/index.d.ts +34 -0
  97. package/vue.config.spec.js +53 -0
@@ -0,0 +1,79 @@
1
+ == Audience
2
+ :icons: font
3
+
4
+ This document is written for the contributors. If you want to integrate ZenUML in your application,
5
+ you should read index.adoc; if you want to create themes, you should read create-my-own-theme.adoc.
6
+
7
+ == Build
8
+ This project is built with vue cli. It has two types of target: the web application and the library.
9
+
10
+ ....
11
+ # to build the library
12
+ yarn build
13
+ # to build the web application
14
+ yarn build:site
15
+ ....
16
+
17
+ === Customize vue.config.js
18
+
19
+ ==== Inline SVG
20
+ When we build the library, SVG must be inlined.
21
+
22
+ An inlined SVG looks like this:
23
+ ....
24
+ <img src='data:image/svg+xml;base64,<svg ... > ... </svg>'>
25
+ ....
26
+
27
+ [NOTE]
28
+ ====
29
+ [TODO] Note that we use the `base64` encoding as it is the default behaviour of webpack 5
30
+ asset module `asset/inline`. However, `utf8` has https://www.npmjs.com/package/svg-url-loader[the following advantages]:
31
+
32
+ 1. Resulting string is shorter (can be ~2 times shorter for 2K-sized icons);
33
+ 2. Resulting string will be compressed better when using gzip compression;
34
+ 3. Browser parses utf-8 encoded string faster than its base64 equivalent.
35
+
36
+ This can be implemented with https://webpack.js.org/guides/asset-modules/#custom-data-uri-generator[custom data URI generator].
37
+ ====
38
+ The default loader build in vue cli service for svg files will not inline the SVG,
39
+ but give a url (relative path) to the svg resource like this:
40
+ ....
41
+ <img src="/assets/arrow.svg">
42
+ ....
43
+ Client applications will not be able to load the SVG properly.
44
+
45
+ To inline the SVG, we need to use https://webpack.js.org/guides/asset-modules/#inlining-assets[asset module `asset/inline`].
46
+
47
+
48
+ [source, javascript]
49
+ ....
50
+ const svgRule = config.module.rule('svg')
51
+ svgRule.store.clear();
52
+ svgRule
53
+ .test(/\.svg$/) // required because of store.clear()
54
+ .type('asset/inline') // <1>
55
+ .end()
56
+ ....
57
+ <1> `asset/inline` exports a data URI of the asset. Previously achievable by using `url-loader`. https://webpack.js.org/guides/asset-modules/#inlining-assets[See more]
58
+
59
+ == Demo pages
60
+ In the public folder, there are some demo pages for testing the library.
61
+
62
+ === How do they work?
63
+
64
+ The demo pages^1^ are built with vue cli service. On the page, there needs to be a `pre`
65
+ element with class `zenuml` and the content being the ZenUML DSL code.
66
+
67
+ For example:
68
+ [source, html]
69
+ ....
70
+ <pre class="zenuml">
71
+ A.method
72
+ </pre>
73
+ ....
74
+
75
+ The entry point of the demo pages is `src/main.ts`. It will find all the `pre` elements with
76
+ class `zenuml` and render the ZenUML DSL code in it.
77
+
78
+
79
+
@@ -0,0 +1,25 @@
1
+ = Creat my own theme
2
+
3
+ Since the elements on the rendered diagram is based on HTML Dom (and svg), it is simple
4
+ to create your own theme. There is a repository on GitHub that have some themes collected
5
+ by third party. You may be able to get some inspiration from there. https://github.com/abruzzi/zenuml-css-overrides
6
+
7
+ == where can I apply themes
8
+
9
+ You can apply themes on the follow products:
10
+
11
+ . JetBrains plugins (Intellij IDEA, WebStore, PhpStore, etc.)
12
+ . https://app.zenuml.com
13
+
14
+ With stylebot browser extension, you can apply themes in any browsers.
15
+
16
+ === JetBrains
17
+
18
+ === app.zenuml.com
19
+
20
+ == Tips
21
+
22
+ === Give occurrence a boarder
23
+
24
+
25
+
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 202.624 202.624" style="enable-background:new 0 0 202.624 202.624" xml:space="preserve"><path d="M202.621 97.416h-38.966V58.45a3.896 3.896 0 0 0-3.897-3.897h-38.966a3.896 3.896 0 0 0-3.897 3.897v38.966H85.724V35.07a3.896 3.896 0 0 0-3.897-3.897H42.862a3.896 3.896 0 0 0-3.897 3.897v62.345H0v7.793h38.966v62.345a3.896 3.896 0 0 0 3.897 3.897h38.966a3.896 3.896 0 0 0 3.897-3.897v-62.345h31.172v38.966a3.896 3.896 0 0 0 3.897 3.897h38.966a3.896 3.896 0 0 0 3.897-3.897v-38.966h38.966v-7.793h-.003zm-124.69 0v66.241H46.759V38.968h31.172v58.448zm77.931 0v42.862H124.69V62.346h31.172v35.07z"/></svg>
@@ -0,0 +1,277 @@
1
+ :icons: font
2
+
3
+ == Font
4
+ Font [.underline]#must# be *preloaded*. Font mainly have impact to Creation
5
+ rendering. The font will impact the width of the participant box which then
6
+ impacts the with of message container for creation.
7
+
8
+ The following code should help with preloading google fonts. But it is not super
9
+ reliable. Specifically, when you disable cache in Chrome. It is not preloaded
10
+ where you can see the impact.
11
+
12
+ ....
13
+ <link rel='preconnect' href='https://fonts.gstatic.com' crossorigin>
14
+ <link rel='preload stylesheet' as='style' href='https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@300;400;500;700&display=swap'>
15
+ ....
16
+
17
+ We have to use `setTimeout` to delay the calculation of the width of the
18
+ message container.
19
+
20
+ == The two layer structure
21
+ At the highest level, the diagram is rendered in two layers:
22
+ the lifeline layer and the message layer.
23
+
24
+ ....
25
+ <div class="sequence-diagram">
26
+ <div class="life-line-layer absolute h-full">
27
+ </div>
28
+ <div class="message-layer">
29
+ </div>
30
+ </div>
31
+ ....
32
+
33
+ === Key classes
34
+ ==== .absolute
35
+ The `absolute` class is used to remove the lifeline layer from the normal
36
+ flow of the document.
37
+
38
+ ==== .h-full
39
+ The `h-full` class is used to make the lifeline layer as tall as the parent
40
+ element. The parent element get the height from the `message-layer`.
41
+
42
+ == The message layer
43
+
44
+ === Occurrence
45
+ _TODO_: explain misalignment of the occurrence concept and the spec.
46
+
47
+ image::images/occurrence.png[width=304,alt="occurrence"]
48
+
49
+ The occurrence is the bar (or invisible bar for async messages) that
50
+ represents the execution of a message.
51
+
52
+ It has a width of 15px and border of 2px. These two values #must not#
53
+ be overridden in themes.
54
+
55
+ It has a padding-left of 5px which pushes the children `interaction` to
56
+ the middle of the occurrence.
57
+ ....
58
+ (occurrenceWidth - occurrenceBorderWidth x 2 - lifelineWidth) / 2
59
+ = (15 - 2 x 2 - 1) / 2
60
+ = 5
61
+ ....
62
+
63
+ Because the lifeline has width of 1px, for normal (left to right) `interaction` s
64
+ we give it a margin left of 1px to avoid the overlap of the lifeline and the
65
+ interaction border. See `interaction` for more details.
66
+
67
+ === Interaction
68
+ The `interaction` is one of the key conceptual elements. It works with
69
+ the `occurrence` to influence high-level layout. The `interaction` is the container
70
+ of the message, children interactions and the response.
71
+
72
+ The `interaction` has a border of 5px. This value #must not# be overridden in themes.
73
+ ....
74
+ (occurrenceWidth - occurrenceBorderWidth x 2 - lifelineWidth) / 2
75
+ = (15 - 2 x 2 - 1) / 2
76
+ = 5
77
+ ....
78
+
79
+ Within Interaction, the DOM structure is like below:
80
+
81
+ ....
82
+ <div class="interaction">
83
+ <div class="occurrence source"></div>
84
+ <comment/>
85
+ <invocation/> <1>
86
+ <occurrence/>
87
+ <message type="return">
88
+ </div>
89
+
90
+ ....
91
+ <1> SelfInvocation or Message
92
+
93
+
94
+ ==== Do not add margin to interaction
95
+ It is on purpose that interaction box overlaps source lifeline but not the target
96
+ lifeline. Do not add #margin# to interaction components. This margin will cause
97
+ interaction's right board overlaps target lifeline and that is accumulative.
98
+
99
+ ==== Debugging
100
+ Disable transparency of the interaction borders.
101
+
102
+ === Common features among Interaction, Interaction and Creation
103
+
104
+ All the three work as a container for the message, children interactions and the
105
+ response. In the normal direction (left to right), they start with the middle
106
+ of the source lifeline and end with the middle of the target lifeline.
107
+
108
+ === Return message
109
+
110
+ The return message is the message that is sent back to the sender of the original
111
+ message. It is rendered as a dashed line.
112
+
113
+ A return message is rendered from three syntax:
114
+
115
+ * `return x` which matches `RETURN expr? SCOL?`
116
+ * `@return A->B: ret` which matches `ANNOTATION_RET asyncMessage EVENT_END?`
117
+ * `x=A.m` or `x=new A()` which matches `assignment? ((from ARROW)? to DOT)? func` or `assignment? NEW construct(OPAR parameters? CPAR)?`
118
+
119
+
120
+ ==== Statement `return x` or `@return A->B: ret`
121
+
122
+ `return x` or `@return A->B: ret` is implemented via the `Return` component.
123
+ In such cases, it has its own context and can have a comment. Then it
124
+ delegates to `SelfInvocation` or `Message`.
125
+
126
+ ===== When do we need `@return A->B: ret`?
127
+
128
+ ....
129
+ Browser->BookController.onPost() {
130
+ BookLibService.Borrow(id) {
131
+ receipt = process(id)
132
+ if (receipt != null) {
133
+ return receipt
134
+ @return BookController->Browser: receipt
135
+ } else {
136
+ return null
137
+ @return BookController->Browser: 404
138
+ }
139
+ }
140
+ }
141
+ ....
142
+
143
+ If the statement is the last statement we set the height of the message to 0px,
144
+ so that it does not push the message down further. This is because a return message
145
+ does not have children and does not need an occurrence.
146
+
147
+ ....
148
+ .statement-container:last-child>.return {
149
+ height: 0;
150
+ }
151
+ ....
152
+
153
+ ==== Return message from `x=A.m` or `x=new A`
154
+ This is implemented in Interaction and Creation components.
155
+
156
+ ....
157
+ <message class="return transform -translate-y-full"/>
158
+ ....
159
+
160
+ ==== Conflicting return messages
161
+ We provide two ways in DSL to represent `return` messages:
162
+
163
+ ....
164
+ // option 1
165
+ x = A.method
166
+ // option 2
167
+ A.method() {
168
+ return y
169
+ }
170
+ ....
171
+
172
+ If you use both, we will render both with overlapping. This is on purpose to expose
173
+ the conflict to the user.
174
+
175
+ .Return message conflict
176
+ image::images/return-message-conflict.png[width=200,alt="return message conflict"]
177
+
178
+ === Message arrow
179
+ .Message arrow (the dashed line and arrow head)
180
+ image::images/creation-component.png[width=224]
181
+
182
+ This time we focus on how to align the arrow line and the arrow head.
183
+ We use a similar approach as pattern #vertically aligning# with pattern
184
+ #shift half the height#. Instead of `items-center` we use `items-end`.
185
+ Then we use `translate-y-1/2` to shift the arrow head down half the
186
+ height of the arrow head. (See Message.vue)
187
+ ....
188
+ <div class="message flex items-end"
189
+ <div class="name flex-grow" style="padding-left: 10px">{{content}}</div>
190
+ <point class="flex-shrink-0 transform translate-y-1/2 -my-px" :fill="fill" :rtl="rtl"/>
191
+ </div>
192
+ ....
193
+
194
+ ==== Key classes
195
+ ===== .flex .items-end
196
+ The `flex` and `items-end` classes are used to align the arrow line
197
+ and the arrow head at the bottom of the message.
198
+
199
+ ===== .flex-grow
200
+ The `flex-grow` class is used to make the message name grow to fill
201
+ the available space.
202
+
203
+ ===== .flex-shrink-0
204
+ The `flex-shrink-0` class is used to make the arrow head not shrink
205
+ when the message name is too long.
206
+
207
+ ===== .transform .translate-y-1/2
208
+ The `transform` and `translate-y-1/2` classes are used to shift the
209
+ arrow head down half the height of the arrow head.
210
+
211
+ === Message arrow right to left
212
+ image::images/message-arrow-rtl.png[width=200,alt="message arrow right to left"]
213
+
214
+ ....
215
+ <div class="message flex items-end" :class="{'flex-row-reverse': rtl}">
216
+ <div class="name flex-grow"
217
+ >{{content}}</div>
218
+ <point class="flex-shrink-0 transform translate-y-1/2 -my-px"/>
219
+ </div>
220
+ ....
221
+
222
+ ==== Key classes
223
+ ===== .flex-row-reverse
224
+ The `flex-row-reverse` class is used to reverse the order of the name and
225
+ the arrow head.
226
+
227
+ === Creation
228
+ image::images/creation-component.png[width=240]
229
+
230
+ ==== Pattern 1: Vertically aligning
231
+ image::images/vertical-alignment.svg[width=40]
232
+
233
+ ....
234
+ <div class="flex items-center">
235
+ <div class="w-10 h-8 bg-blue-200"></div>
236
+ <div class="w-10 h-20 bg-green-200"></div>
237
+ </div>
238
+ ....
239
+
240
+ ==== Pattern 2: Shift half the height
241
+ image::images/shift-up-half-the-height.png[width=50]
242
+
243
+ The message arrow is supposed to point to the middle of the participant
244
+ box. It is not he whole message that is aligned with the participant
245
+ box. So we have to shift the message up half the height of the message.
246
+ ....
247
+ <div class="flex items-center m-10">
248
+ <div class="w-10 h-8 bg-blue-200 transform -translate-y-1/2"></div>
249
+ <div class="w-10 h-20 bg-green-200"></div>
250
+ </div>
251
+ ....
252
+
253
+ This pattern is also used at the arrows. See the image for creation.
254
+
255
+ === Creation participant top
256
+ While all normal participants have their name boxes at the top of the
257
+ diagram, creation participant boxes need to be pushed down to align
258
+ with the message arrow.
259
+
260
+ To implement this, we add a `padding-top` to the containing lifeline
261
+ of the corresponding participant.
262
+
263
+ The padding top is calculated by subtracting the top of message from
264
+ the top of participant's original value.
265
+
266
+ ==== Challenge
267
+ When the message container is mounted, it does not have the correct
268
+ participant box offsetWidth.
269
+
270
+ === Creation right to left
271
+ image::images/creation-rtl.png[width=240,alt="creation right to left"]
272
+
273
+ On top of normal Creation, we need to flip the participant placeholder
274
+ and the message container. We use the `flex-row-reverse` class to flip.
275
+ See "Message right to left" for example using `flex-row-reverse`.
276
+
277
+
@@ -0,0 +1,121 @@
1
+ = Integration Guide
2
+ :icons: font
3
+
4
+ == Audience
5
+ This document is written for those want to integrate ZenUML to their applications. If you are an end
6
+ user, please read tutorials; if your would like to contribute, please read contributor's guide.
7
+
8
+
9
+ == Integration
10
+ An important goal of this project is to be easily integrated into other projects.
11
+ There are mainly two ways to do this.
12
+
13
+ === As a library
14
+
15
+ ZenUML Core exposes a simple API for integration:
16
+
17
+ [source, typescript]
18
+ ----
19
+ interface IZenUml {
20
+ get code(): string | undefined;
21
+ get theme(): string | undefined;
22
+ // Resolve after rendering is finished.
23
+ render: (code: string | undefined, theme: string | undefined) => Promise<IZenUml>
24
+ }
25
+
26
+ // client code
27
+ import ZenUml from '@ZenUML/core'
28
+ const zenUml = new ZenUml(el)
29
+ await zenUml.render('A.method', 'theme-blue')
30
+ ----
31
+
32
+ ==== When rendering is finished
33
+ When rendering is finished, the `render` method will return a promise that resolves to the
34
+ instance of `IZenUml`. The `html` properties of the instance will be updated to the rendered
35
+ HTML.
36
+
37
+ [NOTE]
38
+ ====
39
+ Vue's reactive system works against the `data`, `props` and `computed` properties of a component.
40
+ This means a parent component is not necessarily be notified when a child component is `mounted` or `updated`.
41
+ So this means we can not use the `mounted` or `updated` hook on `LifelineLayer` to emit `rendered` event.
42
+ ====
43
+
44
+ It is tricky to know when the rendering is finished. The `Lifeline` components used `$nextTick`
45
+ in their `mounted` and `updated` hooks to set the top when a `creation` message is sent to it.
46
+ We have to wait until all those `$nextTick` calls are finished.
47
+
48
+ [NOTE]
49
+ ====
50
+ It seems that (to be confirmed) the `$nextTick` calls are queued and executed in ONE tick. This
51
+ makes it easier to control the timing when to resolve the `render` promise. We only need to wait
52
+ ONE `$nextTick` call to be finished.
53
+ ====
54
+
55
+ The diagram is rendered in the following steps:
56
+
57
+ 1. The lifeline layer;
58
+ 2. The message layer;
59
+ 3. Update lifeline layer with `setTimeout` for `creation` messages.
60
+
61
+ === As an iframe
62
+
63
+ You can embed the ZenUML core renderer as an application within another app, where you store the diagram
64
+ data in the host app. It takes around 5 minutes to get a basic example running.
65
+
66
+ ==== Quick test
67
+ To test this out open `https://embed.zenuml.com/embed.html`. In the developer console, type in the
68
+ following command.
69
+
70
+ [source,js]
71
+ ----
72
+ window.postMessage( {action: 'eval', args: { code: 'ZenUML.Hello' }})
73
+ ----
74
+ ==== The protocol
75
+
76
+ The protocol is a simple JSON object with the following fields.
77
+
78
+ [source,json]
79
+ ----
80
+ {
81
+ "action": "eval",
82
+ "args": {
83
+ "code": "ZenUML.Hello",
84
+ "style": "#diagram { background-color: red; }",
85
+ "theme": "blue",
86
+ "css": "https://github.com/abruzzi/zenuml-css-overrides/blob/master/zenuml-override.css"
87
+ }
88
+ }
89
+ ----
90
+
91
+ ==== Example
92
+
93
+ [source,html]
94
+ ----
95
+ <iframe src="https://embed.zenuml.com/embed.html" id="zenuml-iframe"
96
+ style="width: 100%; height: 100%; border: none;">
97
+
98
+ </iframe>
99
+ <script>
100
+ const iframe = document.getElementById('zenuml-iframe');
101
+ const message = {
102
+ action: 'eval',
103
+ args: {
104
+ code: 'ZenUML.Hello',
105
+ style: '#diagram { background-color: red; }',
106
+ theme: 'blue',
107
+ css: ''
108
+ }
109
+ };
110
+ setTimeout(() => {
111
+ iframe.contentWindow.postMessage(message, '*');
112
+ }, 1000);
113
+ </script>
114
+ ----
115
+
116
+ [source,js]
117
+ ----
118
+ document.getElementsByTagName('iframe')[0] // get iframe
119
+ .contentWindow // get target window
120
+ .postMessage({action: "eval", args: { code: 'A.m' }})
121
+ ----
@@ -0,0 +1,22 @@
1
+ = User's guide
2
+
3
+ == Audience
4
+ This document is written for end users of the software. If you want to integrate
5
+ ZenUML into your own application, please refer to the integration guide. If you
6
+ want to contribute to the development of ZenUML, please refer to the contributor's
7
+ guide.
8
+
9
+ == Introduction
10
+ > A Sequence diagram is an interaction diagram that shows how processes operate with one another and in what order.
11
+
12
+ ZenUML is a tool for creating sequence diagrams from text. It runs completely
13
+ in the browser, so you don't need to worry about data privacy or security. See
14
+ https://link[data privacy and security] for more information.
15
+
16
+ ++++
17
+ <iframe src="https://embed.zenuml.com/smoke-creation.html"></iframe>
18
+ ++++
19
+
20
+ == Syntax
21
+
22
+ === Participants
@@ -0,0 +1,78 @@
1
+ Async:
2
+ ```
3
+ asyncMessage
4
+ : source ARROW target COL content
5
+ | source (MINUS | ARROW) target?
6
+ ;
7
+
8
+ content
9
+ : EVENT_PAYLOAD_LXR
10
+ ;
11
+
12
+ source
13
+ : ID | STRING
14
+ ;
15
+
16
+ target
17
+ : ID | STRING
18
+ ;
19
+ ```
20
+ Sync:
21
+ ```
22
+ message
23
+ : messageBody (SCOL | braceBlock)?
24
+ ;
25
+
26
+ // Order of 'func | (to DOT)' is important. Otherwise A.m will be parsed as to messages
27
+ messageBody
28
+ : assignment? ((from ARROW)? to DOT)? func
29
+ | assignment
30
+ | to DOT
31
+ ;
32
+
33
+ // func is also used in exp as parameter with expr: (to DOT)? func;
34
+ func
35
+ : signature (DOT signature)*
36
+ ;
37
+
38
+ from
39
+ : ID | STRING
40
+ ;
41
+
42
+ signature
43
+ : methodName invocation?
44
+ ;
45
+
46
+ // We have removed the alternative rule with single OPAR as we are improving the editor to always close the brackets.
47
+ invocation
48
+ : OPAR parameters? CPAR
49
+ ;
50
+
51
+ assignment
52
+ : (type? assignee ASSIGN)
53
+ ;
54
+ ```
55
+ First of all, `from->to` and `source->target` are very similar. Let's first merge them.
56
+
57
+
58
+ if(!this.rightToLeft) {
59
+ if(this.outOfBand) {
60
+ // A B C
61
+ // inh pro to
62
+ const dist = this.distance2(this.origin, this.providedFrom)
63
+ return dist - indent + fragmentOff
64
+ } else {
65
+ // A B
66
+ // inh to
67
+ // No self call indent here. It is used only for width.
68
+ return fragmentOff
69
+ }
70
+ } else {
71
+ // A B C
72
+ // to pro origin
73
+ // OR
74
+ // A B
75
+ // to origin
76
+ const dist = this.distance2(this.to, this.origin)
77
+ return (dist - indent - fragmentOff) * (-1)
78
+ }
Binary file
@@ -0,0 +1,47 @@
1
+ Since 1.0.63
2
+
3
+ # Highlighting messages
4
+ The renderer will highlight an `Interaction` based on the value of `cursor` in the store.
5
+ For example, for DSL `A.x B.y`, if `cursor` is between [0, 3], `A.x` is highlighted in
6
+ the diagram; if `cursor` is between [4, 7], `B.y` is highlighted.
7
+
8
+ ## What elements can be highlighted?
9
+
10
+ Theoretically, every element can be highlighted. The logic is different for
11
+ different types.
12
+
13
+ We will focus on messages: Creation and Messages (Sync & Async).
14
+
15
+ ### Creation
16
+
17
+ Creations parser definition is:
18
+ ```
19
+ creationBody (SCOL | braceBlock)?
20
+ ```
21
+
22
+ We will highlight the creation call and assignment but NOT the `braceBlock`.
23
+ The triggering cursor must be in between `creationBody`.
24
+
25
+ ### Message
26
+
27
+ Message parser definition is:
28
+ ```
29
+ messageBody (SCOL | braceBlock)?
30
+ ```
31
+ We will highlight the message call and assignment but NOT the `braceBlock`.
32
+ The triggering cursor must be in between `messageBody`.
33
+
34
+ ### Async Message
35
+
36
+ Async message parser definition is:
37
+ ```
38
+ source ARROW target COL content
39
+ ```
40
+ We will highlight the whole message call.
41
+ The triggering curso must bee in between `source ARROW target COL content`.
42
+
43
+
44
+ ## Implementation
45
+
46
+ The global store has a state `cursor`. Each component check whether this cursor
47
+ is in between the range that should set the `isCurrent` status of itself.