@statewalker/fsm-charts 0.2.4 → 0.2.5

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 (123) hide show
  1. package/dist/{chunk-AZBRQNTU.js → chunk-2LFUT2C6.js} +1062 -1110
  2. package/dist/{chunk-SVKVQY7B.js → chunk-ARZYBFNA.js} +4 -4
  3. package/dist/{chunk-36ZLXJVD.js → chunk-CR2M4445.js} +35 -33
  4. package/dist/{chunk-TZHCBZVP.js → chunk-GW2Z65BN.js} +22 -15
  5. package/dist/chunk-PKBMQBKP.js +5 -0
  6. package/dist/{chunk-VILLJJJD.js → chunk-RZ4FP6JB.js} +11 -9
  7. package/dist/index-config.js +2 -1
  8. package/dist/index-dom.js +2 -1
  9. package/dist/{index-html-DgSCNHkR.d.ts → index-html-BBQqYoST.d.ts} +10 -10
  10. package/dist/index-html.d.ts +1 -1
  11. package/dist/index-html.js +2 -1
  12. package/dist/index-layout.d.ts +15 -15
  13. package/dist/index-layout.js +2 -1
  14. package/dist/index-runtime.js +2 -1
  15. package/dist/index.d.ts +3 -3
  16. package/dist/index.js +6 -5
  17. package/package.json +16 -18
  18. package/src/config/concatTransitionsToString.ts +2 -2
  19. package/src/config/index.ts +4 -4
  20. package/src/config/serializeProcessConfig.ts +3 -3
  21. package/src/config/splitTransitionString.ts +2 -2
  22. package/src/config/toFsmStateConfig.ts +3 -3
  23. package/src/dagre/acyclic.js +9 -10
  24. package/src/dagre/add-border-segments.js +11 -7
  25. package/src/dagre/coordinate-system.js +12 -12
  26. package/src/dagre/data/list.js +2 -2
  27. package/src/dagre/debug.d.ts +1 -1
  28. package/src/dagre/debug.js +11 -11
  29. package/src/dagre/greedy-fas.js +17 -21
  30. package/src/dagre/index.d.ts +4 -4
  31. package/src/dagre/index.js +4 -4
  32. package/src/dagre/layout.js +107 -96
  33. package/src/dagre/nesting-graph.js +13 -19
  34. package/src/dagre/normalize.js +7 -7
  35. package/src/dagre/order/add-subgraph-constraints.js +2 -2
  36. package/src/dagre/order/barycenter.d.ts +1 -1
  37. package/src/dagre/order/barycenter.js +4 -4
  38. package/src/dagre/order/build-layer-graph.d.ts +1 -1
  39. package/src/dagre/order/build-layer-graph.js +7 -9
  40. package/src/dagre/order/cross-count.js +14 -17
  41. package/src/dagre/order/index.js +19 -17
  42. package/src/dagre/order/init-order.js +5 -15
  43. package/src/dagre/order/resolve-conflicts.js +10 -14
  44. package/src/dagre/order/sort-subgraph.d.ts +1 -1
  45. package/src/dagre/order/sort-subgraph.js +13 -14
  46. package/src/dagre/order/sort.d.ts +1 -1
  47. package/src/dagre/order/sort.js +6 -10
  48. package/src/dagre/parent-dummy-chains.js +10 -4
  49. package/src/dagre/position/bk.d.ts +3 -3
  50. package/src/dagre/position/bk.js +84 -65
  51. package/src/dagre/position/index.js +7 -11
  52. package/src/dagre/rank/feasible-tree.d.ts +1 -1
  53. package/src/dagre/rank/feasible-tree.js +6 -6
  54. package/src/dagre/rank/index.js +6 -6
  55. package/src/dagre/rank/network-simplex.d.ts +0 -1
  56. package/src/dagre/rank/network-simplex.js +20 -25
  57. package/src/dagre/rank/util.js +2 -6
  58. package/src/dagre/util.d.ts +12 -6
  59. package/src/dagre/util.js +31 -37
  60. package/src/dom/buildSections.ts +16 -12
  61. package/src/dom/description-panels.ts +3 -3
  62. package/src/dom/getStatesDescriptions.ts +1 -1
  63. package/src/full/index.ts +1 -1
  64. package/src/full/toFsmStateCharts.ts +10 -10
  65. package/src/graphlib/alg/components.js +2 -2
  66. package/src/graphlib/alg/dfs.js +5 -5
  67. package/src/graphlib/alg/dijkstra-all.js +4 -4
  68. package/src/graphlib/alg/dijkstra.js +9 -12
  69. package/src/graphlib/alg/find-cycles.js +7 -5
  70. package/src/graphlib/alg/floyd-warshall.js +8 -11
  71. package/src/graphlib/alg/index.d.ts +11 -11
  72. package/src/graphlib/alg/index.js +11 -11
  73. package/src/graphlib/alg/is-acyclic.js +1 -1
  74. package/src/graphlib/alg/postorder.js +2 -2
  75. package/src/graphlib/alg/preorder.js +2 -2
  76. package/src/graphlib/alg/prim.d.ts +1 -1
  77. package/src/graphlib/alg/prim.js +5 -5
  78. package/src/graphlib/alg/tarjan.js +3 -3
  79. package/src/graphlib/alg/topsort.js +1 -1
  80. package/src/graphlib/data/priority-queue.js +8 -10
  81. package/src/graphlib/graph.js +53 -52
  82. package/src/graphlib/index.d.ts +2 -2
  83. package/src/graphlib/index.js +2 -2
  84. package/src/graphlib/json.d.ts +1 -1
  85. package/src/graphlib/json.js +6 -6
  86. package/src/html/buildStatechartCss.ts +2 -2
  87. package/src/html/buildStatechartStyles.ts +1 -1
  88. package/src/html/buildStatechartSvg.ts +7 -7
  89. package/src/html/buildStatechartsPanel.ts +2 -2
  90. package/src/html/index.ts +4 -4
  91. package/src/index-config.ts +2 -2
  92. package/src/index-dom.ts +1 -1
  93. package/src/index-html.ts +2 -2
  94. package/src/index-layout.ts +2 -2
  95. package/src/index-runtime.ts +2 -2
  96. package/src/index.ts +8 -8
  97. package/src/layout/buildCharts.ts +5 -5
  98. package/src/layout/buildFlatCharts.ts +11 -13
  99. package/src/layout/getGraphParamsProvider.ts +5 -8
  100. package/src/layout/getLabelDimensions.ts +5 -5
  101. package/src/layout/index.ts +5 -4
  102. package/src/lodash-es/index.ts +2 -2
  103. package/src/lodash-es/types.ts +37 -35
  104. package/src/runtime/RuntimeStatechartApi.ts +12 -23
  105. package/src/runtime/StateChartIndex.ts +3 -3
  106. package/src/runtime/index.ts +2 -2
  107. package/src/types/FsmStateConfig.ts +1 -1
  108. package/src/types/GraphParamsProvider.ts +2 -2
  109. package/src/types/Position.ts +1 -1
  110. package/src/types/StateChart.ts +2 -2
  111. package/src/types/StateGraphEdge.ts +2 -2
  112. package/src/types/StateGraphNode.ts +2 -2
  113. package/src/types/TransitionsGraph.ts +4 -4
  114. package/src/types/index.ts +11 -11
  115. package/src/utils/BasisCurve.ts +3 -3
  116. package/src/utils/domToText.ts +1 -1
  117. package/src/utils/getPadding.ts +1 -1
  118. package/src/utils/newRegistry.ts +1 -1
  119. package/src/utils/serializeAttrs.ts +6 -6
  120. package/src/utils/serializeCss.ts +3 -3
  121. package/src/utils/serializeStyle.ts +2 -2
  122. package/src/utils/toKebabCase.ts +1 -1
  123. package/CHANGELOG.md +0 -1
