@statewalker/fsm-charts 0.2.5 → 0.2.7
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 +213 -1
- package/dist/StateChart-cXyVRcs-.d.ts +94 -0
- package/dist/StateChart-cXyVRcs-.d.ts.map +1 -0
- package/dist/StateChartIndex-BK2315qj.d.ts +142 -0
- package/dist/StateChartIndex-BK2315qj.d.ts.map +1 -0
- package/dist/StateChartIndex-BOIrc_nq.js +355 -0
- package/dist/StateChartIndex-BOIrc_nq.js.map +1 -0
- package/dist/buildStatechartsPanel-BX7e0GzA.js +494 -0
- package/dist/buildStatechartsPanel-BX7e0GzA.js.map +1 -0
- package/dist/buildStatechartsPanel-hCtZbdiF.d.ts +79 -0
- package/dist/buildStatechartsPanel-hCtZbdiF.d.ts.map +1 -0
- package/dist/defineProperty-C0rC37pP.js +39 -0
- package/dist/description-panels-DI2MNlbK.js +184 -0
- package/dist/description-panels-DI2MNlbK.js.map +1 -0
- package/dist/getLabelDimensions-BY0q7j3D.d.ts +79 -0
- package/dist/getLabelDimensions-BY0q7j3D.d.ts.map +1 -0
- package/dist/getPadding-Cw0e7G2v.js +25 -0
- package/dist/getPadding-Cw0e7G2v.js.map +1 -0
- package/dist/index-config.d.ts +3 -12
- package/dist/index-config.js +2 -2
- package/dist/index-dom.d.ts +2 -49
- package/dist/index-dom.js +2 -2
- package/dist/index-html.d.ts +3 -2
- package/dist/index-html.js +2 -3
- package/dist/index-layout.d.ts +3 -77
- package/dist/index-layout.js +2 -3
- package/dist/index-runtime.d.ts +3 -141
- package/dist/index-runtime.js +2 -2
- package/dist/index.d.ts +11 -10
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -7
- package/dist/layout-Dp671N6q.js +2465 -0
- package/dist/layout-Dp671N6q.js.map +1 -0
- package/dist/newTreeBuilder-CvtLDjGj.d.ts +54 -0
- package/dist/newTreeBuilder-CvtLDjGj.d.ts.map +1 -0
- package/dist/toFsmStateConfig-DlJkyZni.js +135 -0
- package/dist/toFsmStateConfig-DlJkyZni.js.map +1 -0
- package/dist/toFsmStateConfig-DmOlTRjv.d.ts +15 -0
- package/dist/toFsmStateConfig-DmOlTRjv.d.ts.map +1 -0
- package/package.json +52 -27
- package/src/config/concatTransitionsToString.ts +2 -2
- package/src/config/splitTransitionString.ts +1 -3
- package/src/config/toFsmStateConfig.ts +2 -9
- package/src/dom/buildSections.ts +3 -11
- package/src/dom/description-panels.ts +2 -4
- package/src/dom/getStatesDescriptions.ts +3 -9
- package/src/html/buildStatechartStyles.ts +4 -14
- package/src/html/buildStatechartSvg.ts +2 -14
- package/src/html/buildStatechartsPanel.ts +1 -3
- package/src/layout/buildCharts.ts +1 -2
- package/src/layout/buildFlatCharts.ts +6 -8
- package/src/layout/getGraphParamsProvider.ts +3 -12
- package/src/runtime/RuntimeStatechartApi.ts +10 -32
- package/src/runtime/StateChartIndex.ts +6 -23
- package/src/types/GraphParamsProvider.ts +1 -4
- package/src/utils/BasisCurve.ts +5 -14
- package/src/utils/domToText.ts +2 -6
- package/src/utils/getPadding.ts +1 -2
- package/src/utils/newId.ts +2 -1
- package/src/utils/newRegistry.ts +12 -12
- package/src/utils/serializeAttrs.ts +3 -13
- package/src/utils/serializeCss.ts +1 -5
- package/src/utils/serializeStyle.ts +1 -4
- package/src/utils/toKebabCase.ts +1 -4
- package/dist/StateChart-BYBjTmC2.d.ts +0 -82
- package/dist/chunk-2LFUT2C6.js +0 -2691
- package/dist/chunk-ARZYBFNA.js +0 -133
- package/dist/chunk-CR2M4445.js +0 -608
- package/dist/chunk-FIQDLBWD.js +0 -9
- package/dist/chunk-GW2Z65BN.js +0 -429
- package/dist/chunk-PKBMQBKP.js +0 -5
- package/dist/chunk-RZ4FP6JB.js +0 -233
- package/dist/index-html-BBQqYoST.d.ts +0 -75
- package/src/full/index.ts +0 -1
- package/src/full/toFsmStateCharts.ts +0 -119
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
import { t as _defineProperty } from "./defineProperty-C0rC37pP.js";
|
|
2
|
+
import { t as getPadding } from "./getPadding-Cw0e7G2v.js";
|
|
3
|
+
//#region src/utils/toKebabCase.ts
|
|
4
|
+
function toKebabCase(str) {
|
|
5
|
+
str = (str || "").trim().replace(/\s+/gim, "-");
|
|
6
|
+
str = str.replace(/([^A-Z]?)([A-Z])/g, (_, a, b) => `${a.toLowerCase()}-${b.toLowerCase()}`);
|
|
7
|
+
return str;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/utils/serializeCss.ts
|
|
11
|
+
function serializeCss(obj) {
|
|
12
|
+
return visitStyle(obj).join("\n");
|
|
13
|
+
function visitStyle(obj, lines = [], prefixes = [""]) {
|
|
14
|
+
for (const [key, style] of Object.entries(obj)) {
|
|
15
|
+
const selectors = [];
|
|
16
|
+
for (const sel of key.split(",").map((_) => _.trim())) for (const prefix of prefixes) {
|
|
17
|
+
const selector = sel.replace(/^(.)/, (_, ch) => ch === "&" ? prefix : prefix.length > 0 ? `${prefix} ${ch}` : ch);
|
|
18
|
+
selectors.push(selector);
|
|
19
|
+
}
|
|
20
|
+
const selectorRules = [];
|
|
21
|
+
const extensions = [];
|
|
22
|
+
for (let [key, value] of Object.entries(style)) if (typeof value === "object") visitStyle({ [key]: value }, extensions, selectors);
|
|
23
|
+
else {
|
|
24
|
+
key = toKebabCase(key);
|
|
25
|
+
selectorRules.push(` ${key}: ${value};`);
|
|
26
|
+
}
|
|
27
|
+
if (selectorRules.length) {
|
|
28
|
+
lines.push(`${selectors.join(",\n")} {`);
|
|
29
|
+
lines.push(...selectorRules);
|
|
30
|
+
lines.push(`}`);
|
|
31
|
+
}
|
|
32
|
+
lines.push(...extensions);
|
|
33
|
+
}
|
|
34
|
+
return lines;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/html/buildStatechartStyles.ts
|
|
39
|
+
const activeStatesStyle = {
|
|
40
|
+
backgroundColor: "white",
|
|
41
|
+
borderColor: "red",
|
|
42
|
+
borderWidth: "2px",
|
|
43
|
+
labelColor: "red"
|
|
44
|
+
};
|
|
45
|
+
const activeTransitionsStyle = {
|
|
46
|
+
backgroundColor: "#eee",
|
|
47
|
+
borderColor: "none",
|
|
48
|
+
borderWidth: "0",
|
|
49
|
+
lineColor: "red",
|
|
50
|
+
lineWidth: "1px",
|
|
51
|
+
labelColor: "red"
|
|
52
|
+
};
|
|
53
|
+
const selectedStatesStyle = {
|
|
54
|
+
backgroundColor: "white",
|
|
55
|
+
borderColor: "navy",
|
|
56
|
+
borderWidth: "2px",
|
|
57
|
+
labelColor: "navy"
|
|
58
|
+
};
|
|
59
|
+
const selectedTransitionsStyle = {
|
|
60
|
+
backgroundColor: "#eee",
|
|
61
|
+
borderColor: "none",
|
|
62
|
+
borderWidth: "0",
|
|
63
|
+
lineColor: "navy",
|
|
64
|
+
lineWidth: "1px",
|
|
65
|
+
labelColor: "navy"
|
|
66
|
+
};
|
|
67
|
+
function buildStateDetailsStyle({ root = ":root" }) {
|
|
68
|
+
return { [root]: {
|
|
69
|
+
".state-details": {
|
|
70
|
+
backgroundColor: "var(--state-background-color, white)",
|
|
71
|
+
border: "var(--state-border-width, 1px) solid var(--state-border-color, currentColor)",
|
|
72
|
+
borderRadius: "0.5em",
|
|
73
|
+
padding: "0.5em"
|
|
74
|
+
},
|
|
75
|
+
".state-details__label": {
|
|
76
|
+
cursor: "pointer",
|
|
77
|
+
color: "var(--transition-label-color, currentColor)",
|
|
78
|
+
fontFamily: "var(--state-label-font-family, sans-serif)",
|
|
79
|
+
fontSize: "var(--state-label-font-size, 14px)"
|
|
80
|
+
},
|
|
81
|
+
".state-details__content": {
|
|
82
|
+
display: "flex",
|
|
83
|
+
flexDirection: "column",
|
|
84
|
+
gap: "0.5em"
|
|
85
|
+
},
|
|
86
|
+
".state-details__chart": {
|
|
87
|
+
maxWidth: "100%",
|
|
88
|
+
overflow: "auto",
|
|
89
|
+
scrollbarWidth: "thin"
|
|
90
|
+
}
|
|
91
|
+
} };
|
|
92
|
+
}
|
|
93
|
+
function buildStateDetailsStyleWithModifier({ root = ":root", modifier, states }) {
|
|
94
|
+
return { [root]: {
|
|
95
|
+
".state-details": { [`&.state-details--${modifier}`]: {
|
|
96
|
+
backgroundColor: `var(--state-${modifier}-background-color, ${states.backgroundColor})`,
|
|
97
|
+
border: `var(--state-${modifier}-border-width, 1px) solid var(--state-${modifier}-border-color, currentColor)`
|
|
98
|
+
} },
|
|
99
|
+
".state-details__label": { [`&.state-details__label--${modifier}`]: { color: `var(--state-${modifier}-label-color)` } }
|
|
100
|
+
} };
|
|
101
|
+
}
|
|
102
|
+
function buildStatechartStylesWithModifier({ root = ":root", modifier, states, transitions }) {
|
|
103
|
+
return { [root]: {
|
|
104
|
+
[`--transition-${modifier}-background-color`]: transitions.backgroundColor,
|
|
105
|
+
[`--transition-${modifier}-border-color`]: transitions.borderColor,
|
|
106
|
+
[`--transition-${modifier}-border-width`]: transitions.borderWidth,
|
|
107
|
+
[`--transition-${modifier}-line-color`]: transitions.lineColor,
|
|
108
|
+
[`--transition-${modifier}-line-width`]: transitions.lineWidth,
|
|
109
|
+
[`--transition-${modifier}-label-color`]: transitions.labelColor,
|
|
110
|
+
[`--state-${modifier}-background-color`]: states.backgroundColor,
|
|
111
|
+
[`--state-${modifier}-border-color`]: states.borderColor,
|
|
112
|
+
[`--state-${modifier}-border-width`]: states.borderWidth,
|
|
113
|
+
[`--state-${modifier}-label-color`]: states.labelColor,
|
|
114
|
+
".state": { [`&.state--${modifier}`]: {
|
|
115
|
+
"--state-background-color": `var(--state-${modifier}-background-color)`,
|
|
116
|
+
"--state-border-color": `var(--state-${modifier}-border-color)`,
|
|
117
|
+
"--state-border-width": `var(--state-${modifier}-border-width)`,
|
|
118
|
+
"--state-label-color": `var(--state-${modifier}-label-color)`
|
|
119
|
+
} },
|
|
120
|
+
".transition": { [`&.transition--${modifier}`]: {
|
|
121
|
+
"--transition-background-color": `var(--transition-${modifier}-background-color)`,
|
|
122
|
+
"--transition-border-color": `var(--transition-${modifier}-border-color)`,
|
|
123
|
+
"--transition-border-width": `var(--transition-${modifier}-border-width)`,
|
|
124
|
+
"--transition-line-color": `var(--transition-${modifier}-line-color)`,
|
|
125
|
+
"--transition-line-width": `var(--transition-${modifier}-line-width)`,
|
|
126
|
+
"--transition-label-color": `var(--transition-${modifier}-label-color)`
|
|
127
|
+
} }
|
|
128
|
+
} };
|
|
129
|
+
}
|
|
130
|
+
function buildStatechartStyles({ root = ":root" }) {
|
|
131
|
+
return { [root]: {
|
|
132
|
+
"--transition-background-color": "rgba(255,255,255,0.7)",
|
|
133
|
+
"--transition-border-color": "none",
|
|
134
|
+
"--transition-border-width": "1px",
|
|
135
|
+
"--transition-line-color": "silver",
|
|
136
|
+
"--transition-line-width": "1px",
|
|
137
|
+
"--transition-label-color": "gray",
|
|
138
|
+
"--transition-label-font-size": "12px",
|
|
139
|
+
"--transition-label-font-family": "sans-serif",
|
|
140
|
+
".transition__marker": {
|
|
141
|
+
fill: "var(--transition-line-color, currentColor)",
|
|
142
|
+
stroke: "none"
|
|
143
|
+
},
|
|
144
|
+
".transition__line": {
|
|
145
|
+
stroke: "var(--transition-line-color, currentColor)",
|
|
146
|
+
strokeWidth: "var(--transition-line-width, 1px)"
|
|
147
|
+
},
|
|
148
|
+
".transition__box": {
|
|
149
|
+
fill: "var(--transition-background-color, rgba(255,255,255,0.7))",
|
|
150
|
+
stroke: "var(--transition-border-color, none)",
|
|
151
|
+
strokeWidth: "var(--transition-border-width, 1px)",
|
|
152
|
+
borderRadius: "0.5em",
|
|
153
|
+
cursor: "pointer"
|
|
154
|
+
},
|
|
155
|
+
".transition__label": {
|
|
156
|
+
fill: "var(--transition-label-color, currentColor)",
|
|
157
|
+
fontSize: "var(--transition-label-font-size, 12px)",
|
|
158
|
+
fontFamily: "var(--transition-label-font-family, sans-serif)",
|
|
159
|
+
cursor: "pointer"
|
|
160
|
+
},
|
|
161
|
+
"--state-background-color": "white",
|
|
162
|
+
"--state-border-color": "silver",
|
|
163
|
+
"--state-border-width": "1px",
|
|
164
|
+
"--state-label-color": "gray",
|
|
165
|
+
"--state-label-font-size": "14px",
|
|
166
|
+
"--state-label-font-family": "sans-serif",
|
|
167
|
+
".state__box": {
|
|
168
|
+
fill: "var(--state-background-color, white)",
|
|
169
|
+
stroke: "var(--state-border-color, currentColor)",
|
|
170
|
+
strokeWidth: "var(--state-border-width, 1px)",
|
|
171
|
+
borderRadius: "0.5em",
|
|
172
|
+
cursor: "pointer"
|
|
173
|
+
},
|
|
174
|
+
".state__label": {
|
|
175
|
+
color: "var(--state-label-color, currentColor)",
|
|
176
|
+
fill: "var(--state-label-color, currentColor)",
|
|
177
|
+
fontSize: "var(--state-label-font-size, 14px)",
|
|
178
|
+
fontFamily: "var(--state-label-font-family, sans-serif)",
|
|
179
|
+
cursor: "pointer"
|
|
180
|
+
},
|
|
181
|
+
".state__initial": {
|
|
182
|
+
fill: "var(--state-border-color, currentColor)",
|
|
183
|
+
stroke: "var(--state-border-color, currentColor)",
|
|
184
|
+
strokeWidth: "var(--state-border-width, 2px)"
|
|
185
|
+
},
|
|
186
|
+
".state__final": {
|
|
187
|
+
fill: "white",
|
|
188
|
+
stroke: "var(--state-border-color, currentColor)",
|
|
189
|
+
strokeWidth: "var(--state-border-width, 2px)",
|
|
190
|
+
"&.state__final--inner": {
|
|
191
|
+
fill: "var(--state-border-color, currentColor)",
|
|
192
|
+
stroke: "none",
|
|
193
|
+
strokeWidth: "0"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
} };
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/html/buildStatechartCss.ts
|
|
200
|
+
function buildStatechartCss({ prefix = "" } = {}) {
|
|
201
|
+
const root = prefix || ":root";
|
|
202
|
+
return [
|
|
203
|
+
buildStatechartStyles({ root }),
|
|
204
|
+
buildStatechartStylesWithModifier({
|
|
205
|
+
root,
|
|
206
|
+
modifier: "selected",
|
|
207
|
+
states: selectedStatesStyle,
|
|
208
|
+
transitions: selectedTransitionsStyle
|
|
209
|
+
}),
|
|
210
|
+
buildStatechartStylesWithModifier({
|
|
211
|
+
root,
|
|
212
|
+
modifier: "active",
|
|
213
|
+
states: activeStatesStyle,
|
|
214
|
+
transitions: activeTransitionsStyle
|
|
215
|
+
}),
|
|
216
|
+
buildStateDetailsStyle({ root }),
|
|
217
|
+
buildStateDetailsStyleWithModifier({
|
|
218
|
+
root,
|
|
219
|
+
modifier: "selected",
|
|
220
|
+
states: selectedStatesStyle
|
|
221
|
+
}),
|
|
222
|
+
buildStateDetailsStyleWithModifier({
|
|
223
|
+
root,
|
|
224
|
+
modifier: "active",
|
|
225
|
+
states: activeStatesStyle
|
|
226
|
+
})
|
|
227
|
+
].map(serializeCss).join("\n");
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/utils/BasisCurve.ts
|
|
231
|
+
var BasisCurve = class {
|
|
232
|
+
constructor(context) {
|
|
233
|
+
_defineProperty(this, "_context", void 0);
|
|
234
|
+
_defineProperty(this, "_x0", 0);
|
|
235
|
+
_defineProperty(this, "_y0", 0);
|
|
236
|
+
_defineProperty(this, "_x1", 0);
|
|
237
|
+
_defineProperty(this, "_y1", 0);
|
|
238
|
+
_defineProperty(this, "_point", 0);
|
|
239
|
+
_defineProperty(this, "_line", 0);
|
|
240
|
+
this._context = context;
|
|
241
|
+
}
|
|
242
|
+
$point(x, y) {
|
|
243
|
+
this._context.bezierCurveTo((2 * this._x0 + this._x1) / 3, (2 * this._y0 + this._y1) / 3, (this._x0 + 2 * this._x1) / 3, (this._y0 + 2 * this._y1) / 3, (this._x0 + 4 * this._x1 + x) / 6, (this._y0 + 4 * this._y1 + y) / 6);
|
|
244
|
+
}
|
|
245
|
+
areaStart() {
|
|
246
|
+
this._line = 0;
|
|
247
|
+
}
|
|
248
|
+
areaEnd() {
|
|
249
|
+
this._line = NaN;
|
|
250
|
+
}
|
|
251
|
+
lineStart() {
|
|
252
|
+
this._x0 = this._x1 = this._y0 = this._y1 = NaN;
|
|
253
|
+
this._point = 0;
|
|
254
|
+
}
|
|
255
|
+
lineEnd() {
|
|
256
|
+
switch (this._point) {
|
|
257
|
+
case 3: this.$point(this._x1, this._y1);
|
|
258
|
+
case 2: this._context.lineTo(this._x1, this._y1);
|
|
259
|
+
}
|
|
260
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
261
|
+
this._line = 1 - this._line;
|
|
262
|
+
}
|
|
263
|
+
point(x, y) {
|
|
264
|
+
x = +x, y = +y;
|
|
265
|
+
switch (this._point) {
|
|
266
|
+
case 0:
|
|
267
|
+
this._point = 1;
|
|
268
|
+
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
|
|
269
|
+
break;
|
|
270
|
+
case 1:
|
|
271
|
+
this._point = 2;
|
|
272
|
+
break;
|
|
273
|
+
case 2:
|
|
274
|
+
this._point = 3;
|
|
275
|
+
this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6);
|
|
276
|
+
default: this.$point(x, y);
|
|
277
|
+
}
|
|
278
|
+
this._x0 = this._x1, this._x1 = x;
|
|
279
|
+
this._y0 = this._y1, this._y1 = y;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/utils/serializeAttrs.ts
|
|
284
|
+
function serializeAttrs(attrs = {}, { prefix = "", transform = false } = {}) {
|
|
285
|
+
const result = [];
|
|
286
|
+
for (const [key, value] of Object.entries(attrs || {}).sort(([a], [b]) => a > b ? 1 : -1)) {
|
|
287
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
288
|
+
result.push(`${prefix}${escapeValue(key)}=${JSON.stringify(escapeValue(transform ? toKebabCase(String(value)) : value))}`);
|
|
289
|
+
}
|
|
290
|
+
return result.join(" ");
|
|
291
|
+
function escapeValue(value) {
|
|
292
|
+
return String(value).replaceAll(/</gim, "<").replaceAll(/>/gim, ">").replaceAll(/"/gim, """);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region src/html/buildStatechartSvg.ts
|
|
297
|
+
function getBoxParams({ x, y, width, height, padding = 0 }) {
|
|
298
|
+
const [top, right, bottom, left] = getPadding(padding);
|
|
299
|
+
const h = Math.ceil(height - top - bottom);
|
|
300
|
+
return {
|
|
301
|
+
x: x + left,
|
|
302
|
+
y: y - bottom - h,
|
|
303
|
+
width: Math.ceil(width - left - right),
|
|
304
|
+
height: h
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
function buildStatechartSvg({ graph: { width, height, nodes, edges }, newId, stateFontSize = 14, transitionFontSize = 12, println, initialStateKey = "<initial>", finalStateKey = "<final>" }) {
|
|
308
|
+
if (!nodes.length && !edges.length) return;
|
|
309
|
+
width = Math.ceil(width);
|
|
310
|
+
height = Math.ceil(height);
|
|
311
|
+
println(`<svg ${serializeAttrs({
|
|
312
|
+
class: "statechart",
|
|
313
|
+
width,
|
|
314
|
+
height,
|
|
315
|
+
viewbox: `0 0 ${width} ${height}`,
|
|
316
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
317
|
+
})}>`);
|
|
318
|
+
println(`<g class="statechart__transitions">`);
|
|
319
|
+
const markerAttrs = serializeAttrs({
|
|
320
|
+
refX: 19,
|
|
321
|
+
refY: 7,
|
|
322
|
+
markerWidth: 20,
|
|
323
|
+
markerHeight: 14,
|
|
324
|
+
orient: "auto",
|
|
325
|
+
class: "transition__marker",
|
|
326
|
+
stroke: "none",
|
|
327
|
+
fill: "currentColor"
|
|
328
|
+
});
|
|
329
|
+
for (const edge of edges) {
|
|
330
|
+
const { id, points, text } = edge;
|
|
331
|
+
println(` <g class="transition" data-transition-id="${id}">`);
|
|
332
|
+
const markerId = newId("marker");
|
|
333
|
+
println(` <defs>`);
|
|
334
|
+
println(` <marker id="${markerId}" ${markerAttrs}>`);
|
|
335
|
+
println(` <path d="M 19,7 L9,13 L14,7 L9,1 Z"></path>`);
|
|
336
|
+
println(` </marker>`);
|
|
337
|
+
println(` </defs>`);
|
|
338
|
+
const path = [];
|
|
339
|
+
const round = (...n) => n.map(Math.round);
|
|
340
|
+
const base = new BasisCurve({
|
|
341
|
+
bezierCurveTo(x0, y0, x1, y1, x2, y2) {
|
|
342
|
+
path.push(`C${round(x0, y0, x1, y1, x2, y2).join(",")}`);
|
|
343
|
+
},
|
|
344
|
+
moveTo(x, y) {
|
|
345
|
+
path.push(`M${round(x, y).join(",")}`);
|
|
346
|
+
},
|
|
347
|
+
lineTo(x, y) {
|
|
348
|
+
path.push(`L${round(x, y).join(",")}`);
|
|
349
|
+
},
|
|
350
|
+
closePath() {
|
|
351
|
+
path.push("Z");
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
base.lineStart();
|
|
355
|
+
for (const point of points) base.point(point.x, point.y);
|
|
356
|
+
base.lineEnd();
|
|
357
|
+
println(` <path ${serializeAttrs({
|
|
358
|
+
class: "transition__line",
|
|
359
|
+
fill: "none",
|
|
360
|
+
stroke: "currentColor",
|
|
361
|
+
strokeWidth: "1px",
|
|
362
|
+
d: path.join(""),
|
|
363
|
+
"marker-end": `url(#${markerId})`
|
|
364
|
+
})} />`);
|
|
365
|
+
if (text) {
|
|
366
|
+
const { x, y, width, height } = getBoxParams({
|
|
367
|
+
...edge,
|
|
368
|
+
padding: 0
|
|
369
|
+
});
|
|
370
|
+
println(` <rect ${serializeAttrs({
|
|
371
|
+
x,
|
|
372
|
+
y: y - transitionFontSize,
|
|
373
|
+
width,
|
|
374
|
+
height,
|
|
375
|
+
rx: Math.ceil(transitionFontSize / 2),
|
|
376
|
+
ry: Math.ceil(transitionFontSize / 2),
|
|
377
|
+
fill: "rgba(255,255,255,0.7)",
|
|
378
|
+
stroke: "none",
|
|
379
|
+
strokeWidth: "1",
|
|
380
|
+
class: "transition__box"
|
|
381
|
+
})} />`);
|
|
382
|
+
println(` <text ${serializeAttrs({
|
|
383
|
+
class: "transition__label",
|
|
384
|
+
"text-anchor": "middle",
|
|
385
|
+
fill: "currentColor",
|
|
386
|
+
x: Math.round(x + width / 2),
|
|
387
|
+
y: Math.round(y + height / 2 - transitionFontSize / 2)
|
|
388
|
+
})}>${text}</text>`);
|
|
389
|
+
}
|
|
390
|
+
println(` </g>`);
|
|
391
|
+
}
|
|
392
|
+
println("</g>");
|
|
393
|
+
const shift = stateFontSize / 4;
|
|
394
|
+
const initialStateRadius = 6;
|
|
395
|
+
const finalStateRadius = initialStateRadius / 2;
|
|
396
|
+
println(`<g class="statechart__states">`);
|
|
397
|
+
for (const node of nodes) {
|
|
398
|
+
const { key, id, text } = node;
|
|
399
|
+
const { x, y, width, height } = getBoxParams({
|
|
400
|
+
...node,
|
|
401
|
+
padding: shift
|
|
402
|
+
});
|
|
403
|
+
println(` <g class="state" data-state-id="${id}">`);
|
|
404
|
+
if (key === initialStateKey || key === finalStateKey) {
|
|
405
|
+
const cx = Math.round(x + width / 2);
|
|
406
|
+
const cy = Math.round(y + height / 2);
|
|
407
|
+
if (key === initialStateKey) println(` <circle ${serializeAttrs({
|
|
408
|
+
class: "state__initial",
|
|
409
|
+
cx,
|
|
410
|
+
cy,
|
|
411
|
+
r: initialStateRadius,
|
|
412
|
+
fill: "none",
|
|
413
|
+
stroke: "currentColor",
|
|
414
|
+
strokeWidth: "2"
|
|
415
|
+
})} />`);
|
|
416
|
+
else {
|
|
417
|
+
let serializedAttrs = serializeAttrs({
|
|
418
|
+
class: "state__final",
|
|
419
|
+
cx,
|
|
420
|
+
cy,
|
|
421
|
+
r: initialStateRadius,
|
|
422
|
+
fill: "none",
|
|
423
|
+
stroke: "currentColor",
|
|
424
|
+
strokeWidth: 2
|
|
425
|
+
});
|
|
426
|
+
println(` <circle ${serializedAttrs} />`);
|
|
427
|
+
serializedAttrs = serializeAttrs({
|
|
428
|
+
class: "state__final state__final--inner",
|
|
429
|
+
cx,
|
|
430
|
+
cy,
|
|
431
|
+
r: finalStateRadius,
|
|
432
|
+
fill: "currentColor",
|
|
433
|
+
stroke: "none",
|
|
434
|
+
strokeWidth: 0
|
|
435
|
+
});
|
|
436
|
+
println(` <circle ${serializedAttrs} />`);
|
|
437
|
+
}
|
|
438
|
+
} else {
|
|
439
|
+
println(` <rect ${serializeAttrs({
|
|
440
|
+
x,
|
|
441
|
+
y,
|
|
442
|
+
width,
|
|
443
|
+
height,
|
|
444
|
+
rx: Math.ceil(stateFontSize / 2),
|
|
445
|
+
ry: Math.ceil(stateFontSize / 2),
|
|
446
|
+
fill: "none",
|
|
447
|
+
stroke: "currentColor",
|
|
448
|
+
strokeWidth: "2",
|
|
449
|
+
class: "state__box"
|
|
450
|
+
})} />`);
|
|
451
|
+
println(` <text ${serializeAttrs({
|
|
452
|
+
class: "state__label",
|
|
453
|
+
"text-anchor": "middle",
|
|
454
|
+
fill: "currentColor",
|
|
455
|
+
x: Math.round(x + width / 2),
|
|
456
|
+
y: Math.round(y + height / 2 + stateFontSize / 4)
|
|
457
|
+
})}>${text}</text>`);
|
|
458
|
+
}
|
|
459
|
+
println(" </g>");
|
|
460
|
+
}
|
|
461
|
+
println("</g>");
|
|
462
|
+
println("</svg>");
|
|
463
|
+
}
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/html/buildStatechartsPanel.ts
|
|
466
|
+
function buildStatechartsPanel({ statechart, newId, println, initialStateKey = "<initial>", finalStateKey = "<final>" }) {
|
|
467
|
+
render(statechart, println);
|
|
468
|
+
function render(statechart, println) {
|
|
469
|
+
println(` <details class="state-details" data-state-id="${statechart.id}">`);
|
|
470
|
+
println(` <summary class="state-details__label">${statechart.text ?? statechart.state}</summary>`);
|
|
471
|
+
println(` <div class="state-details__content">`);
|
|
472
|
+
const printChildren = (str) => println(` ${str}`);
|
|
473
|
+
if (statechart.nodes.length) {
|
|
474
|
+
println(` <div class="state-details__chart">`);
|
|
475
|
+
buildStatechartSvg({
|
|
476
|
+
graph: statechart,
|
|
477
|
+
newId,
|
|
478
|
+
println: printChildren,
|
|
479
|
+
initialStateKey,
|
|
480
|
+
finalStateKey
|
|
481
|
+
});
|
|
482
|
+
println(` </div>`);
|
|
483
|
+
}
|
|
484
|
+
println(` <div class="state-details__description">`);
|
|
485
|
+
println(` </div>`);
|
|
486
|
+
for (const child of statechart.children || []) render(child, printChildren);
|
|
487
|
+
println(` </div>`);
|
|
488
|
+
println(` </details>`);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
//#endregion
|
|
492
|
+
export { activeTransitionsStyle as a, buildStatechartStyles as c, selectedTransitionsStyle as d, serializeCss as f, activeStatesStyle as i, buildStatechartStylesWithModifier as l, buildStatechartSvg as n, buildStateDetailsStyle as o, toKebabCase as p, buildStatechartCss as r, buildStateDetailsStyleWithModifier as s, buildStatechartsPanel as t, selectedStatesStyle as u };
|
|
493
|
+
|
|
494
|
+
//# sourceMappingURL=buildStatechartsPanel-BX7e0GzA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildStatechartsPanel-BX7e0GzA.js","names":[],"sources":["../src/utils/toKebabCase.ts","../src/utils/serializeCss.ts","../src/html/buildStatechartStyles.ts","../src/html/buildStatechartCss.ts","../src/utils/BasisCurve.ts","../src/utils/serializeAttrs.ts","../src/html/buildStatechartSvg.ts","../src/html/buildStatechartsPanel.ts"],"sourcesContent":["export function toKebabCase(str?: string): string {\n // Remove spaces:\n str = (str || \"\").trim().replace(/\\s+/gim, \"-\");\n // Transform to kebab:\n str = str.replace(/([^A-Z]?)([A-Z])/g, (_, a, b) => `${a.toLowerCase()}-${b.toLowerCase()}`);\n return str;\n\n // return (\n // str.match(\n // /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g\n // ) || []\n // )\n // .join(\"-\")\n // .toLowerCase();\n}\n","import { toKebabCase } from \"./toKebabCase.js\";\n\nexport interface CssTree extends Record<string, string | number | CssTree> {}\n\nexport function serializeCss(obj: CssTree) {\n return visitStyle(obj).join(\"\\n\");\n\n function visitStyle(obj: CssTree, lines: string[] = [], prefixes: string[] = [\"\"]) {\n for (const [key, style] of Object.entries(obj)) {\n const selectors = [];\n for (const sel of key.split(\",\").map((_) => _.trim())) {\n for (const prefix of prefixes) {\n const selector = sel.replace(/^(.)/, (_, ch) =>\n ch === \"&\" ? prefix : prefix.length > 0 ? `${prefix} ${ch}` : ch,\n );\n selectors.push(selector);\n }\n }\n const selectorRules = [];\n const extensions: string[] = [];\n for (let [key, value] of Object.entries(style)) {\n if (typeof value === \"object\") {\n visitStyle({ [key]: value }, extensions, selectors);\n } else {\n key = toKebabCase(key);\n selectorRules.push(` ${key}: ${value};`);\n }\n }\n if (selectorRules.length) {\n lines.push(`${selectors.join(\",\\n\")} {`);\n lines.push(...selectorRules);\n lines.push(`}`);\n }\n lines.push(...extensions);\n }\n return lines;\n }\n}\n","import type { CssTree } from \"../utils/serializeCss.js\";\n\nexport const activeStatesStyle = {\n backgroundColor: \"white\",\n borderColor: \"red\",\n borderWidth: \"2px\",\n labelColor: \"red\",\n};\nexport const activeTransitionsStyle = {\n backgroundColor: \"#eee\",\n borderColor: \"none\",\n borderWidth: \"0\",\n lineColor: \"red\",\n lineWidth: \"1px\",\n labelColor: \"red\",\n};\n\nexport const selectedStatesStyle = {\n backgroundColor: \"white\",\n borderColor: \"navy\",\n borderWidth: \"2px\",\n labelColor: \"navy\",\n};\nexport const selectedTransitionsStyle = {\n backgroundColor: \"#eee\",\n borderColor: \"none\",\n borderWidth: \"0\",\n lineColor: \"navy\",\n lineWidth: \"1px\",\n labelColor: \"navy\",\n};\n\nexport function buildStateDetailsStyle({ root = \":root\" }: { root?: string }): CssTree {\n return {\n [root]: {\n // --------------------------\n // Panels\n\n \".state-details\": {\n backgroundColor: \"var(--state-background-color, white)\",\n border: \"var(--state-border-width, 1px) solid var(--state-border-color, currentColor)\",\n borderRadius: \"0.5em\",\n padding: \"0.5em\",\n },\n \".state-details__label\": {\n cursor: \"pointer\",\n color: \"var(--transition-label-color, currentColor)\",\n fontFamily: \"var(--state-label-font-family, sans-serif)\",\n fontSize: \"var(--state-label-font-size, 14px)\",\n },\n \".state-details__content\": {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.5em\",\n },\n \".state-details__chart\": {\n maxWidth: \"100%\",\n overflow: \"auto\",\n scrollbarWidth: \"thin\",\n },\n },\n };\n}\n\nexport function buildStateDetailsStyleWithModifier({\n root = \":root\",\n modifier,\n states,\n}: {\n root?: string;\n modifier: string;\n states: Record<string, string>;\n}): CssTree {\n return {\n [root]: {\n //\n \".state-details\": {\n [`&.state-details--${modifier}`]: {\n backgroundColor: `var(--state-${modifier}-background-color, ${states.backgroundColor})`,\n border: `var(--state-${modifier}-border-width, 1px) solid var(--state-${modifier}-border-color, currentColor)`,\n },\n },\n \".state-details__label\": {\n [`&.state-details__label--${modifier}`]: {\n color: `var(--state-${modifier}-label-color)`,\n },\n },\n },\n };\n}\n\nexport function buildStatechartStylesWithModifier({\n root = \":root\",\n modifier,\n states,\n transitions,\n}: {\n root?: string;\n modifier: string;\n states: Record<string, string>;\n transitions: Record<string, string>;\n}): CssTree {\n return {\n [root]: {\n // --------------------------------------\n // Default values for transitions\n [`--transition-${modifier}-background-color`]: transitions.backgroundColor,\n [`--transition-${modifier}-border-color`]: transitions.borderColor,\n [`--transition-${modifier}-border-width`]: transitions.borderWidth,\n [`--transition-${modifier}-line-color`]: transitions.lineColor,\n [`--transition-${modifier}-line-width`]: transitions.lineWidth,\n [`--transition-${modifier}-label-color`]: transitions.labelColor,\n\n // --------------------------------------\n // Default values for states\n [`--state-${modifier}-background-color`]: states.backgroundColor,\n [`--state-${modifier}-border-color`]: states.borderColor,\n [`--state-${modifier}-border-width`]: states.borderWidth,\n [`--state-${modifier}-label-color`]: states.labelColor,\n\n \".state\": {\n [`&.state--${modifier}`]: {\n \"--state-background-color\": `var(--state-${modifier}-background-color)`,\n \"--state-border-color\": `var(--state-${modifier}-border-color)`,\n \"--state-border-width\": `var(--state-${modifier}-border-width)`,\n \"--state-label-color\": `var(--state-${modifier}-label-color)`,\n },\n },\n\n \".transition\": {\n [`&.transition--${modifier}`]: {\n \"--transition-background-color\": `var(--transition-${modifier}-background-color)`,\n \"--transition-border-color\": `var(--transition-${modifier}-border-color)`,\n \"--transition-border-width\": `var(--transition-${modifier}-border-width)`,\n \"--transition-line-color\": `var(--transition-${modifier}-line-color)`,\n \"--transition-line-width\": `var(--transition-${modifier}-line-width)`,\n \"--transition-label-color\": `var(--transition-${modifier}-label-color)`,\n },\n },\n },\n };\n}\n\nexport function buildStatechartStyles({ root = \":root\" }: { root?: string }): CssTree {\n return {\n [root]: {\n // --------------------------------------\n // Transitions\n \"--transition-background-color\": \"rgba(255,255,255,0.7)\",\n \"--transition-border-color\": \"none\",\n \"--transition-border-width\": \"1px\",\n \"--transition-line-color\": \"silver\",\n \"--transition-line-width\": \"1px\",\n \"--transition-label-color\": \"gray\",\n \"--transition-label-font-size\": \"12px\",\n \"--transition-label-font-family\": \"sans-serif\",\n\n \".transition__marker\": {\n fill: \"var(--transition-line-color, currentColor)\",\n stroke: \"none\",\n },\n \".transition__line\": {\n stroke: \"var(--transition-line-color, currentColor)\",\n strokeWidth: \"var(--transition-line-width, 1px)\",\n },\n \".transition__box\": {\n fill: \"var(--transition-background-color, rgba(255,255,255,0.7))\",\n stroke: \"var(--transition-border-color, none)\",\n strokeWidth: \"var(--transition-border-width, 1px)\",\n borderRadius: \"0.5em\",\n cursor: \"pointer\",\n },\n \".transition__label\": {\n fill: \"var(--transition-label-color, currentColor)\",\n fontSize: \"var(--transition-label-font-size, 12px)\",\n fontFamily: \"var(--transition-label-font-family, sans-serif)\",\n cursor: \"pointer\",\n },\n\n // --------------------------------------\n // Normal states\n \"--state-background-color\": \"white\",\n \"--state-border-color\": \"silver\",\n \"--state-border-width\": \"1px\",\n \"--state-label-color\": \"gray\",\n \"--state-label-font-size\": \"14px\",\n \"--state-label-font-family\": \"sans-serif\",\n\n \".state__box\": {\n fill: \"var(--state-background-color, white)\",\n stroke: \"var(--state-border-color, currentColor)\",\n strokeWidth: \"var(--state-border-width, 1px)\",\n borderRadius: \"0.5em\",\n cursor: \"pointer\",\n },\n \".state__label\": {\n color: \"var(--state-label-color, currentColor)\",\n fill: \"var(--state-label-color, currentColor)\",\n fontSize: \"var(--state-label-font-size, 14px)\",\n fontFamily: \"var(--state-label-font-family, sans-serif)\",\n cursor: \"pointer\",\n },\n \".state__initial\": {\n fill: \"var(--state-border-color, currentColor)\",\n stroke: \"var(--state-border-color, currentColor)\",\n strokeWidth: \"var(--state-border-width, 2px)\",\n },\n \".state__final\": {\n fill: \"white\",\n stroke: \"var(--state-border-color, currentColor)\",\n strokeWidth: \"var(--state-border-width, 2px)\",\n // ---------------------------\n \"&.state__final--inner\": {\n fill: \"var(--state-border-color, currentColor)\",\n stroke: \"none\",\n strokeWidth: \"0\",\n },\n },\n },\n };\n}\n","import { serializeCss } from \"../utils/serializeCss.js\";\nimport {\n activeStatesStyle,\n activeTransitionsStyle,\n buildStatechartStyles,\n buildStatechartStylesWithModifier,\n buildStateDetailsStyle,\n buildStateDetailsStyleWithModifier,\n selectedStatesStyle,\n selectedTransitionsStyle,\n} from \"./buildStatechartStyles.js\";\n\nexport function buildStatechartCss({ prefix = \"\" } = {}): string {\n const root = prefix || \":root\";\n return [\n buildStatechartStyles({ root }),\n buildStatechartStylesWithModifier({\n root,\n modifier: \"selected\",\n states: selectedStatesStyle,\n transitions: selectedTransitionsStyle,\n }),\n buildStatechartStylesWithModifier({\n root,\n modifier: \"active\",\n states: activeStatesStyle,\n transitions: activeTransitionsStyle,\n }),\n buildStateDetailsStyle({ root }),\n buildStateDetailsStyleWithModifier({\n root,\n modifier: \"selected\",\n states: selectedStatesStyle,\n }),\n buildStateDetailsStyleWithModifier({\n root,\n modifier: \"active\",\n states: activeStatesStyle,\n }),\n ]\n .map(serializeCss)\n .join(\"\\n\");\n}\n","// This file contains the implementation of the BasisCurve class\n// copied from d3-shape/src/curve/basis.ts (Mike Bostock, MIT License)\n\nexport type DrawContext = {\n bezierCurveTo(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): void;\n moveTo(x: number, y: number): void;\n lineTo(x: number, y: number): void;\n closePath(): void;\n};\n\nexport class BasisCurve {\n _context: DrawContext;\n _x0: number = 0;\n _y0: number = 0;\n _x1: number = 0;\n _y1: number = 0;\n _point: number = 0;\n _line: number = 0;\n constructor(context: DrawContext) {\n this._context = context;\n }\n $point(x: number, y: number) {\n this._context.bezierCurveTo(\n (2 * this._x0 + this._x1) / 3,\n (2 * this._y0 + this._y1) / 3,\n (this._x0 + 2 * this._x1) / 3,\n (this._y0 + 2 * this._y1) / 3,\n (this._x0 + 4 * this._x1 + x) / 6,\n (this._y0 + 4 * this._y1 + y) / 6,\n );\n }\n\n areaStart() {\n this._line = 0;\n }\n\n areaEnd() {\n this._line = NaN;\n }\n\n lineStart() {\n this._x0 = this._x1 = this._y0 = this._y1 = NaN;\n this._point = 0;\n }\n\n lineEnd() {\n switch (this._point) {\n // biome-ignore lint/suspicious/noFallthroughSwitchClause: deliberate fall-through, as in the d3-shape basis curve this ports\n case 3:\n this.$point(this._x1, this._y1); // falls through\n case 2:\n this._context.lineTo(this._x1, this._y1);\n break;\n }\n if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();\n this._line = 1 - this._line;\n }\n\n point(x: number, y: number) {\n (x = +x), (y = +y);\n switch (this._point) {\n case 0:\n this._point = 1;\n this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);\n break;\n case 1:\n this._point = 2;\n break;\n // biome-ignore lint/suspicious/noFallthroughSwitchClause: deliberate fall-through, as in the d3-shape basis curve this ports\n case 2:\n this._point = 3;\n this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); // falls through\n default:\n this.$point(x, y);\n break;\n }\n (this._x0 = this._x1), (this._x1 = x);\n (this._y0 = this._y1), (this._y1 = y);\n }\n}\n","import { toKebabCase } from \"./toKebabCase.js\";\n\nexport function serializeAttrs(\n attrs: Record<string, string | number | undefined> = {},\n { prefix = \"\", transform = false }: { prefix?: string; transform?: boolean } = {},\n) {\n const result: string[] = [];\n for (const [key, value] of Object.entries(attrs || {}).sort(([a], [b]) => (a > b ? 1 : -1))) {\n if (value === undefined || value === null || value === \"\") continue;\n result.push(\n `${prefix}${escapeValue(key)}=${JSON.stringify(escapeValue(transform ? toKebabCase(String(value)) : value))}`,\n );\n }\n return result.join(\" \");\n\n function escapeValue(value: string | number | undefined): string {\n return String(value)\n .replaceAll(/</gim, \"<\")\n .replaceAll(/>/gim, \">\")\n .replaceAll(/\"/gim, \""\");\n }\n}\n","import type { Dimensions, Padding, Position, TransitionsGraph } from \"../types/index.js\";\nimport { BasisCurve } from \"../utils/BasisCurve.js\";\nimport { getPadding } from \"../utils/getPadding.js\";\nimport { serializeAttrs } from \"../utils/serializeAttrs.js\";\n\nfunction getBoxParams({\n x,\n y,\n width,\n height,\n padding = 0,\n}: Position & Dimensions & { padding?: Padding }) {\n const [top, right, bottom, left] = getPadding(padding);\n const h = Math.ceil(height - top - bottom);\n return {\n x: x + left,\n y: y - bottom - h,\n width: Math.ceil(width - left - right),\n height: h,\n };\n}\n\nexport function buildStatechartSvg({\n graph: { width, height, nodes, edges },\n newId,\n stateFontSize = 14,\n transitionFontSize = 12,\n println,\n initialStateKey = \"<initial>\",\n finalStateKey = \"<final>\",\n}: {\n graph: TransitionsGraph;\n newId: (prefix: string) => string;\n println: (str: string) => void;\n stateFontSize?: number;\n transitionFontSize?: number;\n initialStateKey?: string;\n finalStateKey?: string;\n}) {\n if (!nodes.length && !edges.length) return;\n width = Math.ceil(width);\n height = Math.ceil(height);\n println(\n `<svg ${serializeAttrs({\n class: \"statechart\",\n width,\n height,\n viewbox: `0 0 ${width} ${height}`,\n xmlns: \"http://www.w3.org/2000/svg\",\n })}>`,\n );\n\n /*\n --------------------------------------------------- \n Transitions visualization\n\n CSS Classes:\n .transitions .transition-marker\n .transitions .transition .transition-line\n .transitions .transition .transition-box\n .transitions .transition .transition-label\n --------------------------------------------------- \n */\n println(`<g class=\"statechart__transitions\">`);\n\n const markerAttrs = serializeAttrs({\n refX: 19,\n refY: 7,\n markerWidth: 20,\n markerHeight: 14,\n orient: \"auto\",\n class: \"transition__marker\",\n stroke: \"none\",\n fill: \"currentColor\",\n });\n\n for (const edge of edges) {\n const { id, points, text } = edge;\n println(` <g class=\"transition\" data-transition-id=\"${id}\">`);\n const markerId = newId(\"marker\");\n\n println(` <defs>`);\n println(` <marker id=\"${markerId}\" ${markerAttrs}>`);\n println(` <path d=\"M 19,7 L9,13 L14,7 L9,1 Z\"></path>`);\n println(` </marker>`);\n println(` </defs>`);\n\n const path: string[] = [];\n const round = (...n: number[]) => n.map(Math.round);\n const base = new BasisCurve({\n bezierCurveTo(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number) {\n path.push(`C${round(x0, y0, x1, y1, x2, y2).join(\",\")}`);\n },\n moveTo(x: number, y: number) {\n path.push(`M${round(x, y).join(\",\")}`);\n },\n lineTo(x: number, y: number) {\n path.push(`L${round(x, y).join(\",\")}`);\n },\n closePath() {\n path.push(\"Z\");\n },\n });\n base.lineStart();\n for (const point of points) {\n base.point(point.x, point.y);\n }\n base.lineEnd();\n\n const serializedAttrs = serializeAttrs({\n class: \"transition__line\",\n fill: \"none\",\n stroke: \"currentColor\",\n strokeWidth: \"1px\",\n d: path.join(\"\"),\n \"marker-end\": `url(#${markerId})`,\n });\n println(` <path ${serializedAttrs} />`);\n\n if (text) {\n const { x, y, width, height } = getBoxParams({\n ...edge,\n padding: 0,\n });\n\n const rectAttrs = serializeAttrs({\n x,\n y: y - transitionFontSize,\n width,\n height,\n rx: Math.ceil(transitionFontSize / 2),\n ry: Math.ceil(transitionFontSize / 2),\n fill: \"rgba(255,255,255,0.7)\",\n stroke: \"none\",\n strokeWidth: \"1\",\n class: \"transition__box\",\n });\n println(` <rect ${rectAttrs} />`);\n\n const textAttrs = serializeAttrs({\n class: \"transition__label\",\n \"text-anchor\": \"middle\",\n fill: \"currentColor\",\n x: Math.round(x + width / 2),\n y: Math.round(y + height / 2 - transitionFontSize / 2),\n });\n println(` <text ${textAttrs}>${text}</text>`);\n }\n println(` </g>`);\n }\n println(\"</g>\");\n\n /*\n --------------------------------------------------- \n States visualization\n\n CSS Classes:\n .states .state\n .states .state .state-box \n .states .state .state-initial \n .states .state .state-final \n .states .state .state-final.inner \n .states .state .state-label\n --------------------------------------------------- \n */\n\n const shift = stateFontSize / 4;\n const initialStateRadius = 6;\n const finalStateRadius = initialStateRadius / 2;\n\n println(`<g class=\"statechart__states\">`);\n for (const node of nodes) {\n const { key, id, text } = node;\n const { x, y, width, height } = getBoxParams({ ...node, padding: shift });\n\n println(` <g class=\"state\" data-state-id=\"${id}\">`);\n if (key === initialStateKey || key === finalStateKey) {\n const cx = Math.round(x + width / 2);\n const cy = Math.round(y + height / 2);\n if (key === initialStateKey) {\n const serializedAttrs = serializeAttrs({\n class: \"state__initial\",\n cx,\n cy,\n r: initialStateRadius,\n fill: \"none\",\n stroke: \"currentColor\",\n strokeWidth: \"2\",\n });\n println(` <circle ${serializedAttrs} />`);\n } else {\n let serializedAttrs = serializeAttrs({\n class: \"state__final\",\n cx,\n cy,\n r: initialStateRadius,\n fill: \"none\",\n stroke: \"currentColor\",\n strokeWidth: 2,\n });\n println(` <circle ${serializedAttrs} />`);\n\n serializedAttrs = serializeAttrs({\n class: \"state__final state__final--inner\",\n cx,\n cy,\n r: finalStateRadius,\n fill: \"currentColor\",\n stroke: \"none\",\n strokeWidth: 0,\n });\n println(` <circle ${serializedAttrs} />`);\n }\n } else {\n const rectAttrs = serializeAttrs({\n x,\n y,\n width,\n height,\n rx: Math.ceil(stateFontSize / 2),\n ry: Math.ceil(stateFontSize / 2),\n fill: \"none\",\n stroke: \"currentColor\",\n strokeWidth: \"2\",\n class: \"state__box\",\n });\n println(` <rect ${rectAttrs} />`);\n\n const textAttrs = serializeAttrs({\n class: \"state__label\",\n \"text-anchor\": \"middle\",\n fill: \"currentColor\",\n x: Math.round(x + width / 2),\n y: Math.round(y + height / 2 + stateFontSize / 4),\n });\n println(` <text ${textAttrs}>${text}</text>`);\n }\n println(\" </g>\");\n }\n println(\"</g>\");\n\n println(\"</svg>\");\n}\n","import type { StateChart } from \"../types/StateChart.js\";\nimport { buildStatechartSvg } from \"./buildStatechartSvg.js\";\n\nexport function buildStatechartsPanel({\n statechart,\n newId,\n println,\n initialStateKey = \"<initial>\",\n finalStateKey = \"<final>\",\n}: {\n statechart: StateChart;\n newId: (prefix: string) => string;\n println: (str: string) => void;\n initialStateKey?: string;\n finalStateKey?: string;\n}): void {\n render(statechart, println);\n\n function render(statechart: StateChart, println: (str: string) => void) {\n println(` <details class=\"state-details\" data-state-id=\"${statechart.id}\">`);\n println(\n ` <summary class=\"state-details__label\">${statechart.text ?? statechart.state}</summary>`,\n );\n println(` <div class=\"state-details__content\">`);\n const printChildren = (str: string) => println(` ${str}`);\n if (statechart.nodes.length) {\n println(` <div class=\"state-details__chart\">`);\n buildStatechartSvg({\n graph: statechart,\n newId,\n println: printChildren,\n initialStateKey,\n finalStateKey,\n });\n println(` </div>`);\n }\n println(` <div class=\"state-details__description\">`);\n println(` </div>`);\n for (const child of statechart.children || []) {\n render(child, printChildren);\n }\n println(` </div>`);\n println(` </details>`);\n }\n}\n"],"mappings":";;;AAAA,SAAgB,YAAY,KAAsB;CAEhD,OAAO,OAAO,GAAA,CAAI,KAAK,CAAC,CAAC,QAAQ,UAAU,GAAG;CAE9C,MAAM,IAAI,QAAQ,sBAAsB,GAAG,GAAG,MAAM,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,GAAG;CAC3F,OAAO;AAST;;;ACVA,SAAgB,aAAa,KAAc;CACzC,OAAO,WAAW,GAAG,CAAC,CAAC,KAAK,IAAI;CAEhC,SAAS,WAAW,KAAc,QAAkB,CAAC,GAAG,WAAqB,CAAC,EAAE,GAAG;EACjF,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QA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EAClD,MAAM,iBAAiB,QAAgB,QAAQ,OAAO,KAAK;EAC3D,IAAI,WAAW,MAAM,QAAQ;GAC3B,QAAQ,0CAA0C;GAClD,mBAAmB;IACjB,OAAO;IACP;IACA,SAAS;IACT;IACA;GACF,CAAC;GACD,QAAQ,YAAY;EACtB;EACA,QAAQ,8CAA8C;EACtD,QAAQ,YAAY;EACpB,KAAK,MAAM,SAAS,WAAW,YAAY,CAAC,GAC1C,OAAO,OAAO,aAAa;EAE7B,QAAQ,YAAY;EACpB,QAAQ,cAAc;CACxB;AACF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { n as TransitionsGraph, t as StateChart } from "./StateChart-cXyVRcs-.js";
|
|
2
|
+
//#region src/html/buildStatechartCss.d.ts
|
|
3
|
+
declare function buildStatechartCss({ prefix }?: {
|
|
4
|
+
prefix?: string | undefined;
|
|
5
|
+
}): string;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/utils/serializeCss.d.ts
|
|
8
|
+
interface CssTree extends Record<string, string | number | CssTree> {}
|
|
9
|
+
declare function serializeCss(obj: CssTree): string;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/html/buildStatechartStyles.d.ts
|
|
12
|
+
declare const activeStatesStyle: {
|
|
13
|
+
backgroundColor: string;
|
|
14
|
+
borderColor: string;
|
|
15
|
+
borderWidth: string;
|
|
16
|
+
labelColor: string;
|
|
17
|
+
};
|
|
18
|
+
declare const activeTransitionsStyle: {
|
|
19
|
+
backgroundColor: string;
|
|
20
|
+
borderColor: string;
|
|
21
|
+
borderWidth: string;
|
|
22
|
+
lineColor: string;
|
|
23
|
+
lineWidth: string;
|
|
24
|
+
labelColor: string;
|
|
25
|
+
};
|
|
26
|
+
declare const selectedStatesStyle: {
|
|
27
|
+
backgroundColor: string;
|
|
28
|
+
borderColor: string;
|
|
29
|
+
borderWidth: string;
|
|
30
|
+
labelColor: string;
|
|
31
|
+
};
|
|
32
|
+
declare const selectedTransitionsStyle: {
|
|
33
|
+
backgroundColor: string;
|
|
34
|
+
borderColor: string;
|
|
35
|
+
borderWidth: string;
|
|
36
|
+
lineColor: string;
|
|
37
|
+
lineWidth: string;
|
|
38
|
+
labelColor: string;
|
|
39
|
+
};
|
|
40
|
+
declare function buildStateDetailsStyle({ root }: {
|
|
41
|
+
root?: string;
|
|
42
|
+
}): CssTree;
|
|
43
|
+
declare function buildStateDetailsStyleWithModifier({ root, modifier, states }: {
|
|
44
|
+
root?: string;
|
|
45
|
+
modifier: string;
|
|
46
|
+
states: Record<string, string>;
|
|
47
|
+
}): CssTree;
|
|
48
|
+
declare function buildStatechartStylesWithModifier({ root, modifier, states, transitions }: {
|
|
49
|
+
root?: string;
|
|
50
|
+
modifier: string;
|
|
51
|
+
states: Record<string, string>;
|
|
52
|
+
transitions: Record<string, string>;
|
|
53
|
+
}): CssTree;
|
|
54
|
+
declare function buildStatechartStyles({ root }: {
|
|
55
|
+
root?: string;
|
|
56
|
+
}): CssTree;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/html/buildStatechartSvg.d.ts
|
|
59
|
+
declare function buildStatechartSvg({ graph: { width, height, nodes, edges }, newId, stateFontSize, transitionFontSize, println, initialStateKey, finalStateKey }: {
|
|
60
|
+
graph: TransitionsGraph;
|
|
61
|
+
newId: (prefix: string) => string;
|
|
62
|
+
println: (str: string) => void;
|
|
63
|
+
stateFontSize?: number;
|
|
64
|
+
transitionFontSize?: number;
|
|
65
|
+
initialStateKey?: string;
|
|
66
|
+
finalStateKey?: string;
|
|
67
|
+
}): void;
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/html/buildStatechartsPanel.d.ts
|
|
70
|
+
declare function buildStatechartsPanel({ statechart, newId, println, initialStateKey, finalStateKey }: {
|
|
71
|
+
statechart: StateChart;
|
|
72
|
+
newId: (prefix: string) => string;
|
|
73
|
+
println: (str: string) => void;
|
|
74
|
+
initialStateKey?: string;
|
|
75
|
+
finalStateKey?: string;
|
|
76
|
+
}): void;
|
|
77
|
+
//#endregion
|
|
78
|
+
export { buildStateDetailsStyle as a, buildStatechartStylesWithModifier as c, CssTree as d, serializeCss as f, activeTransitionsStyle as i, selectedStatesStyle as l, buildStatechartSvg as n, buildStateDetailsStyleWithModifier as o, buildStatechartCss as p, activeStatesStyle as r, buildStatechartStyles as s, buildStatechartsPanel as t, selectedTransitionsStyle as u };
|
|
79
|
+
//# sourceMappingURL=buildStatechartsPanel-hCtZbdiF.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildStatechartsPanel-hCtZbdiF.d.ts","names":[],"sources":["../src/html/buildStatechartCss.ts","../src/utils/serializeCss.ts","../src/html/buildStatechartStyles.ts","../src/html/buildStatechartSvg.ts","../src/html/buildStatechartsPanel.ts"],"mappings":";;iBAYgB,qBAAqB;;;;;UCVpB,gBAAgB,iCAAiC;iBAElD,aAAa,KAAK;;;cCFrB;EACX;EACA;EACA;EACA;;cAEW;EACX;EACA;EACA;EACA;EACA;EACA;;cAGW;EACX;EACA;EACA;EACA;;cAEW;EACX;EACA;EACA;EACA;EACA;EACA;;iBAGc,yBAAyB;EAAoB;IAAkB;iBAgC/D,qCACd,MACA,UACA;EAEA;EACA;EACA,QAAQ;IACN;iBAmBY,oCACd,MACA,UACA,QACA;EAEA;EACA;EACA,QAAQ;EACR,aAAa;IACX;iBA0CY,wBAAwB;EAAoB;IAAkB;;;iBCzH9D,qBACd,SAAS,OAAO,QAAQ,OAAO,SAC/B,OACA,eACA,oBACA,SACA,iBACA;EAEA,OAAO;EACP,QAAQ;EACR,UAAU;EACV;EACA;EACA;EACA;;;;iBClCc,wBACd,YACA,OACA,SACA,iBACA;EAEA,YAAY;EACZ,QAAQ;EACR,UAAU;EACV;EACA"}
|