@statewalker/fsm-charts 0.1.5 → 0.1.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.
@@ -2,8 +2,8 @@ import { getPadding } from './chunk-NXWOFQMO.js';
2
2
  import { __publicField } from './chunk-XEO3YXBM.js';
3
3
 
4
4
  // src/utils/toKebabCase.ts
5
- function toKebabCase2(str) {
6
- str = str.trim().replace(/\s+/gim, "-");
5
+ function toKebabCase(str) {
6
+ str = (str || "").trim().replace(/\s+/gim, "-");
7
7
  str = str.replace(
8
8
  /([^A-Z]?)([A-Z])/g,
9
9
  (_, a, b) => a.toLowerCase() + "-" + b.toLowerCase()
@@ -32,7 +32,7 @@ function serializeCss(obj) {
32
32
  if (typeof value === "object") {
33
33
  visitStyle({ [key2]: value }, extensions, selectors);
34
34
  } else {
35
- key2 = toKebabCase2(key2);
35
+ key2 = toKebabCase(key2);
36
36
  selectorRules.push(` ${key2}: ${value};`);
37
37
  }
38
38
  }
@@ -294,7 +294,9 @@ function serializeAttrs(attrs = {}, {
294
294
  if (value === void 0 || value === null || value === "")
295
295
  continue;
296
296
  result.push(
297
- `${prefix}${escapeValue(key)}${"=" + JSON.stringify(escapeValue(transform ? toKebabCase(value) : value))}`
297
+ `${prefix}${escapeValue(key)}${"=" + JSON.stringify(
298
+ escapeValue(transform ? toKebabCase(String(value)) : value)
299
+ )}`
298
300
  );
299
301
  }
300
302
  return result.join(" ");
@@ -598,4 +600,4 @@ function buildStatechartsPanel({
598
600
  }
599
601
  }
600
602
 
601
- export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle, serializeCss, toKebabCase2 as toKebabCase };
603
+ export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle, serializeCss, toKebabCase };
@@ -1,3 +1,3 @@
1
- export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle } from './chunk-NLFRNVS3.js';
1
+ export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle } from './chunk-2BBNBZQI.js';
2
2
  import './chunk-NXWOFQMO.js';
3
3
  import './chunk-XEO3YXBM.js';
package/dist/index.d.ts CHANGED
@@ -3,6 +3,6 @@ export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimension
3
3
  export { C as CssTree, c as activeStatesStyle, d as activeTransitionsStyle, f as buildStateDetailsStyle, g as buildStateDetailsStyleWithModifier, b as buildStatechartCss, i as buildStatechartStyles, h as buildStatechartStylesWithModifier, j as buildStatechartSvg, a as buildStatechartsPanel, s as selectedStatesStyle, e as selectedTransitionsStyle, k as serializeCss } from './index-html-D4UI0s_n.js';
4
4
  export { RuntimeListener, RuntimeStatechartApi, StateChartIndex } from './index-runtime.js';
5
5
 
6
- declare function toKebabCase(str: string): string;
6
+ declare function toKebabCase(str?: string): string;
7
7
 
8
8
  export { toKebabCase };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-OTGN3OYG.js';
2
- export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle, serializeCss, toKebabCase } from './chunk-NLFRNVS3.js';
2
+ export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle, serializeCss, toKebabCase } from './chunk-2BBNBZQI.js';
3
3
  import './chunk-NXWOFQMO.js';
4
4
  export { RuntimeStatechartApi, StateChartIndex } from './chunk-NXS24DZQ.js';
5
5
  import './chunk-XEO3YXBM.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statewalker/fsm-charts",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "HFSM Implementation",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/statewalker/statewalker-fsm-charts",
@@ -21,6 +21,13 @@
21
21
  "types": "./dist/index.d.ts",
