@babsey/code-graph 0.0.15 → 0.0.17
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/dist/code-graph.css +1 -1
- package/dist/code-graph.js +675 -611
- package/dist/code-graph.umd.cjs +1 -1
- package/dist/code.d.ts +4 -2
- package/dist/codeNode/codeNode.d.ts +5 -2
- package/dist/codeNode/defineCodeNode.d.ts +2 -1
- package/dist/codeNode/dynamicCodeNode.d.ts +3 -2
- package/dist/codeNodeInterfaces/baseStringInterface.d.ts +1 -0
- package/dist/codeNodeInterfaces/checkbox/checkboxInterface.d.ts +1 -0
- package/dist/codeNodeInterfaces/codeNode/codeNodeInterface.d.ts +2 -1
- package/dist/codeNodeInterfaces/codeNodeInput/codeNodeInputInterface.d.ts +2 -0
- package/dist/codeNodeInterfaces/index.d.ts +2 -0
- package/dist/codeNodeInterfaces/integer/integerInterface.d.ts +0 -2
- package/dist/codeNodeInterfaces/listInput/listInputInterface.d.ts +5 -0
- package/dist/codeNodeInterfaces/select/selectInterface.d.ts +0 -2
- package/dist/codeNodeInterfaces/slider/sliderInterface.d.ts +1 -2
- package/dist/codeNodeInterfaces/textInput/textInputInterface.d.ts +0 -2
- package/dist/codeNodeInterfaces/textareaInput/textareaInputInterface.d.ts +0 -2
- package/dist/codeNodeInterfaces/tupleInput/tupleInputInterface.d.ts +5 -0
- package/dist/components/node/CodeGraphNode.vue.d.ts +4 -4
- package/dist/icons/DotsVertical.vue.d.ts +2 -0
- package/dist/icons/TransitionBottom.vue.d.ts +2 -0
- package/dist/icons/index.d.ts +3 -1
- package/dist/interfaceTypes/default.d.ts +1 -0
- package/package.json +4 -3
- /package/dist/icons/{VerticalDots.vue.d.ts → CodeVariable.vue.d.ts} +0 -0
package/dist/code-graph.js
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import { AbstractNode as
|
|
2
|
-
import { CheckboxInterfaceComponent as
|
|
3
|
-
import
|
|
4
|
-
import { reactive as
|
|
5
|
-
import
|
|
6
|
-
import { v4 as
|
|
7
|
-
import { usePointer as
|
|
8
|
-
|
|
1
|
+
import { AbstractNode as Ae, sortTopologically as Ce, NodeInterface as Fe, displayInSidebar as Ie, NodeInterfaceType as G, BaklavaInterfaceTypes as We, CheckboxInterfaceComponent as Xe, setType as E, IntegerInterfaceComponent as Je, TextInputInterfaceComponent as se, NumberInterfaceComponent as Ye, SelectInterfaceComponent as qe, SliderInterfaceComponent as Qe, TextareaInputInterfaceComponent as Ke, allowMultipleConnections as Y, IntegerInterface as Ze, TextInputInterface as et, useViewModel as F, useTemporaryConnection as tt, Components as we, useGraph as ne, GRAPH_NODE_TYPE_PREFIX as K, useTransform as st, useNodeCategories as nt, BaklavaEditor as ot, DEFAULT_TOOLBAR_COMMANDS as at, useBaklava as it, DependencyEngine as rt, applyResult as lt } from "baklavajs";
|
|
2
|
+
import { CheckboxInterfaceComponent as In, NumberInterfaceComponent as Nn } from "baklavajs";
|
|
3
|
+
import q from "mustache";
|
|
4
|
+
import { reactive as R, defineComponent as L, createElementBlock as r, openBlock as i, toDisplayString as B, markRaw as M, ref as T, computed as _, onMounted as oe, onUpdated as Ne, normalizeClass as U, createCommentVNode as I, createElementVNode as l, unref as y, renderSlot as Z, createStaticVNode as Q, onBeforeUnmount as dt, normalizeStyle as ae, withModifiers as P, createBlock as S, withDirectives as ie, Fragment as z, createTextVNode as ut, createVNode as V, withKeys as ee, vModelText as re, renderList as H, nextTick as ct, toRef as Me, resolveDynamicComponent as pt, inject as ht, Transition as vt, withCtx as J, onUnmounted as mt, normalizeProps as ft, guardReactiveProps as gt, mergeProps as bt } from "vue";
|
|
5
|
+
import yt from "toposort";
|
|
6
|
+
import { v4 as _t } from "uuid";
|
|
7
|
+
import { usePointer as wt } from "@vueuse/core";
|
|
8
|
+
q.escape = (s) => s;
|
|
9
|
+
class kt extends Ae {
|
|
9
10
|
state;
|
|
10
11
|
code;
|
|
11
12
|
isCodeNode = !0;
|
|
12
|
-
|
|
13
|
+
name = "";
|
|
14
|
+
codeTemplate;
|
|
13
15
|
inputs = {};
|
|
14
16
|
outputs = {};
|
|
15
17
|
constructor() {
|
|
16
|
-
super(), this.initializeIo(), this.width = 400, this.twoColumn = !0, this.state =
|
|
18
|
+
super(), this.initializeIo(), this.width = 400, this.twoColumn = !0, this.state = R({
|
|
17
19
|
codeTemplate: "",
|
|
18
20
|
hidden: !1,
|
|
19
21
|
integrated: !1,
|
|
20
22
|
modules: [],
|
|
21
23
|
script: "",
|
|
22
24
|
variableName: ""
|
|
23
|
-
})
|
|
25
|
+
}), this.codeTemplate = function() {
|
|
26
|
+
return `${this.name}(${xt(this.codeNodeInputs).join(", ")})`;
|
|
27
|
+
};
|
|
24
28
|
}
|
|
25
29
|
get codeNodeInputs() {
|
|
26
30
|
return Object.fromEntries(Object.entries(this.inputs).filter(([e, t]) => t.type != "node"));
|
|
@@ -43,6 +47,8 @@ class yt extends De {
|
|
|
43
47
|
get shortId() {
|
|
44
48
|
return this.id.slice(0, 6);
|
|
45
49
|
}
|
|
50
|
+
get subgraph() {
|
|
51
|
+
}
|
|
46
52
|
get variableName() {
|
|
47
53
|
return this.state.variableName ? this.state.variableName + (this.idxByVariableNames + 1) : "";
|
|
48
54
|
}
|
|
@@ -54,14 +60,14 @@ class yt extends De {
|
|
|
54
60
|
getConnectedNodes(e) {
|
|
55
61
|
let t = [];
|
|
56
62
|
if (e !== "inputs") {
|
|
57
|
-
const
|
|
58
|
-
|
|
63
|
+
const n = this.graph?.connections.filter((o) => o.from.name !== "_node").filter((o) => o.from.nodeId === this.id).map((o) => o.to.nodeId);
|
|
64
|
+
n && (t = t.concat(n));
|
|
59
65
|
}
|
|
60
66
|
if (e !== "outputs") {
|
|
61
|
-
const
|
|
62
|
-
|
|
67
|
+
const n = this.graph?.connections.filter((o) => o.from.name !== "_node").filter((o) => o.to.nodeId === this.id).map((o) => o.from.nodeId);
|
|
68
|
+
n && (t = t.concat(n));
|
|
63
69
|
}
|
|
64
|
-
return !t || t.length == 0 ? [] : t.map((
|
|
70
|
+
return !t || t.length == 0 ? [] : t.map((n) => this.graph?.findNodeById(n));
|
|
65
71
|
}
|
|
66
72
|
registerCode(e) {
|
|
67
73
|
this.code = e;
|
|
@@ -70,33 +76,49 @@ class yt extends De {
|
|
|
70
76
|
* Render code of this node.
|
|
71
77
|
*/
|
|
72
78
|
renderCode() {
|
|
73
|
-
this.state.codeTemplate = this.codeTemplate.call(this);
|
|
74
79
|
const e = {};
|
|
75
|
-
Object.keys(this.inputs).forEach((
|
|
76
|
-
if (
|
|
77
|
-
const o = this.inputs[
|
|
78
|
-
o && o.state && (e[
|
|
80
|
+
Object.keys(this.inputs).forEach((n) => {
|
|
81
|
+
if (n === "_node") return;
|
|
82
|
+
const o = this.inputs[n];
|
|
83
|
+
o && o.state && (e[n] = o.state.script.length > 0 ? o.state.script : o.getValue());
|
|
79
84
|
});
|
|
80
85
|
const t = {};
|
|
81
|
-
Object.keys(this.outputs).forEach((
|
|
82
|
-
if (
|
|
83
|
-
const o = this.outputs[
|
|
84
|
-
o && o.state && (t[
|
|
85
|
-
}), this.state.script =
|
|
86
|
+
Object.keys(this.outputs).forEach((n) => {
|
|
87
|
+
if (n === "_node") return;
|
|
88
|
+
const o = this.outputs[n];
|
|
89
|
+
o && o.state && (t[n] = o.getValue());
|
|
90
|
+
}), this.state.script = q.render(this.state.codeTemplate, { inputs: e, outputs: t }), this.outputs.code && (this.outputs.code.state.script = this.state.script);
|
|
91
|
+
}
|
|
92
|
+
resetInputInterfaceScript() {
|
|
93
|
+
Object.values(this.inputs).forEach((e) => e.state.script = "");
|
|
86
94
|
}
|
|
87
|
-
|
|
95
|
+
updateCodeTemplate() {
|
|
96
|
+
this.state.codeTemplate = this.codeTemplate.call(this);
|
|
97
|
+
}
|
|
98
|
+
updateConnectedInputInterfaces() {
|
|
88
99
|
if (!this.graph) return;
|
|
89
100
|
const { connectionsFromNode: e } = Ce(this.graph);
|
|
90
|
-
e.has(this)
|
|
91
|
-
|
|
92
|
-
|
|
101
|
+
if (!e.has(this)) return;
|
|
102
|
+
const t = e.get(this);
|
|
103
|
+
t && t.forEach((n) => {
|
|
104
|
+
if (!n.from.isCodeNode || !n.to.isCodeNode) return;
|
|
105
|
+
const o = this.graph?.findNodeById(n.from.nodeId);
|
|
106
|
+
if (o)
|
|
107
|
+
if (o.renderCode(), n.to.allowMultipleConnections)
|
|
108
|
+
if (n.to.state.script.startsWith("[") && n.to.state.script.endsWith("]")) {
|
|
109
|
+
const a = JSON.parse(n.to.state.script);
|
|
110
|
+
n.to.state.script = JSON.stringify([...a, n.from.script]);
|
|
111
|
+
} else
|
|
112
|
+
n.to.state.script += n.from.script;
|
|
113
|
+
else
|
|
114
|
+
n.to.state.script = n.from.script;
|
|
93
115
|
});
|
|
94
116
|
}
|
|
95
117
|
updateOutputVariableName() {
|
|
96
|
-
this.outputs.code && (this.outputs.code.name = this.variableName);
|
|
118
|
+
this.outputs.code && (this.outputs.code.name = this.state.integrated ? "" : this.variableName);
|
|
97
119
|
}
|
|
98
120
|
}
|
|
99
|
-
class
|
|
121
|
+
class $e extends kt {
|
|
100
122
|
/**
|
|
101
123
|
* The default implementation does nothing.
|
|
102
124
|
* Overwrite this method to do calculation.
|
|
@@ -110,7 +132,7 @@ class Me extends yt {
|
|
|
110
132
|
}
|
|
111
133
|
save() {
|
|
112
134
|
const e = super.save();
|
|
113
|
-
return
|
|
135
|
+
return Ct(this.graph, e), e;
|
|
114
136
|
}
|
|
115
137
|
updateModules(e) {
|
|
116
138
|
if (e)
|
|
@@ -121,68 +143,51 @@ class Me extends yt {
|
|
|
121
143
|
}
|
|
122
144
|
}
|
|
123
145
|
}
|
|
124
|
-
const
|
|
125
|
-
const e = [], t = Object.keys(
|
|
126
|
-
return t.forEach((
|
|
127
|
-
if (n
|
|
128
|
-
const a = e.length < t.indexOf(
|
|
129
|
-
e.push(`${a}{{
|
|
146
|
+
const xt = (s) => {
|
|
147
|
+
const e = [], t = Object.keys(s);
|
|
148
|
+
return t.forEach((n) => {
|
|
149
|
+
if (s[n]?.hidden) return;
|
|
150
|
+
const a = e.length < t.indexOf(n) ? `${n}=` : "";
|
|
151
|
+
e.push(`${a}{{ inputs.${n} }}`);
|
|
130
152
|
}), e;
|
|
131
|
-
}, Oe = (
|
|
132
|
-
if (!
|
|
133
|
-
const t =
|
|
153
|
+
}, Oe = (s, e) => {
|
|
154
|
+
if (!s) return;
|
|
155
|
+
const t = s.findNodeById(e.id);
|
|
134
156
|
if (!t || t.subgraph) return;
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
o !== "_node" &&
|
|
157
|
+
const n = t;
|
|
158
|
+
n.state && (n.state.integrated = e.integrated, n.state.modules = e.modules, n.state.props = e.props), Object.entries(e.inputs).forEach(([o, a]) => {
|
|
159
|
+
o !== "_node" && n.inputs[o] && (n.inputs[o].hidden = a.hidden);
|
|
138
160
|
}), Object.entries(e.outputs).forEach(([o, a]) => {
|
|
139
|
-
o !== "_node" &&
|
|
161
|
+
o !== "_node" && n.outputs[o] && (n.outputs[o].hidden = a.hidden);
|
|
140
162
|
});
|
|
141
|
-
},
|
|
142
|
-
if (!
|
|
143
|
-
const t =
|
|
163
|
+
}, Ct = (s, e) => {
|
|
164
|
+
if (!s) return;
|
|
165
|
+
const t = s.findNodeById(e.id);
|
|
144
166
|
if (!t || t.subgraph) return;
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
o !== "_node" &&
|
|
167
|
+
const n = t;
|
|
168
|
+
n.state && (e.integrated = n.state.integrated, e.modules = n.state.modules), Object.entries(e.inputs).forEach(([o, a]) => {
|
|
169
|
+
o !== "_node" && n.inputs[o] && (a.hidden = n.inputs[o].hidden);
|
|
148
170
|
}), Object.entries(e.outputs).forEach(([o, a]) => {
|
|
149
|
-
o !== "_node" &&
|
|
171
|
+
o !== "_node" && n.outputs[o] && (a.hidden = n.outputs[o].hidden);
|
|
150
172
|
});
|
|
151
|
-
},
|
|
152
|
-
let e;
|
|
153
|
-
if (n.value == null) return "None";
|
|
154
|
-
switch (n.type) {
|
|
155
|
-
case "boolean":
|
|
156
|
-
e = n.value ? "True" : "False";
|
|
157
|
-
break;
|
|
158
|
-
case "string":
|
|
159
|
-
e = `'${n.value}'`;
|
|
160
|
-
break;
|
|
161
|
-
case void 0:
|
|
162
|
-
e = "None";
|
|
163
|
-
break;
|
|
164
|
-
default:
|
|
165
|
-
e = `${n.value}`;
|
|
166
|
-
}
|
|
167
|
-
return e;
|
|
168
|
-
}, Ct = ["title"], ae = /* @__PURE__ */ j({
|
|
173
|
+
}, It = ["title"], le = /* @__PURE__ */ L({
|
|
169
174
|
__name: "CodeNodeInterface",
|
|
170
175
|
props: {
|
|
171
176
|
intf: {}
|
|
172
177
|
},
|
|
173
|
-
setup(
|
|
178
|
+
setup(s) {
|
|
174
179
|
return (e, t) => (i(), r("div", {
|
|
175
|
-
title:
|
|
176
|
-
},
|
|
180
|
+
title: s.intf.state?.script
|
|
181
|
+
}, B(s.intf.name), 9, It));
|
|
177
182
|
}
|
|
178
183
|
});
|
|
179
|
-
class
|
|
184
|
+
class D extends Fe {
|
|
180
185
|
isCodeNode = !0;
|
|
181
186
|
code;
|
|
182
187
|
state;
|
|
183
188
|
type = null;
|
|
184
189
|
constructor(e, t) {
|
|
185
|
-
super(e, t), this.setComponent(
|
|
190
|
+
super(e, t), this.setComponent(M(le)), this.state = R({
|
|
186
191
|
optional: !1,
|
|
187
192
|
script: ""
|
|
188
193
|
});
|
|
@@ -193,97 +198,112 @@ class R extends Pe {
|
|
|
193
198
|
get shortId() {
|
|
194
199
|
return this.id.slice(0, 6);
|
|
195
200
|
}
|
|
196
|
-
|
|
197
|
-
// return super.value
|
|
198
|
-
// }
|
|
199
|
-
// override set value(value: T) {
|
|
200
|
-
// super.value = value;
|
|
201
|
-
// if (this.name !== '_node') this.setHidden(false);
|
|
202
|
-
// }
|
|
201
|
+
getValue = () => `${this.value ?? "None"}`;
|
|
203
202
|
}
|
|
204
|
-
const
|
|
205
|
-
|
|
203
|
+
const on = (s, e) => {
|
|
204
|
+
s.state.optional = e, s.setHidden(e);
|
|
206
205
|
};
|
|
207
|
-
class
|
|
206
|
+
class W extends D {
|
|
208
207
|
constructor(e = "", t) {
|
|
209
|
-
super(e, t), this.setComponent(
|
|
208
|
+
super(e, t), this.setComponent(M(le)), this.use(Ie, !0);
|
|
209
|
+
}
|
|
210
|
+
get value() {
|
|
211
|
+
return super.value;
|
|
212
|
+
}
|
|
213
|
+
set value(e) {
|
|
214
|
+
super.value = e, this.name !== "_node" && this.setHidden(!1);
|
|
210
215
|
}
|
|
211
216
|
}
|
|
212
|
-
const
|
|
213
|
-
new
|
|
217
|
+
const Te = new G("boolean"), Nt = new G("dict"), Ee = new G("list"), A = new G("node"), de = new G("number"), ue = new G("string"), Se = new G("tuple"), an = (s) => {
|
|
218
|
+
new We(s.editor, { viewPlugin: s }).addTypes(Te, Nt, Ee, A, de, ue, Se);
|
|
214
219
|
};
|
|
215
|
-
class
|
|
220
|
+
class rn extends W {
|
|
216
221
|
constructor(e, t) {
|
|
217
|
-
super(e, t), this.setComponent(
|
|
222
|
+
super(e, t), this.setComponent(M(Xe)), this.use(E, Te);
|
|
218
223
|
}
|
|
224
|
+
getValue = () => this.value ? "True" : "False";
|
|
219
225
|
}
|
|
220
|
-
class
|
|
226
|
+
class Mt extends D {
|
|
221
227
|
isCodeNodeOutput = !0;
|
|
222
228
|
constructor(e = "", t = "") {
|
|
223
|
-
super(e, t), this.setComponent(
|
|
229
|
+
super(e, t), this.setComponent(M(le));
|
|
224
230
|
}
|
|
225
231
|
get script() {
|
|
226
232
|
return this.name.length > 0 ? this.name : this.state.script;
|
|
227
233
|
}
|
|
228
234
|
}
|
|
229
|
-
class
|
|
235
|
+
class ce extends W {
|
|
230
236
|
min;
|
|
231
237
|
max;
|
|
232
|
-
constructor(e, t,
|
|
233
|
-
super(e, t), this.min =
|
|
238
|
+
constructor(e, t, n, o) {
|
|
239
|
+
super(e, t), this.min = n, this.max = o, this.use(E, de);
|
|
234
240
|
}
|
|
235
241
|
validate(e) {
|
|
236
242
|
return (this.min === void 0 || e >= this.min) && (this.max === void 0 || e <= this.max);
|
|
237
243
|
}
|
|
238
244
|
}
|
|
239
|
-
class
|
|
240
|
-
component =
|
|
245
|
+
class ln extends ce {
|
|
246
|
+
component = M(Je);
|
|
241
247
|
validate(e) {
|
|
242
248
|
return Number.isInteger(e) && super.validate(e);
|
|
243
249
|
}
|
|
244
250
|
}
|
|
245
|
-
class
|
|
246
|
-
|
|
251
|
+
class dn extends W {
|
|
252
|
+
constructor(e = "", t = "") {
|
|
253
|
+
super(e, t), this.setComponent(M(se)), this.use(E, Ee);
|
|
254
|
+
}
|
|
255
|
+
getValue = () => `[${this.value}]`;
|
|
256
|
+
}
|
|
257
|
+
class un extends ce {
|
|
258
|
+
component = M(Ye);
|
|
247
259
|
}
|
|
248
|
-
class
|
|
260
|
+
class pe extends W {
|
|
249
261
|
constructor(e, t) {
|
|
250
|
-
super(e, t), this.use(
|
|
262
|
+
super(e, t), this.use(E, ue);
|
|
251
263
|
}
|
|
264
|
+
getValue = () => `'${this.value}'`;
|
|
252
265
|
}
|
|
253
|
-
class
|
|
254
|
-
component =
|
|
266
|
+
class cn extends pe {
|
|
267
|
+
component = M(qe);
|
|
255
268
|
items;
|
|
256
|
-
constructor(e, t,
|
|
257
|
-
super(e, t), this.items =
|
|
269
|
+
constructor(e, t, n) {
|
|
270
|
+
super(e, t), this.items = n;
|
|
258
271
|
}
|
|
259
272
|
}
|
|
260
|
-
class
|
|
261
|
-
component =
|
|
273
|
+
class pn extends ce {
|
|
274
|
+
component = M(Qe);
|
|
262
275
|
min;
|
|
263
276
|
max;
|
|
264
|
-
constructor(e, t,
|
|
265
|
-
super(e, t,
|
|
277
|
+
constructor(e, t, n, o) {
|
|
278
|
+
super(e, t, n, o), this.min = n, this.max = o;
|
|
266
279
|
}
|
|
280
|
+
getValue = () => `${Math.round(this.value * 1e3) / 1e3}`;
|
|
267
281
|
}
|
|
268
|
-
class
|
|
269
|
-
component =
|
|
282
|
+
class hn extends pe {
|
|
283
|
+
component = M(se);
|
|
270
284
|
}
|
|
271
|
-
class
|
|
272
|
-
component =
|
|
285
|
+
class vn extends pe {
|
|
286
|
+
component = M(Ke);
|
|
273
287
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
288
|
+
class mn extends W {
|
|
289
|
+
constructor(e = "", t = "") {
|
|
290
|
+
super(e, t), this.setComponent(M(se)), this.use(E, Se);
|
|
291
|
+
}
|
|
292
|
+
getValue = () => `(${this.value})`;
|
|
293
|
+
}
|
|
294
|
+
function fn(s) {
|
|
295
|
+
return class extends $e {
|
|
296
|
+
type = s.type;
|
|
277
297
|
inputs = {};
|
|
278
298
|
outputs = {};
|
|
279
299
|
constructor() {
|
|
280
|
-
super(), this._title =
|
|
300
|
+
super(), this._title = s.title ?? s.type, this.name = s.name ?? s.type, this.updateModules(s.modules), s.variableName && (this.state.variableName = s.variableName), s.codeTemplate && (this.codeTemplate = s.codeTemplate), this.addInput(
|
|
281
301
|
"_node",
|
|
282
|
-
new
|
|
302
|
+
new D("", []).use(E, A).use(Y).setHidden(!0)
|
|
283
303
|
), this.addOutput(
|
|
284
304
|
"_node",
|
|
285
|
-
new
|
|
286
|
-
), this.executeFactory("input",
|
|
305
|
+
new D("", []).use(E, A).use(Y).setHidden(!0)
|
|
306
|
+
), this.executeFactory("input", s.inputs), this.executeFactory("output", s.outputs), s.onCreate?.call(this);
|
|
287
307
|
}
|
|
288
308
|
// public calculate = definition.calculate
|
|
289
309
|
// ? (inputs: I, globalValues: CalculationContext) => ({
|
|
@@ -292,23 +312,23 @@ function on(n) {
|
|
|
292
312
|
// })
|
|
293
313
|
// : undefined
|
|
294
314
|
onPlaced() {
|
|
295
|
-
|
|
315
|
+
s.onPlaced?.call(this);
|
|
296
316
|
}
|
|
297
317
|
onDestroy() {
|
|
298
|
-
|
|
318
|
+
s.onDestroy?.call(this);
|
|
299
319
|
}
|
|
300
320
|
onCodeUpdate() {
|
|
301
|
-
|
|
321
|
+
s.onCodeUpdate?.call(this);
|
|
302
322
|
}
|
|
303
323
|
executeFactory(e, t) {
|
|
304
|
-
Object.keys(t || {}).forEach((
|
|
305
|
-
const o = t[
|
|
306
|
-
e === "input" ? this.addInput(
|
|
324
|
+
Object.keys(t || {}).forEach((n) => {
|
|
325
|
+
const o = t[n]();
|
|
326
|
+
e === "input" ? this.addInput(n, o) : this.addOutput(n, o);
|
|
307
327
|
});
|
|
308
328
|
}
|
|
309
329
|
};
|
|
310
330
|
}
|
|
311
|
-
class
|
|
331
|
+
class $t extends $e {
|
|
312
332
|
/**
|
|
313
333
|
* The default implementation does nothing.
|
|
314
334
|
* Overwrite this method to do calculation.
|
|
@@ -318,34 +338,34 @@ class It extends Me {
|
|
|
318
338
|
*/
|
|
319
339
|
calculate;
|
|
320
340
|
}
|
|
321
|
-
function
|
|
322
|
-
return class extends
|
|
323
|
-
type =
|
|
341
|
+
function gn(s) {
|
|
342
|
+
return class extends $t {
|
|
343
|
+
type = s.type;
|
|
324
344
|
inputs = {};
|
|
325
345
|
outputs = {};
|
|
326
346
|
calculate;
|
|
327
347
|
preventUpdate = !1;
|
|
328
|
-
staticInputKeys = Object.keys(
|
|
329
|
-
staticOutputKeys = Object.keys(
|
|
348
|
+
staticInputKeys = Object.keys(s.inputs ?? {});
|
|
349
|
+
staticOutputKeys = Object.keys(s.outputs ?? {});
|
|
330
350
|
constructor() {
|
|
331
|
-
super(), this._title =
|
|
351
|
+
super(), this._title = s.title ?? s.type, this.name = s.name ?? s.type, this.updateModules(s.modules), s.codeTemplate && (this.codeTemplate = s.codeTemplate), s.variableName && (this.state.variableName = s.variableName), this.addInput(
|
|
332
352
|
"_node",
|
|
333
|
-
new
|
|
353
|
+
new D("", []).use(E, A).use(Y).setHidden(!0)
|
|
334
354
|
), this.addOutput(
|
|
335
355
|
"_node",
|
|
336
|
-
new
|
|
337
|
-
), this.staticInputKeys.push("_node"), this.staticOutputKeys.push("_node"), this.executeFactory("input",
|
|
356
|
+
new D("", []).use(E, A).use(Y).setHidden(!0)
|
|
357
|
+
), this.staticInputKeys.push("_node"), this.staticOutputKeys.push("_node"), this.executeFactory("input", s.inputs), this.executeFactory("output", s.outputs), s.onCreate?.call(this);
|
|
338
358
|
}
|
|
339
359
|
onPlaced() {
|
|
340
360
|
this.events.update.subscribe(this, (e) => {
|
|
341
361
|
e && (e.type === "input" && this.staticInputKeys.includes(e.name) || e.type === "output" && this.staticOutputKeys.includes(e.name)) && this.onUpdate();
|
|
342
|
-
}), this.onUpdate(),
|
|
362
|
+
}), this.onUpdate(), s.onPlaced?.call(this);
|
|
343
363
|
}
|
|
344
364
|
onDestroy() {
|
|
345
|
-
|
|
365
|
+
s.onDestroy?.call(this);
|
|
346
366
|
}
|
|
347
367
|
onCodeUpdate() {
|
|
348
|
-
|
|
368
|
+
s.onCodeUpdate?.call(this);
|
|
349
369
|
}
|
|
350
370
|
load(e) {
|
|
351
371
|
this.preventUpdate = !0, this.hooks.beforeLoad.execute(e), this.id = e.id, this.title = e.title;
|
|
@@ -357,17 +377,17 @@ function an(n) {
|
|
|
357
377
|
for (const t of Object.keys(e.inputs))
|
|
358
378
|
if (!this.staticInputKeys.includes(t)) {
|
|
359
379
|
if (!this.inputs[t]) {
|
|
360
|
-
const
|
|
380
|
+
const n = e.inputs[t].value;
|
|
361
381
|
let o;
|
|
362
|
-
typeof
|
|
382
|
+
typeof n == "number" ? o = new Ze(t, n).use(E, de) : o = new et(t, JSON.stringify(n)).use(E, ue), o.use(Ie, !0), this.addInput(t, o);
|
|
363
383
|
}
|
|
364
384
|
this.inputs[t] && (this.inputs[t].load(e.inputs[t]), this.inputs[t].nodeId = this.id);
|
|
365
385
|
}
|
|
366
386
|
for (const t of Object.keys(e.outputs))
|
|
367
387
|
if (!this.staticOutputKeys.includes(t)) {
|
|
368
388
|
if (!this.outputs[t]) {
|
|
369
|
-
const
|
|
370
|
-
this.addOutput(t,
|
|
389
|
+
const n = new Mt(t);
|
|
390
|
+
this.addOutput(t, n);
|
|
371
391
|
}
|
|
372
392
|
this.outputs[t] && (this.outputs[t].load(e.outputs[t]), this.outputs[t].nodeId = this.id);
|
|
373
393
|
}
|
|
@@ -376,39 +396,40 @@ function an(n) {
|
|
|
376
396
|
onUpdate() {
|
|
377
397
|
if (this.preventUpdate) return;
|
|
378
398
|
this.graph && this.graph.activeTransactions++;
|
|
379
|
-
const e = this.getStaticValues(this.staticInputKeys, this.inputs), t = this.getStaticValues(this.staticOutputKeys, this.outputs),
|
|
380
|
-
this.updateInterfaces("input",
|
|
399
|
+
const e = this.getStaticValues(this.staticInputKeys, this.inputs), t = this.getStaticValues(this.staticOutputKeys, this.outputs), n = s.onUpdate.call(this, e, t);
|
|
400
|
+
this.updateInterfaces("input", n.inputs ?? {}, n.forceUpdateInputs ?? []), this.updateInterfaces("output", n.outputs ?? {}, n.forceUpdateOutputs ?? []), this.graph && this.graph.activeTransactions--;
|
|
381
401
|
}
|
|
382
402
|
getStaticValues(e, t) {
|
|
383
|
-
const
|
|
403
|
+
const n = {};
|
|
384
404
|
for (const o of e)
|
|
385
|
-
|
|
386
|
-
return
|
|
405
|
+
n[o] = t[o].value;
|
|
406
|
+
return n;
|
|
387
407
|
}
|
|
388
|
-
updateInterfaces(e, t,
|
|
408
|
+
updateInterfaces(e, t, n) {
|
|
389
409
|
const o = e === "input" ? this.staticInputKeys : this.staticOutputKeys, a = e === "input" ? this.inputs : this.outputs;
|
|
390
|
-
for (const
|
|
391
|
-
o.includes(
|
|
392
|
-
for (const
|
|
393
|
-
if (a[
|
|
394
|
-
const
|
|
395
|
-
e === "input" ? this.addInput(
|
|
410
|
+
for (const d of Object.keys(a))
|
|
411
|
+
o.includes(d) || t[d] && !n.includes(d) || (e === "input" ? this.removeInput(d) : this.removeOutput(d));
|
|
412
|
+
for (const d of Object.keys(t)) {
|
|
413
|
+
if (a[d]) continue;
|
|
414
|
+
const u = t[d]();
|
|
415
|
+
e === "input" ? this.addInput(d, u) : this.addOutput(d, u);
|
|
396
416
|
}
|
|
397
417
|
}
|
|
398
418
|
executeFactory(e, t) {
|
|
399
|
-
Object.keys(t || {}).forEach((
|
|
400
|
-
const o = t[
|
|
401
|
-
e === "input" ? this.addInput(
|
|
419
|
+
Object.keys(t || {}).forEach((n) => {
|
|
420
|
+
const o = t[n]();
|
|
421
|
+
e === "input" ? this.addInput(n, o) : this.addOutput(n, o);
|
|
402
422
|
});
|
|
403
423
|
}
|
|
404
424
|
};
|
|
405
425
|
}
|
|
406
|
-
|
|
426
|
+
q.escape = (s) => s;
|
|
427
|
+
class Ot {
|
|
407
428
|
_id;
|
|
408
429
|
_viewModel;
|
|
409
430
|
_state;
|
|
410
431
|
constructor(e) {
|
|
411
|
-
this._id =
|
|
432
|
+
this._id = _t(), this._viewModel = e, this._state = R({
|
|
412
433
|
autosort: !1,
|
|
413
434
|
modules: {},
|
|
414
435
|
script: "",
|
|
@@ -417,7 +438,7 @@ class Mt {
|
|
|
417
438
|
});
|
|
418
439
|
}
|
|
419
440
|
get codeNodes() {
|
|
420
|
-
return
|
|
441
|
+
return te(this.graph);
|
|
421
442
|
}
|
|
422
443
|
get connections() {
|
|
423
444
|
return this.graph.connections;
|
|
@@ -447,8 +468,8 @@ class Mt {
|
|
|
447
468
|
this.graph._nodes = e;
|
|
448
469
|
}
|
|
449
470
|
get scriptedCodeNodes() {
|
|
450
|
-
return
|
|
451
|
-
(e) => e.state?.
|
|
471
|
+
return te(this.graph).filter(
|
|
472
|
+
(e) => !e.state?.integrated
|
|
452
473
|
);
|
|
453
474
|
}
|
|
454
475
|
get shortId() {
|
|
@@ -478,7 +499,7 @@ class Mt {
|
|
|
478
499
|
* @param props optional
|
|
479
500
|
* @returns code node
|
|
480
501
|
*/
|
|
481
|
-
addNodeAtCoordinates = (e, t = { x: 0, y: 0 },
|
|
502
|
+
addNodeAtCoordinates = (e, t = { x: 0, y: 0 }, n) => (this.addNode(e, n), e.position && (e.position = t), e);
|
|
482
503
|
/**
|
|
483
504
|
* Add connection of code nodes
|
|
484
505
|
* @param from code node interface
|
|
@@ -515,7 +536,7 @@ class Mt {
|
|
|
515
536
|
*/
|
|
516
537
|
hasConnection(e, t) {
|
|
517
538
|
return this.connections.some(
|
|
518
|
-
(
|
|
539
|
+
(n) => n.from.id === e.id && n.to.id === t.id
|
|
519
540
|
);
|
|
520
541
|
}
|
|
521
542
|
/**
|
|
@@ -553,7 +574,10 @@ class Mt {
|
|
|
553
574
|
* Render code.
|
|
554
575
|
*/
|
|
555
576
|
renderCode() {
|
|
556
|
-
this.state.script =
|
|
577
|
+
this.state.script = q.render(this.state.template || "", this);
|
|
578
|
+
}
|
|
579
|
+
resetInputInterfaceScript() {
|
|
580
|
+
this.codeNodes.forEach((e) => e.resetInputInterfaceScript());
|
|
557
581
|
}
|
|
558
582
|
/**
|
|
559
583
|
* Save code graph.
|
|
@@ -569,12 +593,12 @@ class Mt {
|
|
|
569
593
|
* @param nodeStates a list of node state.
|
|
570
594
|
*/
|
|
571
595
|
saveNodeStates(e) {
|
|
572
|
-
e.forEach((t,
|
|
573
|
-
const o = this.nodes[
|
|
574
|
-
Object.entries(t.inputs).forEach(([a]) => {
|
|
575
|
-
t.inputs && o.inputs[a] && (
|
|
576
|
-
}), Object.entries(t.outputs).forEach(([a]) => {
|
|
577
|
-
t.outputs && o.outputs[a] && (
|
|
596
|
+
e.forEach((t, n) => {
|
|
597
|
+
const o = this.nodes[n];
|
|
598
|
+
Object.entries(t.inputs).forEach(([a, d]) => {
|
|
599
|
+
t.inputs && o.inputs[a] && (d.hidden = o.inputs[a].hidden);
|
|
600
|
+
}), Object.entries(t.outputs).forEach(([a, d]) => {
|
|
601
|
+
t.outputs && o.outputs[a] && (d.hidden = o.outputs[a].hidden);
|
|
578
602
|
});
|
|
579
603
|
});
|
|
580
604
|
}
|
|
@@ -589,78 +613,127 @@ class Mt {
|
|
|
589
613
|
a.from.nodeId
|
|
590
614
|
]);
|
|
591
615
|
let t = [...this.nodeIds];
|
|
592
|
-
t.reverse(), t =
|
|
593
|
-
const
|
|
594
|
-
t = t.concat(
|
|
616
|
+
t.reverse(), t = yt.array(t, e), t.reverse();
|
|
617
|
+
const n = this.graph.nodes.map((a) => a.id).filter((a) => !t.includes(a));
|
|
618
|
+
t = t.concat(n);
|
|
595
619
|
const o = t.map((a) => this.findNodeById(a));
|
|
596
620
|
o && (this.nodes = o);
|
|
597
621
|
} catch {
|
|
598
622
|
console.warn("Failed to sort nodes.");
|
|
599
623
|
}
|
|
600
624
|
}
|
|
625
|
+
updateCodeTemplates() {
|
|
626
|
+
this.codeNodes.forEach((e) => e.updateCodeTemplate());
|
|
627
|
+
}
|
|
601
628
|
updateOutputVariableNames() {
|
|
602
629
|
this.codeNodes.forEach((e) => e.updateOutputVariableName());
|
|
603
630
|
}
|
|
604
631
|
}
|
|
605
|
-
const
|
|
632
|
+
const te = (s) => {
|
|
606
633
|
let e = [];
|
|
607
|
-
return
|
|
608
|
-
t.subgraph ? e = e.concat(
|
|
634
|
+
return s.nodes.forEach((t) => {
|
|
635
|
+
t.subgraph ? e = e.concat(te(t.subgraph)) : t.isCodeNode && e.push(t);
|
|
609
636
|
}), e;
|
|
610
|
-
},
|
|
611
|
-
x:
|
|
637
|
+
}, bn = (s = 0, e = 100) => ({
|
|
638
|
+
x: s * 420,
|
|
612
639
|
y: e
|
|
613
|
-
}),
|
|
614
|
-
const e = { ...
|
|
640
|
+
}), yn = (s) => {
|
|
641
|
+
const e = { ...s.position };
|
|
615
642
|
return e.x -= 400, e.y += 50, e;
|
|
616
|
-
},
|
|
617
|
-
const { calculationOrder: e, connectionsFromNode: t } = Ce(
|
|
618
|
-
e.forEach((
|
|
619
|
-
if (!
|
|
620
|
-
const o =
|
|
643
|
+
}, _n = (s) => {
|
|
644
|
+
const { calculationOrder: e, connectionsFromNode: t } = Ce(s);
|
|
645
|
+
e.forEach((n) => {
|
|
646
|
+
if (!n.isCodeNode) return;
|
|
647
|
+
const o = n;
|
|
621
648
|
t.has(o) && t.get(o).forEach((a) => {
|
|
622
649
|
a.to.state && a.from.script && (a.to.state.script = a.from.script);
|
|
623
650
|
});
|
|
624
651
|
});
|
|
625
|
-
},
|
|
652
|
+
}, Tt = ["id"], Et = { class: "align-middle" }, ke = /* @__PURE__ */ L({
|
|
626
653
|
__name: "CodeGraphNodeInterface",
|
|
627
654
|
props: {
|
|
628
655
|
node: {},
|
|
629
656
|
intf: {}
|
|
630
657
|
},
|
|
631
|
-
setup(
|
|
632
|
-
const e =
|
|
633
|
-
"--connected":
|
|
634
|
-
})),
|
|
635
|
-
|
|
636
|
-
},
|
|
637
|
-
|
|
638
|
-
},
|
|
658
|
+
setup(s) {
|
|
659
|
+
const e = s, { viewModel: t } = F(), { hoveredOver: n, temporaryConnection: o } = tt(), a = T(null), d = _(() => e.intf.connectionCount > 0), u = _(() => ({
|
|
660
|
+
"--connected": d.value
|
|
661
|
+
})), m = () => {
|
|
662
|
+
n(e.intf);
|
|
663
|
+
}, w = () => {
|
|
664
|
+
n(void 0);
|
|
665
|
+
}, k = () => {
|
|
639
666
|
a.value && t.value.hooks.renderInterface.execute({ intf: e.intf, el: a.value });
|
|
640
667
|
};
|
|
641
|
-
return
|
|
642
|
-
id:
|
|
668
|
+
return oe(k), Ne(k), (O, j) => (i(), r("div", {
|
|
669
|
+
id: s.intf.id,
|
|
643
670
|
ref_key: "el",
|
|
644
671
|
ref: a,
|
|
645
|
-
class: U(["baklava-node-interface",
|
|
672
|
+
class: U(["baklava-node-interface", u.value])
|
|
646
673
|
}, [
|
|
647
|
-
|
|
674
|
+
s.intf.port ? (i(), r("div", {
|
|
648
675
|
key: 0,
|
|
649
|
-
class: U(["__port", { "--selected":
|
|
650
|
-
onPointerover:
|
|
651
|
-
onPointerout:
|
|
676
|
+
class: U(["__port", { "--selected": y(o)?.from === s.intf }]),
|
|
677
|
+
onPointerover: m,
|
|
678
|
+
onPointerout: w
|
|
652
679
|
}, null, 34)) : I("", !0),
|
|
653
|
-
|
|
654
|
-
|
|
680
|
+
l("span", Et, [
|
|
681
|
+
Z(O.$slots, "default")
|
|
655
682
|
])
|
|
656
|
-
], 10,
|
|
683
|
+
], 10, Tt));
|
|
657
684
|
}
|
|
658
|
-
}),
|
|
659
|
-
const t =
|
|
660
|
-
for (const [
|
|
661
|
-
t[
|
|
685
|
+
}), $ = (s, e) => {
|
|
686
|
+
const t = s.__vccOpts || s;
|
|
687
|
+
for (const [n, o] of e)
|
|
688
|
+
t[n] = o;
|
|
662
689
|
return t;
|
|
663
|
-
},
|
|
690
|
+
}, St = {}, zt = {
|
|
691
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
692
|
+
width: "24",
|
|
693
|
+
height: "24",
|
|
694
|
+
viewBox: "0 0 24 24",
|
|
695
|
+
fill: "none",
|
|
696
|
+
stroke: "currentColor",
|
|
697
|
+
"stroke-width": "2",
|
|
698
|
+
"stroke-linecap": "round",
|
|
699
|
+
"stroke-linejoin": "round",
|
|
700
|
+
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-code-variable"
|
|
701
|
+
};
|
|
702
|
+
function Vt(s, e) {
|
|
703
|
+
return i(), r("svg", zt, [...e[0] || (e[0] = [
|
|
704
|
+
l("path", {
|
|
705
|
+
stroke: "none",
|
|
706
|
+
d: "M0 0h24v24H0z",
|
|
707
|
+
fill: "none"
|
|
708
|
+
}, null, -1),
|
|
709
|
+
l("path", { d: "M4 8m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z" }, null, -1)
|
|
710
|
+
])]);
|
|
711
|
+
}
|
|
712
|
+
const Bt = /* @__PURE__ */ $(St, [["render", Vt]]), jt = {}, Lt = {
|
|
713
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
714
|
+
width: "24",
|
|
715
|
+
height: "24",
|
|
716
|
+
viewBox: "0 0 24 24",
|
|
717
|
+
fill: "none",
|
|
718
|
+
stroke: "currentColor",
|
|
719
|
+
"stroke-width": "2",
|
|
720
|
+
"stroke-linecap": "round",
|
|
721
|
+
"stroke-linejoin": "round",
|
|
722
|
+
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-dots-vertical"
|
|
723
|
+
};
|
|
724
|
+
function Ut(s, e) {
|
|
725
|
+
return i(), r("svg", Lt, [...e[0] || (e[0] = [
|
|
726
|
+
l("path", {
|
|
727
|
+
stroke: "none",
|
|
728
|
+
d: "M0 0h24v24H0z",
|
|
729
|
+
fill: "none"
|
|
730
|
+
}, null, -1),
|
|
731
|
+
l("path", { d: "M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
|
|
732
|
+
l("path", { d: "M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
|
|
733
|
+
l("path", { d: "M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1)
|
|
734
|
+
])]);
|
|
735
|
+
}
|
|
736
|
+
const Gt = /* @__PURE__ */ $(jt, [["render", Ut]]), Rt = {}, Dt = {
|
|
664
737
|
xmlns: "http://www.w3.org/2000/svg",
|
|
665
738
|
width: "24",
|
|
666
739
|
height: "24",
|
|
@@ -668,17 +741,17 @@ const Z = (n) => {
|
|
|
668
741
|
fill: "currentColor",
|
|
669
742
|
class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-collapse"
|
|
670
743
|
};
|
|
671
|
-
function
|
|
672
|
-
return i(), r("svg",
|
|
673
|
-
|
|
744
|
+
function Pt(s, e) {
|
|
745
|
+
return i(), r("svg", Dt, [...e[0] || (e[0] = [
|
|
746
|
+
l("path", {
|
|
674
747
|
stroke: "none",
|
|
675
748
|
d: "M0 0h24v24H0z",
|
|
676
749
|
fill: "none"
|
|
677
750
|
}, null, -1),
|
|
678
|
-
|
|
751
|
+
l("path", { d: "M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-2.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z" }, null, -1)
|
|
679
752
|
])]);
|
|
680
753
|
}
|
|
681
|
-
const
|
|
754
|
+
const Ht = /* @__PURE__ */ $(Rt, [["render", Pt]]), At = {}, Ft = {
|
|
682
755
|
xmlns: "http://www.w3.org/2000/svg",
|
|
683
756
|
width: "24",
|
|
684
757
|
height: "24",
|
|
@@ -686,17 +759,17 @@ const St = /* @__PURE__ */ S(Tt, [["render", zt]]), Bt = {}, Lt = {
|
|
|
686
759
|
fill: "currentColor",
|
|
687
760
|
class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-expand"
|
|
688
761
|
};
|
|
689
|
-
function
|
|
690
|
-
return i(), r("svg",
|
|
691
|
-
|
|
762
|
+
function Wt(s, e) {
|
|
763
|
+
return i(), r("svg", Ft, [...e[0] || (e[0] = [
|
|
764
|
+
l("path", {
|
|
692
765
|
stroke: "none",
|
|
693
766
|
d: "M0 0h24v24H0z",
|
|
694
767
|
fill: "none"
|
|
695
768
|
}, null, -1),
|
|
696
|
-
|
|
769
|
+
l("path", { d: "M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-4.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z" }, null, -1)
|
|
697
770
|
])]);
|
|
698
771
|
}
|
|
699
|
-
const
|
|
772
|
+
const Xt = /* @__PURE__ */ $(At, [["render", Wt]]), Jt = {}, Yt = {
|
|
700
773
|
xmlns: "http://www.w3.org/2000/svg",
|
|
701
774
|
width: "24",
|
|
702
775
|
height: "24",
|
|
@@ -704,17 +777,17 @@ const jt = /* @__PURE__ */ S(Bt, [["render", Vt]]), Ut = {}, Gt = {
|
|
|
704
777
|
fill: "currentColor",
|
|
705
778
|
class: "balkava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"
|
|
706
779
|
};
|
|
707
|
-
function
|
|
708
|
-
return i(), r("svg",
|
|
709
|
-
|
|
780
|
+
function qt(s, e) {
|
|
781
|
+
return i(), r("svg", Yt, [...e[0] || (e[0] = [
|
|
782
|
+
l("path", {
|
|
710
783
|
stroke: "none",
|
|
711
784
|
d: "M0 0h24v24H0z",
|
|
712
785
|
fill: "none"
|
|
713
786
|
}, null, -1),
|
|
714
|
-
|
|
787
|
+
l("path", { d: "M6 21a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3zm8 -16h-8a1 1 0 0 0 -1 1v12a1 1 0 0 0 1 1h8z" }, null, -1)
|
|
715
788
|
])]);
|
|
716
789
|
}
|
|
717
|
-
const
|
|
790
|
+
const Qt = /* @__PURE__ */ $(Jt, [["render", qt]]), Kt = {}, Zt = {
|
|
718
791
|
xmlns: "http://www.w3.org/2000/svg",
|
|
719
792
|
width: "24",
|
|
720
793
|
height: "24",
|
|
@@ -722,17 +795,17 @@ const Dt = /* @__PURE__ */ S(Ut, [["render", Rt]]), Pt = {}, At = {
|
|
|
722
795
|
fill: "currentColor",
|
|
723
796
|
class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-collapse"
|
|
724
797
|
};
|
|
725
|
-
function
|
|
726
|
-
return i(), r("svg",
|
|
727
|
-
|
|
798
|
+
function es(s, e) {
|
|
799
|
+
return i(), r("svg", Zt, [...e[0] || (e[0] = [
|
|
800
|
+
l("path", {
|
|
728
801
|
stroke: "none",
|
|
729
802
|
d: "M0 0h24v24H0z",
|
|
730
803
|
fill: "none"
|
|
731
804
|
}, null, -1),
|
|
732
|
-
|
|
805
|
+
l("path", { d: "M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-5.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z" }, null, -1)
|
|
733
806
|
])]);
|
|
734
807
|
}
|
|
735
|
-
const
|
|
808
|
+
const ts = /* @__PURE__ */ $(Kt, [["render", es]]), ss = {}, ns = {
|
|
736
809
|
xmlns: "http://www.w3.org/2000/svg",
|
|
737
810
|
width: "24",
|
|
738
811
|
height: "24",
|
|
@@ -740,19 +813,18 @@ const Ft = /* @__PURE__ */ S(Pt, [["render", Ht]]), Wt = {}, Xt = {
|
|
|
740
813
|
fill: "currentColor",
|
|
741
814
|
class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-expand"
|
|
742
815
|
};
|
|
743
|
-
function
|
|
744
|
-
return i(), r("svg",
|
|
745
|
-
|
|
816
|
+
function os(s, e) {
|
|
817
|
+
return i(), r("svg", ns, [...e[0] || (e[0] = [
|
|
818
|
+
l("path", {
|
|
746
819
|
stroke: "none",
|
|
747
820
|
d: "M0 0h24v24H0z",
|
|
748
821
|
fill: "none"
|
|
749
822
|
}, null, -1),
|
|
750
|
-
|
|
823
|
+
l("path", { d: "M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-3.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z" }, null, -1)
|
|
751
824
|
])]);
|
|
752
825
|
}
|
|
753
|
-
const
|
|
826
|
+
const as = /* @__PURE__ */ $(ss, [["render", os]]), is = {}, rs = {
|
|
754
827
|
xmlns: "http://www.w3.org/2000/svg",
|
|
755
|
-
class: "baklava-icon",
|
|
756
828
|
width: "24",
|
|
757
829
|
height: "24",
|
|
758
830
|
viewBox: "0 0 24 24",
|
|
@@ -760,16 +832,16 @@ const qt = /* @__PURE__ */ S(Wt, [["render", Yt]]), Jt = {}, Qt = {
|
|
|
760
832
|
stroke: "currentColor",
|
|
761
833
|
"stroke-width": "2",
|
|
762
834
|
"stroke-linecap": "round",
|
|
763
|
-
"stroke-linejoin": "round"
|
|
835
|
+
"stroke-linejoin": "round",
|
|
836
|
+
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema"
|
|
764
837
|
};
|
|
765
|
-
function
|
|
766
|
-
return i(), r("svg",
|
|
767
|
-
|
|
838
|
+
function ls(s, e) {
|
|
839
|
+
return i(), r("svg", rs, [...e[0] || (e[0] = [
|
|
840
|
+
Q('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M5 2h5v4h-5z"></path><path d="M15 10h5v4h-5z"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h5"></path><path d="M7.5 6v4"></path><path d="M7.5 14v4"></path>', 8)
|
|
768
841
|
])]);
|
|
769
842
|
}
|
|
770
|
-
const
|
|
843
|
+
const ds = /* @__PURE__ */ $(is, [["render", ls]]), us = {}, cs = {
|
|
771
844
|
xmlns: "http://www.w3.org/2000/svg",
|
|
772
|
-
class: "baklava-icon",
|
|
773
845
|
width: "24",
|
|
774
846
|
height: "24",
|
|
775
847
|
viewBox: "0 0 24 24",
|
|
@@ -777,16 +849,16 @@ const Kt = /* @__PURE__ */ S(Jt, [["render", Zt]]), es = {}, ts = {
|
|
|
777
849
|
stroke: "currentColor",
|
|
778
850
|
"stroke-width": "2",
|
|
779
851
|
"stroke-linecap": "round",
|
|
780
|
-
"stroke-linejoin": "round"
|
|
852
|
+
"stroke-linejoin": "round",
|
|
853
|
+
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema-off"
|
|
781
854
|
};
|
|
782
|
-
function
|
|
783
|
-
return i(), r("svg",
|
|
784
|
-
|
|
855
|
+
function ps(s, e) {
|
|
856
|
+
return i(), r("svg", cs, [...e[0] || (e[0] = [
|
|
857
|
+
Q('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M6 2h4v4m-4 0h-1v-1"></path><path d="M15 11v-1h5v4h-2"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h2"></path><path d="M7.5 7.5v2.5"></path><path d="M7.5 14v4"></path><path d="M3 3l18 18"></path>', 9)
|
|
785
858
|
])]);
|
|
786
859
|
}
|
|
787
|
-
const
|
|
860
|
+
const hs = /* @__PURE__ */ $(us, [["render", ps]]), vs = {}, ms = {
|
|
788
861
|
xmlns: "http://www.w3.org/2000/svg",
|
|
789
|
-
class: "baklava-icon",
|
|
790
862
|
width: "24",
|
|
791
863
|
height: "24",
|
|
792
864
|
viewBox: "0 0 24 24",
|
|
@@ -794,56 +866,38 @@ const ns = /* @__PURE__ */ S(es, [["render", ss]]), os = {}, as = {
|
|
|
794
866
|
stroke: "currentColor",
|
|
795
867
|
"stroke-width": "2",
|
|
796
868
|
"stroke-linecap": "round",
|
|
797
|
-
"stroke-linejoin": "round"
|
|
869
|
+
"stroke-linejoin": "round",
|
|
870
|
+
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-transition-bottom"
|
|
798
871
|
};
|
|
799
|
-
function
|
|
800
|
-
return i(), r("svg",
|
|
801
|
-
|
|
872
|
+
function fs(s, e) {
|
|
873
|
+
return i(), r("svg", ms, [...e[0] || (e[0] = [
|
|
874
|
+
Q('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M21 18a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3"></path><path d="M3 3m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z"></path><path d="M12 9v8"></path><path d="M9 14l3 3l3 -3"></path>', 5)
|
|
802
875
|
])]);
|
|
803
876
|
}
|
|
804
|
-
const
|
|
877
|
+
const gs = /* @__PURE__ */ $(vs, [["render", fs]]), bs = {}, ys = {
|
|
805
878
|
xmlns: "http://www.w3.org/2000/svg",
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
height: "16",
|
|
879
|
+
width: "24",
|
|
880
|
+
height: "24",
|
|
809
881
|
viewBox: "0 0 24 24",
|
|
810
|
-
"stroke-width": "2",
|
|
811
|
-
stroke: "currentColor",
|
|
812
882
|
fill: "none",
|
|
883
|
+
stroke: "currentColor",
|
|
884
|
+
"stroke-width": "2",
|
|
813
885
|
"stroke-linecap": "round",
|
|
814
|
-
"stroke-linejoin": "round"
|
|
886
|
+
"stroke-linejoin": "round",
|
|
887
|
+
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-trash-off"
|
|
815
888
|
};
|
|
816
|
-
function
|
|
817
|
-
return i(), r("svg",
|
|
818
|
-
|
|
819
|
-
stroke: "none",
|
|
820
|
-
d: "M0 0h24v24H0z",
|
|
821
|
-
fill: "none"
|
|
822
|
-
}, null, -1),
|
|
823
|
-
d("circle", {
|
|
824
|
-
cx: "12",
|
|
825
|
-
cy: "12",
|
|
826
|
-
r: "1"
|
|
827
|
-
}, null, -1),
|
|
828
|
-
d("circle", {
|
|
829
|
-
cx: "12",
|
|
830
|
-
cy: "19",
|
|
831
|
-
r: "1"
|
|
832
|
-
}, null, -1),
|
|
833
|
-
d("circle", {
|
|
834
|
-
cx: "12",
|
|
835
|
-
cy: "5",
|
|
836
|
-
r: "1"
|
|
837
|
-
}, null, -1)
|
|
889
|
+
function _s(s, e) {
|
|
890
|
+
return i(), r("svg", ys, [...e[0] || (e[0] = [
|
|
891
|
+
Q('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M3 3l18 18"></path><path d="M4 7h3m4 0h9"></path><path d="M10 11l0 6"></path><path d="M14 14l0 3"></path><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l.077 -.923"></path><path d="M18.384 14.373l.616 -7.373"></path><path d="M9 5v-1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"></path>', 8)
|
|
838
892
|
])]);
|
|
839
893
|
}
|
|
840
|
-
const
|
|
894
|
+
const ws = /* @__PURE__ */ $(bs, [["render", _s]]), ks = ["id", "data-node-type"], xs = {
|
|
841
895
|
class: "__title-label",
|
|
842
896
|
style: { "flex-grow": "1" }
|
|
843
|
-
},
|
|
897
|
+
}, Cs = { key: 0 }, Is = {
|
|
844
898
|
class: "__menu",
|
|
845
899
|
style: { display: "flex" }
|
|
846
|
-
},
|
|
900
|
+
}, Ns = { class: "__outputs" }, Ms = { key: 0 }, $s = ["id", "title"], Os = { class: "__inputs" }, Ts = { key: 0 }, Es = ["id", "title"], Ss = /* @__PURE__ */ L({
|
|
847
901
|
__name: "CodeGraphNode",
|
|
848
902
|
props: {
|
|
849
903
|
node: {},
|
|
@@ -851,94 +905,96 @@ const cs = /* @__PURE__ */ S(ds, [["render", us]]), ps = ["id", "data-node-type"
|
|
|
851
905
|
dragging: { type: Boolean }
|
|
852
906
|
},
|
|
853
907
|
emits: ["select", "start-drag", "update"],
|
|
854
|
-
setup(
|
|
855
|
-
const t =
|
|
856
|
-
let
|
|
857
|
-
const
|
|
908
|
+
setup(s, { emit: e }) {
|
|
909
|
+
const t = we.ContextMenu, n = we.NodeInterface, o = s, a = _(() => o.node), d = e, { viewModel: u } = F(), { graph: m, switchGraph: w } = ne(), k = T(null), O = T(!1), j = T(""), x = T(null), f = T(!1);
|
|
910
|
+
let g = 0, v = 0;
|
|
911
|
+
const h = T(!1), C = _(() => {
|
|
858
912
|
const c = [
|
|
859
913
|
{ value: "edit", label: "Edit" },
|
|
860
914
|
{ value: "rename", label: "Rename" },
|
|
861
915
|
{ value: "delete", label: "Delete" }
|
|
862
916
|
];
|
|
863
|
-
return o.node.type.startsWith(
|
|
864
|
-
}),
|
|
917
|
+
return o.node.type.startsWith(K) && c.push({ value: "editSubgraph", label: "Edit Subgraph" }), c;
|
|
918
|
+
}), N = _(() => ({
|
|
865
919
|
"--selected": o.selected,
|
|
866
920
|
"--dragging": o.dragging,
|
|
867
921
|
"--two-column": !!o.node.twoColumn,
|
|
868
922
|
"--hidden": a.value.state?.hidden
|
|
869
|
-
})),
|
|
870
|
-
"--reverse-y": o.node.reverseY ??
|
|
871
|
-
})),
|
|
923
|
+
})), ze = _(() => ({
|
|
924
|
+
"--reverse-y": o.node.reverseY ?? u.value.settings.nodes.reverseY
|
|
925
|
+
})), Ve = _(() => ({
|
|
872
926
|
top: `${o.node.position?.y ?? 0}px`,
|
|
873
927
|
left: `${o.node.position?.x ?? 0}px`,
|
|
874
|
-
"--width": `${o.node.width ??
|
|
875
|
-
})),
|
|
876
|
-
|
|
877
|
-
},
|
|
878
|
-
o.selected ||
|
|
879
|
-
},
|
|
880
|
-
|
|
881
|
-
},
|
|
882
|
-
const c =
|
|
928
|
+
"--width": `${o.node.width ?? u.value.settings.nodes.defaultWidth}px`
|
|
929
|
+
})), Be = _(() => Object.values(o.node.inputs).filter((c) => !c.hidden)), je = _(() => Object.values(o.node.outputs).filter((c) => !c.hidden)), he = () => {
|
|
930
|
+
d("select");
|
|
931
|
+
}, Le = (c) => {
|
|
932
|
+
o.selected || he(), d("start-drag", c);
|
|
933
|
+
}, ve = () => {
|
|
934
|
+
h.value = !0;
|
|
935
|
+
}, Ue = () => {
|
|
936
|
+
const c = u.value.displayedGraph.sidebar;
|
|
883
937
|
c.nodeId = "", c.visible = !1;
|
|
884
|
-
},
|
|
885
|
-
const c =
|
|
938
|
+
}, me = () => {
|
|
939
|
+
const c = u.value.displayedGraph.sidebar;
|
|
886
940
|
c.nodeId = o.node.id, c.visible = !0;
|
|
887
|
-
},
|
|
888
|
-
const c =
|
|
941
|
+
}, Ge = () => {
|
|
942
|
+
const c = u.value.displayedGraph.sidebar;
|
|
889
943
|
c.nodeId = o.node.id;
|
|
890
|
-
},
|
|
944
|
+
}, Re = async (c) => {
|
|
891
945
|
switch (c) {
|
|
892
946
|
case "edit":
|
|
893
|
-
|
|
947
|
+
me();
|
|
894
948
|
break;
|
|
895
949
|
case "delete":
|
|
896
|
-
|
|
950
|
+
m.value.removeNode(o.node);
|
|
897
951
|
break;
|
|
898
952
|
case "rename":
|
|
899
|
-
|
|
953
|
+
j.value = o.node.title, O.value = !0, await ct(), x.value?.focus();
|
|
900
954
|
break;
|
|
901
955
|
case "editSubgraph":
|
|
902
|
-
|
|
956
|
+
w(o.node.template);
|
|
903
957
|
break;
|
|
904
958
|
}
|
|
905
|
-
},
|
|
906
|
-
o.node.title =
|
|
907
|
-
}, me = () => {
|
|
908
|
-
y.value && l.value.hooks.renderNode.execute({ node: o.node, el: y.value });
|
|
909
|
-
}, Ue = (c) => {
|
|
910
|
-
m.value = !0, f = o.node.width, h = c.clientX, c.preventDefault();
|
|
911
|
-
}, fe = (c) => {
|
|
912
|
-
if (!m.value) return;
|
|
913
|
-
const N = c.clientX - h, g = f + N / v.value.scaling, Ge = l.value.settings.nodes.minWidth, Re = l.value.settings.nodes.maxWidth;
|
|
914
|
-
o.node.width = Math.max(Ge, Math.min(Re, g));
|
|
959
|
+
}, fe = () => {
|
|
960
|
+
o.node.title = j.value, O.value = !1;
|
|
915
961
|
}, ge = () => {
|
|
916
|
-
|
|
962
|
+
k.value && u.value.hooks.renderNode.execute({ node: o.node, el: k.value });
|
|
963
|
+
}, De = (c) => {
|
|
964
|
+
f.value = !0, g = o.node.width, v = c.clientX, c.preventDefault();
|
|
965
|
+
}, be = (c) => {
|
|
966
|
+
a.value.state && (a.value.state.integrated = c, d("update"));
|
|
967
|
+
}, ye = (c) => {
|
|
968
|
+
if (!f.value) return;
|
|
969
|
+
const b = c.clientX - v, p = g + b / m.value.scaling, Pe = u.value.settings.nodes.minWidth, He = u.value.settings.nodes.maxWidth;
|
|
970
|
+
o.node.width = Math.max(Pe, Math.min(He, p));
|
|
971
|
+
}, _e = () => {
|
|
972
|
+
f.value = !1;
|
|
917
973
|
};
|
|
918
|
-
return
|
|
919
|
-
|
|
920
|
-
}), Ne(
|
|
921
|
-
window.removeEventListener("mousemove",
|
|
922
|
-
}), (c,
|
|
974
|
+
return oe(() => {
|
|
975
|
+
ge(), window.addEventListener("mousemove", ye), window.addEventListener("mouseup", _e);
|
|
976
|
+
}), Ne(ge), dt(() => {
|
|
977
|
+
window.removeEventListener("mousemove", ye), window.removeEventListener("mouseup", _e);
|
|
978
|
+
}), (c, b) => (i(), r("div", {
|
|
923
979
|
id: a.value.id,
|
|
924
980
|
ref_key: "el",
|
|
925
|
-
ref:
|
|
926
|
-
class: U([
|
|
981
|
+
ref: k,
|
|
982
|
+
class: U([N.value, "baklava-node"]),
|
|
927
983
|
"data-node-type": a.value.type,
|
|
928
|
-
style:
|
|
929
|
-
onPointerdown:
|
|
984
|
+
style: ae(Ve.value),
|
|
985
|
+
onPointerdown: he
|
|
930
986
|
}, [
|
|
931
|
-
|
|
987
|
+
y(u).settings.nodes.resizable ? (i(), r("div", {
|
|
932
988
|
key: 0,
|
|
933
989
|
class: "__resize-handle",
|
|
934
|
-
onMousedown:
|
|
990
|
+
onMousedown: De
|
|
935
991
|
}, null, 32)) : I("", !0),
|
|
936
|
-
|
|
992
|
+
l("div", {
|
|
937
993
|
class: "__title",
|
|
938
|
-
onPointerdown: P(
|
|
939
|
-
onContextmenu: P(
|
|
994
|
+
onPointerdown: P(Le, ["self", "stop"]),
|
|
995
|
+
onContextmenu: P(ve, ["prevent"])
|
|
940
996
|
}, [
|
|
941
|
-
a.value.inputs._node ? (i(),
|
|
997
|
+
a.value.inputs._node ? (i(), S(ke, {
|
|
942
998
|
key: 0,
|
|
943
999
|
node: a.value,
|
|
944
1000
|
intf: a.value.inputs._node,
|
|
@@ -946,55 +1002,64 @@ const cs = /* @__PURE__ */ S(ds, [["render", us]]), ps = ["id", "data-node-type"
|
|
|
946
1002
|
"data-interface-type": "node",
|
|
947
1003
|
style: { "flex-grow": "0" }
|
|
948
1004
|
}, null, 8, ["node", "intf"])) : I("", !0),
|
|
949
|
-
|
|
1005
|
+
O.value ? ie((i(), r("input", {
|
|
950
1006
|
key: 2,
|
|
951
1007
|
ref_key: "renameInputEl",
|
|
952
|
-
ref:
|
|
953
|
-
"onUpdate:modelValue":
|
|
1008
|
+
ref: x,
|
|
1009
|
+
"onUpdate:modelValue": b[3] || (b[3] = (p) => j.value = p),
|
|
954
1010
|
class: "baklava-input",
|
|
955
1011
|
placeholder: "Node Name",
|
|
956
1012
|
style: { "flex-grow": "1" },
|
|
957
1013
|
type: "text",
|
|
958
|
-
onBlur:
|
|
959
|
-
onKeydown:
|
|
1014
|
+
onBlur: fe,
|
|
1015
|
+
onKeydown: ee(fe, ["enter"])
|
|
960
1016
|
}, null, 544)), [
|
|
961
|
-
[
|
|
962
|
-
]) : (i(), r(
|
|
963
|
-
|
|
964
|
-
a.value.idx > -1 ? (i(), r("span",
|
|
965
|
-
|
|
1017
|
+
[re, j.value]
|
|
1018
|
+
]) : (i(), r(z, { key: 1 }, [
|
|
1019
|
+
l("div", xs, [
|
|
1020
|
+
a.value.idx > -1 ? (i(), r("span", Cs, B(a.value.idx + 1) + " - ", 1)) : I("", !0),
|
|
1021
|
+
ut(B(a.value.title) + " (" + B(a.value.shortId) + ") ", 1)
|
|
966
1022
|
]),
|
|
967
|
-
|
|
968
|
-
a.value.subgraph ? I("", !0) : (i(), r(
|
|
969
|
-
|
|
1023
|
+
l("div", Is, [
|
|
1024
|
+
a.value.subgraph ? I("", !0) : (i(), r(z, { key: 0 }, [
|
|
1025
|
+
a.value.state.integrated ? (i(), S(y(Bt), {
|
|
970
1026
|
key: 0,
|
|
971
1027
|
class: "--clickable mx-1",
|
|
972
|
-
onClick:
|
|
973
|
-
})) :
|
|
1028
|
+
onClick: b[0] || (b[0] = (p) => be(!1))
|
|
1029
|
+
})) : (i(), S(y(gs), {
|
|
974
1030
|
key: 1,
|
|
975
1031
|
class: "--clickable mx-1",
|
|
976
|
-
onClick:
|
|
977
|
-
}))
|
|
1032
|
+
onClick: b[1] || (b[1] = (p) => be(!0))
|
|
1033
|
+
})),
|
|
1034
|
+
!y(u).displayedGraph.sidebar.visible && y(u).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), S(y(as), {
|
|
978
1035
|
key: 2,
|
|
979
1036
|
class: "--clickable mx-1",
|
|
980
|
-
onClick:
|
|
1037
|
+
onClick: me
|
|
1038
|
+
})) : y(u).displayedGraph.sidebar.visible && y(u).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), S(y(Qt), {
|
|
1039
|
+
key: 3,
|
|
1040
|
+
class: "--clickable mx-1",
|
|
1041
|
+
onClick: Ge
|
|
1042
|
+
})) : (i(), S(y(ts), {
|
|
1043
|
+
key: 4,
|
|
1044
|
+
class: "--clickable mx-1",
|
|
1045
|
+
onClick: Ue
|
|
981
1046
|
}))
|
|
982
1047
|
], 64)),
|
|
983
|
-
|
|
1048
|
+
V(y(Gt), {
|
|
984
1049
|
class: "--clickable mx-1",
|
|
985
|
-
onClick:
|
|
1050
|
+
onClick: ve
|
|
986
1051
|
}),
|
|
987
|
-
|
|
988
|
-
modelValue:
|
|
989
|
-
"onUpdate:modelValue":
|
|
1052
|
+
V(y(t), {
|
|
1053
|
+
modelValue: h.value,
|
|
1054
|
+
"onUpdate:modelValue": b[2] || (b[2] = (p) => h.value = p),
|
|
990
1055
|
x: 0,
|
|
991
1056
|
y: 0,
|
|
992
1057
|
items: C.value,
|
|
993
|
-
onClick:
|
|
1058
|
+
onClick: Re
|
|
994
1059
|
}, null, 8, ["modelValue", "items"])
|
|
995
1060
|
])
|
|
996
1061
|
], 64)),
|
|
997
|
-
a.value.outputs._node ? (i(),
|
|
1062
|
+
a.value.outputs._node ? (i(), S(ke, {
|
|
998
1063
|
key: 3,
|
|
999
1064
|
node: a.value,
|
|
1000
1065
|
intf: a.value.outputs._node,
|
|
@@ -1002,73 +1067,74 @@ const cs = /* @__PURE__ */ S(ds, [["render", us]]), ps = ["id", "data-node-type"
|
|
|
1002
1067
|
"data-interface-type": "node"
|
|
1003
1068
|
}, null, 8, ["node", "intf"])) : I("", !0)
|
|
1004
1069
|
], 32),
|
|
1005
|
-
|
|
1006
|
-
class: U(["__content",
|
|
1007
|
-
onKeydown:
|
|
1070
|
+
l("div", {
|
|
1071
|
+
class: U(["__content", ze.value]),
|
|
1072
|
+
onKeydown: b[4] || (b[4] = ee(P(() => {
|
|
1008
1073
|
}, ["stop"]), ["delete"])),
|
|
1009
|
-
onContextmenu:
|
|
1074
|
+
onContextmenu: b[5] || (b[5] = P(() => {
|
|
1010
1075
|
}, ["prevent"]))
|
|
1011
1076
|
}, [
|
|
1012
|
-
|
|
1013
|
-
(i(!0), r(
|
|
1014
|
-
key:
|
|
1077
|
+
l("div", Ns, [
|
|
1078
|
+
(i(!0), r(z, null, H(je.value, (p) => (i(), r(z, {
|
|
1079
|
+
key: p.id
|
|
1015
1080
|
}, [
|
|
1016
|
-
a.value.state?.hidden ? (i(), r("div",
|
|
1017
|
-
|
|
1081
|
+
a.value.state?.hidden ? (i(), r("div", Ms, [
|
|
1082
|
+
p.port ? (i(), r("div", {
|
|
1018
1083
|
key: 0,
|
|
1019
|
-
id:
|
|
1020
|
-
title:
|
|
1084
|
+
id: p.id,
|
|
1085
|
+
title: p.name,
|
|
1021
1086
|
class: "baklava-node-interface --output --connected"
|
|
1022
|
-
}, [...
|
|
1023
|
-
|
|
1024
|
-
])], 8,
|
|
1025
|
-
])) :
|
|
1087
|
+
}, [...b[6] || (b[6] = [
|
|
1088
|
+
l("div", { class: "__port" }, null, -1)
|
|
1089
|
+
])], 8, $s)) : I("", !0)
|
|
1090
|
+
])) : Z(c.$slots, "nodeInterface", {
|
|
1026
1091
|
key: 1,
|
|
1027
1092
|
type: "output",
|
|
1028
1093
|
node: a.value,
|
|
1029
|
-
intf:
|
|
1094
|
+
intf: p
|
|
1030
1095
|
}, () => [
|
|
1031
|
-
|
|
1096
|
+
V(y(n), {
|
|
1032
1097
|
node: a.value,
|
|
1033
|
-
intf:
|
|
1034
|
-
|
|
1098
|
+
intf: p,
|
|
1099
|
+
title: p.type
|
|
1100
|
+
}, null, 8, ["node", "intf", "title"])
|
|
1035
1101
|
])
|
|
1036
1102
|
], 64))), 128))
|
|
1037
1103
|
]),
|
|
1038
|
-
|
|
1039
|
-
(i(!0), r(
|
|
1040
|
-
key:
|
|
1104
|
+
l("div", Os, [
|
|
1105
|
+
(i(!0), r(z, null, H(Be.value, (p) => (i(), r(z, {
|
|
1106
|
+
key: p.id
|
|
1041
1107
|
}, [
|
|
1042
|
-
a.value.state?.hidden ? (i(), r("div",
|
|
1043
|
-
|
|
1108
|
+
a.value.state?.hidden ? (i(), r("div", Ts, [
|
|
1109
|
+
p.port ? (i(), r("div", {
|
|
1044
1110
|
key: 0,
|
|
1045
|
-
id:
|
|
1046
|
-
title:
|
|
1111
|
+
id: p.id,
|
|
1112
|
+
title: p.name,
|
|
1047
1113
|
class: "baklava-node-interface --input --connected"
|
|
1048
|
-
}, [...
|
|
1049
|
-
|
|
1050
|
-
])], 8,
|
|
1051
|
-
])) :
|
|
1114
|
+
}, [...b[7] || (b[7] = [
|
|
1115
|
+
l("div", { class: "__port" }, null, -1)
|
|
1116
|
+
])], 8, Es)) : I("", !0)
|
|
1117
|
+
])) : Z(c.$slots, "nodeInterface", {
|
|
1052
1118
|
key: 1,
|
|
1053
1119
|
node: a.value,
|
|
1054
|
-
intf:
|
|
1120
|
+
intf: p,
|
|
1055
1121
|
type: "input"
|
|
1056
1122
|
}, () => [
|
|
1057
|
-
|
|
1123
|
+
V(y(n), {
|
|
1058
1124
|
node: a.value,
|
|
1059
|
-
intf:
|
|
1060
|
-
title:
|
|
1125
|
+
intf: p,
|
|
1126
|
+
title: p.type
|
|
1061
1127
|
}, null, 8, ["node", "intf", "title"])
|
|
1062
1128
|
])
|
|
1063
1129
|
], 64))), 128))
|
|
1064
1130
|
])
|
|
1065
1131
|
], 34)
|
|
1066
|
-
], 46,
|
|
1132
|
+
], 46, ks));
|
|
1067
1133
|
}
|
|
1068
|
-
}),
|
|
1134
|
+
}), zs = ["title"], Vs = {
|
|
1069
1135
|
key: 0,
|
|
1070
1136
|
class: "__label"
|
|
1071
|
-
},
|
|
1137
|
+
}, Bs = /* @__PURE__ */ L({
|
|
1072
1138
|
__name: "Checkbox",
|
|
1073
1139
|
props: {
|
|
1074
1140
|
disabled: { type: Boolean },
|
|
@@ -1077,121 +1143,121 @@ const cs = /* @__PURE__ */ S(ds, [["render", us]]), ps = ["id", "data-node-type"
|
|
|
1077
1143
|
name: {}
|
|
1078
1144
|
},
|
|
1079
1145
|
emits: ["update:modelValue"],
|
|
1080
|
-
setup(
|
|
1146
|
+
setup(s, { emit: e }) {
|
|
1081
1147
|
const t = e;
|
|
1082
|
-
return (
|
|
1148
|
+
return (n, o) => (i(), r("div", {
|
|
1083
1149
|
class: U(["baklava-checkbox", { "--checked": s.inversed ? !s.modelValue : s.modelValue, "--disabled": s.disabled }]),
|
|
1084
1150
|
title: s.name,
|
|
1085
1151
|
onClick: o[0] || (o[0] = (a) => t("update:modelValue", !s.modelValue))
|
|
1086
1152
|
}, [
|
|
1087
|
-
o[1] || (o[1] =
|
|
1088
|
-
|
|
1153
|
+
o[1] || (o[1] = l("div", { class: "__checkmark-container" }, [
|
|
1154
|
+
l("svg", {
|
|
1089
1155
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1090
1156
|
width: "18",
|
|
1091
1157
|
height: "18",
|
|
1092
1158
|
viewBox: "0 0 18 18"
|
|
1093
1159
|
}, [
|
|
1094
|
-
|
|
1160
|
+
l("path", {
|
|
1095
1161
|
class: "__checkmark",
|
|
1096
1162
|
d: "M 6 5 L 6 10 L 16 10",
|
|
1097
1163
|
transform: "rotate(-45 10 10)"
|
|
1098
1164
|
})
|
|
1099
1165
|
])
|
|
1100
1166
|
], -1)),
|
|
1101
|
-
s.name ? (i(), r("div",
|
|
1102
|
-
], 10,
|
|
1167
|
+
s.name ? (i(), r("div", Vs, B(s.name), 1)) : I("", !0)
|
|
1168
|
+
], 10, zs));
|
|
1103
1169
|
}
|
|
1104
|
-
}),
|
|
1170
|
+
}), js = { class: "__header" }, Ls = { class: "__node-name" }, Us = { style: { display: "flex" } }, Gs = {
|
|
1105
1171
|
key: 1,
|
|
1106
1172
|
class: "__interface"
|
|
1107
|
-
},
|
|
1173
|
+
}, Rs = /* @__PURE__ */ L({
|
|
1108
1174
|
__name: "CodeGraphSidebar",
|
|
1109
|
-
setup(
|
|
1110
|
-
const { viewModel: e } = F(), { graph: t } =
|
|
1111
|
-
let
|
|
1112
|
-
const
|
|
1113
|
-
const
|
|
1114
|
-
return t.value.nodes.find((
|
|
1115
|
-
}),
|
|
1175
|
+
setup(s) {
|
|
1176
|
+
const { viewModel: e } = F(), { graph: t } = ne(), n = T(null), o = Me(e.value.settings.sidebar, "width"), a = _(() => e.value.settings.sidebar.resizable);
|
|
1177
|
+
let d = 0, u = 0;
|
|
1178
|
+
const m = _(() => {
|
|
1179
|
+
const v = t.value.sidebar.nodeId;
|
|
1180
|
+
return t.value.nodes.find((h) => h.id === v);
|
|
1181
|
+
}), w = _(() => m.value), k = _(() => ({
|
|
1116
1182
|
width: `${o.value}px`
|
|
1117
|
-
})),
|
|
1183
|
+
})), O = _(() => w.value ? [...Object.values(w.value.inputs), ...Object.values(w.value.outputs)].filter((h) => h.displayInSidebar && h.component) : []), j = () => {
|
|
1118
1184
|
t.value.sidebar.visible = !1;
|
|
1119
|
-
},
|
|
1120
|
-
|
|
1121
|
-
},
|
|
1122
|
-
|
|
1185
|
+
}, x = () => {
|
|
1186
|
+
m.value?.events.update.emit(null);
|
|
1187
|
+
}, f = (v) => {
|
|
1188
|
+
d = o.value, u = v.clientX, window.addEventListener("mousemove", g), window.addEventListener(
|
|
1123
1189
|
"mouseup",
|
|
1124
1190
|
() => {
|
|
1125
|
-
window.removeEventListener("mousemove",
|
|
1191
|
+
window.removeEventListener("mousemove", g);
|
|
1126
1192
|
},
|
|
1127
1193
|
{ once: !0 }
|
|
1128
1194
|
);
|
|
1129
|
-
},
|
|
1130
|
-
const
|
|
1131
|
-
let
|
|
1132
|
-
|
|
1195
|
+
}, g = (v) => {
|
|
1196
|
+
const h = n.value?.parentElement?.getBoundingClientRect().width ?? 500, C = v.clientX - u;
|
|
1197
|
+
let N = d - C;
|
|
1198
|
+
N < 300 ? N = 300 : N > 0.9 * h && (N = 0.9 * h), o.value = N;
|
|
1133
1199
|
};
|
|
1134
|
-
return (
|
|
1200
|
+
return (v, h) => (i(), r("div", {
|
|
1135
1201
|
ref_key: "el",
|
|
1136
|
-
ref:
|
|
1137
|
-
class: U(["baklava-sidebar", { "--open":
|
|
1138
|
-
style:
|
|
1202
|
+
ref: n,
|
|
1203
|
+
class: U(["baklava-sidebar", { "--open": y(t).sidebar.visible }]),
|
|
1204
|
+
style: ae(k.value)
|
|
1139
1205
|
}, [
|
|
1140
1206
|
a.value ? (i(), r("div", {
|
|
1141
1207
|
key: 0,
|
|
1142
1208
|
class: "__resizer",
|
|
1143
|
-
onMousedown:
|
|
1209
|
+
onMousedown: f
|
|
1144
1210
|
}, null, 32)) : I("", !0),
|
|
1145
|
-
|
|
1146
|
-
|
|
1211
|
+
l("div", js, [
|
|
1212
|
+
l("button", {
|
|
1147
1213
|
tabindex: "-1",
|
|
1148
1214
|
class: "__close",
|
|
1149
|
-
onClick:
|
|
1215
|
+
onClick: j
|
|
1150
1216
|
}, "×"),
|
|
1151
|
-
|
|
1152
|
-
|
|
1217
|
+
l("div", Ls, [
|
|
1218
|
+
l("b", null, B(m.value ? m.value.title : ""), 1)
|
|
1153
1219
|
])
|
|
1154
1220
|
]),
|
|
1155
|
-
(i(!0), r(
|
|
1221
|
+
(i(!0), r(z, null, H(O.value, (C) => (i(), r("div", {
|
|
1156
1222
|
key: C.id,
|
|
1157
1223
|
class: "__interface"
|
|
1158
1224
|
}, [
|
|
1159
|
-
|
|
1160
|
-
|
|
1225
|
+
l("div", Us, [
|
|
1226
|
+
V(Bs, {
|
|
1161
1227
|
modelValue: C.hidden,
|
|
1162
1228
|
"onUpdate:modelValue": [
|
|
1163
|
-
(
|
|
1164
|
-
|
|
1229
|
+
(N) => C.hidden = N,
|
|
1230
|
+
h[0] || (h[0] = () => m.value?.events.update.emit(null))
|
|
1165
1231
|
],
|
|
1166
1232
|
disabled: !C.optional,
|
|
1167
1233
|
inversed: "",
|
|
1168
|
-
style: { "
|
|
1234
|
+
style: { "padding-right": "8px" }
|
|
1169
1235
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"]),
|
|
1170
|
-
(i(),
|
|
1236
|
+
(i(), S(pt(C.component), {
|
|
1171
1237
|
modelValue: C.value,
|
|
1172
|
-
"onUpdate:modelValue": (
|
|
1173
|
-
node:
|
|
1238
|
+
"onUpdate:modelValue": (N) => C.value = N,
|
|
1239
|
+
node: m.value,
|
|
1174
1240
|
intf: C,
|
|
1175
1241
|
style: { width: "100%" }
|
|
1176
1242
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
|
|
1177
1243
|
])
|
|
1178
1244
|
]))), 128)),
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
"onUpdate:modelValue":
|
|
1245
|
+
w.value && w.value.state ? (i(), r("div", Gs, [
|
|
1246
|
+
h[2] || (h[2] = l("label", null, "Variable name", -1)),
|
|
1247
|
+
ie(l("input", {
|
|
1248
|
+
"onUpdate:modelValue": h[1] || (h[1] = (C) => w.value.state.variableName = C),
|
|
1183
1249
|
type: "text",
|
|
1184
1250
|
class: "baklava-input",
|
|
1185
1251
|
title: "Variable name",
|
|
1186
|
-
onBlur:
|
|
1187
|
-
onKeydown:
|
|
1252
|
+
onBlur: x,
|
|
1253
|
+
onKeydown: ee(x, ["enter"])
|
|
1188
1254
|
}, null, 544), [
|
|
1189
|
-
[
|
|
1255
|
+
[re, w.value.state.variableName]
|
|
1190
1256
|
])
|
|
1191
1257
|
])) : I("", !0)
|
|
1192
1258
|
], 6));
|
|
1193
1259
|
}
|
|
1194
|
-
}),
|
|
1260
|
+
}), Ds = L({
|
|
1195
1261
|
props: {
|
|
1196
1262
|
type: {
|
|
1197
1263
|
type: String,
|
|
@@ -1202,120 +1268,120 @@ const cs = /* @__PURE__ */ S(ds, [["render", us]]), ps = ["id", "data-node-type"
|
|
|
1202
1268
|
required: !0
|
|
1203
1269
|
}
|
|
1204
1270
|
},
|
|
1205
|
-
setup(
|
|
1206
|
-
const { viewModel: e } = F(), { switchGraph: t } =
|
|
1207
|
-
return { showContextMenu:
|
|
1271
|
+
setup(s) {
|
|
1272
|
+
const { viewModel: e } = F(), { switchGraph: t } = ne(), n = T(!1), o = _(() => s.type.startsWith(K));
|
|
1273
|
+
return { showContextMenu: n, hasContextMenu: o, contextMenuItems: [
|
|
1208
1274
|
{ label: "Edit Subgraph", value: "editSubgraph" },
|
|
1209
1275
|
{ label: "Delete Subgraph", value: "deleteSubgraph" }
|
|
1210
1276
|
], openContextMenu: () => {
|
|
1211
|
-
|
|
1212
|
-
}, onContextMenuClick: (
|
|
1213
|
-
const
|
|
1214
|
-
if (
|
|
1215
|
-
switch (
|
|
1277
|
+
n.value = !0;
|
|
1278
|
+
}, onContextMenuClick: (m) => {
|
|
1279
|
+
const w = s.type.substring(K.length), k = e.value.editor.graphTemplates.find((O) => O.id === w);
|
|
1280
|
+
if (k)
|
|
1281
|
+
switch (m) {
|
|
1216
1282
|
case "editSubgraph":
|
|
1217
|
-
t(
|
|
1283
|
+
t(k);
|
|
1218
1284
|
break;
|
|
1219
1285
|
case "deleteSubgraph":
|
|
1220
|
-
e.value.editor.removeGraphTemplate(
|
|
1286
|
+
e.value.editor.removeGraphTemplate(k);
|
|
1221
1287
|
break;
|
|
1222
1288
|
}
|
|
1223
1289
|
} };
|
|
1224
1290
|
}
|
|
1225
|
-
}),
|
|
1226
|
-
function
|
|
1291
|
+
}), Ps = ["data-node-type"], Hs = { class: "__title" }, As = { class: "__title-label" };
|
|
1292
|
+
function Fs(s, e, t, n, o, a) {
|
|
1227
1293
|
return i(), r("div", {
|
|
1228
1294
|
class: "baklava-node --palette",
|
|
1229
|
-
"data-node-type":
|
|
1295
|
+
"data-node-type": s.type
|
|
1230
1296
|
}, [
|
|
1231
|
-
|
|
1232
|
-
|
|
1297
|
+
l("div", Hs, [
|
|
1298
|
+
l("div", As, B(s.title), 1)
|
|
1233
1299
|
])
|
|
1234
|
-
], 8,
|
|
1300
|
+
], 8, Ps);
|
|
1235
1301
|
}
|
|
1236
|
-
const
|
|
1302
|
+
const xe = /* @__PURE__ */ $(Ds, [["render", Fs]]), Ws = {
|
|
1237
1303
|
class: "baklava-node --palette",
|
|
1238
1304
|
style: { "margin-top": "-20px", "margin-bottom": "20px" }
|
|
1239
|
-
},
|
|
1305
|
+
}, Xs = {
|
|
1240
1306
|
key: 0,
|
|
1241
1307
|
style: { display: "flex", "justify-content": "space-between" }
|
|
1242
|
-
},
|
|
1308
|
+
}, Js = ["onClick"], Ys = {
|
|
1243
1309
|
key: 0,
|
|
1244
1310
|
style: { margin: "auto 0", "font-size": "12px" }
|
|
1245
|
-
},
|
|
1311
|
+
}, qs = /* @__PURE__ */ L({
|
|
1246
1312
|
__name: "CodeNodePalette",
|
|
1247
|
-
setup(
|
|
1248
|
-
const { viewModel: e } = F(), { x: t, y:
|
|
1249
|
-
(
|
|
1250
|
-
(
|
|
1313
|
+
setup(s) {
|
|
1314
|
+
const { viewModel: e } = F(), { x: t, y: n } = wt(), { transform: o } = st(), a = nt(e), d = ht("editorEl"), u = T(""), m = T(null), w = () => u.value ? a.value.filter(
|
|
1315
|
+
(x) => x.name.toLowerCase().includes(u.value.toLowerCase()) || Object.values(x.nodeTypes).some(
|
|
1316
|
+
(f) => f.title.toLowerCase().includes(u.value.toLowerCase())
|
|
1251
1317
|
)
|
|
1252
|
-
) : a.value,
|
|
1253
|
-
(
|
|
1254
|
-
) : Object.values(
|
|
1255
|
-
if (!
|
|
1256
|
-
const { left:
|
|
1318
|
+
) : a.value, k = (x) => u.value ? Object.values(x).filter(
|
|
1319
|
+
(f) => f.category.toLowerCase().includes(u.value.toLowerCase()) || f.title.toLowerCase().includes(u.value.toLowerCase())
|
|
1320
|
+
) : Object.values(x), O = _(() => {
|
|
1321
|
+
if (!m.value || !d?.value) return {};
|
|
1322
|
+
const { left: x, top: f } = d.value.getBoundingClientRect();
|
|
1257
1323
|
return {
|
|
1258
|
-
top: `${
|
|
1259
|
-
left: `${t.value -
|
|
1324
|
+
top: `${n.value - f}px`,
|
|
1325
|
+
left: `${t.value - x}px`
|
|
1260
1326
|
};
|
|
1261
|
-
}),
|
|
1262
|
-
|
|
1263
|
-
type:
|
|
1264
|
-
nodeInformation:
|
|
1327
|
+
}), j = (x, f) => {
|
|
1328
|
+
m.value = {
|
|
1329
|
+
type: x,
|
|
1330
|
+
nodeInformation: f
|
|
1265
1331
|
};
|
|
1266
|
-
const
|
|
1267
|
-
const
|
|
1268
|
-
e.value.displayedGraph.addNode(
|
|
1269
|
-
const
|
|
1270
|
-
|
|
1332
|
+
const g = () => {
|
|
1333
|
+
const v = R(new f.type());
|
|
1334
|
+
e.value.displayedGraph.addNode(v);
|
|
1335
|
+
const h = d.value.getBoundingClientRect(), [C, N] = o(t.value - h.left, n.value - h.top);
|
|
1336
|
+
v.position.x = C, v.position.y = N, m.value = null, document.removeEventListener("pointerup", g);
|
|
1271
1337
|
};
|
|
1272
|
-
document.addEventListener("pointerup",
|
|
1338
|
+
document.addEventListener("pointerup", g);
|
|
1273
1339
|
};
|
|
1274
|
-
return (
|
|
1275
|
-
|
|
1276
|
-
class: U(["baklava-node-palette", { "--open":
|
|
1277
|
-
onContextmenu:
|
|
1340
|
+
return (x, f) => (i(), r(z, null, [
|
|
1341
|
+
l("div", {
|
|
1342
|
+
class: U(["baklava-node-palette", { "--open": y(e).settings.palette.enabled }]),
|
|
1343
|
+
onContextmenu: f[1] || (f[1] = P(() => {
|
|
1278
1344
|
}, ["stop", "prevent"]))
|
|
1279
1345
|
}, [
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
"onUpdate:modelValue":
|
|
1346
|
+
l("div", Ws, [
|
|
1347
|
+
ie(l("input", {
|
|
1348
|
+
"onUpdate:modelValue": f[0] || (f[0] = (g) => u.value = g),
|
|
1283
1349
|
type: "text",
|
|
1284
1350
|
class: "baklava-input",
|
|
1285
1351
|
title: "Filter nodes",
|
|
1286
|
-
onKeyup:
|
|
1352
|
+
onKeyup: w
|
|
1287
1353
|
}, null, 544), [
|
|
1288
|
-
[
|
|
1354
|
+
[re, u.value]
|
|
1289
1355
|
])
|
|
1290
1356
|
]),
|
|
1291
|
-
(i(!0), r(
|
|
1292
|
-
key:
|
|
1357
|
+
(i(!0), r(z, null, H(w(), (g) => (i(), r("section", {
|
|
1358
|
+
key: g.name
|
|
1293
1359
|
}, [
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
onClick: (
|
|
1360
|
+
g.name !== "default" ? (i(), r("h3", Xs, [
|
|
1361
|
+
l("div", {
|
|
1362
|
+
onClick: (v) => u.value = g.name,
|
|
1297
1363
|
style: { cursor: "pointer" }
|
|
1298
|
-
},
|
|
1299
|
-
|
|
1364
|
+
}, B(g.name), 9, Js),
|
|
1365
|
+
k(g.nodeTypes).length < Object.values(g.nodeTypes).length ? (i(), r("div", Ys, " ( " + B(k(g.nodeTypes).length) + " / " + B(Object.values(g.nodeTypes).length) + " ) ", 1)) : I("", !0)
|
|
1300
1366
|
])) : I("", !0),
|
|
1301
|
-
(i(!0), r(
|
|
1302
|
-
key:
|
|
1303
|
-
type:
|
|
1304
|
-
title:
|
|
1305
|
-
onPointerdown: (
|
|
1367
|
+
(i(!0), r(z, null, H(k(g.nodeTypes), (v) => (i(), S(xe, {
|
|
1368
|
+
key: v.type,
|
|
1369
|
+
type: v.type,
|
|
1370
|
+
title: v.title,
|
|
1371
|
+
onPointerdown: (h) => j(v.type, v)
|
|
1306
1372
|
}, null, 8, ["type", "title", "onPointerdown"]))), 128))
|
|
1307
1373
|
]))), 128))
|
|
1308
1374
|
], 34),
|
|
1309
|
-
|
|
1310
|
-
default:
|
|
1311
|
-
|
|
1375
|
+
V(vt, { name: "fade" }, {
|
|
1376
|
+
default: J(() => [
|
|
1377
|
+
m.value ? (i(), r("div", {
|
|
1312
1378
|
key: 0,
|
|
1313
1379
|
class: "baklava-dragged-node",
|
|
1314
|
-
style:
|
|
1380
|
+
style: ae(O.value)
|
|
1315
1381
|
}, [
|
|
1316
|
-
|
|
1317
|
-
type:
|
|
1318
|
-
title:
|
|
1382
|
+
V(xe, {
|
|
1383
|
+
type: m.value.type,
|
|
1384
|
+
title: m.value.nodeInformation.title
|
|
1319
1385
|
}, null, 8, ["type", "title"])
|
|
1320
1386
|
], 4)) : I("", !0)
|
|
1321
1387
|
]),
|
|
@@ -1323,69 +1389,69 @@ const we = /* @__PURE__ */ S(Es, [["render", Ls]]), Vs = {
|
|
|
1323
1389
|
})
|
|
1324
1390
|
], 64));
|
|
1325
1391
|
}
|
|
1326
|
-
}),
|
|
1392
|
+
}), wn = /* @__PURE__ */ L({
|
|
1327
1393
|
__name: "CodeGraphEditor",
|
|
1328
1394
|
props: {
|
|
1329
1395
|
viewModel: {}
|
|
1330
1396
|
},
|
|
1331
|
-
setup(
|
|
1332
|
-
const t =
|
|
1333
|
-
return
|
|
1397
|
+
setup(s) {
|
|
1398
|
+
const t = Me(s, "viewModel"), n = (o) => o.events.update.emit(null);
|
|
1399
|
+
return oe(() => {
|
|
1334
1400
|
t.value.subscribe(), t.value.engine.start();
|
|
1335
|
-
}),
|
|
1401
|
+
}), mt(() => {
|
|
1336
1402
|
t.value.unsubscribe(), t.value.engine.stop();
|
|
1337
|
-
}), (o, a) => (i(),
|
|
1338
|
-
palette:
|
|
1339
|
-
|
|
1403
|
+
}), (o, a) => (i(), S(y(ot), { "view-model": t.value }, {
|
|
1404
|
+
palette: J(() => [
|
|
1405
|
+
V(qs)
|
|
1340
1406
|
]),
|
|
1341
|
-
node:
|
|
1342
|
-
|
|
1343
|
-
onUpdate: (
|
|
1407
|
+
node: J((d) => [
|
|
1408
|
+
V(Ss, bt(d, {
|
|
1409
|
+
onUpdate: (u) => n(d.node)
|
|
1344
1410
|
}), null, 16, ["onUpdate"])
|
|
1345
1411
|
]),
|
|
1346
|
-
sidebar:
|
|
1347
|
-
|
|
1412
|
+
sidebar: J((d) => [
|
|
1413
|
+
V(Rs, ft(gt(d)), null, 16)
|
|
1348
1414
|
]),
|
|
1349
1415
|
_: 1
|
|
1350
1416
|
}, 8, ["view-model"]));
|
|
1351
1417
|
}
|
|
1352
|
-
}),
|
|
1418
|
+
}), Qs = (s) => {
|
|
1353
1419
|
const e = "TOGGLE_PALETTE";
|
|
1354
|
-
|
|
1355
|
-
execute: () =>
|
|
1420
|
+
s.commandHandler.registerCommand(e, {
|
|
1421
|
+
execute: () => s.settings.palette.enabled = !s.settings.palette.enabled,
|
|
1356
1422
|
canExecute: () => !0
|
|
1357
1423
|
});
|
|
1358
1424
|
const t = "CLEAR_ALL";
|
|
1359
|
-
|
|
1360
|
-
execute: () =>
|
|
1361
|
-
canExecute: () =>
|
|
1425
|
+
s.commandHandler.registerCommand(t, {
|
|
1426
|
+
execute: () => s.code.clear(),
|
|
1427
|
+
canExecute: () => s.displayedGraph.nodes.length > 0
|
|
1362
1428
|
});
|
|
1363
|
-
const
|
|
1364
|
-
|
|
1365
|
-
execute: () =>
|
|
1366
|
-
canExecute: () =>
|
|
1367
|
-
}),
|
|
1429
|
+
const n = "TOGGLE_MINIMAP";
|
|
1430
|
+
s.commandHandler.registerCommand(n, {
|
|
1431
|
+
execute: () => s.settings.enableMinimap = !s.settings.enableMinimap,
|
|
1432
|
+
canExecute: () => s.displayedGraph.nodes.length > 1
|
|
1433
|
+
}), s.settings.toolbar.commands = [
|
|
1368
1434
|
{
|
|
1369
1435
|
command: e,
|
|
1370
1436
|
title: "Toggle palette",
|
|
1371
1437
|
// Tooltip text
|
|
1372
|
-
icon:
|
|
1438
|
+
icon: _(() => s.settings.palette.enabled ? Ht : Xt)
|
|
1373
1439
|
},
|
|
1374
|
-
...
|
|
1440
|
+
...at,
|
|
1375
1441
|
{
|
|
1376
1442
|
command: t,
|
|
1377
1443
|
title: "Clear all",
|
|
1378
1444
|
// Tooltip text
|
|
1379
|
-
icon:
|
|
1445
|
+
icon: ws
|
|
1380
1446
|
},
|
|
1381
1447
|
{
|
|
1382
|
-
command:
|
|
1448
|
+
command: n,
|
|
1383
1449
|
title: "Toggle minimap",
|
|
1384
1450
|
// Tooltip text
|
|
1385
|
-
icon:
|
|
1451
|
+
icon: _(() => s.settings.enableMinimap ? hs : ds)
|
|
1386
1452
|
}
|
|
1387
1453
|
];
|
|
1388
|
-
},
|
|
1454
|
+
}, X = {
|
|
1389
1455
|
enableMinimap: !1,
|
|
1390
1456
|
toolbar: {
|
|
1391
1457
|
enabled: !0
|
|
@@ -1400,74 +1466,72 @@ const we = /* @__PURE__ */ S(Es, [["render", Ls]]), Vs = {
|
|
|
1400
1466
|
},
|
|
1401
1467
|
displayValueOnHover: !1
|
|
1402
1468
|
};
|
|
1403
|
-
function
|
|
1404
|
-
const e =
|
|
1405
|
-
e.code =
|
|
1469
|
+
function kn(s) {
|
|
1470
|
+
const e = it(s?.existingEditor);
|
|
1471
|
+
e.code = s?.code ? new s.code(e) : new Ot(e), Qs(e);
|
|
1406
1472
|
const t = {};
|
|
1407
|
-
return Object.keys(
|
|
1408
|
-
t[
|
|
1409
|
-
}), e.settings =
|
|
1473
|
+
return Object.keys(X).forEach((n) => {
|
|
1474
|
+
t[n] = typeof X[n] == "object" ? { ...e.settings[n], ...X[n] } : X[n];
|
|
1475
|
+
}), e.settings = R({ ...e.settings, ...t }), e.settings.nodes.defaultWidth = 350, e.state = R({
|
|
1410
1476
|
modules: {},
|
|
1411
1477
|
token: null
|
|
1412
|
-
}), e.engine = new
|
|
1478
|
+
}), e.engine = new rt(e.editor), e.subscribe = () => {
|
|
1413
1479
|
e.state.token && e.unsubscribe();
|
|
1414
|
-
const
|
|
1415
|
-
e.displayedGraph.events.addNode.subscribe(
|
|
1416
|
-
e.engine.pause(), e.code && (e.code.onCodeUpdate(), e.code.sortNodes()), e.engine.resume();
|
|
1417
|
-
}), e.engine.events.beforeNodeCalculation.subscribe(
|
|
1480
|
+
const n = Symbol();
|
|
1481
|
+
e.displayedGraph.events.addNode.subscribe(n, (o) => o.code = e.code), e.engine.events.beforeRun.subscribe(n, () => {
|
|
1482
|
+
e.engine.pause(), e.code && (e.code.onCodeUpdate(), e.code.sortNodes(), e.code.updateCodeTemplates(), e.code.resetInputInterfaceScript()), e.engine.resume();
|
|
1483
|
+
}), e.engine.events.beforeNodeCalculation.subscribe(n, (o) => {
|
|
1418
1484
|
e.engine.pause();
|
|
1419
1485
|
const a = o.node;
|
|
1420
|
-
a.isCodeNode && (a.updateOutputVariableName(), a.
|
|
1421
|
-
}), e.engine.events.afterRun.subscribe(
|
|
1422
|
-
e.engine.pause(),
|
|
1423
|
-
}), e.state.token =
|
|
1486
|
+
a.isCodeNode && (a.updateOutputVariableName(), a.updateConnectedInputInterfaces()), e.engine.resume();
|
|
1487
|
+
}), e.engine.events.afterRun.subscribe(n, (o) => {
|
|
1488
|
+
e.engine.pause(), lt(o, e.editor), e.code && (e.code.renderNodeCodes(), e.code.renderCode()), e.engine.resume();
|
|
1489
|
+
}), e.state.token = n;
|
|
1424
1490
|
}, e.unsubscribe = () => {
|
|
1425
1491
|
if (!e.state.token) return;
|
|
1426
|
-
const
|
|
1427
|
-
e.displayedGraph.events.addNode.unsubscribe(
|
|
1492
|
+
const n = e.state.token;
|
|
1493
|
+
e.displayedGraph.events.addNode.unsubscribe(n), e.engine.events.beforeRun.unsubscribe(n), e.engine.events.afterRun.unsubscribe(n), e.state.token = null;
|
|
1428
1494
|
}, e;
|
|
1429
1495
|
}
|
|
1430
1496
|
export {
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
rn as getPositionAtColumn,
|
|
1463
|
-
dn as getPositionBeforeNode,
|
|
1464
|
-
xt as listType,
|
|
1497
|
+
kt as AbstractCodeNode,
|
|
1498
|
+
rn as CheckboxInterface,
|
|
1499
|
+
In as CheckboxInterfaceComponent,
|
|
1500
|
+
Ot as Code,
|
|
1501
|
+
wn as CodeGraphEditor,
|
|
1502
|
+
$e as CodeNode,
|
|
1503
|
+
W as CodeNodeInputInterface,
|
|
1504
|
+
D as CodeNodeInterface,
|
|
1505
|
+
Mt as CodeNodeOutputInterface,
|
|
1506
|
+
X as DEFAULT_SETTINGS,
|
|
1507
|
+
$t as DynamicCodeNode,
|
|
1508
|
+
ln as IntegerInterface,
|
|
1509
|
+
dn as ListInputInterface,
|
|
1510
|
+
un as NumberInterface,
|
|
1511
|
+
Nn as NumberInterfaceComponent,
|
|
1512
|
+
cn as SelectInterface,
|
|
1513
|
+
pn as SliderInterface,
|
|
1514
|
+
hn as TextInputInterface,
|
|
1515
|
+
vn as TextareaInputInterface,
|
|
1516
|
+
mn as TupleInputInterface,
|
|
1517
|
+
an as addDefaultInterfaceTypes,
|
|
1518
|
+
Qs as addToolbarCommands,
|
|
1519
|
+
Te as booleanType,
|
|
1520
|
+
fn as defineCodeNode,
|
|
1521
|
+
gn as defineDynamicCodeNode,
|
|
1522
|
+
Nt as dictType,
|
|
1523
|
+
xt as formatInputs,
|
|
1524
|
+
te as getCodeNodes,
|
|
1525
|
+
bn as getPositionAtColumn,
|
|
1526
|
+
yn as getPositionBeforeNode,
|
|
1527
|
+
Ee as listType,
|
|
1465
1528
|
Oe as loadNodeState,
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1529
|
+
A as nodeType,
|
|
1530
|
+
de as numberType,
|
|
1531
|
+
Ct as saveNodeState,
|
|
1532
|
+
on as setOptional,
|
|
1533
|
+
ue as stringType,
|
|
1534
|
+
_n as transferCodeScript,
|
|
1535
|
+
Se as tupleType,
|
|
1536
|
+
kn as useCodeGraph
|
|
1473
1537
|
};
|