@stonecrop/node-editor 0.4.27 → 0.4.29

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.
@@ -1,11 +1,11 @@
1
1
  import { type Elements, type Element, type XYPosition, Position } from '@vue-flow/core';
2
- import type { AnyStateMachine, AnyStateNodeDefinition, StatesConfig } from 'xstate';
2
+ import type { AnyStateNodeDefinition, AnyStateNodeConfig } from 'xstate';
3
3
  /**
4
4
  * Editor states
5
5
  * @public
6
6
  */
7
7
  export type EditorStates = {
8
- [key: string]: AnyStateMachine | AnyStateNodeDefinition | StatesConfig<any, any, any>;
8
+ [key: string]: AnyStateNodeDefinition | AnyStateNodeConfig['states'];
9
9
  };
10
10
  /**
11
11
  * Flow elements
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAEnF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,sBAAsB,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;CACrF,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,CAClC;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,EAC3C;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAC3C,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAChC;IAAE,QAAQ,CAAC,EAA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;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG;QACd,QAAQ,CAAC,EAAE,UAAU,CAAA;QACrB,cAAc,CAAC,EAAE,QAAQ,CAAA;QACzB,cAAc,CAAC,EAAE,QAAQ,CAAA;KACzB,CAAA;CACD,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/node-editor",
3
- "version": "0.4.27",
3
+ "version": "0.4.29",
4
4
  "description": "Node editor UI for Stonecrop",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "require": "./dist/node-editor.umd.cjs"
26
26
  },
27
- "./styles": "./dist/style.css"
27
+ "./styles": "./dist/node-editor.css"
28
28
  },
29
29
  "typings": "./dist/src/index.d.ts",
30
30
  "files": [
@@ -35,7 +35,7 @@
35
35
  "@vue-flow/core": "^1.45.0",
36
36
  "vue": "^3.5.17",
37
37
  "vue-router": "^4.5.1",
38
- "xstate": "^4.38.3"
38
+ "xstate": "^5.20.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@microsoft/api-documenter": "^7.26.29",
@@ -61,7 +61,7 @@
61
61
  "prepublish": "heft build && vite build && rushx docs",
62
62
  "build": "heft build && vite build && rushx docs",
63
63
  "dev": "vite",
64
- "docs": "api-documenter markdown -i temp -o ../docs/node_editor",
64
+ "docs": "cd ../common/autoinstallers/doc-tools && node generate-docs.mjs node_editor",
65
65
  "lint": "eslint . --ext .ts,.vue",
66
66
  "preview": "vite preview"
67
67
  }
@@ -24,6 +24,10 @@ const elements = computed<FlowElements>({
24
24
  const stateElements: FlowElements = []
25
25
  const stateHash: Record<string, FlowElement> = {}
26
26
 
27
+ if (!states.value) {
28
+ return stateElements
29
+ }
30
+
27
31
  let index = 0
28
32
  for (const [key, value] of Object.entries(states.value)) {
29
33
  const el: Node = {
@@ -34,7 +38,7 @@ const elements = computed<FlowElements>({
34
38
  sourcePosition: layout[key]?.sourcePosition || Position.Right,
35
39
  }
36
40
 
37
- if (value.type === 'final') {
41
+ if (value?.type === 'final') {
38
42
  el.type = 'output'
39
43
  el.class = 'default-output-node'
40
44
  }
@@ -43,13 +47,14 @@ const elements = computed<FlowElements>({
43
47
  }
44
48
 
45
49
  for (const [key, value] of Object.entries(states.value)) {
46
- if (value.on) {
50
+ if (value?.on) {
47
51
  for (const [edgeKey, edgeValue] of Object.entries(value.on)) {
48
- // If the proxy array 'value.on' has more than one edge, 'edgeValue' will contain a proxy object
52
+ // NOTE: If the proxy array 'value.on' has more than one edge, 'edgeValue' will contain a proxy object
49
53
  // where 'target' can be accessed. Otherwise, 'edgeValue' will be available directly.
54
+
55
+ // TODO: resolve type issues with xstate
56
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
50
57
  const target = edgeValue.target || edgeValue
51
- // TODO: handle typescript errors for both types of states
52
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
53
58
  stateElements.push({
54
59
  id: `${key}-${target}`,
55
60
  source: key,
@@ -120,6 +125,9 @@ const onElementsChange = (elements: FlowElements) => {
120
125
  // add edges to states
121
126
  const label = idToLabel[edgeKey]
122
127
  for (const [key, value] of Object.entries(edgeValue)) {
128
+ if (!states[label]) {
129
+ states[label] = { on: {} }
130
+ }
123
131
  states[label].on[key] = value
124
132
  }
125
133
  }
@@ -1,12 +1,12 @@
1
1
  import { type Elements, type Element, type XYPosition, Position } from '@vue-flow/core'
2
- import type { AnyStateMachine, AnyStateNodeDefinition, StatesConfig } from 'xstate'
2
+ import type { AnyStateNodeDefinition, AnyStateNodeConfig } from 'xstate'
3
3
 
4
4
  /**
5
5
  * Editor states
6
6
  * @public
7
7
  */
8
8
  export type EditorStates = {
9
- [key: string]: AnyStateMachine | AnyStateNodeDefinition | StatesConfig<any, any, any>
9
+ [key: string]: AnyStateNodeDefinition | AnyStateNodeConfig['states']
10
10
  }
11
11
 
12
12
  /**