@babsey/code-graph 0.0.7 → 0.0.9
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 -37
- package/dist/code-graph.js +869 -1265
- package/dist/code-graph.umd.cjs +1 -1833
- package/dist/lib/index.d.ts +0 -1
- package/package.json +2 -3
package/dist/code-graph.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import { AbstractNode, NodeInterfaceType, NodeInterface, ButtonInterfaceComponent, CheckboxInterfaceComponent, IntegerInterfaceComponent, NumberInterfaceComponent, SelectInterfaceComponent, SliderInterfaceComponent, TextInputInterfaceComponent, TextareaInputInterfaceComponent, setType, allowMultipleConnections, IntegerInterface as
|
|
2
|
-
import { ButtonInterfaceComponent as
|
|
3
|
-
import
|
|
4
|
-
import { reactive, defineComponent, createElementBlock, openBlock, toDisplayString, markRaw
|
|
5
|
-
import
|
|
6
|
-
import { v4 } from "uuid";
|
|
7
|
-
import { usePointer } from "@vueuse/core";
|
|
8
|
-
class
|
|
1
|
+
import { AbstractNode as Be, NodeInterfaceType as P, NodeInterface as Ve, ButtonInterfaceComponent as Le, CheckboxInterfaceComponent as Ge, IntegerInterfaceComponent as Ue, NumberInterfaceComponent as je, SelectInterfaceComponent as Re, SliderInterfaceComponent as Pe, TextInputInterfaceComponent as ge, TextareaInputInterfaceComponent as De, setType as j, allowMultipleConnections as X, IntegerInterface as Ae, TextInputInterface as He, displayInSidebar as Fe, sortTopologically as We, useViewModel as H, useTemporaryConnection as Xe, Components as ve, useGraph as K, GRAPH_NODE_TYPE_PREFIX as J, useTransform as Ye, useNodeCategories as Je, BaklavaEditor as qe, DEFAULT_TOOLBAR_COMMANDS as Qe, useBaklava as Ze, DependencyEngine as Ke, applyResult as et } from "baklavajs";
|
|
2
|
+
import { ButtonInterfaceComponent as an, CheckboxInterfaceComponent as rn, IntegerInterfaceComponent as ln, NumberInterfaceComponent as dn, SelectInterfaceComponent as un, SliderInterfaceComponent as cn, TextInputInterfaceComponent as pn, TextareaInputInterfaceComponent as hn } from "baklavajs";
|
|
3
|
+
import be from "mustache";
|
|
4
|
+
import { reactive as R, defineComponent as G, createElementBlock as r, openBlock as i, toDisplayString as L, markRaw as $, ref as E, computed as f, onMounted as ee, onUpdated as _e, normalizeClass as U, createCommentVNode as N, createElementVNode as l, unref as _, renderSlot as q, createStaticVNode as te, onBeforeUnmount as tt, normalizeStyle as se, withModifiers as D, createBlock as V, withDirectives as ne, Fragment as T, createTextVNode as st, createVNode as S, withKeys as Q, vModelText as oe, renderList as A, nextTick as nt, toRef as ye, resolveDynamicComponent as ot, inject as at, Transition as it, withCtx as W, onUnmounted as rt, normalizeProps as lt, guardReactiveProps as dt, mergeProps as ut } from "vue";
|
|
5
|
+
import ct from "toposort";
|
|
6
|
+
import { v4 as pt } from "uuid";
|
|
7
|
+
import { usePointer as ht } from "@vueuse/core";
|
|
8
|
+
class vt extends Be {
|
|
9
9
|
state;
|
|
10
10
|
code;
|
|
11
|
-
isCodeNode =
|
|
11
|
+
isCodeNode = !0;
|
|
12
12
|
inputs = {};
|
|
13
13
|
outputs = {};
|
|
14
14
|
constructor() {
|
|
15
|
-
super()
|
|
16
|
-
this.initializeIo();
|
|
17
|
-
this.width = 400;
|
|
18
|
-
this.twoColumn = true;
|
|
19
|
-
this.state = reactive({
|
|
15
|
+
super(), this.initializeIo(), this.width = 400, this.twoColumn = !0, this.state = R({
|
|
20
16
|
codeTemplate: "{{ &outputs.code }}",
|
|
21
|
-
hidden:
|
|
22
|
-
integrated:
|
|
17
|
+
hidden: !1,
|
|
18
|
+
integrated: !1,
|
|
23
19
|
modules: [],
|
|
24
20
|
script: "",
|
|
25
21
|
variableName: ""
|
|
@@ -29,7 +25,7 @@ class AbstractCodeNode extends AbstractNode {
|
|
|
29
25
|
return this.state.codeTemplate;
|
|
30
26
|
}
|
|
31
27
|
get idx() {
|
|
32
|
-
return this.code?.codeNodes.filter((
|
|
28
|
+
return this.code?.codeNodes.filter((e) => !e.state.integrated).indexOf(this) ?? -1;
|
|
33
29
|
}
|
|
34
30
|
get idxByVariableNames() {
|
|
35
31
|
return this.code?.getNodesBySameVariableNames(this.state.variableName).indexOf(this) ?? -1;
|
|
@@ -48,48 +44,43 @@ class AbstractCodeNode extends AbstractNode {
|
|
|
48
44
|
* @param type inputs or outputs
|
|
49
45
|
* @returns code node instances
|
|
50
46
|
*/
|
|
51
|
-
getConnectedNodes(
|
|
52
|
-
let
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
|
|
47
|
+
getConnectedNodes(e) {
|
|
48
|
+
let t = [];
|
|
49
|
+
if (e !== "inputs") {
|
|
50
|
+
const s = this.graph?.connections.filter((n) => n.from.name !== "_node").filter((n) => n.from.nodeId === this.id).map((n) => n.to.nodeId);
|
|
51
|
+
s && (t = t.concat(s));
|
|
56
52
|
}
|
|
57
|
-
if (
|
|
58
|
-
const
|
|
59
|
-
|
|
53
|
+
if (e !== "outputs") {
|
|
54
|
+
const s = this.graph?.connections.filter((n) => n.from.name !== "_node").filter((n) => n.to.nodeId === this.id).map((n) => n.from.nodeId);
|
|
55
|
+
s && (t = t.concat(s));
|
|
60
56
|
}
|
|
61
|
-
|
|
62
|
-
return nodeIds.map((nodeId) => this.graph?.findNodeById(nodeId));
|
|
57
|
+
return !t || t.length == 0 ? [] : t.map((s) => this.graph?.findNodeById(s));
|
|
63
58
|
}
|
|
64
|
-
registerCode(
|
|
65
|
-
this.code =
|
|
59
|
+
registerCode(e) {
|
|
60
|
+
this.code = e;
|
|
66
61
|
}
|
|
67
62
|
/**
|
|
68
63
|
* Render code of this node.
|
|
69
64
|
*/
|
|
70
65
|
renderCode() {
|
|
71
|
-
const
|
|
72
|
-
Object.keys(this.inputs).forEach((
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
if (intf && intf.state) inputs[intfKey] = intf.state.script.length > 0 ? intf.state.script : value;
|
|
66
|
+
const e = {};
|
|
67
|
+
Object.keys(this.inputs).forEach((s) => {
|
|
68
|
+
if (s === "_node") return;
|
|
69
|
+
const n = this.inputs[s], a = n.isString ? `'${n.value}'` : n.value;
|
|
70
|
+
n && n.state && (e[s] = n.state.script.length > 0 ? n.state.script : a);
|
|
77
71
|
});
|
|
78
|
-
const
|
|
79
|
-
Object.keys(this.outputs).forEach((
|
|
80
|
-
if (
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
this.state.script = mustache.render(this.state.codeTemplate, { inputs, outputs });
|
|
86
|
-
if (this.outputs.code) this.outputs.code.state.script = this.state.script;
|
|
72
|
+
const t = {};
|
|
73
|
+
Object.keys(this.outputs).forEach((s) => {
|
|
74
|
+
if (s === "_node") return;
|
|
75
|
+
const n = this.outputs[s], a = n.isString ? `'${n.value}'` : n.value;
|
|
76
|
+
n && n.state && (t[s] = a);
|
|
77
|
+
}), this.state.script = be.render(this.state.codeTemplate, { inputs: e, outputs: t }), this.outputs.code && (this.outputs.code.state.script = this.state.script);
|
|
87
78
|
}
|
|
88
79
|
updateOutputVariableName() {
|
|
89
|
-
|
|
80
|
+
this.outputs.code && (this.outputs.code.name = this.variableName);
|
|
90
81
|
}
|
|
91
82
|
}
|
|
92
|
-
class
|
|
83
|
+
class we extends vt {
|
|
93
84
|
/**
|
|
94
85
|
* The default implementation does nothing.
|
|
95
86
|
* Overwrite this method to do calculation.
|
|
@@ -98,89 +89,63 @@ class CodeNode extends AbstractCodeNode {
|
|
|
98
89
|
* @return Values for output interfaces
|
|
99
90
|
*/
|
|
100
91
|
calculate;
|
|
101
|
-
load(
|
|
102
|
-
super.load(
|
|
103
|
-
loadNodeState(this.graph, state);
|
|
92
|
+
load(e) {
|
|
93
|
+
super.load(e), xe(this.graph, e);
|
|
104
94
|
}
|
|
105
95
|
save() {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this.state.modules.push(modules2.slice(0, modules2.length - 1).join("."));
|
|
96
|
+
const e = super.save();
|
|
97
|
+
return mt(this.graph, e), e;
|
|
98
|
+
}
|
|
99
|
+
updateModules(e) {
|
|
100
|
+
if (e)
|
|
101
|
+
this.state.modules = e;
|
|
102
|
+
else if (this.type.includes(".")) {
|
|
103
|
+
const t = this.type.split(".");
|
|
104
|
+
this.state.modules.push(t.slice(0, t.length - 1).join("."));
|
|
116
105
|
}
|
|
117
106
|
}
|
|
118
107
|
}
|
|
119
|
-
const
|
|
120
|
-
if (!
|
|
121
|
-
const
|
|
122
|
-
if (!
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
Object.entries(nodeState.inputs).forEach(([inputKey, inputItem]) => {
|
|
130
|
-
if (inputKey === "_node") return;
|
|
131
|
-
if (codeNode.inputs[inputKey]) codeNode.inputs[inputKey].hidden = inputItem.hidden;
|
|
132
|
-
});
|
|
133
|
-
Object.entries(nodeState.outputs).forEach(([outputKey, outputItem]) => {
|
|
134
|
-
if (outputKey === "_node") return;
|
|
135
|
-
if (codeNode.outputs[outputKey]) codeNode.outputs[outputKey].hidden = outputItem.hidden;
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
const saveNodeState = (graph, nodeState) => {
|
|
139
|
-
if (!graph) return;
|
|
140
|
-
const node = graph.findNodeById(nodeState.id);
|
|
141
|
-
if (!node || node.subgraph) return;
|
|
142
|
-
const codeNode = node;
|
|
143
|
-
if (codeNode.state) {
|
|
144
|
-
nodeState.integrated = codeNode.state.integrated;
|
|
145
|
-
nodeState.modules = codeNode.state.modules;
|
|
146
|
-
}
|
|
147
|
-
Object.entries(nodeState.inputs).forEach(([inputKey, inputItem]) => {
|
|
148
|
-
if (inputKey === "_node") return;
|
|
149
|
-
if (codeNode.inputs[inputKey]) inputItem.hidden = codeNode.inputs[inputKey].hidden;
|
|
108
|
+
const xe = (o, e) => {
|
|
109
|
+
if (!o) return;
|
|
110
|
+
const t = o.findNodeById(e.id);
|
|
111
|
+
if (!t || t.subgraph) return;
|
|
112
|
+
const s = t;
|
|
113
|
+
s.state && (s.state.integrated = e.integrated, s.state.modules = e.modules, s.state.props = e.props), Object.entries(e.inputs).forEach(([n, a]) => {
|
|
114
|
+
n !== "_node" && s.inputs[n] && (s.inputs[n].hidden = a.hidden);
|
|
115
|
+
}), Object.entries(e.outputs).forEach(([n, a]) => {
|
|
116
|
+
n !== "_node" && s.outputs[n] && (s.outputs[n].hidden = a.hidden);
|
|
150
117
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
118
|
+
}, mt = (o, e) => {
|
|
119
|
+
if (!o) return;
|
|
120
|
+
const t = o.findNodeById(e.id);
|
|
121
|
+
if (!t || t.subgraph) return;
|
|
122
|
+
const s = t;
|
|
123
|
+
s.state && (e.integrated = s.state.integrated, e.modules = s.state.modules), Object.entries(e.inputs).forEach(([n, a]) => {
|
|
124
|
+
n !== "_node" && s.inputs[n] && (a.hidden = s.inputs[n].hidden);
|
|
125
|
+
}), Object.entries(e.outputs).forEach(([n, a]) => {
|
|
126
|
+
n !== "_node" && s.outputs[n] && (a.hidden = s.outputs[n].hidden);
|
|
154
127
|
});
|
|
155
128
|
};
|
|
156
|
-
new
|
|
157
|
-
new
|
|
158
|
-
new
|
|
159
|
-
const
|
|
160
|
-
const numberType = new NodeInterfaceType("number");
|
|
161
|
-
const stringType = new NodeInterfaceType("string");
|
|
162
|
-
const _hoisted_1$f = ["title"];
|
|
163
|
-
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
129
|
+
new P("boolean");
|
|
130
|
+
new P("dict");
|
|
131
|
+
new P("list");
|
|
132
|
+
const Y = new P("node"), ft = new P("number"), gt = new P("string"), bt = ["title"], ae = /* @__PURE__ */ G({
|
|
164
133
|
__name: "CodeNodeInterface",
|
|
165
134
|
props: {
|
|
166
135
|
intf: {}
|
|
167
136
|
},
|
|
168
|
-
setup(
|
|
169
|
-
return (
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}, toDisplayString(_ctx.intf.name), 9, _hoisted_1$f);
|
|
173
|
-
};
|
|
137
|
+
setup(o) {
|
|
138
|
+
return (e, t) => (i(), r("div", {
|
|
139
|
+
title: e.intf.state?.script
|
|
140
|
+
}, L(e.intf.name), 9, bt));
|
|
174
141
|
}
|
|
175
142
|
});
|
|
176
|
-
class
|
|
177
|
-
optional =
|
|
143
|
+
class M extends Ve {
|
|
144
|
+
optional = !1;
|
|
178
145
|
code;
|
|
179
146
|
state;
|
|
180
|
-
constructor(
|
|
181
|
-
super(
|
|
182
|
-
this.setComponent(markRaw(_sfc_main$g));
|
|
183
|
-
this.state = reactive({
|
|
147
|
+
constructor(e, t) {
|
|
148
|
+
super(e, t), this.setComponent($(ae)), this.state = R({
|
|
184
149
|
script: ""
|
|
185
150
|
});
|
|
186
151
|
}
|
|
@@ -195,48 +160,42 @@ class CodeNodeInterface extends NodeInterface {
|
|
|
195
160
|
// if (this.name !== '_node') this.setHidden(false);
|
|
196
161
|
// }
|
|
197
162
|
}
|
|
198
|
-
class
|
|
199
|
-
component =
|
|
163
|
+
class Ps extends M {
|
|
164
|
+
component = $(Le);
|
|
200
165
|
callback;
|
|
201
|
-
constructor(
|
|
202
|
-
super(
|
|
203
|
-
this.callback = callback;
|
|
204
|
-
this.setPort(false);
|
|
166
|
+
constructor(e, t) {
|
|
167
|
+
super(e, void 0), this.callback = t, this.setPort(!1);
|
|
205
168
|
}
|
|
206
169
|
}
|
|
207
|
-
class
|
|
208
|
-
component =
|
|
170
|
+
class Ds extends M {
|
|
171
|
+
component = $(Ge);
|
|
209
172
|
}
|
|
210
|
-
class
|
|
173
|
+
class ie extends M {
|
|
211
174
|
min;
|
|
212
175
|
max;
|
|
213
|
-
constructor(
|
|
214
|
-
super(
|
|
215
|
-
this.min = min;
|
|
216
|
-
this.max = max;
|
|
176
|
+
constructor(e, t, s, n) {
|
|
177
|
+
super(e, t), this.min = s, this.max = n;
|
|
217
178
|
}
|
|
218
|
-
validate(
|
|
219
|
-
return (this.min === void 0 ||
|
|
179
|
+
validate(e) {
|
|
180
|
+
return (this.min === void 0 || e >= this.min) && (this.max === void 0 || e <= this.max);
|
|
220
181
|
}
|
|
221
182
|
}
|
|
222
|
-
class
|
|
223
|
-
component =
|
|
224
|
-
validate(
|
|
225
|
-
return Number.isInteger(
|
|
183
|
+
class As extends ie {
|
|
184
|
+
component = $(Ue);
|
|
185
|
+
validate(e) {
|
|
186
|
+
return Number.isInteger(e) && super.validate(e);
|
|
226
187
|
}
|
|
227
188
|
}
|
|
228
|
-
class
|
|
229
|
-
isCodeInput =
|
|
230
|
-
constructor(
|
|
231
|
-
super(
|
|
232
|
-
this.setComponent(markRaw(_sfc_main$g));
|
|
189
|
+
class Hs extends M {
|
|
190
|
+
isCodeInput = !0;
|
|
191
|
+
constructor(e = "", t) {
|
|
192
|
+
super(e, t), this.setComponent($(ae));
|
|
233
193
|
}
|
|
234
194
|
}
|
|
235
|
-
class
|
|
236
|
-
isCodeOutput =
|
|
237
|
-
constructor(
|
|
238
|
-
super(
|
|
239
|
-
this.setComponent(markRaw(_sfc_main$g));
|
|
195
|
+
class _t extends M {
|
|
196
|
+
isCodeOutput = !0;
|
|
197
|
+
constructor(e = "", t = "") {
|
|
198
|
+
super(e, t), this.setComponent($(ae));
|
|
240
199
|
}
|
|
241
200
|
get script() {
|
|
242
201
|
return this.state.script;
|
|
@@ -244,95 +203,77 @@ class CodeOutputInterface extends CodeNodeInterface {
|
|
|
244
203
|
get value() {
|
|
245
204
|
return super.value;
|
|
246
205
|
}
|
|
247
|
-
set value(
|
|
248
|
-
super.value = value;
|
|
249
|
-
this.state.script = this.name.length > 0 ? this.name : this.value;
|
|
206
|
+
set value(e) {
|
|
207
|
+
super.value = e, this.state.script = this.name.length > 0 ? this.name : this.value;
|
|
250
208
|
}
|
|
251
209
|
}
|
|
252
|
-
class
|
|
253
|
-
component =
|
|
210
|
+
class Fs extends ie {
|
|
211
|
+
component = $(je);
|
|
254
212
|
}
|
|
255
|
-
class
|
|
256
|
-
component =
|
|
213
|
+
class Ws extends M {
|
|
214
|
+
component = $(Re);
|
|
257
215
|
items;
|
|
258
|
-
constructor(
|
|
259
|
-
super(
|
|
260
|
-
this.items = items;
|
|
216
|
+
constructor(e, t, s) {
|
|
217
|
+
super(e, t), this.items = s;
|
|
261
218
|
}
|
|
262
219
|
}
|
|
263
|
-
class
|
|
264
|
-
component =
|
|
220
|
+
class Xs extends ie {
|
|
221
|
+
component = $(Pe);
|
|
265
222
|
min;
|
|
266
223
|
max;
|
|
267
|
-
constructor(
|
|
268
|
-
super(
|
|
269
|
-
this.min = min;
|
|
270
|
-
this.max = max;
|
|
224
|
+
constructor(e, t, s, n) {
|
|
225
|
+
super(e, t, s, n), this.min = s, this.max = n;
|
|
271
226
|
}
|
|
272
227
|
}
|
|
273
|
-
class
|
|
274
|
-
component =
|
|
275
|
-
constructor(
|
|
276
|
-
super(
|
|
277
|
-
this.setPort(false);
|
|
228
|
+
class Ys extends M {
|
|
229
|
+
component = $(ge);
|
|
230
|
+
constructor(e, t) {
|
|
231
|
+
super(e, t), this.setPort(!1);
|
|
278
232
|
}
|
|
279
233
|
}
|
|
280
|
-
class
|
|
281
|
-
isString =
|
|
282
|
-
component =
|
|
234
|
+
class Js extends M {
|
|
235
|
+
isString = !0;
|
|
236
|
+
component = $(ge);
|
|
283
237
|
}
|
|
284
|
-
class
|
|
285
|
-
component =
|
|
238
|
+
class qs extends M {
|
|
239
|
+
component = $(De);
|
|
286
240
|
}
|
|
287
|
-
function
|
|
288
|
-
return class extends
|
|
289
|
-
type =
|
|
241
|
+
function Qs(o) {
|
|
242
|
+
return class extends we {
|
|
243
|
+
type = o.type;
|
|
290
244
|
inputs = {};
|
|
291
245
|
outputs = {};
|
|
292
246
|
constructor() {
|
|
293
|
-
super()
|
|
294
|
-
this._title = definition.title ?? definition.type;
|
|
295
|
-
this.updateModules(definition.modules);
|
|
296
|
-
if (definition.codeTemplate) this.state.codeTemplate = definition.codeTemplate(this);
|
|
297
|
-
if (definition.variableName) this.state.variableName = definition.variableName;
|
|
298
|
-
this.addInput(
|
|
247
|
+
super(), this._title = o.title ?? o.type, this.updateModules(o.modules), o.codeTemplate && (this.state.codeTemplate = o.codeTemplate(this)), o.variableName && (this.state.variableName = o.variableName), this.addInput(
|
|
299
248
|
"_node",
|
|
300
|
-
new
|
|
301
|
-
)
|
|
302
|
-
this.addOutput(
|
|
249
|
+
new M("", []).use(j, Y).use(X).setHidden(!0)
|
|
250
|
+
), this.addOutput(
|
|
303
251
|
"_node",
|
|
304
|
-
new
|
|
305
|
-
);
|
|
306
|
-
this.executeFactory("input", definition.inputs);
|
|
307
|
-
this.executeFactory("output", definition.outputs);
|
|
308
|
-
definition.onCreate?.call(this);
|
|
252
|
+
new M("", []).use(j, Y).use(X).setHidden(!0)
|
|
253
|
+
), this.executeFactory("input", o.inputs), this.executeFactory("output", o.outputs), o.onCreate?.call(this);
|
|
309
254
|
}
|
|
310
|
-
calculate =
|
|
311
|
-
...
|
|
255
|
+
calculate = o.calculate ? (e, t) => ({
|
|
256
|
+
...o.calculate.call(this, e, t),
|
|
312
257
|
_node: null
|
|
313
258
|
}) : void 0;
|
|
314
259
|
onPlaced() {
|
|
315
|
-
|
|
260
|
+
o.onPlaced?.call(this);
|
|
316
261
|
}
|
|
317
262
|
onDestroy() {
|
|
318
|
-
|
|
263
|
+
o.onDestroy?.call(this);
|
|
319
264
|
}
|
|
320
265
|
onCodeUpdate() {
|
|
321
|
-
|
|
266
|
+
o.onCodeUpdate?.call(this);
|
|
322
267
|
}
|
|
323
|
-
executeFactory(
|
|
324
|
-
Object.keys(
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
this.addInput(k, intf);
|
|
328
|
-
} else {
|
|
329
|
-
this.addOutput(k, intf);
|
|
330
|
-
}
|
|
268
|
+
executeFactory(e, t) {
|
|
269
|
+
Object.keys(t || {}).forEach((s) => {
|
|
270
|
+
const n = t[s]();
|
|
271
|
+
e === "input" ? this.addInput(s, n) : this.addOutput(s, n);
|
|
331
272
|
});
|
|
332
273
|
}
|
|
333
274
|
};
|
|
334
275
|
}
|
|
335
|
-
class
|
|
276
|
+
class yt extends we {
|
|
336
277
|
/**
|
|
337
278
|
* The default implementation does nothing.
|
|
338
279
|
* Overwrite this method to do calculation.
|
|
@@ -342,169 +283,101 @@ class DynamicCodeNode extends CodeNode {
|
|
|
342
283
|
*/
|
|
343
284
|
calculate;
|
|
344
285
|
}
|
|
345
|
-
function
|
|
346
|
-
return class extends
|
|
347
|
-
type =
|
|
286
|
+
function Zs(o) {
|
|
287
|
+
return class extends yt {
|
|
288
|
+
type = o.type;
|
|
348
289
|
inputs = {};
|
|
349
290
|
outputs = {};
|
|
350
291
|
calculate;
|
|
351
|
-
preventUpdate =
|
|
352
|
-
staticInputKeys = Object.keys(
|
|
353
|
-
staticOutputKeys = Object.keys(
|
|
292
|
+
preventUpdate = !1;
|
|
293
|
+
staticInputKeys = Object.keys(o.inputs ?? {});
|
|
294
|
+
staticOutputKeys = Object.keys(o.outputs ?? {});
|
|
354
295
|
constructor() {
|
|
355
|
-
super()
|
|
356
|
-
this._title = definition.title ?? definition.type;
|
|
357
|
-
this.updateModules(definition.modules);
|
|
358
|
-
if (definition.codeTemplate) this.state.codeTemplate = definition.codeTemplate(this);
|
|
359
|
-
if (definition.variableName) this.state.variableName = definition.variableName;
|
|
360
|
-
this.addInput(
|
|
296
|
+
super(), this._title = o.title ?? o.type, this.updateModules(o.modules), o.codeTemplate && (this.state.codeTemplate = o.codeTemplate(this)), o.variableName && (this.state.variableName = o.variableName), this.addInput(
|
|
361
297
|
"_node",
|
|
362
|
-
new
|
|
363
|
-
)
|
|
364
|
-
this.addOutput(
|
|
298
|
+
new M("", []).use(j, Y).use(X).setHidden(!0)
|
|
299
|
+
), this.addOutput(
|
|
365
300
|
"_node",
|
|
366
|
-
new
|
|
367
|
-
)
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
this.executeFactory("output", definition.outputs);
|
|
372
|
-
if (definition.calculate) {
|
|
373
|
-
this.calculate = (inputs, globalValues) => ({
|
|
374
|
-
...definition.calculate?.call(this, inputs, globalValues),
|
|
375
|
-
_node: null
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
definition.onCreate?.call(this);
|
|
301
|
+
new M("", []).use(j, Y).use(X).setHidden(!0)
|
|
302
|
+
), this.staticInputKeys.push("_node"), this.staticOutputKeys.push("_node"), this.executeFactory("input", o.inputs), this.executeFactory("output", o.outputs), o.calculate && (this.calculate = (e, t) => ({
|
|
303
|
+
...o.calculate?.call(this, e, t),
|
|
304
|
+
_node: null
|
|
305
|
+
})), o.onCreate?.call(this);
|
|
379
306
|
}
|
|
380
307
|
onPlaced() {
|
|
381
|
-
this.events.update.subscribe(this, (
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
this.onUpdate();
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
this.onUpdate();
|
|
388
|
-
definition.onPlaced?.call(this);
|
|
308
|
+
this.events.update.subscribe(this, (e) => {
|
|
309
|
+
e && (e.type === "input" && this.staticInputKeys.includes(e.name) || e.type === "output" && this.staticOutputKeys.includes(e.name)) && this.onUpdate();
|
|
310
|
+
}), this.onUpdate(), o.onPlaced?.call(this);
|
|
389
311
|
}
|
|
390
312
|
onDestroy() {
|
|
391
|
-
|
|
313
|
+
o.onDestroy?.call(this);
|
|
392
314
|
}
|
|
393
315
|
onCodeUpdate() {
|
|
394
|
-
|
|
316
|
+
o.onCodeUpdate?.call(this);
|
|
395
317
|
}
|
|
396
|
-
load(
|
|
397
|
-
this.preventUpdate =
|
|
398
|
-
this.
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
if (
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
this.outputs[k].nodeId = this.id;
|
|
410
|
-
if (k === "_node") continue;
|
|
411
|
-
this.outputs[k].hidden = state.outputs[k].hidden;
|
|
412
|
-
}
|
|
413
|
-
this.preventUpdate = false;
|
|
414
|
-
this.onUpdate();
|
|
415
|
-
this.preventUpdate = true;
|
|
416
|
-
for (const k of Object.keys(state.inputs)) {
|
|
417
|
-
if (this.staticInputKeys.includes(k)) continue;
|
|
418
|
-
if (!this.inputs[k]) {
|
|
419
|
-
const value = state.inputs[k].value;
|
|
420
|
-
let inputInterface;
|
|
421
|
-
if (typeof value == "number") {
|
|
422
|
-
inputInterface = new IntegerInterface$1(k, value).use(setType, numberType);
|
|
423
|
-
} else {
|
|
424
|
-
inputInterface = new TextInputInterface$1(k, JSON.stringify(value)).use(setType, stringType);
|
|
318
|
+
load(e) {
|
|
319
|
+
this.preventUpdate = !0, this.hooks.beforeLoad.execute(e), this.id = e.id, this.title = e.title;
|
|
320
|
+
for (const t of this.staticInputKeys)
|
|
321
|
+
this.inputs[t].load(e.inputs[t]), this.inputs[t].nodeId = this.id, t !== "_node" && (this.inputs[t].hidden = e.inputs[t].hidden);
|
|
322
|
+
for (const t of this.staticOutputKeys)
|
|
323
|
+
this.outputs[t].load(e.outputs[t]), this.outputs[t].nodeId = this.id, t !== "_node" && (this.outputs[t].hidden = e.outputs[t].hidden);
|
|
324
|
+
this.preventUpdate = !1, this.onUpdate(), this.preventUpdate = !0;
|
|
325
|
+
for (const t of Object.keys(e.inputs))
|
|
326
|
+
if (!this.staticInputKeys.includes(t)) {
|
|
327
|
+
if (!this.inputs[t]) {
|
|
328
|
+
const s = e.inputs[t].value;
|
|
329
|
+
let n;
|
|
330
|
+
typeof s == "number" ? n = new Ae(t, s).use(j, ft) : n = new He(t, JSON.stringify(s)).use(j, gt), n.use(Fe, !0), this.addInput(t, n);
|
|
425
331
|
}
|
|
426
|
-
|
|
427
|
-
this.addInput(k, inputInterface);
|
|
428
|
-
}
|
|
429
|
-
if (this.inputs[k]) {
|
|
430
|
-
this.inputs[k].load(state.inputs[k]);
|
|
431
|
-
this.inputs[k].nodeId = this.id;
|
|
332
|
+
this.inputs[t] && (this.inputs[t].load(e.inputs[t]), this.inputs[t].nodeId = this.id);
|
|
432
333
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
if (this.outputs[k]) {
|
|
441
|
-
this.outputs[k].load(state.outputs[k]);
|
|
442
|
-
this.outputs[k].nodeId = this.id;
|
|
334
|
+
for (const t of Object.keys(e.outputs))
|
|
335
|
+
if (!this.staticOutputKeys.includes(t)) {
|
|
336
|
+
if (!this.outputs[t]) {
|
|
337
|
+
const s = new _t(t);
|
|
338
|
+
this.addOutput(t, s);
|
|
339
|
+
}
|
|
340
|
+
this.outputs[t] && (this.outputs[t].load(e.outputs[t]), this.outputs[t].nodeId = this.id);
|
|
443
341
|
}
|
|
444
|
-
|
|
445
|
-
loadNodeState(this.graph, state);
|
|
446
|
-
this.preventUpdate = false;
|
|
447
|
-
this.events.loaded.emit(this);
|
|
342
|
+
xe(this.graph, e), this.preventUpdate = !1, this.events.loaded.emit(this);
|
|
448
343
|
}
|
|
449
344
|
onUpdate() {
|
|
450
345
|
if (this.preventUpdate) return;
|
|
451
|
-
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
const result = definition.onUpdate.call(this, inputValues, outputValues);
|
|
455
|
-
this.updateInterfaces("input", result.inputs ?? {}, result.forceUpdateInputs ?? []);
|
|
456
|
-
this.updateInterfaces("output", result.outputs ?? {}, result.forceUpdateOutputs ?? []);
|
|
457
|
-
if (this.graph) this.graph.activeTransactions--;
|
|
346
|
+
this.graph && this.graph.activeTransactions++;
|
|
347
|
+
const e = this.getStaticValues(this.staticInputKeys, this.inputs), t = this.getStaticValues(this.staticOutputKeys, this.outputs), s = o.onUpdate.call(this, e, t);
|
|
348
|
+
this.updateInterfaces("input", s.inputs ?? {}, s.forceUpdateInputs ?? []), this.updateInterfaces("output", s.outputs ?? {}, s.forceUpdateOutputs ?? []), this.graph && this.graph.activeTransactions--;
|
|
458
349
|
}
|
|
459
|
-
getStaticValues(
|
|
460
|
-
const
|
|
461
|
-
for (const
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
return values;
|
|
350
|
+
getStaticValues(e, t) {
|
|
351
|
+
const s = {};
|
|
352
|
+
for (const n of e)
|
|
353
|
+
s[n] = t[n].value;
|
|
354
|
+
return s;
|
|
465
355
|
}
|
|
466
|
-
updateInterfaces(
|
|
467
|
-
const
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
if (
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
this.removeOutput(k);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
for (const k of Object.keys(newInterfaces)) {
|
|
478
|
-
if (currentInterfaces[k]) continue;
|
|
479
|
-
const intf = newInterfaces[k]();
|
|
480
|
-
if (type === "input") {
|
|
481
|
-
this.addInput(k, intf);
|
|
482
|
-
} else {
|
|
483
|
-
this.addOutput(k, intf);
|
|
484
|
-
}
|
|
356
|
+
updateInterfaces(e, t, s) {
|
|
357
|
+
const n = e === "input" ? this.staticInputKeys : this.staticOutputKeys, a = e === "input" ? this.inputs : this.outputs;
|
|
358
|
+
for (const u of Object.keys(a))
|
|
359
|
+
n.includes(u) || t[u] && !s.includes(u) || (e === "input" ? this.removeInput(u) : this.removeOutput(u));
|
|
360
|
+
for (const u of Object.keys(t)) {
|
|
361
|
+
if (a[u]) continue;
|
|
362
|
+
const d = t[u]();
|
|
363
|
+
e === "input" ? this.addInput(u, d) : this.addOutput(u, d);
|
|
485
364
|
}
|
|
486
365
|
}
|
|
487
|
-
executeFactory(
|
|
488
|
-
Object.keys(
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
this.addInput(k, intf);
|
|
492
|
-
} else {
|
|
493
|
-
this.addOutput(k, intf);
|
|
494
|
-
}
|
|
366
|
+
executeFactory(e, t) {
|
|
367
|
+
Object.keys(t || {}).forEach((s) => {
|
|
368
|
+
const n = t[s]();
|
|
369
|
+
e === "input" ? this.addInput(s, n) : this.addOutput(s, n);
|
|
495
370
|
});
|
|
496
371
|
}
|
|
497
372
|
};
|
|
498
373
|
}
|
|
499
|
-
class
|
|
374
|
+
class wt {
|
|
500
375
|
_id;
|
|
501
376
|
_viewModel;
|
|
502
377
|
_state;
|
|
503
|
-
constructor(
|
|
504
|
-
this._id =
|
|
505
|
-
|
|
506
|
-
this._state = reactive({
|
|
507
|
-
autosort: false,
|
|
378
|
+
constructor(e) {
|
|
379
|
+
this._id = pt(), this._viewModel = e, this._state = R({
|
|
380
|
+
autosort: !1,
|
|
508
381
|
modules: {},
|
|
509
382
|
script: "",
|
|
510
383
|
token: null,
|
|
@@ -512,13 +385,13 @@ class Code {
|
|
|
512
385
|
});
|
|
513
386
|
}
|
|
514
387
|
get codeNodes() {
|
|
515
|
-
return
|
|
388
|
+
return Z(this.graph);
|
|
516
389
|
}
|
|
517
390
|
get connections() {
|
|
518
391
|
return this.graph.connections;
|
|
519
392
|
}
|
|
520
|
-
set connections(
|
|
521
|
-
this.graph._connections =
|
|
393
|
+
set connections(e) {
|
|
394
|
+
this.graph._connections = e;
|
|
522
395
|
}
|
|
523
396
|
get graph() {
|
|
524
397
|
return this.viewModel.displayedGraph;
|
|
@@ -527,26 +400,23 @@ class Code {
|
|
|
527
400
|
return this._id;
|
|
528
401
|
}
|
|
529
402
|
get modules() {
|
|
530
|
-
let
|
|
531
|
-
this.codeNodes.filter((
|
|
532
|
-
|
|
533
|
-
});
|
|
534
|
-
if (!categories) return [];
|
|
535
|
-
categories.sort();
|
|
536
|
-
return Array.from(new Set(categories.map((category) => this.viewModel.state.modules[category])));
|
|
403
|
+
let e = [];
|
|
404
|
+
return this.codeNodes.filter((t) => t.state.modules?.length > 0).forEach((t) => {
|
|
405
|
+
e = e.concat(t.state.modules);
|
|
406
|
+
}), e ? (e.sort(), Array.from(new Set(e.map((t) => this.viewModel.state.modules[t])))) : [];
|
|
537
407
|
}
|
|
538
408
|
get nodeIds() {
|
|
539
|
-
return this.codeNodes.map((
|
|
409
|
+
return this.codeNodes.map((e) => e.id);
|
|
540
410
|
}
|
|
541
411
|
get nodes() {
|
|
542
412
|
return this.graph.nodes;
|
|
543
413
|
}
|
|
544
|
-
set nodes(
|
|
545
|
-
this.graph._nodes =
|
|
414
|
+
set nodes(e) {
|
|
415
|
+
this.graph._nodes = e;
|
|
546
416
|
}
|
|
547
417
|
get scriptedCodeNodes() {
|
|
548
|
-
return
|
|
549
|
-
(
|
|
418
|
+
return Z(this.graph).filter(
|
|
419
|
+
(e) => e.state?.script.length > 0
|
|
550
420
|
);
|
|
551
421
|
}
|
|
552
422
|
get shortId() {
|
|
@@ -559,17 +429,15 @@ class Code {
|
|
|
559
429
|
return this._viewModel;
|
|
560
430
|
}
|
|
561
431
|
get visibleNodes() {
|
|
562
|
-
return this.codeNodes.filter((
|
|
432
|
+
return this.codeNodes.filter((e) => !e.state?.hidden);
|
|
563
433
|
}
|
|
564
434
|
/**
|
|
565
435
|
* Add code node to graph.
|
|
566
436
|
* @param node code node
|
|
567
437
|
* @param props optional
|
|
568
438
|
*/
|
|
569
|
-
addNode(
|
|
570
|
-
|
|
571
|
-
if (props) node.state.props = props;
|
|
572
|
-
return this.graph.addNode(node);
|
|
439
|
+
addNode(e, t) {
|
|
440
|
+
return e.code || (e.code = this), t && (e.state.props = t), this.graph.addNode(e);
|
|
573
441
|
}
|
|
574
442
|
/**
|
|
575
443
|
* Add code node at coordinates.
|
|
@@ -578,40 +446,33 @@ class Code {
|
|
|
578
446
|
* @param props optional
|
|
579
447
|
* @returns code node
|
|
580
448
|
*/
|
|
581
|
-
addNodeAtCoordinates = (
|
|
582
|
-
this.addNode(node, props);
|
|
583
|
-
if (node.position) node.position = position;
|
|
584
|
-
return node;
|
|
585
|
-
};
|
|
449
|
+
addNodeAtCoordinates = (e, t = { x: 0, y: 0 }, s) => (this.addNode(e, s), e.position && (e.position = t), e);
|
|
586
450
|
/**
|
|
587
451
|
* Add connection of code nodes
|
|
588
452
|
* @param from code node interface
|
|
589
453
|
* @param to code node interface
|
|
590
454
|
*/
|
|
591
|
-
addConnection(
|
|
592
|
-
|
|
593
|
-
if (to.name !== "_node") to.hidden = false;
|
|
594
|
-
this.graph.addConnection(from, to);
|
|
455
|
+
addConnection(e, t) {
|
|
456
|
+
e.name !== "_node" && (e.hidden = !1), t.name !== "_node" && (t.hidden = !1), this.graph.addConnection(e, t);
|
|
595
457
|
}
|
|
596
458
|
/**
|
|
597
459
|
* Clear code graph.
|
|
598
460
|
*/
|
|
599
461
|
clear() {
|
|
600
|
-
this.nodes = [];
|
|
601
|
-
this.connections = [];
|
|
462
|
+
this.nodes = [], this.connections = [];
|
|
602
463
|
}
|
|
603
|
-
findNodeById(
|
|
604
|
-
return this.graph.findNodeById(
|
|
464
|
+
findNodeById(e) {
|
|
465
|
+
return this.graph.findNodeById(e);
|
|
605
466
|
}
|
|
606
|
-
findNodeByType(
|
|
607
|
-
return this.codeNodes.find((
|
|
467
|
+
findNodeByType(e) {
|
|
468
|
+
return this.codeNodes.find((t) => t.type === e);
|
|
608
469
|
}
|
|
609
|
-
getNodesBySameType(
|
|
610
|
-
return this.codeNodes.filter((
|
|
470
|
+
getNodesBySameType(e) {
|
|
471
|
+
return this.codeNodes.filter((t) => t.type === e);
|
|
611
472
|
}
|
|
612
|
-
getNodesBySameVariableNames(
|
|
473
|
+
getNodesBySameVariableNames(e) {
|
|
613
474
|
return this.codeNodes.filter(
|
|
614
|
-
(
|
|
475
|
+
(t) => t.state.variableName === e
|
|
615
476
|
);
|
|
616
477
|
}
|
|
617
478
|
/**
|
|
@@ -620,73 +481,68 @@ class Code {
|
|
|
620
481
|
* @param to node interface
|
|
621
482
|
* @returns boolean
|
|
622
483
|
*/
|
|
623
|
-
hasConnection(
|
|
484
|
+
hasConnection(e, t) {
|
|
624
485
|
return this.connections.some(
|
|
625
|
-
(
|
|
486
|
+
(s) => s.from.id === e.id && s.to.id === t.id
|
|
626
487
|
);
|
|
627
488
|
}
|
|
628
489
|
/**
|
|
629
490
|
* Load template from the file.
|
|
630
491
|
*/
|
|
631
|
-
loadTemplate(
|
|
632
|
-
|
|
633
|
-
this._state.template =
|
|
492
|
+
loadTemplate(e) {
|
|
493
|
+
e.then((t) => {
|
|
494
|
+
this._state.template = t.default ?? "";
|
|
634
495
|
});
|
|
635
496
|
}
|
|
636
497
|
onCodeUpdate() {
|
|
637
|
-
this.codeNodes.forEach((
|
|
498
|
+
this.codeNodes.forEach((e) => e.onCodeUpdate());
|
|
638
499
|
}
|
|
639
500
|
/**
|
|
640
501
|
* Remove connection from the graph
|
|
641
502
|
* @param connection connection between code nodes
|
|
642
503
|
*/
|
|
643
|
-
removeConnection(
|
|
644
|
-
this.graph.removeConnection(
|
|
504
|
+
removeConnection(e) {
|
|
505
|
+
this.graph.removeConnection(e);
|
|
645
506
|
}
|
|
646
507
|
/**
|
|
647
508
|
* Remove node from the graph.
|
|
648
509
|
* @param codeNode code node
|
|
649
510
|
*/
|
|
650
|
-
removeNode(
|
|
651
|
-
this.graph.removeNode(
|
|
511
|
+
removeNode(e) {
|
|
512
|
+
this.graph.removeNode(e);
|
|
652
513
|
}
|
|
653
514
|
/**
|
|
654
515
|
* Render node codes.
|
|
655
516
|
*/
|
|
656
517
|
renderNodeCodes() {
|
|
657
|
-
|
|
658
|
-
this.codeNodes.forEach((node) => node.renderCode());
|
|
518
|
+
this.codeNodes.length !== 0 && this.codeNodes.forEach((e) => e.renderCode());
|
|
659
519
|
}
|
|
660
520
|
/**
|
|
661
521
|
* Render code.
|
|
662
522
|
*/
|
|
663
523
|
renderCode() {
|
|
664
|
-
this.state.script =
|
|
524
|
+
this.state.script = be.render(this.state.template || "", this);
|
|
665
525
|
}
|
|
666
526
|
/**
|
|
667
527
|
* Save code graph.
|
|
668
528
|
* @returns graph state
|
|
669
529
|
*/
|
|
670
530
|
save() {
|
|
671
|
-
|
|
672
|
-
const
|
|
673
|
-
|
|
674
|
-
this.saveNodeStates(editorState.graph.nodes);
|
|
675
|
-
return JSON.parse(JSON.stringify(editorState));
|
|
531
|
+
this.state.autosort && this.sortNodes();
|
|
532
|
+
const e = this.viewModel.editor.save();
|
|
533
|
+
return e.graph.id = this.id, this.saveNodeStates(e.graph.nodes), JSON.parse(JSON.stringify(e));
|
|
676
534
|
}
|
|
677
535
|
/**
|
|
678
536
|
* Save node states.
|
|
679
537
|
* @param nodeStates a list of node state.
|
|
680
538
|
*/
|
|
681
|
-
saveNodeStates(
|
|
682
|
-
|
|
683
|
-
const
|
|
684
|
-
Object.entries(
|
|
685
|
-
|
|
686
|
-
})
|
|
687
|
-
|
|
688
|
-
if (nodeState.outputs && node.outputs[outputKey])
|
|
689
|
-
nodeState.outputs[outputKey].hidden = node.outputs[outputKey].hidden;
|
|
539
|
+
saveNodeStates(e) {
|
|
540
|
+
e.forEach((t, s) => {
|
|
541
|
+
const n = this.nodes[s];
|
|
542
|
+
Object.entries(t.inputs).forEach(([a]) => {
|
|
543
|
+
t.inputs && n.inputs[a] && (t.inputs[a].hidden = n.inputs[a].hidden);
|
|
544
|
+
}), Object.entries(t.outputs).forEach(([a]) => {
|
|
545
|
+
t.outputs && n.outputs[a] && (t.outputs[a].hidden = n.outputs[a].hidden);
|
|
690
546
|
});
|
|
691
547
|
});
|
|
692
548
|
}
|
|
@@ -694,124 +550,85 @@ class Code {
|
|
|
694
550
|
* Sort code nodes.
|
|
695
551
|
*/
|
|
696
552
|
sortNodes() {
|
|
697
|
-
if (this.nodes.length === 0 || this.connections.length === 0)
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
console.warn("Failed to sort nodes.");
|
|
713
|
-
}
|
|
553
|
+
if (!(this.nodes.length === 0 || this.connections.length === 0))
|
|
554
|
+
try {
|
|
555
|
+
const e = this.connections.map((a) => [
|
|
556
|
+
a.to.nodeId,
|
|
557
|
+
a.from.nodeId
|
|
558
|
+
]);
|
|
559
|
+
let t = [...this.nodeIds];
|
|
560
|
+
t.reverse(), t = ct.array(t, e), t.reverse();
|
|
561
|
+
const s = this.graph.nodes.map((a) => a.id).filter((a) => !t.includes(a));
|
|
562
|
+
t = t.concat(s);
|
|
563
|
+
const n = t.map((a) => this.findNodeById(a));
|
|
564
|
+
n && (this.nodes = n);
|
|
565
|
+
} catch {
|
|
566
|
+
console.warn("Failed to sort nodes.");
|
|
567
|
+
}
|
|
714
568
|
}
|
|
715
569
|
updateOutputVariableNames() {
|
|
716
|
-
this.codeNodes.forEach((
|
|
570
|
+
this.codeNodes.forEach((e) => e.updateOutputVariableName());
|
|
717
571
|
}
|
|
718
572
|
}
|
|
719
|
-
const
|
|
720
|
-
let
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
};
|
|
738
|
-
const getPositionBeforeNode = (node) => {
|
|
739
|
-
const position = { ...node.position };
|
|
740
|
-
position.x -= 400;
|
|
741
|
-
position.y += 50;
|
|
742
|
-
return position;
|
|
743
|
-
};
|
|
744
|
-
const transferCodeScript = (graph) => {
|
|
745
|
-
const { calculationOrder, connectionsFromNode } = sortTopologically(graph);
|
|
746
|
-
calculationOrder.forEach((node) => {
|
|
747
|
-
if (!node.isCodeNode) return;
|
|
748
|
-
const codeNode = node;
|
|
749
|
-
if (connectionsFromNode.has(codeNode)) {
|
|
750
|
-
connectionsFromNode.get(codeNode).forEach((c) => {
|
|
751
|
-
if (c.to.state && c.from.script) c.to.state.script = c.from.script;
|
|
752
|
-
});
|
|
753
|
-
}
|
|
573
|
+
const Z = (o) => {
|
|
574
|
+
let e = [];
|
|
575
|
+
return o.nodes.forEach((t) => {
|
|
576
|
+
t.subgraph ? e = e.concat(Z(t.subgraph)) : t.isCodeNode && e.push(t);
|
|
577
|
+
}), e;
|
|
578
|
+
}, Ks = (o = 0, e = 100) => ({
|
|
579
|
+
x: o * 420,
|
|
580
|
+
y: e
|
|
581
|
+
}), en = (o) => {
|
|
582
|
+
const e = { ...o.position };
|
|
583
|
+
return e.x -= 400, e.y += 50, e;
|
|
584
|
+
}, xt = (o) => {
|
|
585
|
+
const { calculationOrder: e, connectionsFromNode: t } = We(o);
|
|
586
|
+
e.forEach((s) => {
|
|
587
|
+
if (!s.isCodeNode) return;
|
|
588
|
+
const n = s;
|
|
589
|
+
t.has(n) && t.get(n).forEach((a) => {
|
|
590
|
+
a.to.state && a.from.script && (a.to.state.script = a.from.script);
|
|
591
|
+
});
|
|
754
592
|
});
|
|
755
|
-
}
|
|
756
|
-
const _hoisted_1$e = ["id"];
|
|
757
|
-
const _hoisted_2$5 = { class: "align-middle" };
|
|
758
|
-
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
593
|
+
}, kt = ["id"], Ct = { class: "align-middle" }, me = /* @__PURE__ */ G({
|
|
759
594
|
__name: "CodeGraphNodeInterface",
|
|
760
595
|
props: {
|
|
761
596
|
node: {},
|
|
762
597
|
intf: {}
|
|
763
598
|
},
|
|
764
|
-
setup(
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
const startHover = () => {
|
|
774
|
-
hoveredOver(props.intf);
|
|
599
|
+
setup(o) {
|
|
600
|
+
const e = o, { viewModel: t } = H(), { hoveredOver: s, temporaryConnection: n } = Xe(), a = E(null), u = f(() => e.intf.connectionCount > 0), d = f(() => ({
|
|
601
|
+
"--connected": u.value
|
|
602
|
+
})), h = () => {
|
|
603
|
+
s(e.intf);
|
|
604
|
+
}, O = () => {
|
|
605
|
+
s(void 0);
|
|
606
|
+
}, x = () => {
|
|
607
|
+
a.value && t.value.hooks.renderInterface.execute({ intf: e.intf, el: a.value });
|
|
775
608
|
};
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
createElementVNode("span", _hoisted_2$5, [
|
|
800
|
-
renderSlot(_ctx.$slots, "default")
|
|
801
|
-
])
|
|
802
|
-
], 10, _hoisted_1$e);
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
});
|
|
806
|
-
const _export_sfc = (sfc, props) => {
|
|
807
|
-
const target = sfc.__vccOpts || sfc;
|
|
808
|
-
for (const [key, val] of props) {
|
|
809
|
-
target[key] = val;
|
|
810
|
-
}
|
|
811
|
-
return target;
|
|
812
|
-
};
|
|
813
|
-
const _sfc_main$e = {};
|
|
814
|
-
const _hoisted_1$d = {
|
|
609
|
+
return ee(x), _e(x), (k, B) => (i(), r("div", {
|
|
610
|
+
id: k.intf.id,
|
|
611
|
+
ref_key: "el",
|
|
612
|
+
ref: a,
|
|
613
|
+
class: U(["baklava-node-interface", d.value])
|
|
614
|
+
}, [
|
|
615
|
+
k.intf.port ? (i(), r("div", {
|
|
616
|
+
key: 0,
|
|
617
|
+
class: U(["__port", { "--selected": _(n)?.from === k.intf }]),
|
|
618
|
+
onPointerover: h,
|
|
619
|
+
onPointerout: O
|
|
620
|
+
}, null, 34)) : N("", !0),
|
|
621
|
+
l("span", Ct, [
|
|
622
|
+
q(k.$slots, "default")
|
|
623
|
+
])
|
|
624
|
+
], 10, kt));
|
|
625
|
+
}
|
|
626
|
+
}), z = (o, e) => {
|
|
627
|
+
const t = o.__vccOpts || o;
|
|
628
|
+
for (const [s, n] of e)
|
|
629
|
+
t[s] = n;
|
|
630
|
+
return t;
|
|
631
|
+
}, It = {}, Nt = {
|
|
815
632
|
xmlns: "http://www.w3.org/2000/svg",
|
|
816
633
|
width: "24",
|
|
817
634
|
height: "24",
|
|
@@ -819,19 +636,17 @@ const _hoisted_1$d = {
|
|
|
819
636
|
fill: "currentColor",
|
|
820
637
|
class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-collapse"
|
|
821
638
|
};
|
|
822
|
-
function
|
|
823
|
-
return
|
|
824
|
-
|
|
639
|
+
function Mt(o, e) {
|
|
640
|
+
return i(), r("svg", Nt, [...e[0] || (e[0] = [
|
|
641
|
+
l("path", {
|
|
825
642
|
stroke: "none",
|
|
826
643
|
d: "M0 0h24v24H0z",
|
|
827
644
|
fill: "none"
|
|
828
645
|
}, null, -1),
|
|
829
|
-
|
|
646
|
+
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)
|
|
830
647
|
])]);
|
|
831
648
|
}
|
|
832
|
-
const
|
|
833
|
-
const _sfc_main$d = {};
|
|
834
|
-
const _hoisted_1$c = {
|
|
649
|
+
const Ot = /* @__PURE__ */ z(It, [["render", Mt]]), $t = {}, Et = {
|
|
835
650
|
xmlns: "http://www.w3.org/2000/svg",
|
|
836
651
|
width: "24",
|
|
837
652
|
height: "24",
|
|
@@ -839,19 +654,17 @@ const _hoisted_1$c = {
|
|
|
839
654
|
fill: "currentColor",
|
|
840
655
|
class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-expand"
|
|
841
656
|
};
|
|
842
|
-
function
|
|
843
|
-
return
|
|
844
|
-
|
|
657
|
+
function Tt(o, e) {
|
|
658
|
+
return i(), r("svg", Et, [...e[0] || (e[0] = [
|
|
659
|
+
l("path", {
|
|
845
660
|
stroke: "none",
|
|
846
661
|
d: "M0 0h24v24H0z",
|
|
847
662
|
fill: "none"
|
|
848
663
|
}, null, -1),
|
|
849
|
-
|
|
664
|
+
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)
|
|
850
665
|
])]);
|
|
851
666
|
}
|
|
852
|
-
const
|
|
853
|
-
const _sfc_main$c = {};
|
|
854
|
-
const _hoisted_1$b = {
|
|
667
|
+
const St = /* @__PURE__ */ z($t, [["render", Tt]]), zt = {}, Bt = {
|
|
855
668
|
xmlns: "http://www.w3.org/2000/svg",
|
|
856
669
|
width: "24",
|
|
857
670
|
height: "24",
|
|
@@ -859,19 +672,17 @@ const _hoisted_1$b = {
|
|
|
859
672
|
fill: "currentColor",
|
|
860
673
|
class: "balkava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"
|
|
861
674
|
};
|
|
862
|
-
function
|
|
863
|
-
return
|
|
864
|
-
|
|
675
|
+
function Vt(o, e) {
|
|
676
|
+
return i(), r("svg", Bt, [...e[0] || (e[0] = [
|
|
677
|
+
l("path", {
|
|
865
678
|
stroke: "none",
|
|
866
679
|
d: "M0 0h24v24H0z",
|
|
867
680
|
fill: "none"
|
|
868
681
|
}, null, -1),
|
|
869
|
-
|
|
682
|
+
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)
|
|
870
683
|
])]);
|
|
871
684
|
}
|
|
872
|
-
const
|
|
873
|
-
const _sfc_main$b = {};
|
|
874
|
-
const _hoisted_1$a = {
|
|
685
|
+
const Lt = /* @__PURE__ */ z(zt, [["render", Vt]]), Gt = {}, Ut = {
|
|
875
686
|
xmlns: "http://www.w3.org/2000/svg",
|
|
876
687
|
width: "24",
|
|
877
688
|
height: "24",
|
|
@@ -879,19 +690,17 @@ const _hoisted_1$a = {
|
|
|
879
690
|
fill: "currentColor",
|
|
880
691
|
class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-collapse"
|
|
881
692
|
};
|
|
882
|
-
function
|
|
883
|
-
return
|
|
884
|
-
|
|
693
|
+
function jt(o, e) {
|
|
694
|
+
return i(), r("svg", Ut, [...e[0] || (e[0] = [
|
|
695
|
+
l("path", {
|
|
885
696
|
stroke: "none",
|
|
886
697
|
d: "M0 0h24v24H0z",
|
|
887
698
|
fill: "none"
|
|
888
699
|
}, null, -1),
|
|
889
|
-
|
|
700
|
+
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)
|
|
890
701
|
])]);
|
|
891
702
|
}
|
|
892
|
-
const
|
|
893
|
-
const _sfc_main$a = {};
|
|
894
|
-
const _hoisted_1$9 = {
|
|
703
|
+
const Rt = /* @__PURE__ */ z(Gt, [["render", jt]]), Pt = {}, Dt = {
|
|
895
704
|
xmlns: "http://www.w3.org/2000/svg",
|
|
896
705
|
width: "24",
|
|
897
706
|
height: "24",
|
|
@@ -899,19 +708,17 @@ const _hoisted_1$9 = {
|
|
|
899
708
|
fill: "currentColor",
|
|
900
709
|
class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-expand"
|
|
901
710
|
};
|
|
902
|
-
function
|
|
903
|
-
return
|
|
904
|
-
|
|
711
|
+
function At(o, e) {
|
|
712
|
+
return i(), r("svg", Dt, [...e[0] || (e[0] = [
|
|
713
|
+
l("path", {
|
|
905
714
|
stroke: "none",
|
|
906
715
|
d: "M0 0h24v24H0z",
|
|
907
716
|
fill: "none"
|
|
908
717
|
}, null, -1),
|
|
909
|
-
|
|
718
|
+
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)
|
|
910
719
|
])]);
|
|
911
720
|
}
|
|
912
|
-
const
|
|
913
|
-
const _sfc_main$9 = {};
|
|
914
|
-
const _hoisted_1$8 = {
|
|
721
|
+
const Ht = /* @__PURE__ */ z(Pt, [["render", At]]), Ft = {}, Wt = {
|
|
915
722
|
xmlns: "http://www.w3.org/2000/svg",
|
|
916
723
|
class: "baklava-icon",
|
|
917
724
|
width: "24",
|
|
@@ -923,14 +730,12 @@ const _hoisted_1$8 = {
|
|
|
923
730
|
"stroke-linecap": "round",
|
|
924
731
|
"stroke-linejoin": "round"
|
|
925
732
|
};
|
|
926
|
-
function
|
|
927
|
-
return
|
|
928
|
-
|
|
733
|
+
function Xt(o, e) {
|
|
734
|
+
return i(), r("svg", Wt, [...e[0] || (e[0] = [
|
|
735
|
+
te('<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)
|
|
929
736
|
])]);
|
|
930
737
|
}
|
|
931
|
-
const
|
|
932
|
-
const _sfc_main$8 = {};
|
|
933
|
-
const _hoisted_1$7 = {
|
|
738
|
+
const Yt = /* @__PURE__ */ z(Ft, [["render", Xt]]), Jt = {}, qt = {
|
|
934
739
|
xmlns: "http://www.w3.org/2000/svg",
|
|
935
740
|
class: "baklava-icon",
|
|
936
741
|
width: "24",
|
|
@@ -942,14 +747,12 @@ const _hoisted_1$7 = {
|
|
|
942
747
|
"stroke-linecap": "round",
|
|
943
748
|
"stroke-linejoin": "round"
|
|
944
749
|
};
|
|
945
|
-
function
|
|
946
|
-
return
|
|
947
|
-
|
|
750
|
+
function Qt(o, e) {
|
|
751
|
+
return i(), r("svg", qt, [...e[0] || (e[0] = [
|
|
752
|
+
te('<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)
|
|
948
753
|
])]);
|
|
949
754
|
}
|
|
950
|
-
const
|
|
951
|
-
const _sfc_main$7 = {};
|
|
952
|
-
const _hoisted_1$6 = {
|
|
755
|
+
const Zt = /* @__PURE__ */ z(Jt, [["render", Qt]]), Kt = {}, es = {
|
|
953
756
|
xmlns: "http://www.w3.org/2000/svg",
|
|
954
757
|
class: "baklava-icon",
|
|
955
758
|
width: "24",
|
|
@@ -961,14 +764,12 @@ const _hoisted_1$6 = {
|
|
|
961
764
|
"stroke-linecap": "round",
|
|
962
765
|
"stroke-linejoin": "round"
|
|
963
766
|
};
|
|
964
|
-
function
|
|
965
|
-
return
|
|
966
|
-
|
|
767
|
+
function ts(o, e) {
|
|
768
|
+
return i(), r("svg", es, [...e[0] || (e[0] = [
|
|
769
|
+
te('<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)
|
|
967
770
|
])]);
|
|
968
771
|
}
|
|
969
|
-
const
|
|
970
|
-
const _sfc_main$6 = {};
|
|
971
|
-
const _hoisted_1$5 = {
|
|
772
|
+
const ss = /* @__PURE__ */ z(Kt, [["render", ts]]), ns = {}, os = {
|
|
972
773
|
xmlns: "http://www.w3.org/2000/svg",
|
|
973
774
|
class: "baklava-icon",
|
|
974
775
|
width: "16",
|
|
@@ -980,338 +781,262 @@ const _hoisted_1$5 = {
|
|
|
980
781
|
"stroke-linecap": "round",
|
|
981
782
|
"stroke-linejoin": "round"
|
|
982
783
|
};
|
|
983
|
-
function
|
|
984
|
-
return
|
|
985
|
-
|
|
784
|
+
function as(o, e) {
|
|
785
|
+
return i(), r("svg", os, [...e[0] || (e[0] = [
|
|
786
|
+
l("path", {
|
|
986
787
|
stroke: "none",
|
|
987
788
|
d: "M0 0h24v24H0z",
|
|
988
789
|
fill: "none"
|
|
989
790
|
}, null, -1),
|
|
990
|
-
|
|
791
|
+
l("circle", {
|
|
991
792
|
cx: "12",
|
|
992
793
|
cy: "12",
|
|
993
794
|
r: "1"
|
|
994
795
|
}, null, -1),
|
|
995
|
-
|
|
796
|
+
l("circle", {
|
|
996
797
|
cx: "12",
|
|
997
798
|
cy: "19",
|
|
998
799
|
r: "1"
|
|
999
800
|
}, null, -1),
|
|
1000
|
-
|
|
801
|
+
l("circle", {
|
|
1001
802
|
cx: "12",
|
|
1002
803
|
cy: "5",
|
|
1003
804
|
r: "1"
|
|
1004
805
|
}, null, -1)
|
|
1005
806
|
])]);
|
|
1006
807
|
}
|
|
1007
|
-
const
|
|
1008
|
-
const _hoisted_1$4 = ["id", "data-node-type"];
|
|
1009
|
-
const _hoisted_2$4 = {
|
|
808
|
+
const is = /* @__PURE__ */ z(ns, [["render", as]]), rs = ["id", "data-node-type"], ls = {
|
|
1010
809
|
class: "__title-label",
|
|
1011
810
|
style: { "flex-grow": "1" }
|
|
1012
|
-
}
|
|
1013
|
-
const _hoisted_3$2 = { key: 0 };
|
|
1014
|
-
const _hoisted_4$1 = {
|
|
811
|
+
}, ds = { key: 0 }, us = {
|
|
1015
812
|
class: "__menu",
|
|
1016
|
-
style: {
|
|
1017
|
-
}
|
|
1018
|
-
const _hoisted_5 = { class: "__outputs" };
|
|
1019
|
-
const _hoisted_6 = { key: 0 };
|
|
1020
|
-
const _hoisted_7 = ["id", "title"];
|
|
1021
|
-
const _hoisted_8 = { class: "__inputs" };
|
|
1022
|
-
const _hoisted_9 = { key: 0 };
|
|
1023
|
-
const _hoisted_10 = ["id", "title"];
|
|
1024
|
-
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
813
|
+
style: { display: "flex" }
|
|
814
|
+
}, cs = { class: "__outputs" }, ps = { key: 0 }, hs = ["id", "title"], vs = { class: "__inputs" }, ms = { key: 0 }, fs = ["id", "title"], gs = /* @__PURE__ */ G({
|
|
1025
815
|
__name: "CodeGraphNode",
|
|
1026
816
|
props: {
|
|
1027
817
|
node: {},
|
|
1028
|
-
selected: { type: Boolean, default:
|
|
818
|
+
selected: { type: Boolean, default: !1 },
|
|
1029
819
|
dragging: { type: Boolean }
|
|
1030
820
|
},
|
|
1031
821
|
emits: ["select", "start-drag", "update"],
|
|
1032
|
-
setup(
|
|
1033
|
-
const ContextMenu =
|
|
1034
|
-
|
|
1035
|
-
const
|
|
1036
|
-
|
|
1037
|
-
const emit = __emit;
|
|
1038
|
-
const { viewModel } = useViewModel();
|
|
1039
|
-
const { graph, switchGraph } = useGraph();
|
|
1040
|
-
const el = ref(null);
|
|
1041
|
-
const renaming = ref(false);
|
|
1042
|
-
const tempName = ref("");
|
|
1043
|
-
const renameInputEl = ref(null);
|
|
1044
|
-
const isResizing = ref(false);
|
|
1045
|
-
let resizeStartWidth = 0;
|
|
1046
|
-
let resizeStartMouseX = 0;
|
|
1047
|
-
const showContextMenu = ref(false);
|
|
1048
|
-
const contextMenuItems = computed(() => {
|
|
1049
|
-
const items = [
|
|
822
|
+
setup(o, { emit: e }) {
|
|
823
|
+
const t = ve.ContextMenu, s = ve.NodeInterface, n = o, a = f(() => n.node), u = e, { viewModel: d } = H(), { graph: h, switchGraph: O } = K(), x = E(null), k = E(!1), B = E(""), y = E(null), m = E(!1);
|
|
824
|
+
let g = 0, b = 0;
|
|
825
|
+
const p = E(!1), w = f(() => {
|
|
826
|
+
const c = [
|
|
1050
827
|
{ value: "edit", label: "Edit" },
|
|
1051
828
|
{ value: "rename", label: "Rename" },
|
|
1052
829
|
{ value: "delete", label: "Delete" }
|
|
1053
830
|
];
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
"--
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
"
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
})
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
};
|
|
1084
|
-
const openContextMenu = () => {
|
|
1085
|
-
showContextMenu.value = true;
|
|
1086
|
-
};
|
|
1087
|
-
const closeSidebar = () => {
|
|
1088
|
-
const sidebar = viewModel.value.displayedGraph.sidebar;
|
|
1089
|
-
sidebar.nodeId = "";
|
|
1090
|
-
sidebar.visible = false;
|
|
1091
|
-
};
|
|
1092
|
-
const openSidebar = () => {
|
|
1093
|
-
const sidebar = viewModel.value.displayedGraph.sidebar;
|
|
1094
|
-
sidebar.nodeId = props.node.id;
|
|
1095
|
-
sidebar.visible = true;
|
|
1096
|
-
};
|
|
1097
|
-
const updateSidebar = () => {
|
|
1098
|
-
const sidebar = viewModel.value.displayedGraph.sidebar;
|
|
1099
|
-
sidebar.nodeId = props.node.id;
|
|
1100
|
-
};
|
|
1101
|
-
const onContextMenuClick = async (action) => {
|
|
1102
|
-
switch (action) {
|
|
831
|
+
return n.node.type.startsWith(J) && c.push({ value: "editSubgraph", label: "Edit Subgraph" }), c;
|
|
832
|
+
}), I = f(() => ({
|
|
833
|
+
"--selected": n.selected,
|
|
834
|
+
"--dragging": n.dragging,
|
|
835
|
+
"--two-column": !!n.node.twoColumn,
|
|
836
|
+
"--hidden": a.value.state?.hidden
|
|
837
|
+
})), ke = f(() => ({
|
|
838
|
+
"--reverse-y": n.node.reverseY ?? d.value.settings.nodes.reverseY
|
|
839
|
+
})), Ce = f(() => ({
|
|
840
|
+
top: `${n.node.position?.y ?? 0}px`,
|
|
841
|
+
left: `${n.node.position?.x ?? 0}px`,
|
|
842
|
+
"--width": `${n.node.width ?? d.value.settings.nodes.defaultWidth}px`
|
|
843
|
+
})), Ie = f(() => Object.values(n.node.inputs).filter((c) => !c.hidden)), Ne = f(() => Object.values(n.node.outputs).filter((c) => !c.hidden)), re = () => {
|
|
844
|
+
u("select");
|
|
845
|
+
}, Me = (c) => {
|
|
846
|
+
n.selected || re(), u("start-drag", c);
|
|
847
|
+
}, le = () => {
|
|
848
|
+
p.value = !0;
|
|
849
|
+
}, Oe = () => {
|
|
850
|
+
const c = d.value.displayedGraph.sidebar;
|
|
851
|
+
c.nodeId = "", c.visible = !1;
|
|
852
|
+
}, de = () => {
|
|
853
|
+
const c = d.value.displayedGraph.sidebar;
|
|
854
|
+
c.nodeId = n.node.id, c.visible = !0;
|
|
855
|
+
}, $e = () => {
|
|
856
|
+
const c = d.value.displayedGraph.sidebar;
|
|
857
|
+
c.nodeId = n.node.id;
|
|
858
|
+
}, Ee = async (c) => {
|
|
859
|
+
switch (c) {
|
|
1103
860
|
case "edit":
|
|
1104
|
-
|
|
861
|
+
de();
|
|
1105
862
|
break;
|
|
1106
863
|
case "delete":
|
|
1107
|
-
|
|
864
|
+
h.value.removeNode(n.node);
|
|
1108
865
|
break;
|
|
1109
866
|
case "rename":
|
|
1110
|
-
|
|
1111
|
-
renaming.value = true;
|
|
1112
|
-
await nextTick();
|
|
1113
|
-
renameInputEl.value?.focus();
|
|
867
|
+
B.value = n.node.title, k.value = !0, await nt(), y.value?.focus();
|
|
1114
868
|
break;
|
|
1115
869
|
case "editSubgraph":
|
|
1116
|
-
|
|
870
|
+
O(n.node.template);
|
|
1117
871
|
break;
|
|
1118
872
|
}
|
|
873
|
+
}, ue = () => {
|
|
874
|
+
n.node.title = B.value, k.value = !1;
|
|
875
|
+
}, ce = () => {
|
|
876
|
+
x.value && d.value.hooks.renderNode.execute({ node: n.node, el: x.value });
|
|
877
|
+
}, Te = (c) => {
|
|
878
|
+
m.value = !0, g = n.node.width, b = c.clientX, c.preventDefault();
|
|
879
|
+
}, pe = (c) => {
|
|
880
|
+
if (!m.value) return;
|
|
881
|
+
const C = c.clientX - b, v = g + C / h.value.scaling, Se = d.value.settings.nodes.minWidth, ze = d.value.settings.nodes.maxWidth;
|
|
882
|
+
n.node.width = Math.max(Se, Math.min(ze, v));
|
|
883
|
+
}, he = () => {
|
|
884
|
+
m.value = !1;
|
|
1119
885
|
};
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
};
|
|
1143
|
-
const stopResize = () => {
|
|
1144
|
-
isResizing.value = false;
|
|
1145
|
-
};
|
|
1146
|
-
onMounted(() => {
|
|
1147
|
-
onRender();
|
|
1148
|
-
window.addEventListener("mousemove", doResize);
|
|
1149
|
-
window.addEventListener("mouseup", stopResize);
|
|
1150
|
-
});
|
|
1151
|
-
onUpdated(onRender);
|
|
1152
|
-
onBeforeUnmount(() => {
|
|
1153
|
-
window.removeEventListener("mousemove", doResize);
|
|
1154
|
-
window.removeEventListener("mouseup", stopResize);
|
|
1155
|
-
});
|
|
1156
|
-
return (_ctx, _cache) => {
|
|
1157
|
-
return openBlock(), createElementBlock("div", {
|
|
1158
|
-
id: node.value.id,
|
|
1159
|
-
ref_key: "el",
|
|
1160
|
-
ref: el,
|
|
1161
|
-
class: normalizeClass([classes.value, "baklava-node"]),
|
|
1162
|
-
"data-node-type": node.value.type,
|
|
1163
|
-
style: normalizeStyle(styles.value),
|
|
1164
|
-
onPointerdown: select
|
|
886
|
+
return ee(() => {
|
|
887
|
+
ce(), window.addEventListener("mousemove", pe), window.addEventListener("mouseup", he);
|
|
888
|
+
}), _e(ce), tt(() => {
|
|
889
|
+
window.removeEventListener("mousemove", pe), window.removeEventListener("mouseup", he);
|
|
890
|
+
}), (c, C) => (i(), r("div", {
|
|
891
|
+
id: a.value.id,
|
|
892
|
+
ref_key: "el",
|
|
893
|
+
ref: x,
|
|
894
|
+
class: U([I.value, "baklava-node"]),
|
|
895
|
+
"data-node-type": a.value.type,
|
|
896
|
+
style: se(Ce.value),
|
|
897
|
+
onPointerdown: re
|
|
898
|
+
}, [
|
|
899
|
+
_(d).settings.nodes.resizable ? (i(), r("div", {
|
|
900
|
+
key: 0,
|
|
901
|
+
class: "__resize-handle",
|
|
902
|
+
onMousedown: Te
|
|
903
|
+
}, null, 32)) : N("", !0),
|
|
904
|
+
l("div", {
|
|
905
|
+
class: "__title",
|
|
906
|
+
onPointerdown: D(Me, ["self", "stop"]),
|
|
907
|
+
onContextmenu: D(le, ["prevent"])
|
|
1165
908
|
}, [
|
|
1166
|
-
|
|
909
|
+
a.value.inputs._node ? (i(), V(me, {
|
|
1167
910
|
key: 0,
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
!unref(viewModel).displayedGraph.sidebar.visible && unref(viewModel).displayedGraph.sidebar.nodeId !== node.value.id ? (openBlock(), createBlock(unref(LayoutSidebarRightExpand), {
|
|
1192
|
-
key: 0,
|
|
1193
|
-
class: "--clickable mx-1",
|
|
1194
|
-
onClick: openSidebar
|
|
1195
|
-
})) : unref(viewModel).displayedGraph.sidebar.visible && unref(viewModel).displayedGraph.sidebar.nodeId !== node.value.id ? (openBlock(), createBlock(unref(LayoutSidebarRight), {
|
|
1196
|
-
key: 1,
|
|
1197
|
-
class: "--clickable mx-1",
|
|
1198
|
-
onClick: updateSidebar
|
|
1199
|
-
})) : (openBlock(), createBlock(unref(LayoutSidebarRightCollapse), {
|
|
1200
|
-
key: 2,
|
|
1201
|
-
class: "--clickable mx-1",
|
|
1202
|
-
onClick: closeSidebar
|
|
1203
|
-
}))
|
|
1204
|
-
], 64)) : createCommentVNode("", true),
|
|
1205
|
-
createVNode(unref(VerticalDots), {
|
|
1206
|
-
class: "--clickable mx-1",
|
|
1207
|
-
onClick: openContextMenu
|
|
1208
|
-
}),
|
|
1209
|
-
createVNode(unref(ContextMenu), {
|
|
1210
|
-
modelValue: showContextMenu.value,
|
|
1211
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => showContextMenu.value = $event),
|
|
1212
|
-
x: 0,
|
|
1213
|
-
y: 0,
|
|
1214
|
-
items: contextMenuItems.value,
|
|
1215
|
-
onClick: onContextMenuClick
|
|
1216
|
-
}, null, 8, ["modelValue", "items"])
|
|
1217
|
-
])
|
|
1218
|
-
], 64)) : withDirectives((openBlock(), createElementBlock("input", {
|
|
1219
|
-
key: 2,
|
|
1220
|
-
ref_key: "renameInputEl",
|
|
1221
|
-
ref: renameInputEl,
|
|
1222
|
-
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => tempName.value = $event),
|
|
1223
|
-
class: "baklava-input",
|
|
1224
|
-
placeholder: "Node Name",
|
|
1225
|
-
style: { "flex-grow": "1" },
|
|
1226
|
-
type: "text",
|
|
1227
|
-
onBlur: doneRenaming,
|
|
1228
|
-
onKeydown: withKeys(doneRenaming, ["enter"])
|
|
1229
|
-
}, null, 544)), [
|
|
1230
|
-
[vModelText, tempName.value]
|
|
1231
|
-
]),
|
|
1232
|
-
node.value.outputs._node ? (openBlock(), createBlock(_sfc_main$f, {
|
|
1233
|
-
key: 3,
|
|
1234
|
-
node: node.value,
|
|
1235
|
-
intf: node.value.outputs._node,
|
|
1236
|
-
class: "--output",
|
|
1237
|
-
"data-interface-type": "node"
|
|
1238
|
-
}, null, 8, ["node", "intf"])) : createCommentVNode("", true)
|
|
1239
|
-
], 32),
|
|
1240
|
-
createElementVNode("div", {
|
|
1241
|
-
class: normalizeClass(["__content", classesContent.value]),
|
|
1242
|
-
onKeydown: _cache[2] || (_cache[2] = withKeys(withModifiers(() => {
|
|
1243
|
-
}, ["stop"]), ["delete"])),
|
|
1244
|
-
onContextmenu: _cache[3] || (_cache[3] = withModifiers(() => {
|
|
1245
|
-
}, ["prevent"]))
|
|
1246
|
-
}, [
|
|
1247
|
-
createElementVNode("div", _hoisted_5, [
|
|
1248
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(displayedOutputs.value, (output) => {
|
|
1249
|
-
return openBlock(), createElementBlock(Fragment, {
|
|
1250
|
-
key: output.id
|
|
1251
|
-
}, [
|
|
1252
|
-
node.value.state?.hidden ? (openBlock(), createElementBlock("div", _hoisted_6, [
|
|
1253
|
-
output.port ? (openBlock(), createElementBlock("div", {
|
|
1254
|
-
key: 0,
|
|
1255
|
-
id: output.id,
|
|
1256
|
-
title: output.name,
|
|
1257
|
-
class: "baklava-node-interface --output --connected"
|
|
1258
|
-
}, [..._cache[4] || (_cache[4] = [
|
|
1259
|
-
createElementVNode("div", { class: "__port" }, null, -1)
|
|
1260
|
-
])], 8, _hoisted_7)) : createCommentVNode("", true)
|
|
1261
|
-
])) : renderSlot(_ctx.$slots, "nodeInterface", {
|
|
1262
|
-
key: 1,
|
|
1263
|
-
type: "output",
|
|
1264
|
-
node: node.value,
|
|
1265
|
-
intf: output
|
|
1266
|
-
}, () => [
|
|
1267
|
-
createVNode(unref(NodeInterface2), {
|
|
1268
|
-
node: node.value,
|
|
1269
|
-
intf: output
|
|
1270
|
-
}, null, 8, ["node", "intf"])
|
|
1271
|
-
])
|
|
1272
|
-
], 64);
|
|
1273
|
-
}), 128))
|
|
911
|
+
node: a.value,
|
|
912
|
+
intf: a.value.inputs._node,
|
|
913
|
+
class: "--input",
|
|
914
|
+
"data-interface-type": "node",
|
|
915
|
+
style: { "flex-grow": "0" }
|
|
916
|
+
}, null, 8, ["node", "intf"])) : N("", !0),
|
|
917
|
+
k.value ? ne((i(), r("input", {
|
|
918
|
+
key: 2,
|
|
919
|
+
ref_key: "renameInputEl",
|
|
920
|
+
ref: y,
|
|
921
|
+
"onUpdate:modelValue": C[1] || (C[1] = (v) => B.value = v),
|
|
922
|
+
class: "baklava-input",
|
|
923
|
+
placeholder: "Node Name",
|
|
924
|
+
style: { "flex-grow": "1" },
|
|
925
|
+
type: "text",
|
|
926
|
+
onBlur: ue,
|
|
927
|
+
onKeydown: Q(ue, ["enter"])
|
|
928
|
+
}, null, 544)), [
|
|
929
|
+
[oe, B.value]
|
|
930
|
+
]) : (i(), r(T, { key: 1 }, [
|
|
931
|
+
l("div", ls, [
|
|
932
|
+
a.value.idx > -1 ? (i(), r("span", ds, L(a.value.idx + 1) + " - ", 1)) : N("", !0),
|
|
933
|
+
st(L(a.value.title) + " (" + L(a.value.shortId) + ") ", 1)
|
|
1274
934
|
]),
|
|
1275
|
-
|
|
1276
|
-
(
|
|
1277
|
-
|
|
1278
|
-
key:
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
}
|
|
935
|
+
l("div", us, [
|
|
936
|
+
a.value.subgraph ? N("", !0) : (i(), r(T, { key: 0 }, [
|
|
937
|
+
!_(d).displayedGraph.sidebar.visible && _(d).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), V(_(Ht), {
|
|
938
|
+
key: 0,
|
|
939
|
+
class: "--clickable mx-1",
|
|
940
|
+
onClick: de
|
|
941
|
+
})) : _(d).displayedGraph.sidebar.visible && _(d).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), V(_(Lt), {
|
|
942
|
+
key: 1,
|
|
943
|
+
class: "--clickable mx-1",
|
|
944
|
+
onClick: $e
|
|
945
|
+
})) : (i(), V(_(Rt), {
|
|
946
|
+
key: 2,
|
|
947
|
+
class: "--clickable mx-1",
|
|
948
|
+
onClick: Oe
|
|
949
|
+
}))
|
|
950
|
+
], 64)),
|
|
951
|
+
S(_(is), {
|
|
952
|
+
class: "--clickable mx-1",
|
|
953
|
+
onClick: le
|
|
954
|
+
}),
|
|
955
|
+
S(_(t), {
|
|
956
|
+
modelValue: p.value,
|
|
957
|
+
"onUpdate:modelValue": C[0] || (C[0] = (v) => p.value = v),
|
|
958
|
+
x: 0,
|
|
959
|
+
y: 0,
|
|
960
|
+
items: w.value,
|
|
961
|
+
onClick: Ee
|
|
962
|
+
}, null, 8, ["modelValue", "items"])
|
|
1303
963
|
])
|
|
1304
|
-
],
|
|
1305
|
-
|
|
1306
|
-
|
|
964
|
+
], 64)),
|
|
965
|
+
a.value.outputs._node ? (i(), V(me, {
|
|
966
|
+
key: 3,
|
|
967
|
+
node: a.value,
|
|
968
|
+
intf: a.value.outputs._node,
|
|
969
|
+
class: "--output",
|
|
970
|
+
"data-interface-type": "node"
|
|
971
|
+
}, null, 8, ["node", "intf"])) : N("", !0)
|
|
972
|
+
], 32),
|
|
973
|
+
l("div", {
|
|
974
|
+
class: U(["__content", ke.value]),
|
|
975
|
+
onKeydown: C[2] || (C[2] = Q(D(() => {
|
|
976
|
+
}, ["stop"]), ["delete"])),
|
|
977
|
+
onContextmenu: C[3] || (C[3] = D(() => {
|
|
978
|
+
}, ["prevent"]))
|
|
979
|
+
}, [
|
|
980
|
+
l("div", cs, [
|
|
981
|
+
(i(!0), r(T, null, A(Ne.value, (v) => (i(), r(T, {
|
|
982
|
+
key: v.id
|
|
983
|
+
}, [
|
|
984
|
+
a.value.state?.hidden ? (i(), r("div", ps, [
|
|
985
|
+
v.port ? (i(), r("div", {
|
|
986
|
+
key: 0,
|
|
987
|
+
id: v.id,
|
|
988
|
+
title: v.name,
|
|
989
|
+
class: "baklava-node-interface --output --connected"
|
|
990
|
+
}, [...C[4] || (C[4] = [
|
|
991
|
+
l("div", { class: "__port" }, null, -1)
|
|
992
|
+
])], 8, hs)) : N("", !0)
|
|
993
|
+
])) : q(c.$slots, "nodeInterface", {
|
|
994
|
+
key: 1,
|
|
995
|
+
type: "output",
|
|
996
|
+
node: a.value,
|
|
997
|
+
intf: v
|
|
998
|
+
}, () => [
|
|
999
|
+
S(_(s), {
|
|
1000
|
+
node: a.value,
|
|
1001
|
+
intf: v
|
|
1002
|
+
}, null, 8, ["node", "intf"])
|
|
1003
|
+
])
|
|
1004
|
+
], 64))), 128))
|
|
1005
|
+
]),
|
|
1006
|
+
l("div", vs, [
|
|
1007
|
+
(i(!0), r(T, null, A(Ie.value, (v) => (i(), r(T, {
|
|
1008
|
+
key: v.id
|
|
1009
|
+
}, [
|
|
1010
|
+
a.value.state?.hidden ? (i(), r("div", ms, [
|
|
1011
|
+
v.port ? (i(), r("div", {
|
|
1012
|
+
key: 0,
|
|
1013
|
+
id: v.id,
|
|
1014
|
+
title: v.name,
|
|
1015
|
+
class: "baklava-node-interface --input --connected"
|
|
1016
|
+
}, [...C[5] || (C[5] = [
|
|
1017
|
+
l("div", { class: "__port" }, null, -1)
|
|
1018
|
+
])], 8, fs)) : N("", !0)
|
|
1019
|
+
])) : q(c.$slots, "nodeInterface", {
|
|
1020
|
+
key: 1,
|
|
1021
|
+
node: a.value,
|
|
1022
|
+
intf: v,
|
|
1023
|
+
type: "input"
|
|
1024
|
+
}, () => [
|
|
1025
|
+
S(_(s), {
|
|
1026
|
+
node: a.value,
|
|
1027
|
+
intf: v,
|
|
1028
|
+
title: v.name
|
|
1029
|
+
}, null, 8, ["node", "intf", "title"])
|
|
1030
|
+
])
|
|
1031
|
+
], 64))), 128))
|
|
1032
|
+
])
|
|
1033
|
+
], 34)
|
|
1034
|
+
], 46, rs));
|
|
1307
1035
|
}
|
|
1308
|
-
})
|
|
1309
|
-
const _hoisted_1$3 = ["title"];
|
|
1310
|
-
const _hoisted_2$3 = {
|
|
1036
|
+
}), bs = ["title"], _s = {
|
|
1311
1037
|
key: 0,
|
|
1312
1038
|
class: "__label"
|
|
1313
|
-
}
|
|
1314
|
-
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
1039
|
+
}, ys = /* @__PURE__ */ G({
|
|
1315
1040
|
__name: "Checkbox",
|
|
1316
1041
|
props: {
|
|
1317
1042
|
modelValue: { type: Boolean },
|
|
@@ -1319,494 +1044,373 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
1319
1044
|
name: {}
|
|
1320
1045
|
},
|
|
1321
1046
|
emits: ["update:modelValue"],
|
|
1322
|
-
setup(
|
|
1323
|
-
const
|
|
1324
|
-
return (
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
}, [
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
], 10, _hoisted_1$3);
|
|
1346
|
-
};
|
|
1047
|
+
setup(o, { emit: e }) {
|
|
1048
|
+
const t = e;
|
|
1049
|
+
return (s, n) => (i(), r("div", {
|
|
1050
|
+
class: U(["baklava-checkbox", { "--checked": s.inversed ? !s.modelValue : s.modelValue }]),
|
|
1051
|
+
title: s.name,
|
|
1052
|
+
onClick: n[0] || (n[0] = (a) => t("update:modelValue", !s.modelValue))
|
|
1053
|
+
}, [
|
|
1054
|
+
n[1] || (n[1] = l("div", { class: "__checkmark-container" }, [
|
|
1055
|
+
l("svg", {
|
|
1056
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1057
|
+
width: "18",
|
|
1058
|
+
height: "18",
|
|
1059
|
+
viewBox: "0 0 18 18"
|
|
1060
|
+
}, [
|
|
1061
|
+
l("path", {
|
|
1062
|
+
class: "__checkmark",
|
|
1063
|
+
d: "M 6 5 L 6 10 L 16 10",
|
|
1064
|
+
transform: "rotate(-45 10 10)"
|
|
1065
|
+
})
|
|
1066
|
+
])
|
|
1067
|
+
], -1)),
|
|
1068
|
+
s.name ? (i(), r("div", _s, L(s.name), 1)) : N("", !0)
|
|
1069
|
+
], 10, bs));
|
|
1347
1070
|
}
|
|
1348
|
-
})
|
|
1349
|
-
const _hoisted_1$2 = { class: "__header" };
|
|
1350
|
-
const _hoisted_2$2 = { class: "__node-name" };
|
|
1351
|
-
const _hoisted_3$1 = { style: { "display": "flex" } };
|
|
1352
|
-
const _hoisted_4 = {
|
|
1071
|
+
}), ws = { class: "__header" }, xs = { class: "__node-name" }, ks = { style: { display: "flex" } }, Cs = {
|
|
1353
1072
|
key: 1,
|
|
1354
1073
|
class: "__interface"
|
|
1355
|
-
}
|
|
1356
|
-
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
1074
|
+
}, Is = /* @__PURE__ */ G({
|
|
1357
1075
|
__name: "CodeGraphSidebar",
|
|
1358
|
-
setup(
|
|
1359
|
-
const { viewModel } =
|
|
1360
|
-
|
|
1361
|
-
const
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
width: `${width.value}px`
|
|
1373
|
-
}));
|
|
1374
|
-
const displayedInterfaces = computed(() => {
|
|
1375
|
-
if (!node.value) return [];
|
|
1376
|
-
const allIntfs = [...Object.values(node.value.inputs), ...Object.values(node.value.outputs)];
|
|
1377
|
-
return allIntfs.filter((intf) => intf.displayInSidebar && intf.component);
|
|
1378
|
-
});
|
|
1379
|
-
const close = () => {
|
|
1380
|
-
graph.value.sidebar.visible = false;
|
|
1381
|
-
};
|
|
1382
|
-
const doneRenaming = () => {
|
|
1383
|
-
node.value?.events.update.emit(null);
|
|
1384
|
-
};
|
|
1385
|
-
const startResize = (event) => {
|
|
1386
|
-
resizeStartWidth = width.value;
|
|
1387
|
-
resizeStartMouseX = event.clientX;
|
|
1388
|
-
window.addEventListener("mousemove", onMouseMove);
|
|
1389
|
-
window.addEventListener(
|
|
1076
|
+
setup(o) {
|
|
1077
|
+
const { viewModel: e } = H(), { graph: t } = K(), s = E(null), n = ye(e.value.settings.sidebar, "width"), a = f(() => e.value.settings.sidebar.resizable);
|
|
1078
|
+
let u = 0, d = 0;
|
|
1079
|
+
const h = f(() => {
|
|
1080
|
+
const b = t.value.sidebar.nodeId;
|
|
1081
|
+
return t.value.nodes.find((p) => p.id === b);
|
|
1082
|
+
}), O = f(() => h.value), x = f(() => ({
|
|
1083
|
+
width: `${n.value}px`
|
|
1084
|
+
})), k = f(() => h.value ? [...Object.values(h.value.inputs), ...Object.values(h.value.outputs)].filter((p) => p.displayInSidebar && p.component) : []), B = () => {
|
|
1085
|
+
t.value.sidebar.visible = !1;
|
|
1086
|
+
}, y = () => {
|
|
1087
|
+
h.value?.events.update.emit(null);
|
|
1088
|
+
}, m = (b) => {
|
|
1089
|
+
u = n.value, d = b.clientX, window.addEventListener("mousemove", g), window.addEventListener(
|
|
1390
1090
|
"mouseup",
|
|
1391
1091
|
() => {
|
|
1392
|
-
window.removeEventListener("mousemove",
|
|
1092
|
+
window.removeEventListener("mousemove", g);
|
|
1393
1093
|
},
|
|
1394
|
-
{ once:
|
|
1094
|
+
{ once: !0 }
|
|
1395
1095
|
);
|
|
1096
|
+
}, g = (b) => {
|
|
1097
|
+
const p = s.value?.parentElement?.getBoundingClientRect().width ?? 500, w = b.clientX - d;
|
|
1098
|
+
let I = u - w;
|
|
1099
|
+
I < 300 ? I = 300 : I > 0.9 * p && (I = 0.9 * p), n.value = I;
|
|
1396
1100
|
};
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1101
|
+
return (b, p) => (i(), r("div", {
|
|
1102
|
+
ref_key: "el",
|
|
1103
|
+
ref: s,
|
|
1104
|
+
class: U(["baklava-sidebar", { "--open": _(t).sidebar.visible }]),
|
|
1105
|
+
style: se(x.value)
|
|
1106
|
+
}, [
|
|
1107
|
+
a.value ? (i(), r("div", {
|
|
1108
|
+
key: 0,
|
|
1109
|
+
class: "__resizer",
|
|
1110
|
+
onMousedown: m
|
|
1111
|
+
}, null, 32)) : N("", !0),
|
|
1112
|
+
l("div", ws, [
|
|
1113
|
+
l("button", {
|
|
1114
|
+
tabindex: "-1",
|
|
1115
|
+
class: "__close",
|
|
1116
|
+
onClick: B
|
|
1117
|
+
}, "×"),
|
|
1118
|
+
l("div", xs, [
|
|
1119
|
+
l("b", null, L(h.value ? h.value.title : ""), 1)
|
|
1120
|
+
])
|
|
1121
|
+
]),
|
|
1122
|
+
(i(!0), r(T, null, A(k.value, (w) => (i(), r("div", {
|
|
1123
|
+
key: w.id,
|
|
1124
|
+
class: "__interface"
|
|
1414
1125
|
}, [
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
node: node.value,
|
|
1449
|
-
intf,
|
|
1450
|
-
style: { "width": "100%" }
|
|
1451
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
|
|
1452
|
-
])
|
|
1453
|
-
]);
|
|
1454
|
-
}), 128)),
|
|
1455
|
-
codeNode.value && codeNode.value.state ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
1456
|
-
_cache[2] || (_cache[2] = createElementVNode("label", null, "Variable name", -1)),
|
|
1457
|
-
withDirectives(createElementVNode("input", {
|
|
1458
|
-
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => codeNode.value.state.variableName = $event),
|
|
1459
|
-
type: "text",
|
|
1460
|
-
class: "baklava-input",
|
|
1461
|
-
title: "Variable name",
|
|
1462
|
-
onBlur: doneRenaming,
|
|
1463
|
-
onKeydown: withKeys(doneRenaming, ["enter"])
|
|
1464
|
-
}, null, 544), [
|
|
1465
|
-
[vModelText, codeNode.value.state.variableName]
|
|
1466
|
-
])
|
|
1467
|
-
])) : createCommentVNode("", true)
|
|
1468
|
-
], 6);
|
|
1469
|
-
};
|
|
1126
|
+
l("div", ks, [
|
|
1127
|
+
S(ys, {
|
|
1128
|
+
modelValue: w.hidden,
|
|
1129
|
+
"onUpdate:modelValue": [
|
|
1130
|
+
(I) => w.hidden = I,
|
|
1131
|
+
p[0] || (p[0] = () => h.value?.events.update.emit(null))
|
|
1132
|
+
],
|
|
1133
|
+
inversed: "",
|
|
1134
|
+
style: { "margin-right": "8px" }
|
|
1135
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
|
|
1136
|
+
(i(), V(ot(w.component), {
|
|
1137
|
+
modelValue: w.value,
|
|
1138
|
+
"onUpdate:modelValue": (I) => w.value = I,
|
|
1139
|
+
node: h.value,
|
|
1140
|
+
intf: w,
|
|
1141
|
+
style: { width: "100%" }
|
|
1142
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
|
|
1143
|
+
])
|
|
1144
|
+
]))), 128)),
|
|
1145
|
+
O.value && O.value.state ? (i(), r("div", Cs, [
|
|
1146
|
+
p[2] || (p[2] = l("label", null, "Variable name", -1)),
|
|
1147
|
+
ne(l("input", {
|
|
1148
|
+
"onUpdate:modelValue": p[1] || (p[1] = (w) => O.value.state.variableName = w),
|
|
1149
|
+
type: "text",
|
|
1150
|
+
class: "baklava-input",
|
|
1151
|
+
title: "Variable name",
|
|
1152
|
+
onBlur: y,
|
|
1153
|
+
onKeydown: Q(y, ["enter"])
|
|
1154
|
+
}, null, 544), [
|
|
1155
|
+
[oe, O.value.state.variableName]
|
|
1156
|
+
])
|
|
1157
|
+
])) : N("", !0)
|
|
1158
|
+
], 6));
|
|
1470
1159
|
}
|
|
1471
|
-
})
|
|
1472
|
-
const _sfc_main$2 = defineComponent({
|
|
1160
|
+
}), Ns = G({
|
|
1473
1161
|
props: {
|
|
1474
1162
|
type: {
|
|
1475
1163
|
type: String,
|
|
1476
|
-
required:
|
|
1164
|
+
required: !0
|
|
1477
1165
|
},
|
|
1478
1166
|
title: {
|
|
1479
1167
|
type: String,
|
|
1480
|
-
required:
|
|
1168
|
+
required: !0
|
|
1481
1169
|
}
|
|
1482
1170
|
},
|
|
1483
|
-
setup(
|
|
1484
|
-
const { viewModel } =
|
|
1485
|
-
|
|
1486
|
-
const showContextMenu = ref(false);
|
|
1487
|
-
const hasContextMenu = computed(() => props.type.startsWith(GRAPH_NODE_TYPE_PREFIX));
|
|
1488
|
-
const contextMenuItems = [
|
|
1171
|
+
setup(o) {
|
|
1172
|
+
const { viewModel: e } = H(), { switchGraph: t } = K(), s = E(!1), n = f(() => o.type.startsWith(J));
|
|
1173
|
+
return { showContextMenu: s, hasContextMenu: n, contextMenuItems: [
|
|
1489
1174
|
{ label: "Edit Subgraph", value: "editSubgraph" },
|
|
1490
1175
|
{ label: "Delete Subgraph", value: "deleteSubgraph" }
|
|
1491
|
-
]
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
case "deleteSubgraph":
|
|
1506
|
-
viewModel.value.editor.removeGraphTemplate(graphTemplate);
|
|
1507
|
-
break;
|
|
1508
|
-
}
|
|
1509
|
-
};
|
|
1510
|
-
return { showContextMenu, hasContextMenu, contextMenuItems, openContextMenu, onContextMenuClick };
|
|
1176
|
+
], openContextMenu: () => {
|
|
1177
|
+
s.value = !0;
|
|
1178
|
+
}, onContextMenuClick: (h) => {
|
|
1179
|
+
const O = o.type.substring(J.length), x = e.value.editor.graphTemplates.find((k) => k.id === O);
|
|
1180
|
+
if (x)
|
|
1181
|
+
switch (h) {
|
|
1182
|
+
case "editSubgraph":
|
|
1183
|
+
t(x);
|
|
1184
|
+
break;
|
|
1185
|
+
case "deleteSubgraph":
|
|
1186
|
+
e.value.editor.removeGraphTemplate(x);
|
|
1187
|
+
break;
|
|
1188
|
+
}
|
|
1189
|
+
} };
|
|
1511
1190
|
}
|
|
1512
|
-
});
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
const _hoisted_3 = { class: "__title-label" };
|
|
1516
|
-
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1517
|
-
return openBlock(), createElementBlock("div", {
|
|
1191
|
+
}), Ms = ["data-node-type"], Os = { class: "__title" }, $s = { class: "__title-label" };
|
|
1192
|
+
function Es(o, e, t, s, n, a) {
|
|
1193
|
+
return i(), r("div", {
|
|
1518
1194
|
class: "baklava-node --palette",
|
|
1519
|
-
"data-node-type":
|
|
1195
|
+
"data-node-type": o.type
|
|
1520
1196
|
}, [
|
|
1521
|
-
|
|
1522
|
-
|
|
1197
|
+
l("div", Os, [
|
|
1198
|
+
l("div", $s, L(o.title), 1)
|
|
1523
1199
|
])
|
|
1524
|
-
], 8,
|
|
1200
|
+
], 8, Ms);
|
|
1525
1201
|
}
|
|
1526
|
-
const
|
|
1527
|
-
const _hoisted_1 = {
|
|
1202
|
+
const fe = /* @__PURE__ */ z(Ns, [["render", Es]]), Ts = {
|
|
1528
1203
|
class: "baklava-node --palette",
|
|
1529
1204
|
style: { "margin-top": "-20px", "margin-bottom": "30px" }
|
|
1530
|
-
}
|
|
1531
|
-
const _hoisted_2 = { key: 0 };
|
|
1532
|
-
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
1205
|
+
}, Ss = { key: 0 }, zs = /* @__PURE__ */ G({
|
|
1533
1206
|
__name: "CodeNodePalette",
|
|
1534
|
-
setup(
|
|
1535
|
-
const { viewModel } =
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
return categories2.filter(
|
|
1545
|
-
(c) => Object.values(c.nodeTypes).some(
|
|
1546
|
-
(nodeType2) => nodeType2.title.toLowerCase().includes(searchQuery.value?.toLowerCase())
|
|
1547
|
-
)
|
|
1548
|
-
);
|
|
1549
|
-
}
|
|
1550
|
-
return categories2;
|
|
1551
|
-
};
|
|
1552
|
-
const filterNodesBySearch = (nodeTypes) => {
|
|
1553
|
-
if (searchQuery.value) {
|
|
1554
|
-
return Object.values(nodeTypes).filter(
|
|
1555
|
-
(nt) => nt.title.toLowerCase().includes(searchQuery.value?.toLowerCase())
|
|
1556
|
-
);
|
|
1557
|
-
}
|
|
1558
|
-
return Object.values(nodeTypes);
|
|
1559
|
-
};
|
|
1560
|
-
const draggedNodeStyles = computed(() => {
|
|
1561
|
-
if (!draggedNode.value || !editorEl?.value) return {};
|
|
1562
|
-
const { left, top } = editorEl.value.getBoundingClientRect();
|
|
1207
|
+
setup(o) {
|
|
1208
|
+
const { viewModel: e } = H(), { x: t, y: s } = ht(), { transform: n } = Ye(), a = Je(e), u = at("editorEl"), d = E(""), h = E(null), O = (y) => d.value ? y.filter(
|
|
1209
|
+
(m) => Object.values(m.nodeTypes).some(
|
|
1210
|
+
(g) => g.title.toLowerCase().includes(d.value?.toLowerCase())
|
|
1211
|
+
)
|
|
1212
|
+
) : y, x = (y) => d.value ? Object.values(y).filter(
|
|
1213
|
+
(m) => m.title.toLowerCase().includes(d.value?.toLowerCase())
|
|
1214
|
+
) : Object.values(y), k = f(() => {
|
|
1215
|
+
if (!h.value || !u?.value) return {};
|
|
1216
|
+
const { left: y, top: m } = u.value.getBoundingClientRect();
|
|
1563
1217
|
return {
|
|
1564
|
-
top: `${
|
|
1565
|
-
left: `${
|
|
1218
|
+
top: `${s.value - m}px`,
|
|
1219
|
+
left: `${t.value - y}px`
|
|
1566
1220
|
};
|
|
1567
|
-
})
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
nodeInformation
|
|
1221
|
+
}), B = (y, m) => {
|
|
1222
|
+
h.value = {
|
|
1223
|
+
type: y,
|
|
1224
|
+
nodeInformation: m
|
|
1572
1225
|
};
|
|
1573
|
-
const
|
|
1574
|
-
const
|
|
1575
|
-
|
|
1576
|
-
const
|
|
1577
|
-
|
|
1578
|
-
instance.position.x = x;
|
|
1579
|
-
instance.position.y = y;
|
|
1580
|
-
draggedNode.value = null;
|
|
1581
|
-
document.removeEventListener("pointerup", onDragEnd);
|
|
1226
|
+
const g = () => {
|
|
1227
|
+
const b = R(new m.type());
|
|
1228
|
+
e.value.displayedGraph.addNode(b);
|
|
1229
|
+
const p = u.value.getBoundingClientRect(), [w, I] = n(t.value - p.left, s.value - p.top);
|
|
1230
|
+
b.position.x = w, b.position.y = I, h.value = null, document.removeEventListener("pointerup", g);
|
|
1582
1231
|
};
|
|
1583
|
-
document.addEventListener("pointerup",
|
|
1232
|
+
document.addEventListener("pointerup", g);
|
|
1584
1233
|
};
|
|
1585
|
-
return (
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1234
|
+
return (y, m) => (i(), r(T, null, [
|
|
1235
|
+
l("div", {
|
|
1236
|
+
class: U(["baklava-node-palette", { "--open": _(e).settings.palette.enabled }]),
|
|
1237
|
+
onContextmenu: m[1] || (m[1] = D(() => {
|
|
1238
|
+
}, ["stop", "prevent"]))
|
|
1239
|
+
}, [
|
|
1240
|
+
l("div", Ts, [
|
|
1241
|
+
ne(l("input", {
|
|
1242
|
+
"onUpdate:modelValue": m[0] || (m[0] = (g) => d.value = g),
|
|
1243
|
+
type: "text",
|
|
1244
|
+
class: "baklava-input",
|
|
1245
|
+
title: "Filter node types"
|
|
1246
|
+
}, null, 512), [
|
|
1247
|
+
[oe, d.value]
|
|
1248
|
+
])
|
|
1249
|
+
]),
|
|
1250
|
+
(i(!0), r(T, null, A(O(_(a)), (g) => (i(), r("section", {
|
|
1251
|
+
key: g.name
|
|
1591
1252
|
}, [
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
], 34),
|
|
1618
|
-
createVNode(Transition, { name: "fade" }, {
|
|
1619
|
-
default: withCtx(() => [
|
|
1620
|
-
draggedNode.value ? (openBlock(), createElementBlock("div", {
|
|
1621
|
-
key: 0,
|
|
1622
|
-
class: "baklava-dragged-node",
|
|
1623
|
-
style: normalizeStyle(draggedNodeStyles.value)
|
|
1624
|
-
}, [
|
|
1625
|
-
createVNode(PaletteEntry, {
|
|
1626
|
-
type: draggedNode.value.type,
|
|
1627
|
-
title: draggedNode.value.nodeInformation.title
|
|
1628
|
-
}, null, 8, ["type", "title"])
|
|
1629
|
-
], 4)) : createCommentVNode("", true)
|
|
1630
|
-
]),
|
|
1631
|
-
_: 1
|
|
1632
|
-
})
|
|
1633
|
-
], 64);
|
|
1634
|
-
};
|
|
1253
|
+
g.name !== "default" ? (i(), r("h3", Ss, L(g.name), 1)) : N("", !0),
|
|
1254
|
+
(i(!0), r(T, null, A(x(g.nodeTypes), (b, p) => (i(), V(fe, {
|
|
1255
|
+
key: p,
|
|
1256
|
+
type: p,
|
|
1257
|
+
title: b.title,
|
|
1258
|
+
onPointerdown: (w) => B(p, b)
|
|
1259
|
+
}, null, 8, ["type", "title", "onPointerdown"]))), 128))
|
|
1260
|
+
]))), 128))
|
|
1261
|
+
], 34),
|
|
1262
|
+
S(it, { name: "fade" }, {
|
|
1263
|
+
default: W(() => [
|
|
1264
|
+
h.value ? (i(), r("div", {
|
|
1265
|
+
key: 0,
|
|
1266
|
+
class: "baklava-dragged-node",
|
|
1267
|
+
style: se(k.value)
|
|
1268
|
+
}, [
|
|
1269
|
+
S(fe, {
|
|
1270
|
+
type: h.value.type,
|
|
1271
|
+
title: h.value.nodeInformation.title
|
|
1272
|
+
}, null, 8, ["type", "title"])
|
|
1273
|
+
], 4)) : N("", !0)
|
|
1274
|
+
]),
|
|
1275
|
+
_: 1
|
|
1276
|
+
})
|
|
1277
|
+
], 64));
|
|
1635
1278
|
}
|
|
1636
|
-
})
|
|
1637
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1279
|
+
}), tn = /* @__PURE__ */ G({
|
|
1638
1280
|
__name: "CodeGraphEditor",
|
|
1639
1281
|
props: {
|
|
1640
1282
|
viewModel: {}
|
|
1641
1283
|
},
|
|
1642
|
-
setup(
|
|
1643
|
-
const
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
}, 8, ["view-model"]);
|
|
1669
|
-
};
|
|
1670
|
-
}
|
|
1671
|
-
});
|
|
1672
|
-
const addToolbarCommands = (viewModel) => {
|
|
1673
|
-
const TOGGLE_PALETTE_COMMAND = "TOGGLE_PALETTE";
|
|
1674
|
-
viewModel.commandHandler.registerCommand(TOGGLE_PALETTE_COMMAND, {
|
|
1675
|
-
execute: () => viewModel.settings.palette.enabled = !viewModel.settings.palette.enabled,
|
|
1676
|
-
canExecute: () => true
|
|
1284
|
+
setup(o) {
|
|
1285
|
+
const t = ye(o, "viewModel"), s = (n) => n.events.update.emit(null);
|
|
1286
|
+
return ee(() => {
|
|
1287
|
+
t.value.subscribe(), t.value.engine.start();
|
|
1288
|
+
}), rt(() => {
|
|
1289
|
+
t.value.unsubscribe(), t.value.engine.stop();
|
|
1290
|
+
}), (n, a) => (i(), V(_(qe), { "view-model": t.value }, {
|
|
1291
|
+
palette: W(() => [
|
|
1292
|
+
S(zs)
|
|
1293
|
+
]),
|
|
1294
|
+
node: W((u) => [
|
|
1295
|
+
S(gs, ut(u, {
|
|
1296
|
+
onUpdate: (d) => s(u.node)
|
|
1297
|
+
}), null, 16, ["onUpdate"])
|
|
1298
|
+
]),
|
|
1299
|
+
sidebar: W((u) => [
|
|
1300
|
+
S(Is, lt(dt(u)), null, 16)
|
|
1301
|
+
]),
|
|
1302
|
+
_: 1
|
|
1303
|
+
}, 8, ["view-model"]));
|
|
1304
|
+
}
|
|
1305
|
+
}), Bs = (o) => {
|
|
1306
|
+
const e = "TOGGLE_PALETTE";
|
|
1307
|
+
o.commandHandler.registerCommand(e, {
|
|
1308
|
+
execute: () => o.settings.palette.enabled = !o.settings.palette.enabled,
|
|
1309
|
+
canExecute: () => !0
|
|
1677
1310
|
});
|
|
1678
|
-
const
|
|
1679
|
-
|
|
1680
|
-
execute: () =>
|
|
1681
|
-
canExecute: () =>
|
|
1311
|
+
const t = "CLEAR_ALL";
|
|
1312
|
+
o.commandHandler.registerCommand(t, {
|
|
1313
|
+
execute: () => o.displayedGraph.nodes.forEach((n) => o.displayedGraph.removeNode(n)),
|
|
1314
|
+
canExecute: () => o.displayedGraph.nodes.length > 0
|
|
1682
1315
|
});
|
|
1683
|
-
const
|
|
1684
|
-
|
|
1685
|
-
execute: () =>
|
|
1686
|
-
canExecute: () =>
|
|
1687
|
-
})
|
|
1688
|
-
viewModel.settings.toolbar.commands = [
|
|
1316
|
+
const s = "TOGGLE_MINIMAP";
|
|
1317
|
+
o.commandHandler.registerCommand(s, {
|
|
1318
|
+
execute: () => o.settings.enableMinimap = !o.settings.enableMinimap,
|
|
1319
|
+
canExecute: () => o.displayedGraph.nodes.length > 1
|
|
1320
|
+
}), o.settings.toolbar.commands = [
|
|
1689
1321
|
{
|
|
1690
|
-
command:
|
|
1322
|
+
command: e,
|
|
1691
1323
|
title: "Toggle palette",
|
|
1692
1324
|
// Tooltip text
|
|
1693
|
-
icon:
|
|
1325
|
+
icon: f(() => o.settings.palette.enabled ? Ot : St)
|
|
1694
1326
|
},
|
|
1695
|
-
...
|
|
1327
|
+
...Qe,
|
|
1696
1328
|
{
|
|
1697
|
-
command:
|
|
1329
|
+
command: t,
|
|
1698
1330
|
title: "Clear all",
|
|
1699
1331
|
// Tooltip text
|
|
1700
|
-
icon:
|
|
1332
|
+
icon: ss
|
|
1701
1333
|
},
|
|
1702
1334
|
{
|
|
1703
|
-
command:
|
|
1335
|
+
command: s,
|
|
1704
1336
|
title: "Toggle minimap",
|
|
1705
1337
|
// Tooltip text
|
|
1706
|
-
icon:
|
|
1338
|
+
icon: f(() => o.settings.enableMinimap ? Zt : Yt)
|
|
1707
1339
|
}
|
|
1708
1340
|
];
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
|
-
enableMinimap: false,
|
|
1341
|
+
}, F = {
|
|
1342
|
+
enableMinimap: !1,
|
|
1712
1343
|
toolbar: {
|
|
1713
|
-
enabled:
|
|
1344
|
+
enabled: !0
|
|
1714
1345
|
},
|
|
1715
1346
|
palette: {
|
|
1716
|
-
enabled:
|
|
1347
|
+
enabled: !0
|
|
1717
1348
|
},
|
|
1718
1349
|
sidebar: {
|
|
1719
|
-
enabled:
|
|
1720
|
-
resizable:
|
|
1350
|
+
enabled: !0,
|
|
1351
|
+
resizable: !0,
|
|
1721
1352
|
width: 350
|
|
1722
1353
|
},
|
|
1723
|
-
displayValueOnHover:
|
|
1354
|
+
displayValueOnHover: !1
|
|
1724
1355
|
};
|
|
1725
|
-
function
|
|
1726
|
-
const
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
});
|
|
1733
|
-
viewModel.settings = reactive({ ...viewModel.settings, ...settings });
|
|
1734
|
-
viewModel.settings.nodes.defaultWidth = 350;
|
|
1735
|
-
viewModel.state = reactive({
|
|
1356
|
+
function sn(o) {
|
|
1357
|
+
const e = Ze(o?.existingEditor);
|
|
1358
|
+
e.code = o?.code ? new o.code(e) : new wt(e), Bs(e);
|
|
1359
|
+
const t = {};
|
|
1360
|
+
return Object.keys(F).forEach((s) => {
|
|
1361
|
+
t[s] = typeof F[s] == "object" ? { ...e.settings[s], ...F[s] } : F[s];
|
|
1362
|
+
}), e.settings = R({ ...e.settings, ...t }), e.settings.nodes.defaultWidth = 350, e.state = R({
|
|
1736
1363
|
modules: {},
|
|
1737
1364
|
token: null
|
|
1738
|
-
})
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
viewModel.engine.resume();
|
|
1752
|
-
});
|
|
1753
|
-
viewModel.engine.events.afterRun.subscribe(token, (result) => {
|
|
1754
|
-
viewModel.engine.pause();
|
|
1755
|
-
applyResult(result, viewModel.editor);
|
|
1756
|
-
transferCodeScript(viewModel.displayedGraph);
|
|
1757
|
-
if (viewModel.code) {
|
|
1758
|
-
viewModel.code.renderNodeCodes();
|
|
1759
|
-
viewModel.code.renderCode();
|
|
1760
|
-
}
|
|
1761
|
-
viewModel.engine.resume();
|
|
1762
|
-
});
|
|
1763
|
-
viewModel.state.token = token;
|
|
1764
|
-
};
|
|
1765
|
-
viewModel.unsubscribe = () => {
|
|
1766
|
-
if (!viewModel.state.token) return;
|
|
1767
|
-
const token = viewModel.state.token;
|
|
1768
|
-
viewModel.displayedGraph.events.addNode.unsubscribe(token);
|
|
1769
|
-
viewModel.engine.events.beforeRun.unsubscribe(token);
|
|
1770
|
-
viewModel.engine.events.afterRun.unsubscribe(token);
|
|
1771
|
-
viewModel.state.token = null;
|
|
1772
|
-
};
|
|
1773
|
-
return viewModel;
|
|
1365
|
+
}), e.engine = new Ke(e.editor), e.subscribe = () => {
|
|
1366
|
+
e.state.token && e.unsubscribe();
|
|
1367
|
+
const s = Symbol();
|
|
1368
|
+
e.displayedGraph.events.addNode.subscribe(s, (n) => n.code = e.code), e.engine.events.beforeRun.subscribe(s, () => {
|
|
1369
|
+
e.engine.pause(), e.code && (e.code.onCodeUpdate(), e.code.sortNodes(), e.code.updateOutputVariableNames()), e.engine.resume();
|
|
1370
|
+
}), e.engine.events.afterRun.subscribe(s, (n) => {
|
|
1371
|
+
e.engine.pause(), et(n, e.editor), xt(e.displayedGraph), e.code && (e.code.renderNodeCodes(), e.code.renderCode()), e.engine.resume();
|
|
1372
|
+
}), e.state.token = s;
|
|
1373
|
+
}, e.unsubscribe = () => {
|
|
1374
|
+
if (!e.state.token) return;
|
|
1375
|
+
const s = e.state.token;
|
|
1376
|
+
e.displayedGraph.events.addNode.unsubscribe(s), e.engine.events.beforeRun.unsubscribe(s), e.engine.events.afterRun.unsubscribe(s), e.state.token = null;
|
|
1377
|
+
}, e;
|
|
1774
1378
|
}
|
|
1775
1379
|
export {
|
|
1776
|
-
AbstractCodeNode,
|
|
1777
|
-
ButtonInterface,
|
|
1778
|
-
|
|
1779
|
-
CheckboxInterface,
|
|
1780
|
-
|
|
1781
|
-
Code,
|
|
1782
|
-
|
|
1783
|
-
CodeInputInterface,
|
|
1784
|
-
CodeNode,
|
|
1785
|
-
CodeNodeInterface,
|
|
1786
|
-
CodeOutputInterface,
|
|
1787
|
-
DEFAULT_SETTINGS,
|
|
1788
|
-
DynamicCodeNode,
|
|
1789
|
-
IntegerInterface,
|
|
1790
|
-
|
|
1791
|
-
NumberInterface,
|
|
1792
|
-
|
|
1793
|
-
SelectInterface,
|
|
1794
|
-
|
|
1795
|
-
SliderInterface,
|
|
1796
|
-
|
|
1797
|
-
TextInputInterface,
|
|
1798
|
-
|
|
1799
|
-
TextInterface,
|
|
1800
|
-
TextareaInputInterface,
|
|
1801
|
-
|
|
1802
|
-
addToolbarCommands,
|
|
1803
|
-
defineCodeNode,
|
|
1804
|
-
defineDynamicCodeNode,
|
|
1805
|
-
getCodeNodes,
|
|
1806
|
-
getPositionAtColumn,
|
|
1807
|
-
getPositionBeforeNode,
|
|
1808
|
-
loadNodeState,
|
|
1809
|
-
saveNodeState,
|
|
1810
|
-
transferCodeScript,
|
|
1811
|
-
useCodeGraph
|
|
1380
|
+
vt as AbstractCodeNode,
|
|
1381
|
+
Ps as ButtonInterface,
|
|
1382
|
+
an as ButtonInterfaceComponent,
|
|
1383
|
+
Ds as CheckboxInterface,
|
|
1384
|
+
rn as CheckboxInterfaceComponent,
|
|
1385
|
+
wt as Code,
|
|
1386
|
+
tn as CodeGraphEditor,
|
|
1387
|
+
Hs as CodeInputInterface,
|
|
1388
|
+
we as CodeNode,
|
|
1389
|
+
M as CodeNodeInterface,
|
|
1390
|
+
_t as CodeOutputInterface,
|
|
1391
|
+
F as DEFAULT_SETTINGS,
|
|
1392
|
+
yt as DynamicCodeNode,
|
|
1393
|
+
As as IntegerInterface,
|
|
1394
|
+
ln as IntegerInterfaceComponent,
|
|
1395
|
+
Fs as NumberInterface,
|
|
1396
|
+
dn as NumberInterfaceComponent,
|
|
1397
|
+
Ws as SelectInterface,
|
|
1398
|
+
un as SelectInterfaceComponent,
|
|
1399
|
+
Xs as SliderInterface,
|
|
1400
|
+
cn as SliderInterfaceComponent,
|
|
1401
|
+
Js as TextInputInterface,
|
|
1402
|
+
pn as TextInputInterfaceComponent,
|
|
1403
|
+
Ys as TextInterface,
|
|
1404
|
+
qs as TextareaInputInterface,
|
|
1405
|
+
hn as TextareaInputInterfaceComponent,
|
|
1406
|
+
Bs as addToolbarCommands,
|
|
1407
|
+
Qs as defineCodeNode,
|
|
1408
|
+
Zs as defineDynamicCodeNode,
|
|
1409
|
+
Z as getCodeNodes,
|
|
1410
|
+
Ks as getPositionAtColumn,
|
|
1411
|
+
en as getPositionBeforeNode,
|
|
1412
|
+
xe as loadNodeState,
|
|
1413
|
+
mt as saveNodeState,
|
|
1414
|
+
xt as transferCodeScript,
|
|
1415
|
+
sn as useCodeGraph
|
|
1812
1416
|
};
|