@@ -1,35 +1,37 @@
1
- export type { constant } from "lodash-es";
2
- export type { clone } from "lodash-es";
3
- export type { cloneDeep } from "lodash-es";
4
- export type { defaults } from "lodash-es";
5
- export type { each } from "lodash-es";
6
- export type { forEach } from "lodash-es";
7
- export type { find } from "lodash-es";
8
- export type { filter } from "lodash-es";
9
- export type { flatten } from "lodash-es";
10
- export type { forIn } from "lodash-es";
11
- export type { forOwn } from "lodash-es";
12
- export type { has } from "lodash-es";
13
- export type { isArray } from "lodash-es";
14
- export type { isEmpty } from "lodash-es";
15
- export type { isFunction } from "lodash-es";
16
- export type { isUndefined } from "lodash-es";
17
- export type { keys } from "lodash-es";
18
- export type { last } from "lodash-es";
19
- export type { map } from "lodash-es";
20
- export type { mapValues } from "lodash-es";
21
- export type { max } from "lodash-es";
22
- export type { merge } from "lodash-es";
23
- export type { min } from "lodash-es";
24
- export type { minBy } from "lodash-es";
25
- export type { now } from "lodash-es";
26
- export type { pick } from "lodash-es";
27
- export type { range } from "lodash-es";
28
- export type { reduce } from "lodash-es";
29
- export type { sortBy } from "lodash-es";
30
- export type { size } from "lodash-es";
31
- export type { transform } from "lodash-es";
32
- export type { values } from "lodash-es";
33
- export type { uniqueId } from "lodash-es";
34
- export type { union } from "lodash-es";
35
- export type { zipObject } from "lodash-es";
1
+ export type {
2
+ clone,
3
+ cloneDeep,
4
+ constant,
5
+ defaults,
6
+ each,
7
+ filter,
8
+ find,
9
+ flatten,
10
+ forEach,
11
+ forIn,
12
+ forOwn,
13
+ has,
14
+ isArray,
15
+ isEmpty,
16
+ isFunction,
17
+ isUndefined,
18
+ keys,
19
+ last,
20
+ map,
21
+ mapValues,
22
+ max,
23
+ merge,
24
+ min,
25
+ minBy,
26
+ now,
27
+ pick,
28
+ range,
29
+ reduce,
30
+ size,
31
+ sortBy,
32
+ transform,
33
+ union,
34
+ uniqueId,
35
+ values,
36
+ zipObject,
37
+ } from "lodash-es";
@@ -1,4 +1,4 @@
1
- import type { StateChart } from "../types/index.ts";
1
+ import type { StateChart } from "../types/index.js";
2
2
 