22
22
  "exports": {
23
23
  ".": {
24
+ "import": "./dist/index.js",
25
+ "require": "./dist/index.js"
26
+ },
27
+ "./src": {
28
+ "import": "./src"
29
+ },
30
+ "./src/index.ts": {
24
31
  "import": "./src/index.ts"
25
32
  }
26
33
  },
@@ -1,5 +1,4 @@
1
- import { tail } from "lodash";
2
- import type { CssTree } from "../utils/serializeCss";
1
+ import type { CssTree } from "../utils/serializeCss.ts";
3
2
 
4
3
  export const activeStatesStyle = {
5
4
  backgroundColor: "white",
package/src/index-html.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./types/index.ts";
1
+ export type * from "./types/index.ts";
2
2
  export * from "./html/index.ts";
@@ -1,2 +1,2 @@
1
- export * from "./types/index.ts";
1
+ export type * from "./types/index.ts";
2
2
  export * from "./layout/index.ts";
@@ -1,2 +1,2 @@
1
- export * from "./types/index.ts";
1
+ export type * from "./types/index.ts";
2
2
  export * from "./runtime/index.ts";
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from "./types/index.ts";
1
+ export type * from "./types/index.ts";
2
2
  export * from "./layout/index.ts";
3
3
  export * from "./html/index.ts";
4
4
  export * from "./runtime/index.ts";
@@ -1,10 +1,10 @@
1
- export * from "./Dimensions.ts";
2
- export * from "./FsmStateConfig.ts";
3
- export * from "./GraphParamsProvider.ts";
4
- export * from "./Padding.ts";
5
- export * from "./Position.ts";
6
- export * from "./StateChart.ts";
7
- export * from "./StateGraphEdge.ts";
8
- export * from "./StateGraphNode.ts";
9
- export * from "./Transition.ts";
10
- export * from "./TransitionsGraph.ts";
1
+ export type * from "./Dimensions.ts";
2
+ export type * from "./FsmStateConfig.ts";
3
+ export type * from "./GraphParamsProvider.ts";
4
+ export type * from "./Padding.ts";
5
+ export type * from "./Position.ts";
6
+ export type * from "./StateChart.ts";
7
+ export type * from "./StateGraphEdge.ts";
8
+ export type * from "./StateGraphNode.ts";
9
+ export type * from "./Transition.ts";
10
+ export type * from "./TransitionsGraph.ts";
@@ -1,9 +1,11 @@
1
+ import { toKebabCase } from "./toKebabCase.ts";
2
+
1
3
  export function serializeAttrs(
2
4
  attrs: Record<string, string | number | undefined> = {},
3
5
  {
4
6
  prefix = "",
5
7
  transform = false,
6
- }: { prefix: string; transform: boolean } = {}
8
+ }: { prefix?: string; transform?: boolean } = {}
7
9
  ) {
8
10
  const result: string[] = [];
9
11
  for (const [key, value] of Object.entries(attrs || {}).sort(([a], [b]) =>
@@ -13,7 +15,9 @@ export function serializeAttrs(
13
15
  result.push(
14
16
  `${prefix}${escapeValue(key)}${
15
17
  "=" +
16
- JSON.stringify(escapeValue(transform ? toKebabCase(value) : value))
18
+ JSON.stringify(
19
+ escapeValue(transform ? toKebabCase(String(value)) : value)
20
+ )
17
21
  }`
18
22
  );
19
23
  }
@@ -1,13 +1,13 @@
1
- export function toKebabCase(str: string): string {
1
+ export function toKebabCase(str?: string): string {
2
2
  // Remove spaces:
3
- str = str.trim().replace(/\s+/gim, "-");
3
+ str = (str || "").trim().replace(/\s+/gim, "-");
4
4
  // Transform to kebab:
5
5
  str = str.replace(
6
6
  /([^A-Z]?)([A-Z])/g,
7
7
  (_, a, b) => a.toLowerCase() + "-" + b.toLowerCase()
8
8
  );
9
9
  return str;
10
-
10
+
11
11
  // return (
12
12
  // str.match(
13
13
  // /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g
@@ -15,4 +15,4 @@ export function toKebabCase(str: string): string {
15
15
  // )
16
16
  // .join("-")
17
17
  // .toLowerCase();
18
- }
18
+ }
@@ -1,291 +0,0 @@
1
- // export function constant(value) {
2
- // return function () {
3
- // return value;
4
- // };
5
- // }
6
- // export function clone(obj) {
7
- // return Object.assign({}, obj, {});
8
- // // return JSON.parse(JSON.stringify(obj));
9
- // }
10
-
11
- // export const cloneDeep = clone;
12
- // export function defaults(...list) {
13
- // const result = {};
14
- // for (const obj of list) {
15
- // for (const [key, value] of Object.entries(obj)) {
16
- // if (!(key in result)) {
17
- // result[key] = value;
18
- // }
19
- // }
20
- // }
21
- // return result;
22
- // }
23
- // export function forEach(array, action) {
24
- // if (Array.isArray(array)) array.forEach(action);
25
- // else Object.entries(([key, value]) => action(value, key));
26
- // }
27
- // export const each = forEach;
28
- // export function find(list, check) {
29
- // const idx = list.indexOf(check);
30
- // return idx >= 0 ? list[idx] : undefined;
31
- // }
32
- // export function filter(list, accept) {
33
- // return list.filter(accept);
34
- // }
35
- // // export function flatten(list, accept) {
36
- // // return list.flatten(accept);
37
- // // }
38
- // // export function forIn(obj, action) {
39
- // // for (const [key, value] of Object.entries(obj)) {
40
- // // if (action(value, key, obj) === false) break;
41
- // // }
42
- // // }
43
- // // export function forOwn(obj, action) {
44
- // // for (const [key, value] of Object.entries(obj)) {
45
- // // if (!Object.hasOwnProperty(key)) continue;
46
- // // if (action(value, key, obj) === false) break;
47
- // // }
48
- // // }
49
- // export function has(obj, field) {
50
- // return field in obj;
51
- // }
52
- // export function isArray(obj) {
53
- // return Array.isArray(obj);
54
- // }
55
- // export function isEmpty(obj) {
56
- // if (typeof obj !== "object") return true;
57
- // if (obj === null || obj === undefined) return true;
58
- // if (isArray(obj)) return obj.length === 0;
59
- // return Object.keys(obj).length === 0;
60
- // }
61
- // export function isFunction(obj) {
62
- // return typeof obj === "function";
63
- // }
64
- // export function isUndefined(obj) {
65
- // return obj === undefined;
66
- // }
67
- // export function keys(obj) {
68
- // return Object.keys(obj);
69
- // }
70
- // // export function last(array) {
71
- // // const length = array == null ? 0 : array.length;
72
- // // return length ? array[length - 1] : undefined;
73
- // // }
74
- // export function map(obj, action) {
75
- // if (Array.isArray(obj)) {
76
- // return obj.map(action);
77
- // } else {
78
- // return Object.entries(obj).map(([key, value]) => action(value, key));
79
- // }
80
- // }
81
- // export function mapValues(obj, action) {
82
- // return (Array.isArray(obj) ? obj : Object.values(obj)).map(action);
83
- // }
84
- // export function max(list) {
85
- // let max = undefined;
86
- // for (let i = 0; i < list.length; i++) {
87
- // if (i === 0 || list[i] < max) {
88
- // max = list[i];
89
- // }
90
- // }
91
- // return max;
92
- // }
93
- // export function merge(...list) {
94
- // return list.reduce((result, obj) => {
95
- // for (const [key, value] of Object.entries(obj)) {
96
- // result[key] = value;
97
- // }
98
- // return result;
99
- // }, {});
100
- // }
101
- // export function min(list) {
102
- // return minBy(list, (d) => d);
103
- // }
104
- // export function minBy(list, get) {
105
- // let val, min;
106
- // for (let i = 0; i < list.length; i++) {
107
- // const value = get(list[i], i, list);
108
- // if (i === 0 || value > val) {
109
- // min = list[i];
110
- // val = value;
111
- // }
112
- // }
113
- // return min;
114
- // }
115
- // // export function now() {
116
- // // return Date.now();
117
- // // }
118
- // export function pick(obj, keys) {
119
- // return keys.reduce((result, key) => ((result[key] = obj[key]), result), {});
120
- // }
121
- // export function range(start, stop, step) {
122
- // if (stop === undefined) {
123
- // stop = start;
124
- // start = 0;
125
- // step = start > 0 ? 1 : -1;
126
- // } else if (step === undefined) {
127
- // step = stop > start ? 1 : -1;
128
- // }
129
- // const delta = Math.abs(stop - start);
130
- // let result = [];
131
- // for (let i = 0, val = start; i < delta; i++, val += step) {
132
- // result.push(val);
133
- // }
134
- // return result;
135
- // }
136
- // export function reduce(list, action) {
137
- // if (Array.isArray(list)) return list.reduce(action, {});
138
- // else
139
- // Object.entries(list).reduce(
140
- // (result, [key, value]) => action(result, value, key),
141
- // {}
142
- // );
143
- // }
144
-
145
- // export function sortBy(list, get) {
146
- // return list.sort((a, b) => {
147
- // const keyA = get(a);
148
- // const keyB = get(b);
149
- // return keyA > keyB ? 1 : keyA === keyB ? 0 : -1;
150
- // });
151
- // }
152
- // // export function size(list) {
153
- // // return (Array.isArray(list) ? list : Object.keys(list)).length;
154
- // // }
155
-
156
- // // export const transform = reduce;
157
-
158
- // export function values(obj) {
159
- // return Array.isArray(obj) ? [...obj] : Object.values(obj);
160
- // }
161
-
162
- // let idCounter = 0;
163
- // export function uniqueId(prefix) {
164
- // var id = ++idCounter;
165
- // return toString(prefix) + id;
166
- // }
167
-
168
- // export function union(...values) {
169
- // const set = new Set();
170
- // for (const val of values) {
171
- // for (const item of toArray(val)) {
172
- // set.add(item);
173
- // }
174
- // }
175
- // return [...set];
176
- // }
177
- // function toArray(val) {
178
- // return Array.isArray(val) ? val : val !== undefined ? [val] : [];
179
- // }
180
- // // export { default as zipObject } from "lodash/zipObject.js";
181
-
182
- // // export { default as constant } from "lodash/constant.js";
183
- // // export { default as clone } from "lodash/clone.js";
184
- // // export { default as cloneDeep } from "lodash/cloneDeep.js";
185
- // // export { default as defaults } from "lodash/defaults.js";
186
- // // export { default as each } from "lodash/forEach.js";
187
- // // export { default as forEach } from "lodash/forEach.js";
188
- // // export { default as find } from "lodash/find.js";
189
- // // export { default as filter } from "lodash/filter.js";
190
- // // export { default as flatten } from "lodash/flatten.js";
191
- // // export { default as forIn } from "lodash/forIn.js";
192
- // // export { default as forOwn } from "lodash/forOwn.js";
193
- // // export { default as has } from "lodash/has.js";
194
- // // export { default as isArray } from "lodash/isArray.js";
195
- // // export { default as isEmpty } from "lodash/isEmpty.js";
196
- // // export { default as isFunction } from "lodash/isFunction.js";
197
- // // export { default as isUndefined } from "lodash/isUndefined.js";
198
- // // export { default as keys } from "lodash/keys.js";
199
- // // export { default as last } from "lodash/last.js";
200
- // // export { default as map } from "lodash/map.js";
201
- // // export { default as mapValues } from "lodash/mapValues.js";
202
- // // export { default as max } from "lodash/max.js";
203
- // // export { default as merge } from "lodash/merge.js";
204
- // // export { default as min } from "lodash/min.js";
205
- // // export { default as minBy } from "lodash/minBy.js";
206
- // // export { default as now } from "lodash/now.js";
207
- // // export { default as pick } from "lodash/pick.js";
208
- // // export { default as range } from "lodash/range.js";
209
- // // export { default as reduce } from "lodash/reduce.js";
210
- // // export { default as sortBy } from "lodash/sortBy.js";
211
- // // export { default as size } from "lodash/size.js";
212
- // // export { default as transform } from "lodash/transform.js";
213
- // // export { default as values } from "lodash/values.js";
214
- // // export { default as uniqueId } from "lodash/uniqueId.js";
215
- // // export { default as union } from "lodash/union.js";
216
- // // export { default as zipObject } from "lodash/zipObject.js";
217
-
218
- // // ---------------------------------------
219
- // // export { default as constant } from "lodash.constant";
220
- // // export { default as clone } from "lodash.clone";
221
- // // export { default as cloneDeep } from "lodash.clonedeep";
222
- // // export { default as defaults } from "lodash.defaults";
223
- // // export { default as each } from "lodash.foreach";
224
- // // export { default as forEach } from "lodash.foreach";
225
- // // export { default as find } from "lodash.find";
226
- // // export { default as filter } from "lodash.filter";
227
- // // export { default as flatten } from "lodash.flatten";
228
- // // export { default as forIn } from "lodash.forin";
229
- // // export { default as forOwn } from "lodash.forown";
230
- // // export { default as has } from "lodash.has";
231
- // // export { default as isArray } from "lodash.isarray";
232
- // // export { default as isEmpty } from "lodash.isempty";
233
- // // export { default as isFunction } from "lodash.isfunction";
234
- // // export { default as isUndefined } from "lodash.isundefined";
235
- // // export { default as keys } from "lodash.keys";
236
- // // export { default as last } from "lodash.last";
237
- // // export { default as map } from "lodash.map";
238
- // // export { default as mapValues } from "lodash.mapvalues";
239
- // // export { default as max } from "lodash.max";
240
- // // export { default as merge } from "lodash.merge";
241
- // // export { default as min } from "lodash.min";
242
- // // export { default as minBy } from "lodash.minby";
243
- // // export { default as now } from "lodash.now";
244
- // // export { default as pick } from "lodash.pick";
245
- // // export { default as range } from "lodash.range";
246
- // // export { default as reduce } from "lodash.reduce";
247
- // // export { default as sortBy } from "lodash.sortby";
248
- // // export { default as size } from "lodash.size";
249
- // // export { default as transform } from "lodash.transform";
250
- // // export { default as values } from "lodash.values";
251
- // // export { default as uniqueId } from "lodash.uniqueid";
252
- // // export { default as union } from "lodash.union";
253
- // // export { default as zipObject } from "lodash.zipobject";
254
-
255
- // // export {
256
- // // constant,
257
- // // clone,
258
- // // cloneDeep,
259
- // // defaults,
260
- // // each,
261
- // // find,
262
- // // filter,
263
- // // flatten,
264
- // // forEach,
265
- // // forIn,
266
- // // forOwn,
267
- // // has,
268
- // // isArray,
269
- // // isEmpty,
270
- // // isFunction,
271
- // // isUndefined,
272
- // // keys,
273
- // // last,
274
- // // map,
275
- // // mapValues,
276
- // // max,
277
- // // merge,
278
- // // min,
279
- // // minBy,
280
- // // now,
281
- // // pick,
282
- // // range,
283
- // // reduce,
284
- // // sortBy,
285
- // // size,
286
- // // transform,
287
- // // values,
288
- // // uniqueId,
289
- // // union,
290
- // // zipObject,
291
- // // } from "lodash-es";