@statewalker/fsm-charts 0.2.5 → 0.2.6

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 (74) hide show
  1. package/README.md +206 -1
  2. package/dist/StateChart-cXyVRcs-.d.ts +94 -0
  3. package/dist/StateChart-cXyVRcs-.d.ts.map +1 -0
  4. package/dist/StateChartIndex-BK2315qj.d.ts +142 -0
  5. package/dist/StateChartIndex-BK2315qj.d.ts.map +1 -0
  6. package/dist/StateChartIndex-BOIrc_nq.js +355 -0
  7. package/dist/StateChartIndex-BOIrc_nq.js.map +1 -0
  8. package/dist/buildStatechartsPanel-CxQlIwTh.js +494 -0
  9. package/dist/buildStatechartsPanel-CxQlIwTh.js.map +1 -0
  10. package/dist/buildStatechartsPanel-hCtZbdiF.d.ts +79 -0
  11. package/dist/buildStatechartsPanel-hCtZbdiF.d.ts.map +1 -0
  12. package/dist/defineProperty-C0rC37pP.js +39 -0
  13. package/dist/description-panels-DI2MNlbK.js +184 -0
  14. package/dist/description-panels-DI2MNlbK.js.map +1 -0
  15. package/dist/getLabelDimensions-BY0q7j3D.d.ts +79 -0
  16. package/dist/getLabelDimensions-BY0q7j3D.d.ts.map +1 -0
  17. package/dist/getPadding-Cw0e7G2v.js +25 -0
  18. package/dist/getPadding-Cw0e7G2v.js.map +1 -0
  19. package/dist/index-config.d.ts +3 -12
  20. package/dist/index-config.js +2 -2
  21. package/dist/index-dom.d.ts +2 -49
  22. package/dist/index-dom.js +2 -2
  23. package/dist/index-html.d.ts +3 -2
  24. package/dist/index-html.js +2 -3
  25. package/dist/index-layout.d.ts +3 -77
  26. package/dist/index-layout.js +2 -3
  27. package/dist/index-runtime.d.ts +3 -141
  28. package/dist/index-runtime.js +2 -2
  29. package/dist/index.d.ts +11 -10
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +6 -7
  32. package/dist/layout-Dp671N6q.js +2465 -0
  33. package/dist/layout-Dp671N6q.js.map +1 -0
  34. package/dist/newTreeBuilder-CvtLDjGj.d.ts +54 -0
  35. package/dist/newTreeBuilder-CvtLDjGj.d.ts.map +1 -0
  36. package/dist/toFsmStateConfig-DlJkyZni.js +135 -0
  37. package/dist/toFsmStateConfig-DlJkyZni.js.map +1 -0
  38. package/dist/toFsmStateConfig-DmOlTRjv.d.ts +15 -0
  39. package/dist/toFsmStateConfig-DmOlTRjv.d.ts.map +1 -0
  40. package/package.json +53 -25
  41. package/src/config/concatTransitionsToString.ts +2 -2
  42. package/src/config/splitTransitionString.ts +1 -3
  43. package/src/config/toFsmStateConfig.ts +2 -9
  44. package/src/dom/buildSections.ts +3 -11
  45. package/src/dom/description-panels.ts +2 -4
  46. package/src/dom/getStatesDescriptions.ts +3 -9
  47. package/src/full/toFsmStateCharts.ts +1 -1
  48. package/src/html/buildStatechartStyles.ts +4 -14
  49. package/src/html/buildStatechartSvg.ts +2 -14
  50. package/src/html/buildStatechartsPanel.ts +1 -3
  51. package/src/layout/buildCharts.ts +1 -2
  52. package/src/layout/buildFlatCharts.ts +6 -8
  53. package/src/layout/getGraphParamsProvider.ts +3 -12
  54. package/src/runtime/RuntimeStatechartApi.ts +10 -32
  55. package/src/runtime/StateChartIndex.ts +6 -23
  56. package/src/types/GraphParamsProvider.ts +1 -4
  57. package/src/utils/BasisCurve.ts +5 -14
  58. package/src/utils/domToText.ts +2 -6
  59. package/src/utils/getPadding.ts +1 -2
  60. package/src/utils/newId.ts +2 -1
  61. package/src/utils/newRegistry.ts +12 -12
  62. package/src/utils/serializeAttrs.ts +3 -11
  63. package/src/utils/serializeCss.ts +1 -5
  64. package/src/utils/serializeStyle.ts +1 -4
  65. package/src/utils/toKebabCase.ts +1 -4
  66. package/dist/StateChart-BYBjTmC2.d.ts +0 -82
  67. package/dist/chunk-2LFUT2C6.js +0 -2691
  68. package/dist/chunk-ARZYBFNA.js +0 -133
  69. package/dist/chunk-CR2M4445.js +0 -608
  70. package/dist/chunk-FIQDLBWD.js +0 -9
  71. package/dist/chunk-GW2Z65BN.js +0 -429
  72. package/dist/chunk-PKBMQBKP.js +0 -5
  73. package/dist/chunk-RZ4FP6JB.js +0 -233
  74. package/dist/index-html-BBQqYoST.d.ts +0 -75
@@ -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 };