3
3
  export type RuntimeListener = (id: string) => void;
4
4
  export class RuntimeStatechartApi {
@@ -22,7 +22,7 @@ export class RuntimeStatechartApi {
22
22
  }
23
23
 
24
24
  close() {
25
- Object.values(this._registry).forEach((r) => r && r());
25
+ Object.values(this._registry).forEach((r) => r?.());
26
26
  this._registry = {};
27
27
  this._transitionsClickListeners = {};
28
28
  this._statesClickListeners = {};
@@ -68,7 +68,7 @@ export class RuntimeStatechartApi {
68
68
  this.selectState(id);
69
69
  }
70
70
  }
71
-
71
+
72
72
  focusStates(...stateIds: string[]) {
73
73
  for (let i = 0; i < stateIds.length; i++) {
74
74
  const stateId = stateIds[i];
@@ -81,10 +81,7 @@ export class RuntimeStatechartApi {
81
81
  }
82
82
  }
83
83
 
84
- setStateDescription(
85
- stateId: string,
86
- description: Node | string | undefined,
87
- ) {
84
+ setStateDescription(stateId: string, description: Node | string | undefined) {
88
85
  const descriptionContainer = this.element.querySelector(
89
86
  `details[data-state-id="${stateId}"] .state-details__description`,
90
87
  );
@@ -198,17 +195,13 @@ export class RuntimeStatechartApi {
198
195
  }
199
196
 
200
197
  _addStateModifier(cssSelector: string, modifier: string = "selected") {
201
- this._applyStateModifier(
202
- cssSelector,
203
- modifier,
204
- (elm, cls) => elm && elm.classList.add(cls),
198
+ this._applyStateModifier(cssSelector, modifier, (elm, cls) =>
199
+ elm?.classList.add(cls),
205
200
  );
206
201
  }
207
202
  _removeStateModifier(cssSelector: string, modifier: string = "selected") {
208
- this._applyStateModifier(
209
- cssSelector,
210
- modifier,
211
- (elm, cls) => elm && elm.classList.remove(cls),
203
+ this._applyStateModifier(cssSelector, modifier, (elm, cls) =>
204
+ elm?.classList.remove(cls),
212
205
  );
213
206
  }
214
207
  _applyStateModifier(
@@ -231,20 +224,16 @@ export class RuntimeStatechartApi {
231
224
  }
232
225
 
233
226
  _addTransitionsModifier(cssSelector: string, modifier: string = "selected") {
234
- this._applyTransitionsModifier(
235
- cssSelector,
236
- modifier,
237
- (elm, cls) => elm && elm.classList.add(cls),
227
+ this._applyTransitionsModifier(cssSelector, modifier, (elm, cls) =>
228
+ elm?.classList.add(cls),
238
229
  );
239
230
  }
240
231
  _removeTransitionsModifier(
241
232
  cssSelector: string,
242
233
  modifier: string = "selected",
243
234
  ) {
244
- this._applyTransitionsModifier(
245
- cssSelector,
246
- modifier,
247
- (elm, cls) => elm && elm.classList.remove(cls),
235
+ this._applyTransitionsModifier(cssSelector, modifier, (elm, cls) =>
236
+ elm?.classList.remove(cls),
248
237
  );
249
238
  }
250
239
  _applyTransitionsModifier(
@@ -1,8 +1,8 @@
1
1
  import type {
2
2
  StateChart,
3
- StateGraphNode,
4
3
  StateGraphEdge,
5
- } from "../types/index.ts";
4
+ StateGraphNode,
5
+ } from "../types/index.js";
6
6
 
7
7
  export class StateChartIndex {
8
8
  statechart: StateChart;
@@ -90,7 +90,7 @@ export class StateChartIndex {
90
90
  * @returns a stack of state identifiers for the given states
91
91
  */
92
92
  getStatesIds(...stack: string[]): string[] {
93
- let result = [];
93
+ const result = [];
94
94
  let list = [this.statechart] as (StateChart | StateGraphNode)[];
95
95
  for (let i = 0; list?.length > 0 && i < stack.length; i++) {
96
96
  const key = stack[i];
@@ -1,2 +1,2 @@
1
- export * from "./RuntimeStatechartApi.ts";
2
- export * from "./StateChartIndex.ts";
1
+ export * from "./RuntimeStatechartApi.js";
2
+ export * from "./StateChartIndex.js";
@@ -1,4 +1,4 @@
1
- import type { Transition } from "./Transition.ts";
1
+ import type { Transition } from "./Transition.js";
2
2
 
3
3
  // export type FsmStateKey = string;
4
4
  // export type FsmEventKey = string;
@@ -1,5 +1,5 @@
1
- import type { Dimensions } from "./Dimensions.ts";
2
- import { Label } from "./Label.ts";
1
+ import type { Dimensions } from "./Dimensions.js";
2
+ import type { Label } from "./Label.js";
3
3
 
4
4
  /**
5
5
  * Provides default functions measuring dimensions for state nodes and transition edges in the graph.
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * X/Y position of a node in the graph.
3
3
  */
4
- export type Position = { x: number; y: number; };
4
+ export type Position = { x: number; y: number };
@@ -1,5 +1,5 @@
1
- import type { StateGraphNode } from "./StateGraphNode.ts";
2
- import type { TransitionsGraph } from "./TransitionsGraph.ts";
1
+ import type { StateGraphNode } from "./StateGraphNode.js";
2
+ import type { TransitionsGraph } from "./TransitionsGraph.js";
3
3
 
4
4
  export type StateChart = TransitionsGraph &
5
5
  StateGraphNode & {
@@ -1,5 +1,5 @@
1
- import type { Dimensions } from "./Dimensions.ts";
2
- import type { Position } from "./Position.ts";
1
+ import type { Dimensions } from "./Dimensions.js";
2
+ import type { Position } from "./Position.js";
3
3
 
4
4
  /**
5
5
  * Information about a state graph edge.
@@ -1,5 +1,5 @@
1
- import type { Dimensions } from "./Dimensions.ts";
2
- import type { Position } from "./Position.ts";
1
+ import type { Dimensions } from "./Dimensions.js";
2
+ import type { Position } from "./Position.js";
3
3
 
4
4
  /**
5
5
  * Information about a state node in the graph.
@@ -1,7 +1,7 @@
1
- import type { Dimensions } from "./Dimensions.ts";
2
- import type { Position } from "./Position.ts";
3
- import type { StateGraphEdge } from "./StateGraphEdge.ts";
4
- import type { StateGraphNode } from "./StateGraphNode.ts";
1
+ import type { Dimensions } from "./Dimensions.js";
2
+ import type { Position } from "./Position.js";
3
+ import type { StateGraphEdge } from "./StateGraphEdge.js";
4
+ import type { StateGraphNode } from "./StateGraphNode.js";
5
5
 
6
6
  /**
7
7
  * Coordinates for state nodes and endges corresponding to state transitions.
@@ -1,11 +1,11 @@
1
- export type * from "./Dimensions.ts";
2
- export type * from "./FsmStateConfig.ts";
3
- export type * from "./GraphParamsProvider.ts";
4
- export type * from "./Label.ts";
5
- export type * from "./Padding.ts";
6
- export type * from "./Position.ts";
7
- export type * from "./StateChart.ts";
8
- export type * from "./StateGraphEdge.ts";
9
- export type * from "./StateGraphNode.ts";
10
- export type * from "./Transition.ts";
11
- export type * from "./TransitionsGraph.ts";
1
+ export type * from "./Dimensions.js";
2
+ export type * from "./FsmStateConfig.js";
3
+ export type * from "./GraphParamsProvider.js";
4
+ export type * from "./Label.js";
5
+ export type * from "./Padding.js";
6
+ export type * from "./Position.js";
7
+ export type * from "./StateChart.js";
8
+ export type * from "./StateGraphEdge.js";
9
+ export type * from "./StateGraphNode.js";
10
+ export type * from "./Transition.js";
11
+ export type * from "./TransitionsGraph.js";
@@ -8,7 +8,7 @@ export type DrawContext = {
8
8
  x1: number,
9
9
  y1: number,
10
10
  x2: number,
11
- y2: number
11
+ y2: number,
12
12
  ): void;
13
13
  moveTo(x: number, y: number): void;
14
14
  lineTo(x: number, y: number): void;
@@ -33,7 +33,7 @@ export class BasisCurve {
33
33
  (this._x0 + 2 * this._x1) / 3,
34
34
  (this._y0 + 2 * this._y1) / 3,
35
35
  (this._x0 + 4 * this._x1 + x) / 6,
36
- (this._y0 + 4 * this._y1 + y) / 6
36
+ (this._y0 + 4 * this._y1 + y) / 6,
37
37
  );
38
38
  }
39
39
 
@@ -77,7 +77,7 @@ export class BasisCurve {
77
77
  this._point = 3;
78
78
  this._context.lineTo(
79
79
  (5 * this._x0 + this._x1) / 6,
80
- (5 * this._y0 + this._y1) / 6
80
+ (5 * this._y0 + this._y1) / 6,
81
81
  ); // falls through
82
82
  default:
83
83
  this.$point(x, y);
@@ -20,7 +20,7 @@ export function domToText(elm: HTMLElement) {
20
20
  const child = el.childNodes[i];
21
21
  const result = visitor(el.childNodes[i]);
22
22
  if (child.nodeType !== Node.ELEMENT_NODE) continue;
23
- if (result !== undefined && !Boolean(result)) continue;
23
+ if (result !== undefined && !result) continue;
24
24
  visit(child as HTMLElement, visitor);
25
25
  }
26
26
  }
@@ -1,4 +1,4 @@
1
- import type { Padding } from "../types/Padding.ts";
1
+ import type { Padding } from "../types/Padding.js";
2
2
 
3
3
  /**
4
4
  * Expands a padding value to a 4-element array: [top, right, bottom, left].
@@ -15,7 +15,7 @@ export function newRegistry(
15
15
  const register = (action: () => unknown) => {
16
16
  const id = counter++;
17
17
  return (registrations[id] = Object.assign(
18
- function (skip?: boolean) {
18
+ (skip?: boolean) => {
19
19
  try {
20
20
  delete registrations[id];
21
21
  return !skip && action && action();
@@ -1,24 +1,24 @@
1
- import { toKebabCase } from "./toKebabCase.ts";
1
+ import { toKebabCase } from "./toKebabCase.js";
2
2
 
3
3
  export function serializeAttrs(
4
4
  attrs: Record<string, string | number | undefined> = {},
5
5
  {
6
6
  prefix = "",
7
7
  transform = false,
8
- }: { prefix?: string; transform?: boolean } = {}
8
+ }: { prefix?: string; transform?: boolean } = {},
9
9
  ) {
10
10
  const result: string[] = [];
11
11
  for (const [key, value] of Object.entries(attrs || {}).sort(([a], [b]) =>
12
- a > b ? 1 : -1
12
+ a > b ? 1 : -1,
13
13
  )) {
14
14
  if (value === undefined || value === null || value === "") continue;
15
15
  result.push(
16
16
  `${prefix}${escapeValue(key)}${
17
17
  "=" +
18
18
  JSON.stringify(
19
- escapeValue(transform ? toKebabCase(String(value)) : value)
19
+ escapeValue(transform ? toKebabCase(String(value)) : value),
20
20
  )
21
- }`
21
+ }`,
22
22
  );
23
23
  }
24
24
  return result.join(" ");
@@ -27,6 +27,6 @@ export function serializeAttrs(
27
27
  return String(value)
28
28
  .replaceAll(/</gim, "&lt;")
29
29
  .replaceAll(/>/gim, "&gt;")
30
- .replaceAll(/"/gim, "&qout;");
30
+ .replaceAll(/"/gim, "&quot;");
31
31
  }
32
32
  }
@@ -1,4 +1,4 @@
1
- import { toKebabCase } from "./toKebabCase.ts";
1
+ import { toKebabCase } from "./toKebabCase.js";
2
2
 
3
3
  export interface CssTree extends Record<string, string | number | CssTree> {}
4
4
 
@@ -8,14 +8,14 @@ export function serializeCss(obj: CssTree) {
8
8
  function visitStyle(
9
9
  obj: CssTree,
10
10
  lines: string[] = [],
11
- prefixes: string[] = [""]
11
+ prefixes: string[] = [""],
12
12
  ) {
13
13
  for (const [key, style] of Object.entries(obj)) {
14
14
  const selectors = [];
15
15
  for (const sel of key.split(",").map((_) => _.trim())) {
16
16
  for (const prefix of prefixes) {
17
17
  const selector = sel.replace(/^(.)/, (_, ch) =>
18
- ch === "&" ? prefix : prefix.length > 0 ? prefix + " " + ch : ch
18
+ ch === "&" ? prefix : prefix.length > 0 ? `${prefix} ${ch}` : ch,
19
19
  );
20
20
  selectors.push(selector);
21
21
  }
@@ -1,8 +1,8 @@
1
- import { toKebabCase } from "./toKebabCase.ts";
1
+ import { toKebabCase } from "./toKebabCase.js";
2
2
 
3
3
  export function serializeStyle(
4
4
  style: Record<string, string>,
5
- separator = "; "
5
+ separator = "; ",
6
6
  ) {
7
7
  const str = Object.entries(style)
8
8
  .map(([key, value]) => `${toKebabCase(key)}: ${value}`)
@@ -4,7 +4,7 @@ export function toKebabCase(str?: string): string {
4
4
  // Transform to kebab:
5
5
  str = str.replace(
6
6
  /([^A-Z]?)([A-Z])/g,
7
- (_, a, b) => a.toLowerCase() + "-" + b.toLowerCase()
7
+ (_, a, b) => `${a.toLowerCase()}-${b.toLowerCase()}`,
8
8
  );
9
9
  return str;
10
10
 
package/CHANGELOG.md DELETED
@@ -1 +0,0 @@
1
- # @statewalker/fsm-charts