@stonecrop/node-editor 0.13.3 → 0.13.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/node-editor",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -40,19 +40,15 @@
|
|
|
40
40
|
"vue-router": "^5.0.6"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@eslint/js": "^10.0.1",
|
|
44
43
|
"@microsoft/api-documenter": "^7.30.5",
|
|
45
44
|
"@rushstack/heft": "^1.2.17",
|
|
46
45
|
"@vitejs/plugin-vue": "^6.0.6",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"eslint-plugin-vue": "^10.9.0",
|
|
50
|
-
"globals": "^17.6.0",
|
|
46
|
+
"oxlint": "1.67.0",
|
|
47
|
+
"oxlint-tsgolint": "0.23.0",
|
|
51
48
|
"typescript": "^6.0.3",
|
|
52
|
-
"
|
|
49
|
+
"vite": "^7.3.2",
|
|
53
50
|
"vue": "^3.5.33",
|
|
54
51
|
"vue-router": "^5.0.6",
|
|
55
|
-
"vite": "^7.3.2",
|
|
56
52
|
"stonecrop-rig": "0.7.0"
|
|
57
53
|
},
|
|
58
54
|
"description": "Node editor UI for Stonecrop",
|
|
@@ -67,7 +63,8 @@
|
|
|
67
63
|
"build": "heft build && vite build && rushx docs",
|
|
68
64
|
"dev": "vite",
|
|
69
65
|
"docs": "bash ../common/scripts/run-docs.sh node_editor",
|
|
70
|
-
"lint": "
|
|
66
|
+
"lint": "oxlint",
|
|
67
|
+
"lint:fix": "oxlint --fix",
|
|
71
68
|
"preview": "vite preview"
|
|
72
69
|
}
|
|
73
70
|
}
|
|
@@ -81,35 +81,35 @@ const activeElementIndex = computed(() => {
|
|
|
81
81
|
|
|
82
82
|
const elements = computed({
|
|
83
83
|
get: () => {
|
|
84
|
-
const
|
|
84
|
+
const items = modelValue
|
|
85
85
|
|
|
86
86
|
// Add data to each element
|
|
87
|
-
for (const
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
} else if (
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
for (const element of items) {
|
|
88
|
+
element.data = {}
|
|
89
|
+
if (element.type === 'input') {
|
|
90
|
+
element.data.hasInput = false
|
|
91
|
+
element.data.hasOutput = true
|
|
92
|
+
} else if (element.type === 'output') {
|
|
93
|
+
element.data.hasInput = true
|
|
94
|
+
element.data.hasOutput = false
|
|
95
95
|
} else {
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
element.data.hasInput = true
|
|
97
|
+
element.data.hasOutput = true
|
|
98
98
|
}
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
element.class = 'vue-flow__node-default'
|
|
100
|
+
element.type = 'editable'
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// Add click event to each element
|
|
104
|
-
for (const
|
|
105
|
-
|
|
104
|
+
for (const element of items) {
|
|
105
|
+
element.events = {
|
|
106
106
|
click: () => {
|
|
107
|
-
activeElementKey.value =
|
|
107
|
+
activeElementKey.value = element.id
|
|
108
108
|
},
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
return
|
|
112
|
+
return items
|
|
113
113
|
},
|
|
114
114
|
set: newValue => {
|
|
115
115
|
emit('update:modelValue', JSON.parse(JSON.stringify(newValue)))
|
|
@@ -87,22 +87,22 @@ const elements = computed<FlowElements>({
|
|
|
87
87
|
// TODO: emit('update:modelValue', modelValue)
|
|
88
88
|
},
|
|
89
89
|
})
|
|
90
|
-
const onElementsChange = (
|
|
90
|
+
const onElementsChange = (nextElements: FlowElements) => {
|
|
91
91
|
const edges: Record<string, Record<string, any>> = {}
|
|
92
92
|
const idToLabel: Record<string, string> = {}
|
|
93
|
-
const
|
|
93
|
+
const nextStates: EditorStates = {}
|
|
94
94
|
|
|
95
|
-
for (const el of
|
|
95
|
+
for (const el of nextElements) {
|
|
96
96
|
const label = el.label as string
|
|
97
97
|
|
|
98
98
|
if (el.type === 'input') {
|
|
99
99
|
// it's an input node
|
|
100
|
-
|
|
100
|
+
nextStates[label] = {
|
|
101
101
|
on: {},
|
|
102
102
|
}
|
|
103
103
|
} else if (el.type === 'output') {
|
|
104
104
|
// it's an output node
|
|
105
|
-
|
|
105
|
+
nextStates[label] = {
|
|
106
106
|
type: 'final',
|
|
107
107
|
}
|
|
108
108
|
} else if (el.source && el.target) {
|
|
@@ -113,7 +113,7 @@ const onElementsChange = (elements: FlowElements) => {
|
|
|
113
113
|
}
|
|
114
114
|
} else {
|
|
115
115
|
// it's a state
|
|
116
|
-
|
|
116
|
+
nextStates[label] = {
|
|
117
117
|
on: {},
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -124,13 +124,13 @@ const onElementsChange = (elements: FlowElements) => {
|
|
|
124
124
|
// add edges to states
|
|
125
125
|
const label = idToLabel[edgeKey]
|
|
126
126
|
for (const [key, value] of Object.entries(edgeValue)) {
|
|
127
|
-
if (!
|
|
128
|
-
|
|
127
|
+
if (!nextStates[label]) {
|
|
128
|
+
nextStates[label] = { on: {} }
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
nextStates[label].on[key] = value
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
emit('update:modelValue',
|
|
134
|
+
emit('update:modelValue', nextStates)
|
|
135
135
|
}
|
|
136
136
|
</script>
|