@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
package/dist/chunk-ARZYBFNA.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
// src/config/concatTransitionsToString.ts
|
|
2
|
-
function concatTransitionsToString(transitions) {
|
|
3
|
-
const list = [];
|
|
4
|
-
let str = "";
|
|
5
|
-
let prev;
|
|
6
|
-
for (const [from, event, to] of transitions) {
|
|
7
|
-
if (prev !== from) {
|
|
8
|
-
if (str) list.push(str);
|
|
9
|
-
str = from;
|
|
10
|
-
}
|
|
11
|
-
str += ` -${escape(event)}-> ${escape(to)}`;
|
|
12
|
-
prev = to;
|
|
13
|
-
}
|
|
14
|
-
if (str) list.push(str);
|
|
15
|
-
return list;
|
|
16
|
-
function escape(str2) {
|
|
17
|
-
return str2;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// src/config/serializeProcessConfig.ts
|
|
22
|
-
function serializeProcessConfig(config) {
|
|
23
|
-
if (!config) return "";
|
|
24
|
-
const lines = [];
|
|
25
|
-
visit(config, lines);
|
|
26
|
-
return lines.join("\n");
|
|
27
|
-
function visit(config2, lines2, shift = "") {
|
|
28
|
-
lines2.push(`${shift}{`);
|
|
29
|
-
const { key, states, transitions, ...params } = config2;
|
|
30
|
-
lines2.push(`${shift} "key": ${JSON.stringify(key)}`);
|
|
31
|
-
if (transitions && transitions.length > 0) {
|
|
32
|
-
lines2[lines2.length - 1] += ",";
|
|
33
|
-
lines2.push(`${shift} "transitions": [`);
|
|
34
|
-
for (let i = 0; i < transitions.length; i++) {
|
|
35
|
-
if (i > 0) {
|
|
36
|
-
lines2[lines2.length - 1] += ",";
|
|
37
|
-
}
|
|
38
|
-
lines2.push(`${shift} ${JSON.stringify(transitions[i])}`);
|
|
39
|
-
}
|
|
40
|
-
lines2.push(`${shift} ]`);
|
|
41
|
-
}
|
|
42
|
-
if (states && states.length > 0) {
|
|
43
|
-
lines2[lines2.length - 1] += ",";
|
|
44
|
-
lines2.push(`${shift} "states": [`);
|
|
45
|
-
for (let i = 0; i < states.length; i++) {
|
|
46
|
-
if (i > 0) {
|
|
47
|
-
lines2[lines2.length - 1] += ",";
|
|
48
|
-
}
|
|
49
|
-
visit(states[i], lines2, `${shift} `);
|
|
50
|
-
}
|
|
51
|
-
lines2.push(`${shift} ]`);
|
|
52
|
-
}
|
|
53
|
-
if (params && Object.keys(params).length > 0) {
|
|
54
|
-
lines2[lines2.length - 1] += ",";
|
|
55
|
-
const str = JSON.stringify(params, null, 2);
|
|
56
|
-
const paramsLines = str.split("\n");
|
|
57
|
-
paramsLines.shift();
|
|
58
|
-
paramsLines.pop();
|
|
59
|
-
lines2.push(...paramsLines.map((line) => shift + line));
|
|
60
|
-
}
|
|
61
|
-
lines2.push(`${shift}}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// src/config/splitTransitionString.ts
|
|
66
|
-
function splitTransitionString(str) {
|
|
67
|
-
let list = [];
|
|
68
|
-
let pos = 0;
|
|
69
|
-
const matches = Array.from(
|
|
70
|
-
str.matchAll(/-\s*("[^"]*?"|'[^']*?'|[^-]*?)\s*->/g)
|
|
71
|
-
);
|
|
72
|
-
for (const match of matches) {
|
|
73
|
-
list.push(str.substring(pos, match.index));
|
|
74
|
-
list.push(match[1]);
|
|
75
|
-
pos = match.index + match[0].length;
|
|
76
|
-
}
|
|
77
|
-
list.push(str.substring(pos));
|
|
78
|
-
list = list.map((str2) => str2.trim());
|
|
79
|
-
const transitions = [];
|
|
80
|
-
for (let i = 0; i < list.length - 2; ) {
|
|
81
|
-
const from = list[i++] || "";
|
|
82
|
-
const event = list[i++] || "";
|
|
83
|
-
const to = list[i] || "";
|
|
84
|
-
transitions.push([from, event, to]);
|
|
85
|
-
}
|
|
86
|
-
return transitions;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// src/config/toFsmStateConfig.ts
|
|
90
|
-
function toFsmStateConfig(json) {
|
|
91
|
-
if (!json || typeof json !== "object") return;
|
|
92
|
-
const { key, transitions, states, ...options } = json;
|
|
93
|
-
if (typeof key !== "string") return;
|
|
94
|
-
const stateTransitions = toFsmTransitions(transitions);
|
|
95
|
-
const substates = toArray(states).map(toFsmStateConfig).filter((v) => !!v);
|
|
96
|
-
const state = {
|
|
97
|
-
key,
|
|
98
|
-
transitions: stateTransitions
|
|
99
|
-
};
|
|
100
|
-
if (substates && substates.length > 0) state.states = substates;
|
|
101
|
-
return Object.assign(state, options);
|
|
102
|
-
function toFsmTransitions(json2) {
|
|
103
|
-
const transitions2 = [];
|
|
104
|
-
const index = {};
|
|
105
|
-
const array = toArray(json2);
|
|
106
|
-
for (const line of array) {
|
|
107
|
-
const lineTransitions = typeof line === "string" ? splitTransitionString(line) : [toArray(line)];
|
|
108
|
-
for (const transition of lineTransitions.map(validateTransition)) {
|
|
109
|
-
if (!transition) continue;
|
|
110
|
-
const key2 = transition.join("|");
|
|
111
|
-
if (key2 in index) continue;
|
|
112
|
-
index[key2] = true;
|
|
113
|
-
transitions2.push(transition);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return transitions2;
|
|
117
|
-
}
|
|
118
|
-
function validateTransition(value) {
|
|
119
|
-
const array = toArray(value);
|
|
120
|
-
if (array.length !== 3) return;
|
|
121
|
-
const [from, event, to] = array;
|
|
122
|
-
if (typeof from !== "string" || typeof event !== "string" || typeof to !== "string")
|
|
123
|
-
return;
|
|
124
|
-
return [from, event, to];
|
|
125
|
-
}
|
|
126
|
-
function toArray(value) {
|
|
127
|
-
if (value === void 0) return [];
|
|
128
|
-
if (Array.isArray(value)) return value;
|
|
129
|
-
return [value];
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export { concatTransitionsToString, serializeProcessConfig, splitTransitionString, toFsmStateConfig };
|