@babsey/code-graph 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code-graph.css +1 -1
- package/dist/code-graph.js +1461 -1106
- package/dist/code-graph.umd.cjs +4 -1
- package/package.json +7 -7
- package/dist/code.d.ts +0 -158
- package/dist/codeNode/codeGraphNode.d.ts +0 -11
- package/dist/codeNode/codeNode.d.ts +0 -111
- package/dist/codeNode/defineCodeNode.d.ts +0 -18
- package/dist/codeNode/dynamicCodeNode.d.ts +0 -38
- package/dist/codeNode/index.d.ts +0 -4
- package/dist/codeNodeInterfaces/baseNumericInterface.d.ts +0 -23
- package/dist/codeNodeInterfaces/baseStringInterface.d.ts +0 -5
- package/dist/codeNodeInterfaces/checkbox/checkboxInterface.d.ts +0 -5
- package/dist/codeNodeInterfaces/codeNode/CodeNodeInterface.vue.d.ts +0 -7
- package/dist/codeNodeInterfaces/codeNode/codeNodeInterface.d.ts +0 -23
- package/dist/codeNodeInterfaces/codeNodeInput/codeNodeInputInterface.d.ts +0 -7
- package/dist/codeNodeInterfaces/codeNodeOutput/codeNodeOutputInterface.d.ts +0 -6
- package/dist/codeNodeInterfaces/index.d.ts +0 -12
- package/dist/codeNodeInterfaces/integer/integerInterface.d.ts +0 -6
- package/dist/codeNodeInterfaces/listInput/listInputInterface.d.ts +0 -5
- package/dist/codeNodeInterfaces/number/numberInterface.d.ts +0 -5
- package/dist/codeNodeInterfaces/select/selectInterface.d.ts +0 -12
- package/dist/codeNodeInterfaces/slider/sliderInterface.d.ts +0 -9
- package/dist/codeNodeInterfaces/textInput/TextInputInterface.vue.d.ts +0 -26
- package/dist/codeNodeInterfaces/textInput/textInputInterface.d.ts +0 -7
- package/dist/codeNodeInterfaces/textareaInput/textareaInputInterface.d.ts +0 -5
- package/dist/codeNodeInterfaces/tupleInput/tupleInputInterface.d.ts +0 -5
- package/dist/components/CodeGraphEditor.vue.d.ts +0 -19
- package/dist/components/index.d.ts +0 -1
- package/dist/components/node/CodeGraphNode.vue.d.ts +0 -39
- package/dist/components/nodeInterface/CodeGraphNodeInterface.vue.d.ts +0 -19
- package/dist/components/nodePalette/CodeNodePalette.vue.d.ts +0 -3
- package/dist/components/nodePalette/PaletteEntry.vue.d.ts +0 -31
- package/dist/components/sidebar/Checkbox.vue.d.ts +0 -13
- package/dist/components/sidebar/CodeGraphSidebar.vue.d.ts +0 -15
- package/dist/icons/CodeVariable.vue.d.ts +0 -3
- package/dist/icons/DotsVertical.vue.d.ts +0 -3
- package/dist/icons/LayoutSidebarLeftCollapse.vue.d.ts +0 -3
- package/dist/icons/LayoutSidebarLeftExpand.vue.d.ts +0 -3
- package/dist/icons/LayoutSidebarRight.vue.d.ts +0 -3
- package/dist/icons/LayoutSidebarRightCollapse.vue.d.ts +0 -3
- package/dist/icons/LayoutSidebarRightExpand.vue.d.ts +0 -3
- package/dist/icons/LockCode.vue.d.ts +0 -3
- package/dist/icons/Schema.vue.d.ts +0 -3
- package/dist/icons/SchemaOff.vue.d.ts +0 -3
- package/dist/icons/TransitionBottom.vue.d.ts +0 -3
- package/dist/icons/TrashOff.vue.d.ts +0 -3
- package/dist/icons/index.d.ts +0 -12
- package/dist/index.d.ts +0 -11
- package/dist/interfaceTypes/default.d.ts +0 -9
- package/dist/interfaceTypes/index.d.ts +0 -1
- package/dist/settings.d.ts +0 -11
- package/dist/utils.d.ts +0 -5
- package/dist/viewModel.d.ts +0 -20
package/dist/code-graph.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import Z from "mustache";
|
|
2
|
+
import { reactive as D, defineComponent as F, createElementBlock as p, openBlock as d, toDisplayString as G, markRaw as z, computed as O, createElementVNode as u, withDirectives as de, vModelText as le, createStaticVNode as se, toRef as Be, onMounted as fe, onBeforeUnmount as ze, watch as He, createBlock as j, unref as w, withCtx as ee, createVNode as L, normalizeProps as pt, guardReactiveProps as ht, renderSlot as ne, mergeProps as mt, ref as R, onUpdated as Le, normalizeStyle as ve, normalizeClass as Y, createCommentVNode as M, withModifiers as te, Fragment as B, createTextVNode as ft, withKeys as he, renderList as J, nextTick as vt, inject as gt, Transition as bt, resolveDynamicComponent as Me, shallowReadonly as _t } from "vue";
|
|
3
|
+
import { v4 as K } from "uuid";
|
|
4
|
+
import { AbstractNode as yt, NodeInterface as A, getGraphNodeTypeString as Ue, Graph as Ct, GraphTemplate as It, GRAPH_NODE_TYPE_PREFIX as wt, GRAPH_INPUT_NODE_TYPE as kt, GRAPH_OUTPUT_NODE_TYPE as Nt, Editor as xt } from "@baklavajs/core";
|
|
5
|
+
import { NodeInterfaceType as X, BaklavaInterfaceTypes as Ot, setType as $ } from "@baklavajs/interface-types";
|
|
6
|
+
import { allowMultipleConnections as Q, applyResult as Ae, BaseEngine as Tt, sortTopologically as Et } from "@baklavajs/engine";
|
|
7
|
+
import { displayInSidebar as De, CheckboxInterfaceComponent as $t, useGraph as ge, IntegerInterfaceComponent as Mt, TextInputInterfaceComponent as Fe, NumberInterfaceComponent as Gt, SelectInterfaceComponent as St, SliderInterfaceComponent as Pt, TextareaInputInterfaceComponent as Rt, IntegerInterface as Vt, TextInputInterface as be, DEFAULT_TOOLBAR_COMMANDS as jt, Commands as q, BaklavaEditor as Bt, Components as me, useViewModel as oe, useTemporaryConnection as zt, useTransform as Ht, useNodeCategories as Lt, DEFAULT_SETTINGS as Ut, useCommandHandler as At, useHistory as Dt, useClipboard as Ft, registerDeleteNodesCommand as Wt, registerSaveSubgraphCommand as Yt, registerSwitchToMainGraphCommand as Kt, registerSidebarCommands as Xt, registerZoomToFitCommands as qt, setViewNodeProperties as Jt } from "@baklavajs/renderer-vue";
|
|
8
|
+
import Qt from "toposort";
|
|
9
|
+
import { SequentialHook as Ge } from "@baklavajs/events";
|
|
10
|
+
import { usePointer as Zt } from "@vueuse/core";
|
|
11
|
+
Z.escape = (n) => n;
|
|
12
|
+
class We extends yt {
|
|
9
13
|
state;
|
|
10
|
-
code;
|
|
11
14
|
isCodeNode = !0;
|
|
12
15
|
name = "";
|
|
13
16
|
codeTemplate;
|
|
14
17
|
inputs = {};
|
|
15
18
|
outputs = {};
|
|
16
19
|
constructor() {
|
|
17
|
-
super(), this.initializeIo(), this.twoColumn = !0, this.state =
|
|
20
|
+
super(), this.initializeIo(), this.twoColumn = !0, this.state = D({
|
|
18
21
|
codeTemplate: "",
|
|
19
22
|
hidden: !1,
|
|
20
23
|
integrated: !1,
|
|
@@ -22,26 +25,36 @@ class Ee extends Ke {
|
|
|
22
25
|
modules: [],
|
|
23
26
|
props: null,
|
|
24
27
|
script: "",
|
|
25
|
-
variableName: "
|
|
28
|
+
variableName: "a"
|
|
26
29
|
}), this.codeTemplate = function() {
|
|
27
|
-
return `${this.name}(${
|
|
30
|
+
return `${this.name}(${en(this.codeNodeInputs).join(", ")})`;
|
|
28
31
|
};
|
|
29
32
|
}
|
|
33
|
+
get code() {
|
|
34
|
+
return this.graph.code;
|
|
35
|
+
}
|
|
30
36
|
get codeNodeInputs() {
|
|
31
37
|
return Object.fromEntries(
|
|
32
|
-
Object.entries(this.inputs).filter(
|
|
38
|
+
Object.entries(this.inputs).filter(
|
|
39
|
+
(e) => e[1].isCodeNode && e[1].type != "node"
|
|
40
|
+
)
|
|
33
41
|
);
|
|
34
42
|
}
|
|
35
43
|
get codeNodeOutputs() {
|
|
36
44
|
return Object.fromEntries(
|
|
37
|
-
Object.entries(this.outputs).filter(
|
|
45
|
+
Object.entries(this.outputs).filter(
|
|
46
|
+
(e) => e[1].isCodeNode && e[1].type != "node"
|
|
47
|
+
)
|
|
38
48
|
);
|
|
39
49
|
}
|
|
50
|
+
get graph() {
|
|
51
|
+
return super.graph;
|
|
52
|
+
}
|
|
40
53
|
get idx() {
|
|
41
|
-
return this.
|
|
54
|
+
return this.graph.nodes.filter((e) => !e.state.integrated).indexOf(this) ?? -1;
|
|
42
55
|
}
|
|
43
56
|
get idxByVariableNames() {
|
|
44
|
-
return this.
|
|
57
|
+
return this.graph.getNodesBySameVariableNames(this.state.variableName).filter((e) => !e.state.integrated).indexOf(this) ?? -1;
|
|
45
58
|
}
|
|
46
59
|
get lockCode() {
|
|
47
60
|
return this.state.lockCode;
|
|
@@ -60,10 +73,10 @@ class Ee extends Ke {
|
|
|
60
73
|
);
|
|
61
74
|
}
|
|
62
75
|
get script() {
|
|
63
|
-
return this.
|
|
76
|
+
return this.outputs._code?.value ?? "";
|
|
64
77
|
}
|
|
65
78
|
set script(e) {
|
|
66
|
-
this.
|
|
79
|
+
this.outputs._code && (this.outputs._code.value = e), this.events.update.emit(null);
|
|
67
80
|
}
|
|
68
81
|
get shortId() {
|
|
69
82
|
return this.id.slice(0, 6);
|
|
@@ -79,8 +92,8 @@ class Ee extends Ke {
|
|
|
79
92
|
* @returns code node instance or null
|
|
80
93
|
*/
|
|
81
94
|
getConnectedNodeByInterface(e, t) {
|
|
82
|
-
const
|
|
83
|
-
return
|
|
95
|
+
const s = this.getConnectedNodesByInterface(e, t);
|
|
96
|
+
return s.length > 0 ? s[0] : null;
|
|
84
97
|
}
|
|
85
98
|
/**
|
|
86
99
|
* Get connected nodes to the node.
|
|
@@ -90,14 +103,14 @@ class Ee extends Ke {
|
|
|
90
103
|
getConnectedNodes(e) {
|
|
91
104
|
let t = [];
|
|
92
105
|
if (e !== "inputs") {
|
|
93
|
-
const
|
|
94
|
-
|
|
106
|
+
const s = this.graph.connections.filter((o) => o.from.name !== "_code").filter((o) => o.from.nodeId === this.id).map((o) => o.to.nodeId);
|
|
107
|
+
s && (t = t.concat(s));
|
|
95
108
|
}
|
|
96
109
|
if (e !== "outputs") {
|
|
97
|
-
const
|
|
98
|
-
|
|
110
|
+
const s = this.graph.connections.filter((o) => o.from.name !== "_code").filter((o) => o.to.nodeId === this.id).map((o) => o.from.nodeId);
|
|
111
|
+
s && (t = t.concat(s));
|
|
99
112
|
}
|
|
100
|
-
return !t || t.length == 0 ? [] : t.map((
|
|
113
|
+
return !t || t.length == 0 ? [] : t.map((s) => this.graph.findNodeById(s));
|
|
101
114
|
}
|
|
102
115
|
/**
|
|
103
116
|
* Get connected nodes to the node interface.
|
|
@@ -105,20 +118,20 @@ class Ee extends Ke {
|
|
|
105
118
|
* @returns code node instances
|
|
106
119
|
*/
|
|
107
120
|
getConnectedNodesByInterface(e, t) {
|
|
108
|
-
let
|
|
121
|
+
let s = [];
|
|
109
122
|
if (t !== "outputs" && this.inputs[e]) {
|
|
110
|
-
const o = this.graph
|
|
123
|
+
const o = this.graph.connections.filter(
|
|
111
124
|
(a) => a.to.id === this.inputs[e]?.id || a.from.id === this.inputs[e]?.id
|
|
112
125
|
).map((a) => a.from.nodeId);
|
|
113
|
-
o && (
|
|
126
|
+
o && (s = s.concat(o));
|
|
114
127
|
}
|
|
115
128
|
if (t !== "inputs" && this.outputs[e]) {
|
|
116
|
-
const o = this.graph
|
|
129
|
+
const o = this.graph.connections.filter(
|
|
117
130
|
(a) => a.from.id === this.outputs[e]?.id || a.from.id === this.outputs[e]?.id
|
|
118
131
|
).map((a) => a.to.nodeId);
|
|
119
|
-
o && (
|
|
132
|
+
o && (s = s.concat(o));
|
|
120
133
|
}
|
|
121
|
-
return !
|
|
134
|
+
return !s || s.length == 0 ? [] : s.map((o) => this.graph.findNodeById(o));
|
|
122
135
|
}
|
|
123
136
|
/**
|
|
124
137
|
* Register code
|
|
@@ -130,53 +143,53 @@ class Ee extends Ke {
|
|
|
130
143
|
/**
|
|
131
144
|
* Render code of this node.
|
|
132
145
|
*/
|
|
133
|
-
renderCode() {
|
|
134
|
-
|
|
135
|
-
const e = {};
|
|
136
|
-
Object.keys(this.inputs).forEach((n) => {
|
|
137
|
-
if (n === "_code") return;
|
|
138
|
-
const o = this.inputs[n];
|
|
139
|
-
o && o.state && (e[n] = o.state.script.length > 0 ? o.state.script : o.getValue());
|
|
140
|
-
});
|
|
141
|
-
const t = {};
|
|
142
|
-
Object.keys(this.outputs).forEach((n) => {
|
|
143
|
-
if (n === "_code") return;
|
|
144
|
-
const o = this.outputs[n];
|
|
145
|
-
o && o.state && (t[n] = o.getValue());
|
|
146
|
-
}), this.state.script = Y.render(this.state.codeTemplate, { inputs: e, outputs: t });
|
|
147
|
-
}
|
|
148
|
-
this.outputs.out && (this.outputs.out.state.script = this.script);
|
|
146
|
+
renderCode(e) {
|
|
147
|
+
return Z.render(this.state.codeTemplate, e);
|
|
149
148
|
}
|
|
150
149
|
/**
|
|
151
|
-
*
|
|
150
|
+
* Update code templates.
|
|
152
151
|
*/
|
|
153
|
-
resetInputInterfaceScript() {
|
|
154
|
-
Object.values(this.codeNodeInputs).forEach((e) => e.resetScript());
|
|
155
|
-
}
|
|
156
152
|
updateCodeTemplate() {
|
|
157
153
|
this.state.codeTemplate = this.codeTemplate.call(this);
|
|
158
154
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Update modules.
|
|
157
|
+
* @param modules a list of modules
|
|
158
|
+
*/
|
|
159
|
+
updateModules(e) {
|
|
160
|
+
if (e)
|
|
161
|
+
this.state.modules = e;
|
|
162
|
+
else if (this.type.includes(".")) {
|
|
163
|
+
const t = this.type.split(".");
|
|
164
|
+
this.state.modules.push(t.slice(0, t.length - 1).join("."));
|
|
165
|
+
}
|
|
169
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Update output names.
|
|
169
|
+
*/
|
|
170
170
|
updateOutputNames() {
|
|
171
171
|
Object.values(this.codeNodeOutputs).forEach((e) => {
|
|
172
|
-
e.name = this.state.integrated ? "" : this.variableName + e.
|
|
172
|
+
e.name = this.state.integrated ? "" : this.variableName + e.suffix;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Update output values.
|
|
177
|
+
* @param output return data of calculate function
|
|
178
|
+
*/
|
|
179
|
+
updateOutputValues(e) {
|
|
180
|
+
Object.keys(this.outputs).forEach((t) => {
|
|
181
|
+
t !== "_code" && (e[t] = this.state.integrated ? e._code : this.outputs[t].name);
|
|
173
182
|
});
|
|
174
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Update state props.
|
|
186
|
+
* @param props
|
|
187
|
+
*/
|
|
175
188
|
updateProps(e) {
|
|
176
189
|
this.state.props = e;
|
|
177
190
|
}
|
|
178
191
|
}
|
|
179
|
-
class
|
|
192
|
+
class _e extends We {
|
|
180
193
|
/**
|
|
181
194
|
* The default implementation does nothing.
|
|
182
195
|
* Overwrite this method to do calculation.
|
|
@@ -184,100 +197,80 @@ class Se extends Ee {
|
|
|
184
197
|
* @param globalValues Set of values passed to every node by the engine plugin
|
|
185
198
|
* @return Values for output interfaces
|
|
186
199
|
*/
|
|
187
|
-
calculate
|
|
200
|
+
calculate = (e, t) => {
|
|
201
|
+
const s = {};
|
|
202
|
+
return this.lockCode || (s._code = this.renderCode({ inputs: e, ...t })), this.updateOutputValues(s), s;
|
|
203
|
+
};
|
|
188
204
|
load(e) {
|
|
189
|
-
super.load(e),
|
|
205
|
+
super.load(e), Ye(this.graph, e);
|
|
190
206
|
}
|
|
191
207
|
save() {
|
|
192
208
|
const e = super.save();
|
|
193
|
-
return
|
|
194
|
-
}
|
|
195
|
-
updateModules(e) {
|
|
196
|
-
if (e)
|
|
197
|
-
this.state.modules = e;
|
|
198
|
-
else if (this.type.includes(".")) {
|
|
199
|
-
const t = this.type.split(".");
|
|
200
|
-
this.state.modules.push(t.slice(0, t.length - 1).join("."));
|
|
201
|
-
}
|
|
209
|
+
return tn(this.graph, e), e;
|
|
202
210
|
}
|
|
203
211
|
}
|
|
204
|
-
const
|
|
205
|
-
const t = [],
|
|
206
|
-
return
|
|
207
|
-
if (
|
|
208
|
-
const
|
|
209
|
-
t.push(`${
|
|
212
|
+
const en = (n, e = !0) => {
|
|
213
|
+
const t = [], s = Object.keys(n);
|
|
214
|
+
return s.forEach((o) => {
|
|
215
|
+
if (n[o]?.hidden) return;
|
|
216
|
+
const i = e && t.length < s.indexOf(o) ? `${o}=` : "";
|
|
217
|
+
t.push(`${i}{{ inputs.${o} }}`);
|
|
210
218
|
}), t;
|
|
211
|
-
},
|
|
212
|
-
if (!
|
|
213
|
-
const t =
|
|
219
|
+
}, Ye = (n, e) => {
|
|
220
|
+
if (!n) return;
|
|
221
|
+
const t = n.findNodeById(e.id);
|
|
214
222
|
if (!t || t.subgraph) return;
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
o !== "_code" &&
|
|
223
|
+
const s = t;
|
|
224
|
+
s.state && (s.state.integrated = e.integrated, s.state.modules = e.modules, s.state.props = e.props), Object.entries(e.inputs).forEach(([o, a]) => {
|
|
225
|
+
o !== "_code" && s.inputs[o] && (s.inputs[o].hidden = a.hidden);
|
|
218
226
|
}), Object.entries(e.outputs).forEach(([o, a]) => {
|
|
219
|
-
o !== "_code" &&
|
|
227
|
+
o !== "_code" && s.outputs[o] && (s.outputs[o].hidden = a.hidden);
|
|
220
228
|
});
|
|
221
|
-
},
|
|
222
|
-
if (!
|
|
223
|
-
const t =
|
|
229
|
+
}, tn = (n, e) => {
|
|
230
|
+
if (!n) return;
|
|
231
|
+
const t = n.findNodeById(e.id);
|
|
224
232
|
if (!t || t.subgraph) return;
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
o !== "_code" &&
|
|
233
|
+
const s = t;
|
|
234
|
+
s.state && (e.integrated = s.state.integrated, e.modules = s.state.modules), Object.entries(e.inputs).forEach(([o, a]) => {
|
|
235
|
+
o !== "_code" && s.inputs[o] && (a.hidden = s.inputs[o].hidden);
|
|
228
236
|
}), Object.entries(e.outputs).forEach(([o, a]) => {
|
|
229
|
-
o !== "_code" &&
|
|
237
|
+
o !== "_code" && s.outputs[o] && (a.hidden = s.outputs[o].hidden);
|
|
230
238
|
});
|
|
231
|
-
},
|
|
239
|
+
}, nn = ["title"], ye = /* @__PURE__ */ F({
|
|
232
240
|
__name: "CodeNodeInterface",
|
|
233
241
|
props: {
|
|
234
242
|
intf: {}
|
|
235
243
|
},
|
|
236
|
-
setup(
|
|
237
|
-
return (e, t) => (
|
|
238
|
-
title:
|
|
239
|
-
},
|
|
244
|
+
setup(n) {
|
|
245
|
+
return (e, t) => (d(), p("div", {
|
|
246
|
+
title: n.intf.value
|
|
247
|
+
}, G(n.intf.name), 9, nn));
|
|
240
248
|
}
|
|
241
249
|
});
|
|
242
|
-
class
|
|
250
|
+
class V extends A {
|
|
243
251
|
isCodeNode = !0;
|
|
244
252
|
code;
|
|
245
253
|
state;
|
|
246
254
|
type = null;
|
|
247
255
|
constructor(e, t) {
|
|
248
|
-
super(e, t), this.setComponent(
|
|
249
|
-
optional: !1
|
|
250
|
-
script: ""
|
|
256
|
+
super(e, t), this.setComponent(z(ye)), this.state = D({
|
|
257
|
+
optional: !1
|
|
251
258
|
});
|
|
252
259
|
}
|
|
253
260
|
get optional() {
|
|
254
261
|
return this.state.optional;
|
|
255
262
|
}
|
|
256
|
-
get script() {
|
|
257
|
-
return this.state.script;
|
|
258
|
-
}
|
|
259
|
-
set script(e) {
|
|
260
|
-
this.state.script = e;
|
|
261
|
-
}
|
|
262
263
|
get shortId() {
|
|
263
264
|
return this.id.slice(0, 6);
|
|
264
265
|
}
|
|
265
266
|
getValue = () => `${this.value ?? "None"}`;
|
|
266
|
-
resetScript = () => this.state.script = "";
|
|
267
267
|
setOptional(e) {
|
|
268
268
|
return this.state.optional = e, this.setHidden(e), this;
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
-
class
|
|
271
|
+
class ae extends V {
|
|
272
272
|
constructor(e = "", t) {
|
|
273
|
-
super(e, t), this.setComponent(
|
|
274
|
-
}
|
|
275
|
-
set script(e) {
|
|
276
|
-
if (this.state.script && this.allowMultipleConnections) {
|
|
277
|
-
const t = this.state.script;
|
|
278
|
-
t.startsWith("[") && t.endsWith("]") ? e = JSON.stringify([e, ...JSON.parse(t)]) : e = [e, t].join(", ");
|
|
279
|
-
}
|
|
280
|
-
this.state.script = e;
|
|
273
|
+
super(e, t), this.setComponent(z(ye)), this.use(De, !0);
|
|
281
274
|
}
|
|
282
275
|
get value() {
|
|
283
276
|
return super.value;
|
|
@@ -286,72 +279,77 @@ class Q extends G {
|
|
|
286
279
|
super.value = e, this.name !== "_code" && this.setHidden(!1);
|
|
287
280
|
}
|
|
288
281
|
}
|
|
289
|
-
const
|
|
290
|
-
new
|
|
282
|
+
const Ke = new X("boolean"), sn = new X("dict"), Xe = new X("list"), U = new X("node"), Ce = new X("number"), Ie = new X("string"), qe = new X("tuple"), mo = (n) => {
|
|
283
|
+
new Ot(n.editor, { viewPlugin: n }).addTypes(Ke, sn, Xe, U, Ce, Ie, qe);
|
|
291
284
|
};
|
|
292
|
-
class
|
|
285
|
+
class fo extends ae {
|
|
293
286
|
constructor(e, t) {
|
|
294
|
-
super(e, t), this.setComponent(
|
|
287
|
+
super(e, t), this.setComponent(z($t)), this.use($, Ke);
|
|
295
288
|
}
|
|
296
289
|
getValue = () => this.value ? "True" : "False";
|
|
297
290
|
}
|
|
298
|
-
class
|
|
291
|
+
class on extends V {
|
|
299
292
|
isCodeNodeOutput = !0;
|
|
293
|
+
suffix = "";
|
|
300
294
|
constructor(e = "", t = "") {
|
|
301
|
-
super(e,
|
|
295
|
+
super(e, ""), this.suffix = t, this.setComponent(z(ye));
|
|
302
296
|
}
|
|
303
|
-
get
|
|
304
|
-
return this.
|
|
297
|
+
get codeValue() {
|
|
298
|
+
return this.node?.outputs._code.value ?? "";
|
|
299
|
+
}
|
|
300
|
+
get node() {
|
|
301
|
+
const { graph: e } = ge();
|
|
302
|
+
return e.value.findNodeById(this.nodeId);
|
|
305
303
|
}
|
|
306
304
|
}
|
|
307
|
-
class
|
|
305
|
+
class we extends ae {
|
|
308
306
|
min;
|
|
309
307
|
max;
|
|
310
|
-
constructor(e, t,
|
|
311
|
-
super(e, t), this.min =
|
|
308
|
+
constructor(e, t, s, o) {
|
|
309
|
+
super(e, t), this.min = s, this.max = o, this.use($, Ce);
|
|
312
310
|
}
|
|
313
311
|
validate(e) {
|
|
314
312
|
return (this.min === void 0 || e >= this.min) && (this.max === void 0 || e <= this.max);
|
|
315
313
|
}
|
|
316
314
|
}
|
|
317
|
-
class
|
|
318
|
-
component =
|
|
315
|
+
class vo extends we {
|
|
316
|
+
component = z(Mt);
|
|
319
317
|
validate(e) {
|
|
320
318
|
return Number.isInteger(e) && super.validate(e);
|
|
321
319
|
}
|
|
322
320
|
}
|
|
323
|
-
class
|
|
321
|
+
class go extends ae {
|
|
324
322
|
constructor(e = "", t = "") {
|
|
325
|
-
super(e, t), this.setComponent(
|
|
323
|
+
super(e, t), this.setComponent(z(Fe)), this.use($, Xe);
|
|
326
324
|
}
|
|
327
325
|
getValue = () => `[${this.value}]`;
|
|
328
326
|
}
|
|
329
|
-
class
|
|
330
|
-
component =
|
|
327
|
+
class bo extends we {
|
|
328
|
+
component = z(Gt);
|
|
331
329
|
}
|
|
332
|
-
class
|
|
330
|
+
class ke extends ae {
|
|
333
331
|
constructor(e, t) {
|
|
334
|
-
super(e, t), this.use(
|
|
332
|
+
super(e, t), this.use($, Ie);
|
|
335
333
|
}
|
|
336
334
|
getValue = () => `"${this.value}"`;
|
|
337
335
|
}
|
|
338
|
-
class
|
|
339
|
-
component =
|
|
336
|
+
class _o extends ke {
|
|
337
|
+
component = z(St);
|
|
340
338
|
items;
|
|
341
|
-
constructor(e, t,
|
|
342
|
-
super(e, t), this.items =
|
|
339
|
+
constructor(e, t, s) {
|
|
340
|
+
super(e, t), this.items = s;
|
|
343
341
|
}
|
|
344
342
|
}
|
|
345
|
-
class
|
|
346
|
-
component =
|
|
343
|
+
class yo extends we {
|
|
344
|
+
component = z(Pt);
|
|
347
345
|
min;
|
|
348
346
|
max;
|
|
349
|
-
constructor(e, t,
|
|
350
|
-
super(e, t,
|
|
347
|
+
constructor(e, t, s, o) {
|
|
348
|
+
super(e, t, s, o), this.min = s, this.max = o;
|
|
351
349
|
}
|
|
352
350
|
getValue = () => `${Math.round(this.value * 1e3) / 1e3}`;
|
|
353
351
|
}
|
|
354
|
-
const
|
|
352
|
+
const an = F({
|
|
355
353
|
props: {
|
|
356
354
|
intf: {
|
|
357
355
|
type: Object,
|
|
@@ -363,127 +361,119 @@ const Et = R({
|
|
|
363
361
|
}
|
|
364
362
|
},
|
|
365
363
|
emits: ["update:modelValue"],
|
|
366
|
-
setup(
|
|
367
|
-
return { v:
|
|
368
|
-
get: () =>
|
|
369
|
-
set: (
|
|
370
|
-
e("update:modelValue",
|
|
364
|
+
setup(n, { emit: e }) {
|
|
365
|
+
return { v: O({
|
|
366
|
+
get: () => n.modelValue,
|
|
367
|
+
set: (s) => {
|
|
368
|
+
e("update:modelValue", s);
|
|
371
369
|
}
|
|
372
370
|
}) };
|
|
373
371
|
}
|
|
374
|
-
}),
|
|
375
|
-
const t =
|
|
376
|
-
for (const [
|
|
377
|
-
t[
|
|
372
|
+
}), P = (n, e) => {
|
|
373
|
+
const t = n.__vccOpts || n;
|
|
374
|
+
for (const [s, o] of e)
|
|
375
|
+
t[s] = o;
|
|
378
376
|
return t;
|
|
379
|
-
},
|
|
380
|
-
function
|
|
381
|
-
return
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
"onUpdate:modelValue": e[0] || (e[0] = (
|
|
377
|
+
}, rn = { style: { position: "relative" } }, dn = { style: { "font-size": "12px", padding: "0 6px", position: "absolute", top: "-8px", "background-color": "var(--baklava-node-color-background)" } }, ln = ["placeholder", "title"];
|
|
378
|
+
function un(n, e, t, s, o, a) {
|
|
379
|
+
return d(), p("div", rn, [
|
|
380
|
+
u("label", dn, G(n.intf.name), 1),
|
|
381
|
+
de(u("input", {
|
|
382
|
+
"onUpdate:modelValue": e[0] || (e[0] = (i) => n.v = i),
|
|
385
383
|
type: "text",
|
|
386
384
|
class: "baklava-input",
|
|
387
|
-
placeholder:
|
|
388
|
-
title:
|
|
389
|
-
}, null, 8,
|
|
390
|
-
[
|
|
385
|
+
placeholder: n.intf.name,
|
|
386
|
+
title: n.intf.name
|
|
387
|
+
}, null, 8, ln), [
|
|
388
|
+
[le, n.v]
|
|
391
389
|
])
|
|
392
390
|
]);
|
|
393
391
|
}
|
|
394
|
-
const
|
|
395
|
-
class
|
|
396
|
-
component =
|
|
392
|
+
const cn = /* @__PURE__ */ P(an, [["render", un]]);
|
|
393
|
+
class Co extends ke {
|
|
394
|
+
component = z(cn);
|
|
397
395
|
}
|
|
398
|
-
class
|
|
399
|
-
component =
|
|
396
|
+
class Io extends ke {
|
|
397
|
+
component = z(Rt);
|
|
400
398
|
}
|
|
401
|
-
class
|
|
399
|
+
class wo extends ae {
|
|
402
400
|
constructor(e = "", t = "") {
|
|
403
|
-
super(e, t), this.setComponent(
|
|
401
|
+
super(e, t), this.setComponent(z(Fe)), this.use($, qe);
|
|
404
402
|
}
|
|
405
403
|
getValue = () => `(${this.value})`;
|
|
406
404
|
}
|
|
407
|
-
function
|
|
408
|
-
return class extends
|
|
409
|
-
type =
|
|
405
|
+
function ko(n) {
|
|
406
|
+
return class extends _e {
|
|
407
|
+
type = n.type;
|
|
410
408
|
inputs = {};
|
|
411
409
|
outputs = {};
|
|
412
410
|
constructor() {
|
|
413
|
-
super(), this._title =
|
|
411
|
+
super(), this._title = n.title ?? n.type, this.executeFactory("input", n.inputs), this.executeFactory("output", n.outputs), n.calculate && (this.calculate = (e, t) => n.calculate.call(this, { inputs: e, ...t })), n.onCreate?.call(this), this.name = n.name ?? n.type, this.updateModules(n.modules), n.variableName != null && (this.state.variableName = n.variableName), n.codeTemplate && (this.codeTemplate = n.codeTemplate), this.addInput(
|
|
414
412
|
"_code",
|
|
415
|
-
new
|
|
413
|
+
new V("", []).use($, U).use(Q).setHidden(!0)
|
|
416
414
|
), this.addOutput(
|
|
417
415
|
"_code",
|
|
418
|
-
new
|
|
416
|
+
new V("", []).use($, U).use(Q).setHidden(!0)
|
|
419
417
|
);
|
|
420
418
|
}
|
|
421
419
|
onPlaced() {
|
|
422
|
-
|
|
420
|
+
n.onPlaced?.call(this);
|
|
423
421
|
}
|
|
424
422
|
onConnected() {
|
|
425
|
-
|
|
423
|
+
n.onConnected?.call(this);
|
|
426
424
|
}
|
|
427
425
|
onDestroy() {
|
|
428
|
-
|
|
426
|
+
n.onDestroy?.call(this);
|
|
429
427
|
}
|
|
430
428
|
onUnconnected() {
|
|
431
|
-
|
|
429
|
+
n.onUnconnected?.call(this);
|
|
432
430
|
}
|
|
433
431
|
update() {
|
|
434
|
-
|
|
432
|
+
n.update?.call(this);
|
|
435
433
|
}
|
|
436
434
|
executeFactory(e, t) {
|
|
437
|
-
Object.keys(t || {}).forEach((
|
|
438
|
-
const o = t[
|
|
439
|
-
e === "input" ? this.addInput(
|
|
435
|
+
Object.keys(t || {}).forEach((s) => {
|
|
436
|
+
const o = t[s]();
|
|
437
|
+
e === "input" ? this.addInput(s, o) : this.addOutput(s, o);
|
|
440
438
|
});
|
|
441
439
|
}
|
|
442
440
|
};
|
|
443
441
|
}
|
|
444
|
-
class
|
|
445
|
-
/**
|
|
446
|
-
* The default implementation does nothing.
|
|
447
|
-
* Overwrite this method to do calculation.
|
|
448
|
-
* @param inputs Values of all input interfaces
|
|
449
|
-
* @param globalValues Set of values passed to every node by the engine plugin
|
|
450
|
-
* @return Values for output interfaces
|
|
451
|
-
*/
|
|
452
|
-
calculate;
|
|
442
|
+
class pn extends _e {
|
|
453
443
|
}
|
|
454
|
-
function
|
|
455
|
-
return class extends
|
|
456
|
-
type =
|
|
444
|
+
function No(n) {
|
|
445
|
+
return class extends pn {
|
|
446
|
+
type = n.type;
|
|
457
447
|
inputs = {};
|
|
458
448
|
outputs = {};
|
|
459
449
|
preventUpdate = !1;
|
|
460
|
-
staticInputKeys = Object.keys(
|
|
461
|
-
staticOutputKeys = Object.keys(
|
|
450
|
+
staticInputKeys = Object.keys(n.inputs ?? {});
|
|
451
|
+
staticOutputKeys = Object.keys(n.outputs ?? {});
|
|
462
452
|
constructor() {
|
|
463
|
-
super(), this._title =
|
|
453
|
+
super(), this._title = n.title ?? n.type, this.executeFactory("input", n.inputs), this.executeFactory("output", n.outputs), n.calculate && (this.calculate = (e, t) => n.calculate?.call(this, e, t)), n.onCreate?.call(this), this.name = n.name ?? n.type, this.updateModules(n.modules), n.codeTemplate && (this.codeTemplate = n.codeTemplate), n.variableName && (this.state.variableName = n.variableName), this.addInput(
|
|
464
454
|
"_code",
|
|
465
|
-
new
|
|
455
|
+
new V("", []).use($, U).use(Q).setHidden(!0)
|
|
466
456
|
), this.addOutput(
|
|
467
457
|
"_code",
|
|
468
|
-
new
|
|
458
|
+
new V("", []).use($, U).use(Q).setHidden(!0)
|
|
469
459
|
), this.staticInputKeys.push("_code"), this.staticOutputKeys.push("_code");
|
|
470
460
|
}
|
|
471
461
|
onPlaced() {
|
|
472
462
|
this.events.update.subscribe(this, (e) => {
|
|
473
463
|
e && (e.type === "input" && this.staticInputKeys.includes(e.name) || e.type === "output" && this.staticOutputKeys.includes(e.name)) && this.onUpdate();
|
|
474
|
-
}), this.onUpdate(),
|
|
464
|
+
}), this.onUpdate(), n.onPlaced?.call(this);
|
|
475
465
|
}
|
|
476
466
|
onConnected() {
|
|
477
|
-
|
|
467
|
+
n.onConnected?.call(this);
|
|
478
468
|
}
|
|
479
469
|
onDestroy() {
|
|
480
|
-
|
|
470
|
+
n.onDestroy?.call(this);
|
|
481
471
|
}
|
|
482
472
|
onUnconnected() {
|
|
483
|
-
|
|
473
|
+
n.onUnconnected?.call(this);
|
|
484
474
|
}
|
|
485
475
|
update() {
|
|
486
|
-
|
|
476
|
+
n.update?.call(this);
|
|
487
477
|
}
|
|
488
478
|
load(e) {
|
|
489
479
|
this.preventUpdate = !0, this.hooks.beforeLoad.execute(e), this.id = e.id, this.title = e.title;
|
|
@@ -495,56 +485,105 @@ function jn(s) {
|
|
|
495
485
|
for (const t of Object.keys(e.inputs))
|
|
496
486
|
if (!this.staticInputKeys.includes(t)) {
|
|
497
487
|
if (!this.inputs[t]) {
|
|
498
|
-
const
|
|
488
|
+
const s = e.inputs[t].value;
|
|
499
489
|
let o;
|
|
500
|
-
typeof
|
|
490
|
+
typeof s == "number" ? o = new Vt(t, s).use($, Ce) : o = new be(t, JSON.stringify(s)).use($, Ie), o.use(De, !0), this.addInput(t, o);
|
|
501
491
|
}
|
|
502
492
|
this.inputs[t] && (this.inputs[t].load(e.inputs[t]), this.inputs[t].nodeId = this.id);
|
|
503
493
|
}
|
|
504
494
|
for (const t of Object.keys(e.outputs))
|
|
505
495
|
if (!this.staticOutputKeys.includes(t)) {
|
|
506
496
|
if (!this.outputs[t]) {
|
|
507
|
-
const
|
|
508
|
-
this.addOutput(t,
|
|
497
|
+
const s = new on(t);
|
|
498
|
+
this.addOutput(t, s);
|
|
509
499
|
}
|
|
510
500
|
this.outputs[t] && (this.outputs[t].load(e.outputs[t]), this.outputs[t].nodeId = this.id);
|
|
511
501
|
}
|
|
512
|
-
|
|
502
|
+
Ye(this.graph, e), this.preventUpdate = !1, this.events.loaded.emit(this);
|
|
513
503
|
}
|
|
514
504
|
onUpdate() {
|
|
515
505
|
if (this.preventUpdate) return;
|
|
516
506
|
this.graph && this.graph.activeTransactions++;
|
|
517
|
-
const e = this.getStaticValues(this.staticInputKeys, this.inputs), t = this.getStaticValues(this.staticOutputKeys, this.outputs),
|
|
518
|
-
this.updateInterfaces("input",
|
|
507
|
+
const e = this.getStaticValues(this.staticInputKeys, this.inputs), t = this.getStaticValues(this.staticOutputKeys, this.outputs), s = n.onUpdate.call(this, e, t);
|
|
508
|
+
this.updateInterfaces("input", s.inputs ?? {}, s.forceUpdateInputs ?? []), this.updateInterfaces("output", s.outputs ?? {}, s.forceUpdateOutputs ?? []), this.graph && this.graph.activeTransactions--;
|
|
519
509
|
}
|
|
520
510
|
getStaticValues(e, t) {
|
|
521
|
-
const
|
|
511
|
+
const s = {};
|
|
522
512
|
for (const o of e)
|
|
523
|
-
|
|
524
|
-
return
|
|
513
|
+
s[o] = t[o].value;
|
|
514
|
+
return s;
|
|
525
515
|
}
|
|
526
|
-
updateInterfaces(e, t,
|
|
516
|
+
updateInterfaces(e, t, s) {
|
|
527
517
|
const o = e === "input" ? this.staticInputKeys : this.staticOutputKeys, a = e === "input" ? this.inputs : this.outputs;
|
|
528
|
-
for (const
|
|
529
|
-
o.includes(
|
|
530
|
-
for (const
|
|
531
|
-
if (a[
|
|
532
|
-
const
|
|
533
|
-
e === "input" ? this.addInput(
|
|
518
|
+
for (const i of Object.keys(a))
|
|
519
|
+
o.includes(i) || t[i] && !s.includes(i) || (e === "input" ? this.removeInput(i) : this.removeOutput(i));
|
|
520
|
+
for (const i of Object.keys(t)) {
|
|
521
|
+
if (a[i]) continue;
|
|
522
|
+
const r = t[i]();
|
|
523
|
+
e === "input" ? this.addInput(i, r) : this.addOutput(i, r);
|
|
534
524
|
}
|
|
535
525
|
}
|
|
536
526
|
updateProps(e) {
|
|
537
527
|
this.state.props = e, this.onUpdate();
|
|
538
528
|
}
|
|
539
529
|
executeFactory(e, t) {
|
|
540
|
-
Object.keys(t || {}).forEach((
|
|
541
|
-
const o = t[
|
|
542
|
-
e === "input" ? this.addInput(
|
|
530
|
+
Object.keys(t || {}).forEach((s) => {
|
|
531
|
+
const o = t[s]();
|
|
532
|
+
e === "input" ? this.addInput(s, o) : this.addOutput(s, o);
|
|
543
533
|
});
|
|
544
534
|
}
|
|
545
535
|
};
|
|
546
536
|
}
|
|
547
|
-
const
|
|
537
|
+
const Se = "__baklava_SubgraphInputNode", Pe = "__baklava_SubgraphOutputNode";
|
|
538
|
+
class Je extends _e {
|
|
539
|
+
graphInterfaceId;
|
|
540
|
+
constructor() {
|
|
541
|
+
super(), this.graphInterfaceId = K();
|
|
542
|
+
}
|
|
543
|
+
onPlaced() {
|
|
544
|
+
super.onPlaced(), this.initializeIo();
|
|
545
|
+
}
|
|
546
|
+
load(e) {
|
|
547
|
+
super.load(e), this.graphInterfaceId = e.graphInterfaceId;
|
|
548
|
+
}
|
|
549
|
+
save() {
|
|
550
|
+
return {
|
|
551
|
+
...super.save(),
|
|
552
|
+
graphInterfaceId: this.graphInterfaceId
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
update() {
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
class Qe extends Je {
|
|
559
|
+
static isGraphInputNode(e) {
|
|
560
|
+
return e.type === Se;
|
|
561
|
+
}
|
|
562
|
+
type = Se;
|
|
563
|
+
inputs = {
|
|
564
|
+
name: new A("Name", "Input")
|
|
565
|
+
};
|
|
566
|
+
outputs = {
|
|
567
|
+
placeholder: new A("Value", void 0)
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
class Ze extends Je {
|
|
571
|
+
static isGraphOutputNode(e) {
|
|
572
|
+
return e.type === Pe;
|
|
573
|
+
}
|
|
574
|
+
type = Pe;
|
|
575
|
+
inputs = {
|
|
576
|
+
name: new A("Name", "Output"),
|
|
577
|
+
placeholder: new A("Value", void 0)
|
|
578
|
+
};
|
|
579
|
+
outputs = {
|
|
580
|
+
output: new A("Output", void 0).setHidden(!0)
|
|
581
|
+
};
|
|
582
|
+
calculate = ({ placeholder: e }) => ({
|
|
583
|
+
output: e
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
const hn = [
|
|
548
587
|
"component",
|
|
549
588
|
"connectionCount",
|
|
550
589
|
"events",
|
|
@@ -559,9 +598,9 @@ const Ln = "__baklava_GraphNode-", Gt = [
|
|
|
559
598
|
"templateId",
|
|
560
599
|
"value"
|
|
561
600
|
];
|
|
562
|
-
function
|
|
563
|
-
return class extends
|
|
564
|
-
type =
|
|
601
|
+
function mn(n) {
|
|
602
|
+
return class extends We {
|
|
603
|
+
type = Ue(n);
|
|
565
604
|
get title() {
|
|
566
605
|
return this._title;
|
|
567
606
|
}
|
|
@@ -570,55 +609,39 @@ function Rt(s) {
|
|
|
570
609
|
}
|
|
571
610
|
inputs = {};
|
|
572
611
|
outputs = {};
|
|
573
|
-
template =
|
|
612
|
+
template = n;
|
|
574
613
|
subgraph;
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
// throw new Error(`GraphNode ${this.id}: calculate called without subgraph being initialized`)
|
|
581
|
-
// }
|
|
582
|
-
// if (!context.engine || typeof context.engine !== 'object') {
|
|
583
|
-
// throw new Error(`GraphNode ${this.id}: calculate called but no engine provided in context`)
|
|
584
|
-
// }
|
|
585
|
-
// const graphInputs = context.engine.getInputValues(this.subgraph)
|
|
586
|
-
// // fill subgraph input placeholders
|
|
587
|
-
// for (const input of this.subgraph.inputs) {
|
|
588
|
-
// graphInputs.set(input.nodeInterfaceId, inputs[input.id])
|
|
589
|
-
// }
|
|
590
|
-
// const result: Map<string, Map<string, unknown>> = await context.engine.runGraph(
|
|
591
|
-
// this.subgraph,
|
|
592
|
-
// graphInputs,
|
|
593
|
-
// context.globalValues,
|
|
594
|
-
// )
|
|
595
|
-
// const outputs: Record<string, unknown> = {}
|
|
596
|
-
// for (const output of this.subgraph.outputs) {
|
|
597
|
-
// outputs[output.id] = result.get(output.nodeId)?.get('output')
|
|
598
|
-
// }
|
|
599
|
-
// outputs._calculationResults = result
|
|
600
|
-
// outputs['_code'] = inputs['_code']
|
|
601
|
-
// return outputs
|
|
602
|
-
// }
|
|
603
|
-
/**
|
|
604
|
-
* Render code script of code nodes.
|
|
605
|
-
*/
|
|
606
|
-
renderCodes() {
|
|
607
|
-
if (!this.subgraph) return;
|
|
608
|
-
this.subgraph.nodes.filter((n) => n.isCodeNode).forEach((n) => n.renderCode());
|
|
609
|
-
const t = this.subgraph.nodes;
|
|
610
|
-
this.state.script = Y.render(this.code.state.template || "", { nodes: t });
|
|
614
|
+
update() {
|
|
615
|
+
}
|
|
616
|
+
onConnected() {
|
|
617
|
+
}
|
|
618
|
+
onUnconnected() {
|
|
611
619
|
}
|
|
620
|
+
calculate = async (t, s) => {
|
|
621
|
+
if (!this.subgraph) throw new Error(`GraphNode ${this.id}: calculate called without subgraph being initialized`);
|
|
622
|
+
if (!s.engine || typeof s.engine != "object")
|
|
623
|
+
throw new Error(`GraphNode ${this.id}: calculate called but no engine provided in context`);
|
|
624
|
+
const o = s.engine.getInputValues(this.subgraph);
|
|
625
|
+
for (const r of this.subgraph.inputs)
|
|
626
|
+
o.set(r.nodeInterfaceId, t[r.id]);
|
|
627
|
+
const a = await s.engine.runGraph(
|
|
628
|
+
this.subgraph,
|
|
629
|
+
o,
|
|
630
|
+
s.globalValues
|
|
631
|
+
);
|
|
632
|
+
s.engine.pause(), Ae(a, s.engine.editor), s.engine.resume();
|
|
633
|
+
const i = {};
|
|
634
|
+
for (const r of this.subgraph.outputs)
|
|
635
|
+
i[r.id] = a.get(r.nodeId)?.get("output");
|
|
636
|
+
return i._calculationResults = a, this.lockCode || (i._code = this.renderCode({ inputs: t, ...s.globalValues })), this.updateOutputValues(i), i;
|
|
637
|
+
};
|
|
612
638
|
load(t) {
|
|
613
|
-
if (!this.subgraph)
|
|
614
|
-
|
|
615
|
-
if (!this.template)
|
|
616
|
-
throw new Error("Unable to load graph node without graph template");
|
|
639
|
+
if (!this.subgraph) throw new Error("Cannot load a graph node without a graph");
|
|
640
|
+
if (!this.template) throw new Error("Unable to load graph node without graph template");
|
|
617
641
|
this.subgraph.load(t.graphState), super.load(t);
|
|
618
642
|
}
|
|
619
643
|
save() {
|
|
620
|
-
if (!this.subgraph)
|
|
621
|
-
throw new Error("Cannot save a graph node without a graph");
|
|
644
|
+
if (!this.subgraph) throw new Error("Cannot save a graph node without a graph");
|
|
622
645
|
return {
|
|
623
646
|
...super.save(),
|
|
624
647
|
graphState: this.subgraph.save()
|
|
@@ -629,92 +652,80 @@ function Rt(s) {
|
|
|
629
652
|
this._title = t;
|
|
630
653
|
}), this.initialize();
|
|
631
654
|
}
|
|
632
|
-
onConnected() {
|
|
633
|
-
}
|
|
634
655
|
onDestroy() {
|
|
635
656
|
this.template.events.updated.unsubscribe(this), this.template.events.nameChanged.unsubscribe(this), this.subgraph?.destroy();
|
|
636
657
|
}
|
|
637
|
-
onUnconnected() {
|
|
638
|
-
}
|
|
639
658
|
initialize() {
|
|
640
|
-
this.subgraph && this.subgraph.destroy(), this.subgraph = this.template.createGraph(), this._title = this.template.name, this.updateInterfaces(), this.
|
|
659
|
+
this.subgraph && this.subgraph.destroy(), this.subgraph = this.template.createGraph(), this._title = this.template.name, this.updateInterfaces(), this.state.codeTemplate = `{{ #nodes }}{{ script }}
|
|
660
|
+
{{ /nodes }}`, this.events.update.emit(null);
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Render code of this node.
|
|
664
|
+
*/
|
|
665
|
+
renderCode(t) {
|
|
666
|
+
return this.subgraph ? this.subgraph.renderCode({ nodes: this.subgraph.scriptedCodeNodes }) : Z.render(this.state.codeTemplate, t);
|
|
641
667
|
}
|
|
642
668
|
updateInterfaces() {
|
|
643
|
-
if (!this.subgraph)
|
|
644
|
-
throw new Error("Trying to update interfaces without graph instance");
|
|
669
|
+
if (!this.subgraph) throw new Error("Trying to update interfaces without graph instance");
|
|
645
670
|
for (const t of this.subgraph.inputs)
|
|
646
671
|
t.id in this.inputs ? this.inputs[t.id].name = t.name : this.addInput(t.id, this.createProxyInterface(t, !0));
|
|
647
672
|
for (const t of Object.keys(this.inputs))
|
|
648
|
-
this.subgraph.inputs.some((
|
|
673
|
+
this.subgraph.inputs.some((s) => s.id === t) || this.removeInput(t);
|
|
649
674
|
for (const t of this.subgraph.outputs)
|
|
650
675
|
t.id in this.outputs ? this.outputs[t.id].name = t.name : this.addOutput(t.id, this.createProxyInterface(t, !1));
|
|
651
676
|
for (const t of Object.keys(this.outputs))
|
|
652
|
-
this.subgraph.outputs.some((
|
|
677
|
+
this.subgraph.outputs.some((s) => s.id === t) || this.removeOutput(t);
|
|
653
678
|
this.addInput(
|
|
654
679
|
"_code",
|
|
655
|
-
new
|
|
680
|
+
new V("", []).use($, U).use(Q).setHidden(!0)
|
|
656
681
|
), this.addOutput(
|
|
657
682
|
"_code",
|
|
658
|
-
new
|
|
659
|
-
), this.addOutput(
|
|
660
|
-
"_calculationResults",
|
|
661
|
-
new Le("_calculationResults", void 0).setHidden(!0)
|
|
662
|
-
);
|
|
683
|
+
new V("", []).use($, U).use(Q).setHidden(!0)
|
|
684
|
+
), this.addOutput("_calculationResults", new A("_calculationResults", void 0).setHidden(!0));
|
|
663
685
|
}
|
|
664
686
|
/**
|
|
665
687
|
* When we create a interface in the graph node, we hide certain properties of the interface in the subgraph.
|
|
666
688
|
* For example, the `type` property or the `allowMultipleConnections` property.
|
|
667
689
|
* These properties should be proxied to the subgraph interface, so they behave the same as the original interface.
|
|
668
690
|
*/
|
|
669
|
-
createProxyInterface(t,
|
|
670
|
-
const o = new
|
|
691
|
+
createProxyInterface(t, s) {
|
|
692
|
+
const o = new V(t.name, void 0);
|
|
671
693
|
return new Proxy(o, {
|
|
672
|
-
get: (a,
|
|
673
|
-
if (
|
|
674
|
-
return Reflect.get(a,
|
|
675
|
-
let
|
|
676
|
-
|
|
677
|
-
(
|
|
678
|
-
)?.outputs.placeholder.id :
|
|
679
|
-
(
|
|
694
|
+
get: (a, i) => {
|
|
695
|
+
if (hn.includes(i) || i in a || typeof i == "string" && i.startsWith("__v_"))
|
|
696
|
+
return Reflect.get(a, i);
|
|
697
|
+
let r;
|
|
698
|
+
s ? r = this.subgraph?.nodes.find(
|
|
699
|
+
(_) => Qe.isGraphInputNode(_) && _.graphInterfaceId === t.id
|
|
700
|
+
)?.outputs.placeholder.id : r = this.subgraph?.nodes.find(
|
|
701
|
+
(_) => Ze.isGraphOutputNode(_) && _.graphInterfaceId === t.id
|
|
680
702
|
)?.inputs.placeholder.id;
|
|
681
|
-
const
|
|
682
|
-
if (
|
|
683
|
-
return Reflect.get(_, r);
|
|
703
|
+
const c = this.subgraph?.connections.find((g) => r === (s ? g.from : g.to)?.id), h = s ? c?.to : c?.from;
|
|
704
|
+
if (h) return Reflect.get(h, i);
|
|
684
705
|
}
|
|
685
706
|
});
|
|
686
707
|
}
|
|
687
708
|
};
|
|
688
709
|
}
|
|
689
|
-
|
|
690
|
-
class
|
|
710
|
+
Z.escape = (n) => n;
|
|
711
|
+
class fn {
|
|
691
712
|
_id;
|
|
692
|
-
|
|
713
|
+
_graph = null;
|
|
693
714
|
_state;
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
715
|
+
_engine = null;
|
|
716
|
+
constructor() {
|
|
717
|
+
this._id = K(), this._state = D({
|
|
697
718
|
lockCode: !1,
|
|
698
719
|
modules: {},
|
|
699
720
|
script: "",
|
|
700
|
-
template: ""
|
|
701
|
-
token: null
|
|
721
|
+
template: ""
|
|
702
722
|
});
|
|
703
723
|
}
|
|
704
|
-
get
|
|
705
|
-
return
|
|
706
|
-
}
|
|
707
|
-
get codeNodeIds() {
|
|
708
|
-
return this.codeNodes.map((e) => e.id);
|
|
709
|
-
}
|
|
710
|
-
get connections() {
|
|
711
|
-
return this.graph.connections;
|
|
712
|
-
}
|
|
713
|
-
set connections(e) {
|
|
714
|
-
this.graph._connections = e;
|
|
724
|
+
get engine() {
|
|
725
|
+
return this._engine;
|
|
715
726
|
}
|
|
716
727
|
get graph() {
|
|
717
|
-
return this.
|
|
728
|
+
return this._graph;
|
|
718
729
|
}
|
|
719
730
|
get id() {
|
|
720
731
|
return this._id;
|
|
@@ -723,33 +734,17 @@ class Pt {
|
|
|
723
734
|
return this.state.lockCode;
|
|
724
735
|
}
|
|
725
736
|
set lockCode(e) {
|
|
726
|
-
this.state.lockCode = e, this.
|
|
737
|
+
this.state.lockCode = e, this.engine?.runOnce(null);
|
|
727
738
|
}
|
|
728
739
|
get modules() {
|
|
729
740
|
const e = [];
|
|
730
|
-
return this.codeNodes.filter((t) => t.state.modules?.length > 0).forEach((t) => e.push(...t.state.modules)), e ? (e.sort(), Array.from(
|
|
731
|
-
new Set(e.map((t) => this.viewModel.state.modules[t]))
|
|
732
|
-
)) : [];
|
|
733
|
-
}
|
|
734
|
-
get nodeIds() {
|
|
735
|
-
return this.nodes.map((e) => e.id);
|
|
736
|
-
}
|
|
737
|
-
get nodes() {
|
|
738
|
-
return this.graph.nodes;
|
|
739
|
-
}
|
|
740
|
-
set nodes(e) {
|
|
741
|
-
this.graph._nodes = e;
|
|
741
|
+
return this.graph?.codeNodes.filter((t) => t.state.modules?.length > 0).forEach((t) => e.push(...t.state.modules)), e ? (e.sort(), Array.from(new Set(e.map((t) => this.state.modules[t])))) : [];
|
|
742
742
|
}
|
|
743
743
|
get script() {
|
|
744
744
|
return this.state.script;
|
|
745
745
|
}
|
|
746
746
|
set script(e) {
|
|
747
|
-
this.state.script = e;
|
|
748
|
-
}
|
|
749
|
-
get scriptedCodeNodes() {
|
|
750
|
-
return oe(this.graph).filter(
|
|
751
|
-
(e) => !e.state?.integrated
|
|
752
|
-
);
|
|
747
|
+
this.state.script = e, this.engine?.runOnce(null);
|
|
753
748
|
}
|
|
754
749
|
get shortId() {
|
|
755
750
|
return this.id.slice(0, 6);
|
|
@@ -757,86 +752,11 @@ class Pt {
|
|
|
757
752
|
get state() {
|
|
758
753
|
return this._state;
|
|
759
754
|
}
|
|
760
|
-
get viewModel() {
|
|
761
|
-
return this._viewModel;
|
|
762
|
-
}
|
|
763
|
-
get visibleNodes() {
|
|
764
|
-
return this.codeNodes.filter((e) => !e.state?.hidden);
|
|
765
|
-
}
|
|
766
|
-
/**
|
|
767
|
-
* Add code node to graph.
|
|
768
|
-
* @param node code node
|
|
769
|
-
* @param props optional
|
|
770
|
-
*/
|
|
771
|
-
addNode(e, t) {
|
|
772
|
-
return e.code || (e.code = this), t && (e.state.props = t), this.graph.addNode(e);
|
|
773
|
-
}
|
|
774
|
-
/**
|
|
775
|
-
* Add code node at coordinates.
|
|
776
|
-
* @param node code node
|
|
777
|
-
* @param position position
|
|
778
|
-
* @param props optional
|
|
779
|
-
* @returns code node
|
|
780
|
-
*/
|
|
781
|
-
addNodeAtCoordinates = (e, t = { x: 0, y: 0 }, n) => (this.addNode(e, n), e.position && (e.position = t), e);
|
|
782
|
-
/**
|
|
783
|
-
* Add connection of code nodes
|
|
784
|
-
* @param from code node interface
|
|
785
|
-
* @param to code node interface
|
|
786
|
-
*/
|
|
787
|
-
addConnection(e, t) {
|
|
788
|
-
e.name !== "_code" && (e.hidden = !1), t.name !== "_code" && (t.hidden = !1), this.graph.addConnection(e, t);
|
|
789
|
-
}
|
|
790
755
|
/**
|
|
791
|
-
* Clear code
|
|
756
|
+
* Clear code.
|
|
792
757
|
*/
|
|
793
758
|
clear() {
|
|
794
|
-
this.
|
|
795
|
-
}
|
|
796
|
-
/**
|
|
797
|
-
* Find node by ID.
|
|
798
|
-
* @param id node ID
|
|
799
|
-
* @returns node instance
|
|
800
|
-
*/
|
|
801
|
-
findNodeById(e) {
|
|
802
|
-
return this.graph.findNodeById(e);
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* Find node by type.
|
|
806
|
-
* @param nodeType node type
|
|
807
|
-
* @returns node instance
|
|
808
|
-
*/
|
|
809
|
-
findNodeByType(e) {
|
|
810
|
-
return this.codeNodes.find((t) => t.type === e);
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
* Get nodes of the same type.
|
|
814
|
-
* @param type node type
|
|
815
|
-
* @returns a list of node instances
|
|
816
|
-
*/
|
|
817
|
-
getNodesBySameType(e) {
|
|
818
|
-
return this.codeNodes.filter((t) => t.type === e);
|
|
819
|
-
}
|
|
820
|
-
/**
|
|
821
|
-
* Get nodes of the same variable name.
|
|
822
|
-
* @param variableName variable name
|
|
823
|
-
* @returns a list of node instances
|
|
824
|
-
*/
|
|
825
|
-
getNodesBySameVariableNames(e) {
|
|
826
|
-
return this.codeNodes.filter(
|
|
827
|
-
(t) => t.state.variableName === e
|
|
828
|
-
);
|
|
829
|
-
}
|
|
830
|
-
/**
|
|
831
|
-
* Check whether the graph has this connection.
|
|
832
|
-
* @param from node interface
|
|
833
|
-
* @param to node interface
|
|
834
|
-
* @returns boolean
|
|
835
|
-
*/
|
|
836
|
-
hasConnection(e, t) {
|
|
837
|
-
return this.connections.some(
|
|
838
|
-
(n) => n.from.id === e.id && n.to.id === t.id
|
|
839
|
-
);
|
|
759
|
+
this.state.script = "";
|
|
840
760
|
}
|
|
841
761
|
/**
|
|
842
762
|
* Load template from the file.
|
|
@@ -848,116 +768,98 @@ class Pt {
|
|
|
848
768
|
});
|
|
849
769
|
}
|
|
850
770
|
/**
|
|
851
|
-
*
|
|
852
|
-
* @param
|
|
771
|
+
* Register engine instance.
|
|
772
|
+
* @param engine engine
|
|
853
773
|
*/
|
|
854
|
-
|
|
855
|
-
this.
|
|
774
|
+
registerEngine(e) {
|
|
775
|
+
this._engine = e;
|
|
856
776
|
}
|
|
857
777
|
/**
|
|
858
|
-
*
|
|
859
|
-
* @param
|
|
778
|
+
* Register code graph instance.
|
|
779
|
+
* @param graph code graph
|
|
860
780
|
*/
|
|
861
|
-
|
|
862
|
-
this.
|
|
863
|
-
}
|
|
864
|
-
/**
|
|
865
|
-
* Render code script of code nodes.
|
|
866
|
-
*/
|
|
867
|
-
renderNodeCodes() {
|
|
868
|
-
this.state.lockCode || this.codeNodes.length === 0 || this.codeNodes.forEach((e) => e.renderCode());
|
|
781
|
+
registerGraph(e) {
|
|
782
|
+
this._graph = e;
|
|
869
783
|
}
|
|
870
784
|
/**
|
|
871
785
|
* Render code script.
|
|
872
786
|
*/
|
|
873
|
-
renderCode() {
|
|
874
|
-
|
|
875
|
-
const e = this.scriptedCodeNodes, t = this.modules;
|
|
876
|
-
this.state.script = Y.render(this.state.template || "", { nodes: e, modules: t });
|
|
877
|
-
}
|
|
878
|
-
/**
|
|
879
|
-
* Reset scripts of intput interfaces.
|
|
880
|
-
*/
|
|
881
|
-
resetInputInterfaceScript() {
|
|
882
|
-
this.codeNodes.forEach((e) => e.resetInputInterfaceScript());
|
|
787
|
+
renderCode(e) {
|
|
788
|
+
this.state.script = Z.render(this.state.template || "", e);
|
|
883
789
|
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
790
|
+
}
|
|
791
|
+
const Oo = (n) => {
|
|
792
|
+
n.allowMultipleConnections = !0;
|
|
793
|
+
};
|
|
794
|
+
class vn extends Tt {
|
|
795
|
+
order = /* @__PURE__ */ new Map();
|
|
796
|
+
constructor(e) {
|
|
797
|
+
super(e), e.code.registerEngine(this);
|
|
798
|
+
}
|
|
799
|
+
start() {
|
|
800
|
+
super.start(), this.recalculateOrder = !0, this.calculateWithoutData();
|
|
801
|
+
}
|
|
802
|
+
async runGraph(e, t, s) {
|
|
803
|
+
this.order.has(e.id) || this.order.set(e.id, Et(e));
|
|
804
|
+
const { calculationOrder: o, connectionsFromNode: a } = this.order.get(e.id), i = /* @__PURE__ */ new Map();
|
|
805
|
+
for (const r of o) {
|
|
806
|
+
const c = {};
|
|
807
|
+
Object.entries(r.inputs).forEach(([g, _]) => {
|
|
808
|
+
c[g] = this.getInterfaceValue(t, _.id);
|
|
809
|
+
}), r.isCodeNode && (r.updateCodeTemplate(), r.updateOutputNames()), this.events.beforeNodeCalculation.emit({ inputValues: c, node: r });
|
|
810
|
+
let h;
|
|
811
|
+
if (r.calculate) {
|
|
812
|
+
if (h = await r.calculate(c, { globalValues: s, engine: this }), a.has(r))
|
|
813
|
+
for (const [g, _] of Object.entries(h))
|
|
814
|
+
this.hooks.transferData.execute(h[g], _), a.get(r).forEach((m) => {
|
|
815
|
+
t.set(m.to.id, _);
|
|
816
|
+
});
|
|
817
|
+
} else {
|
|
818
|
+
h = {};
|
|
819
|
+
for (const [g, _] of Object.entries(r.outputs))
|
|
820
|
+
h[g] = this.getInterfaceValue(t, _.id);
|
|
901
821
|
}
|
|
822
|
+
this.events.afterNodeCalculation.emit({ outputValues: h, node: r }), i.set(r.id, new Map(Object.entries(h))), a.has(r) && a.get(r).forEach((g) => {
|
|
823
|
+
const _ = Object.entries(r.outputs).find(([, x]) => x.id === g.from.id)?.[0];
|
|
824
|
+
if (!_)
|
|
825
|
+
throw new Error(
|
|
826
|
+
`Could not find key for interface ${g.from.id}
|
|
827
|
+
This is likely an internal issue. Please report it on GitHub.`
|
|
828
|
+
);
|
|
829
|
+
const m = this.hooks.transferData.execute(h[_], g);
|
|
830
|
+
g.to.allowMultipleConnections ? t.has(g.to.id) ? t.get(g.to.id).push(m) : t.set(g.to.id, [m]) : t.set(g.to.id, m);
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
return i;
|
|
834
|
+
}
|
|
835
|
+
async execute(e) {
|
|
836
|
+
this.recalculateOrder && (this.order.clear(), this.recalculateOrder = !1);
|
|
837
|
+
const t = this.getInputValues(this.editor.graph);
|
|
838
|
+
return await this.runGraph(this.editor.graph, t, e);
|
|
839
|
+
}
|
|
840
|
+
getInputValues(e) {
|
|
841
|
+
const t = /* @__PURE__ */ new Map();
|
|
842
|
+
for (const s of e.nodes)
|
|
843
|
+
Object.values(s.inputs).forEach((o) => {
|
|
844
|
+
o.connectionCount === 0 && t.set(o.id, o.getValue ? o.getValue() : o.value);
|
|
845
|
+
}), s.calculate || Object.values(s.outputs).forEach((o) => {
|
|
846
|
+
t.set(o.id, o.getValue ? o.getValue() : o.value);
|
|
847
|
+
});
|
|
848
|
+
return t;
|
|
902
849
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
*/
|
|
906
|
-
updateCodeNodes() {
|
|
907
|
-
this.codeNodes.forEach((e) => e.update());
|
|
850
|
+
onChange(e) {
|
|
851
|
+
this.recalculateOrder = e || this.recalculateOrder, this.calculateWithoutData();
|
|
908
852
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
853
|
+
getInterfaceValue(e, t) {
|
|
854
|
+
if (!e.has(t))
|
|
855
|
+
throw new Error(
|
|
856
|
+
`Could not find value for interface ${t}
|
|
857
|
+
This is likely an internal issue. Please report it on GitHub.`
|
|
858
|
+
);
|
|
859
|
+
return e.get(t);
|
|
914
860
|
}
|
|
915
861
|
}
|
|
916
|
-
const
|
|
917
|
-
const e = [];
|
|
918
|
-
return s.nodes.length === 0 || s.nodes.forEach((t) => {
|
|
919
|
-
t && (t.hasOwnProperty("subgraph") ? e.push(...oe(t.subgraph)) : t.hasOwnProperty("isCodeNode") && e.push(t));
|
|
920
|
-
}), e;
|
|
921
|
-
}, Rn = (s = 0, e = 100) => ({
|
|
922
|
-
x: s * 420,
|
|
923
|
-
y: e
|
|
924
|
-
}), Pn = (s) => {
|
|
925
|
-
const e = { ...s.position };
|
|
926
|
-
return e.x -= 440, e.y += 50, e;
|
|
927
|
-
}, Ut = ["id"], Ht = { class: "align-middle" }, we = /* @__PURE__ */ R({
|
|
928
|
-
__name: "CodeGraphNodeInterface",
|
|
929
|
-
props: {
|
|
930
|
-
node: {},
|
|
931
|
-
intf: {}
|
|
932
|
-
},
|
|
933
|
-
setup(s) {
|
|
934
|
-
const e = s, { viewModel: t } = K(), { hoveredOver: n, temporaryConnection: o } = ut(), a = V(null), r = b(() => e.intf.connectionCount > 0), u = b(() => ({
|
|
935
|
-
"--connected": r.value
|
|
936
|
-
})), p = () => {
|
|
937
|
-
n(e.intf);
|
|
938
|
-
}, _ = () => {
|
|
939
|
-
n(void 0);
|
|
940
|
-
}, g = () => {
|
|
941
|
-
a.value && t.value.hooks.renderInterface.execute({ intf: e.intf, el: a.value });
|
|
942
|
-
};
|
|
943
|
-
return ie(g), Oe(g), (I, L) => (i(), d("div", {
|
|
944
|
-
id: s.intf.id,
|
|
945
|
-
ref_key: "el",
|
|
946
|
-
ref: a,
|
|
947
|
-
class: P(["baklava-node-interface", u.value])
|
|
948
|
-
}, [
|
|
949
|
-
s.intf.port ? (i(), d("div", {
|
|
950
|
-
key: 0,
|
|
951
|
-
class: P(["__port", { "--selected": k(o)?.from === s.intf }]),
|
|
952
|
-
onPointerover: p,
|
|
953
|
-
onPointerout: _
|
|
954
|
-
}, null, 34)) : N("", !0),
|
|
955
|
-
l("span", Ht, [
|
|
956
|
-
X(I.$slots, "default")
|
|
957
|
-
])
|
|
958
|
-
], 10, Ut));
|
|
959
|
-
}
|
|
960
|
-
}), At = {}, Dt = {
|
|
862
|
+
const gn = {}, bn = {
|
|
961
863
|
xmlns: "http://www.w3.org/2000/svg",
|
|
962
864
|
width: "24",
|
|
963
865
|
height: "24",
|
|
@@ -969,17 +871,17 @@ const oe = (s) => {
|
|
|
969
871
|
"stroke-linejoin": "round",
|
|
970
872
|
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-code-variable"
|
|
971
873
|
};
|
|
972
|
-
function
|
|
973
|
-
return
|
|
974
|
-
|
|
874
|
+
function _n(n, e) {
|
|
875
|
+
return d(), p("svg", bn, [...e[0] || (e[0] = [
|
|
876
|
+
u("path", {
|
|
975
877
|
stroke: "none",
|
|
976
878
|
d: "M0 0h24v24H0z",
|
|
977
879
|
fill: "none"
|
|
978
880
|
}, null, -1),
|
|
979
|
-
|
|
881
|
+
u("path", { d: "M4 8m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z" }, null, -1)
|
|
980
882
|
])]);
|
|
981
883
|
}
|
|
982
|
-
const
|
|
884
|
+
const yn = /* @__PURE__ */ P(gn, [["render", _n]]), Cn = {}, In = {
|
|
983
885
|
xmlns: "http://www.w3.org/2000/svg",
|
|
984
886
|
width: "24",
|
|
985
887
|
height: "24",
|
|
@@ -991,19 +893,19 @@ const Wt = /* @__PURE__ */ O(At, [["render", Ft]]), Xt = {}, Yt = {
|
|
|
991
893
|
"stroke-linejoin": "round",
|
|
992
894
|
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-dots-vertical"
|
|
993
895
|
};
|
|
994
|
-
function
|
|
995
|
-
return
|
|
996
|
-
|
|
896
|
+
function wn(n, e) {
|
|
897
|
+
return d(), p("svg", In, [...e[0] || (e[0] = [
|
|
898
|
+
u("path", {
|
|
997
899
|
stroke: "none",
|
|
998
900
|
d: "M0 0h24v24H0z",
|
|
999
901
|
fill: "none"
|
|
1000
902
|
}, null, -1),
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
903
|
+
u("path", { d: "M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
|
|
904
|
+
u("path", { d: "M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
|
|
905
|
+
u("path", { d: "M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1)
|
|
1004
906
|
])]);
|
|
1005
907
|
}
|
|
1006
|
-
const
|
|
908
|
+
const kn = /* @__PURE__ */ P(Cn, [["render", wn]]), Nn = {}, xn = {
|
|
1007
909
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1008
910
|
width: "24",
|
|
1009
911
|
height: "24",
|
|
@@ -1011,17 +913,17 @@ const qt = /* @__PURE__ */ O(Xt, [["render", Kt]]), Jt = {}, Qt = {
|
|
|
1011
913
|
fill: "currentColor",
|
|
1012
914
|
class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-collapse"
|
|
1013
915
|
};
|
|
1014
|
-
function
|
|
1015
|
-
return
|
|
1016
|
-
|
|
916
|
+
function On(n, e) {
|
|
917
|
+
return d(), p("svg", xn, [...e[0] || (e[0] = [
|
|
918
|
+
u("path", {
|
|
1017
919
|
stroke: "none",
|
|
1018
920
|
d: "M0 0h24v24H0z",
|
|
1019
921
|
fill: "none"
|
|
1020
922
|
}, null, -1),
|
|
1021
|
-
|
|
923
|
+
u("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)
|
|
1022
924
|
])]);
|
|
1023
925
|
}
|
|
1024
|
-
const
|
|
926
|
+
const Tn = /* @__PURE__ */ P(Nn, [["render", On]]), En = {}, $n = {
|
|
1025
927
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1026
928
|
width: "24",
|
|
1027
929
|
height: "24",
|
|
@@ -1029,17 +931,17 @@ const es = /* @__PURE__ */ O(Jt, [["render", Zt]]), ts = {}, ss = {
|
|
|
1029
931
|
fill: "currentColor",
|
|
1030
932
|
class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-expand"
|
|
1031
933
|
};
|
|
1032
|
-
function
|
|
1033
|
-
return
|
|
1034
|
-
|
|
934
|
+
function Mn(n, e) {
|
|
935
|
+
return d(), p("svg", $n, [...e[0] || (e[0] = [
|
|
936
|
+
u("path", {
|
|
1035
937
|
stroke: "none",
|
|
1036
938
|
d: "M0 0h24v24H0z",
|
|
1037
939
|
fill: "none"
|
|
1038
940
|
}, null, -1),
|
|
1039
|
-
|
|
941
|
+
u("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)
|
|
1040
942
|
])]);
|
|
1041
943
|
}
|
|
1042
|
-
const
|
|
944
|
+
const Gn = /* @__PURE__ */ P(En, [["render", Mn]]), Sn = {}, Pn = {
|
|
1043
945
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1044
946
|
width: "24",
|
|
1045
947
|
height: "24",
|
|
@@ -1047,17 +949,17 @@ const os = /* @__PURE__ */ O(ts, [["render", ns]]), as = {}, is = {
|
|
|
1047
949
|
fill: "currentColor",
|
|
1048
950
|
class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"
|
|
1049
951
|
};
|
|
1050
|
-
function
|
|
1051
|
-
return
|
|
1052
|
-
|
|
952
|
+
function Rn(n, e) {
|
|
953
|
+
return d(), p("svg", Pn, [...e[0] || (e[0] = [
|
|
954
|
+
u("path", {
|
|
1053
955
|
stroke: "none",
|
|
1054
956
|
d: "M0 0h24v24H0z",
|
|
1055
957
|
fill: "none"
|
|
1056
958
|
}, null, -1),
|
|
1057
|
-
|
|
959
|
+
u("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)
|
|
1058
960
|
])]);
|
|
1059
961
|
}
|
|
1060
|
-
const
|
|
962
|
+
const Vn = /* @__PURE__ */ P(Sn, [["render", Rn]]), jn = {}, Bn = {
|
|
1061
963
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1062
964
|
width: "24",
|
|
1063
965
|
height: "24",
|
|
@@ -1065,17 +967,17 @@ const ds = /* @__PURE__ */ O(as, [["render", rs]]), ls = {}, us = {
|
|
|
1065
967
|
fill: "currentColor",
|
|
1066
968
|
class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-collapse"
|
|
1067
969
|
};
|
|
1068
|
-
function
|
|
1069
|
-
return
|
|
1070
|
-
|
|
970
|
+
function zn(n, e) {
|
|
971
|
+
return d(), p("svg", Bn, [...e[0] || (e[0] = [
|
|
972
|
+
u("path", {
|
|
1071
973
|
stroke: "none",
|
|
1072
974
|
d: "M0 0h24v24H0z",
|
|
1073
975
|
fill: "none"
|
|
1074
976
|
}, null, -1),
|
|
1075
|
-
|
|
977
|
+
u("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)
|
|
1076
978
|
])]);
|
|
1077
979
|
}
|
|
1078
|
-
const
|
|
980
|
+
const Hn = /* @__PURE__ */ P(jn, [["render", zn]]), Ln = {}, Un = {
|
|
1079
981
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1080
982
|
width: "24",
|
|
1081
983
|
height: "24",
|
|
@@ -1083,17 +985,17 @@ const ps = /* @__PURE__ */ O(ls, [["render", cs]]), hs = {}, ms = {
|
|
|
1083
985
|
fill: "currentColor",
|
|
1084
986
|
class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-expand"
|
|
1085
987
|
};
|
|
1086
|
-
function
|
|
1087
|
-
return
|
|
1088
|
-
|
|
988
|
+
function An(n, e) {
|
|
989
|
+
return d(), p("svg", Un, [...e[0] || (e[0] = [
|
|
990
|
+
u("path", {
|
|
1089
991
|
stroke: "none",
|
|
1090
992
|
d: "M0 0h24v24H0z",
|
|
1091
993
|
fill: "none"
|
|
1092
994
|
}, null, -1),
|
|
1093
|
-
|
|
995
|
+
u("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)
|
|
1094
996
|
])]);
|
|
1095
997
|
}
|
|
1096
|
-
const
|
|
998
|
+
const Dn = /* @__PURE__ */ P(Ln, [["render", An]]), Fn = {}, Wn = {
|
|
1097
999
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1098
1000
|
width: "24",
|
|
1099
1001
|
height: "24",
|
|
@@ -1105,12 +1007,34 @@ const fs = /* @__PURE__ */ O(hs, [["render", vs]]), gs = {}, bs = {
|
|
|
1105
1007
|
"stroke-linejoin": "round",
|
|
1106
1008
|
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-lock-code"
|
|
1107
1009
|
};
|
|
1108
|
-
function
|
|
1109
|
-
return
|
|
1110
|
-
|
|
1010
|
+
function Yn(n, e) {
|
|
1011
|
+
return d(), p("svg", Wn, [...e[0] || (e[0] = [
|
|
1012
|
+
se('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M11.5 21h-4.5a2 2 0 0 1 -2 -2v-6a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2"></path><path d="M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0"></path><path d="M8 11v-4a4 4 0 1 1 8 0v4"></path><path d="M20 21l2 -2l-2 -2"></path><path d="M17 17l-2 2l2 2"></path>', 6)
|
|
1013
|
+
])]);
|
|
1014
|
+
}
|
|
1015
|
+
const Kn = /* @__PURE__ */ P(Fn, [["render", Yn]]), Xn = {}, qn = {
|
|
1016
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1017
|
+
width: "24",
|
|
1018
|
+
height: "24",
|
|
1019
|
+
viewBox: "0 0 24 24",
|
|
1020
|
+
fill: "none",
|
|
1021
|
+
stroke: "currentColor",
|
|
1022
|
+
"stroke-width": "2",
|
|
1023
|
+
"stroke-linecap": "round",
|
|
1024
|
+
"stroke-linejoin": "round",
|
|
1025
|
+
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-player-play"
|
|
1026
|
+
};
|
|
1027
|
+
function Jn(n, e) {
|
|
1028
|
+
return d(), p("svg", qn, [...e[0] || (e[0] = [
|
|
1029
|
+
u("path", {
|
|
1030
|
+
stroke: "none",
|
|
1031
|
+
d: "M0 0h24v24H0z",
|
|
1032
|
+
fill: "none"
|
|
1033
|
+
}, null, -1),
|
|
1034
|
+
u("path", { d: "M7 4v16l13 -8z" }, null, -1)
|
|
1111
1035
|
])]);
|
|
1112
1036
|
}
|
|
1113
|
-
const
|
|
1037
|
+
const Qn = /* @__PURE__ */ P(Xn, [["render", Jn]]), Zn = {}, es = {
|
|
1114
1038
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1115
1039
|
width: "24",
|
|
1116
1040
|
height: "24",
|
|
@@ -1122,12 +1046,12 @@ const ys = /* @__PURE__ */ O(gs, [["render", _s]]), Cs = {}, ks = {
|
|
|
1122
1046
|
"stroke-linejoin": "round",
|
|
1123
1047
|
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema"
|
|
1124
1048
|
};
|
|
1125
|
-
function
|
|
1126
|
-
return
|
|
1127
|
-
|
|
1049
|
+
function ts(n, e) {
|
|
1050
|
+
return d(), p("svg", es, [...e[0] || (e[0] = [
|
|
1051
|
+
se('<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)
|
|
1128
1052
|
])]);
|
|
1129
1053
|
}
|
|
1130
|
-
const
|
|
1054
|
+
const ns = /* @__PURE__ */ P(Zn, [["render", ts]]), ss = {}, os = {
|
|
1131
1055
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1132
1056
|
width: "24",
|
|
1133
1057
|
height: "24",
|
|
@@ -1139,12 +1063,12 @@ const Is = /* @__PURE__ */ O(Cs, [["render", ws]]), Ns = {}, xs = {
|
|
|
1139
1063
|
"stroke-linejoin": "round",
|
|
1140
1064
|
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema-off"
|
|
1141
1065
|
};
|
|
1142
|
-
function
|
|
1143
|
-
return
|
|
1144
|
-
|
|
1066
|
+
function as(n, e) {
|
|
1067
|
+
return d(), p("svg", os, [...e[0] || (e[0] = [
|
|
1068
|
+
se('<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)
|
|
1145
1069
|
])]);
|
|
1146
1070
|
}
|
|
1147
|
-
const
|
|
1071
|
+
const is = /* @__PURE__ */ P(ss, [["render", as]]), rs = {}, ds = {
|
|
1148
1072
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1149
1073
|
width: "24",
|
|
1150
1074
|
height: "24",
|
|
@@ -1156,12 +1080,12 @@ const Os = /* @__PURE__ */ O(Ns, [["render", Ms]]), $s = {}, Ts = {
|
|
|
1156
1080
|
"stroke-linejoin": "round",
|
|
1157
1081
|
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-transition-bottom"
|
|
1158
1082
|
};
|
|
1159
|
-
function
|
|
1160
|
-
return
|
|
1161
|
-
|
|
1083
|
+
function ls(n, e) {
|
|
1084
|
+
return d(), p("svg", ds, [...e[0] || (e[0] = [
|
|
1085
|
+
se('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M21 18a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3"></path><path d="M3 3m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z"></path><path d="M12 9v8"></path><path d="M9 14l3 3l3 -3"></path>', 5)
|
|
1162
1086
|
])]);
|
|
1163
1087
|
}
|
|
1164
|
-
const
|
|
1088
|
+
const us = /* @__PURE__ */ P(rs, [["render", ls]]), cs = {}, ps = {
|
|
1165
1089
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1166
1090
|
width: "24",
|
|
1167
1091
|
height: "24",
|
|
@@ -1173,115 +1097,458 @@ const Ss = /* @__PURE__ */ O($s, [["render", Es]]), Bs = {}, Vs = {
|
|
|
1173
1097
|
"stroke-linejoin": "round",
|
|
1174
1098
|
class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-trash-off"
|
|
1175
1099
|
};
|
|
1176
|
-
function
|
|
1177
|
-
return
|
|
1178
|
-
|
|
1100
|
+
function hs(n, e) {
|
|
1101
|
+
return d(), p("svg", ps, [...e[0] || (e[0] = [
|
|
1102
|
+
se('<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)
|
|
1179
1103
|
])]);
|
|
1180
1104
|
}
|
|
1181
|
-
const
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1105
|
+
const ms = /* @__PURE__ */ P(cs, [["render", hs]]), et = "CLEAR_ALL", tt = "RUN_ENGINE", nt = "TOGGLE_MINIMAP", st = "TOGGLE_PALETTE", fs = (n, e, t) => {
|
|
1106
|
+
const s = t.zoomToFit.paddingLeft;
|
|
1107
|
+
e.registerCommand(st, {
|
|
1108
|
+
execute: () => {
|
|
1109
|
+
t.palette.enabled = !t.palette.enabled, t.zoomToFit.paddingLeft = t.palette.enabled ? s : 50;
|
|
1110
|
+
},
|
|
1111
|
+
canExecute: () => !0
|
|
1112
|
+
}), e.registerCommand(et, {
|
|
1113
|
+
execute: () => n.value.clear(),
|
|
1114
|
+
canExecute: () => n.value.nodes.length > 0
|
|
1115
|
+
}), e.registerCommand(nt, {
|
|
1116
|
+
execute: () => t.enableMinimap = !t.enableMinimap,
|
|
1117
|
+
canExecute: () => n.value.nodes.length > 1
|
|
1118
|
+
});
|
|
1119
|
+
}, vs = (n) => {
|
|
1120
|
+
const e = {
|
|
1121
|
+
command: tt,
|
|
1122
|
+
title: "Run",
|
|
1123
|
+
// Tooltip text
|
|
1124
|
+
icon: O(() => Qn)
|
|
1125
|
+
}, t = {
|
|
1126
|
+
command: st,
|
|
1127
|
+
title: "Toggle palette",
|
|
1128
|
+
// Tooltip text
|
|
1129
|
+
icon: O(() => n.palette.enabled ? Tn : Gn)
|
|
1130
|
+
}, s = {
|
|
1131
|
+
command: et,
|
|
1132
|
+
title: "Clear all",
|
|
1133
|
+
// Tooltip text
|
|
1134
|
+
icon: O(() => ms)
|
|
1135
|
+
}, o = {
|
|
1136
|
+
command: nt,
|
|
1137
|
+
title: "Toggle minimap",
|
|
1138
|
+
// Tooltip text
|
|
1139
|
+
icon: O(() => n.enableMinimap ? is : ns)
|
|
1140
|
+
};
|
|
1141
|
+
n.toolbar.commands = [t, e, ...jt, s, o];
|
|
1142
|
+
}, gs = (n, e) => {
|
|
1143
|
+
e.registerCommand(tt, {
|
|
1144
|
+
execute: () => n.runOnce(null),
|
|
1145
|
+
canExecute: () => !0
|
|
1146
|
+
});
|
|
1147
|
+
};
|
|
1148
|
+
function bs(n) {
|
|
1149
|
+
const e = Symbol("CodeEngineToken");
|
|
1150
|
+
n.engine = new vn(n.editor), gs(n.engine, n.commandHandler), n.loadEditor = (t) => {
|
|
1151
|
+
n.engine?.pause(), n.displayedGraph.clear(), n.editor.load(t), n.commandHandler.executeCommand(q.CLEAR_CLIPBOARD_COMMAND), n.commandHandler.executeCommand(q.CLEAR_HISTORY_COMMAND), n.engine?.resume(), n.engine?.runOnce(null);
|
|
1152
|
+
}, n.newGraph = () => {
|
|
1153
|
+
n.engine?.pause(), n.displayedGraph.clear(), n.commandHandler.executeCommand(q.CLEAR_CLIPBOARD_COMMAND), n.commandHandler.executeCommand(q.CLEAR_HISTORY_COMMAND), n.displayedGraph.id = K(), n.engine?.resume(), n.engine?.runOnce(null);
|
|
1154
|
+
}, n.subscribe = () => {
|
|
1155
|
+
n.displayedGraph.events.addConnection.subscribe(e, (t) => {
|
|
1156
|
+
const s = n.displayedGraph.findNodeById(t.to.nodeId);
|
|
1157
|
+
s && s.isCodeNode && s.onConnected();
|
|
1158
|
+
const o = n.displayedGraph.findNodeById(t.from.nodeId);
|
|
1159
|
+
o && o.isCodeNode && o.onConnected();
|
|
1160
|
+
}), n.displayedGraph.events.removeConnection.subscribe(e, (t) => {
|
|
1161
|
+
const s = n.displayedGraph.findNodeById(t.to.nodeId);
|
|
1162
|
+
s && s.isCodeNode && s.onUnconnected();
|
|
1163
|
+
const o = n.displayedGraph.findNodeById(t.from.nodeId);
|
|
1164
|
+
o && o.isCodeNode && o.onUnconnected();
|
|
1165
|
+
}), n.engine?.events.beforeRun.subscribe(e, () => {
|
|
1166
|
+
n.engine?.pause(), n.displayedGraph.sortNodes(), n.engine?.resume();
|
|
1167
|
+
}), n.engine?.events.afterRun.subscribe(e, (t) => {
|
|
1168
|
+
n.engine?.pause(), Ae(t, n.editor), n.editor.saveState(), n.code.state.lockCode || n.code.renderCode({
|
|
1169
|
+
nodes: n.editor.graph.scriptedCodeNodes,
|
|
1170
|
+
modules: n.editor.graph.modules
|
|
1171
|
+
}), n.engine?.resume();
|
|
1172
|
+
});
|
|
1173
|
+
}, n.unsubscribe = () => {
|
|
1174
|
+
n.displayedGraph.events.addConnection.unsubscribe(e), n.displayedGraph.events.removeConnection.unsubscribe(e), n.engine?.events.beforeRun.unsubscribe(e), n.engine?.events.afterRun.unsubscribe(e);
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
class ue extends Ct {
|
|
1178
|
+
code = null;
|
|
1179
|
+
editor;
|
|
1180
|
+
_state = D({
|
|
1181
|
+
codeTemplate: "{{ #nodes }}{{ script }}{{ /nodes }}",
|
|
1182
|
+
lockCode: !1
|
|
1183
|
+
});
|
|
1184
|
+
constructor(e, t) {
|
|
1185
|
+
super(e, t), this.editor = e, this.template = t, e.code && (this.code = e.code);
|
|
1186
|
+
}
|
|
1187
|
+
get codeNodes() {
|
|
1188
|
+
return ot(this);
|
|
1189
|
+
}
|
|
1190
|
+
get connections() {
|
|
1191
|
+
return super.connections;
|
|
1192
|
+
}
|
|
1193
|
+
set connections(e) {
|
|
1194
|
+
this._connections = e;
|
|
1195
|
+
}
|
|
1196
|
+
get nodeIds() {
|
|
1197
|
+
return this.nodes.map((e) => e.id);
|
|
1198
|
+
}
|
|
1199
|
+
get nodes() {
|
|
1200
|
+
return super.nodes;
|
|
1201
|
+
}
|
|
1202
|
+
set nodes(e) {
|
|
1203
|
+
this._nodes = e;
|
|
1204
|
+
}
|
|
1205
|
+
get scriptedCodeNodes() {
|
|
1206
|
+
return this.nodes.filter((e) => !e.state?.integrated);
|
|
1207
|
+
}
|
|
1208
|
+
get shortId() {
|
|
1209
|
+
return this.id.slice(0, 6);
|
|
1210
|
+
}
|
|
1211
|
+
get state() {
|
|
1212
|
+
return this._state;
|
|
1213
|
+
}
|
|
1214
|
+
get visibleNodes() {
|
|
1215
|
+
return this.nodes.filter((e) => !e.state?.hidden);
|
|
1216
|
+
}
|
|
1217
|
+
// /**
|
|
1218
|
+
// * Add code node to graph.
|
|
1219
|
+
// * @param node code node
|
|
1220
|
+
// * @param props optional
|
|
1221
|
+
// */
|
|
1222
|
+
// public override addNode(node: AbstractCodeNode, props?: unknown): AbstractCodeNode | undefined {
|
|
1223
|
+
// if (node.state && props) node.state.props = props;
|
|
1224
|
+
// return super.addNode(node as AbstractNode) as AbstractCodeNode;
|
|
1225
|
+
// }
|
|
1226
|
+
/**
|
|
1227
|
+
* Add code node at coordinates.
|
|
1228
|
+
* @param node code node
|
|
1229
|
+
* @param position position
|
|
1230
|
+
* @param props optional
|
|
1231
|
+
* @returns code node
|
|
1232
|
+
*/
|
|
1233
|
+
addNodeAtCoordinates = (e, t = { x: 0, y: 0 }, s) => (this.addNode(e, s), e.position && (e.position = t), e);
|
|
1234
|
+
/**
|
|
1235
|
+
* Add connection of code nodes
|
|
1236
|
+
* @param from code node interface
|
|
1237
|
+
* @param to code node interface
|
|
1238
|
+
*/
|
|
1239
|
+
addConnection(e, t) {
|
|
1240
|
+
e?.name !== "_code" && (e.hidden = !1), t?.name !== "_code" && (t.hidden = !1), super.addConnection(e, t);
|
|
1241
|
+
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Clear code graph.
|
|
1244
|
+
*/
|
|
1245
|
+
clear() {
|
|
1246
|
+
this.selectedNodes = [], this._nodes = [], this._connections = [];
|
|
1247
|
+
}
|
|
1248
|
+
/**
|
|
1249
|
+
* Find node by type.
|
|
1250
|
+
* @param nodeType node type
|
|
1251
|
+
* @returns node instance
|
|
1252
|
+
*/
|
|
1253
|
+
findNodeByType(e) {
|
|
1254
|
+
return this.nodes.find((t) => t.type === e);
|
|
1255
|
+
}
|
|
1256
|
+
/**
|
|
1257
|
+
* Get nodes of the same type.
|
|
1258
|
+
* @param type node type
|
|
1259
|
+
* @returns a list of node instances
|
|
1260
|
+
*/
|
|
1261
|
+
getNodesBySameType(e) {
|
|
1262
|
+
return this.nodes.filter((t) => t.type === e);
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Get nodes of the same variable name.
|
|
1266
|
+
* @param variableName variable name
|
|
1267
|
+
* @returns a list of node instances
|
|
1268
|
+
*/
|
|
1269
|
+
getNodesBySameVariableNames(e) {
|
|
1270
|
+
return this.nodes.filter(
|
|
1271
|
+
(t) => t.state?.variableName === e
|
|
1272
|
+
);
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1275
|
+
* Check whether the graph has this connection.
|
|
1276
|
+
* @param from node interface
|
|
1277
|
+
* @param to node interface
|
|
1278
|
+
* @returns boolean
|
|
1279
|
+
*/
|
|
1280
|
+
hasConnection(e, t) {
|
|
1281
|
+
return this.connections.some(
|
|
1282
|
+
(s) => s.from.id === e.id && s.to.id === t.id
|
|
1283
|
+
);
|
|
1284
|
+
}
|
|
1285
|
+
/**
|
|
1286
|
+
* Render code script.
|
|
1287
|
+
*/
|
|
1288
|
+
renderCode(e) {
|
|
1289
|
+
return Z.render(this.state?.codeTemplate || "", e);
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Sort code nodes.
|
|
1293
|
+
*/
|
|
1294
|
+
sortNodes() {
|
|
1295
|
+
if (!(this.nodes.length === 0 || this.connections.length === 0))
|
|
1296
|
+
try {
|
|
1297
|
+
let e = this.nodeIds;
|
|
1298
|
+
const t = this.connections.filter(
|
|
1299
|
+
(a) => e.includes(a.to.nodeId) && e.includes(a.from.nodeId)
|
|
1300
|
+
).map((a) => [a.to.nodeId, a.from.nodeId]);
|
|
1301
|
+
e.reverse(), e = Qt.array(e, t), e.reverse();
|
|
1302
|
+
const s = this.nodes.map((a) => a.id).filter((a) => !e.includes(a));
|
|
1303
|
+
e = [...e, ...s];
|
|
1304
|
+
const o = e.map((a) => this.findNodeById(a));
|
|
1305
|
+
o && (this.nodes = o);
|
|
1306
|
+
} catch {
|
|
1307
|
+
console.warn("Failed to sort nodes.");
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
const ot = (n) => {
|
|
1312
|
+
const e = [];
|
|
1313
|
+
return n.nodes.length === 0 || n.nodes.forEach((t) => {
|
|
1314
|
+
t && (t.hasOwnProperty("subgraph") ? e.push(...ot(t.subgraph)) : t.hasOwnProperty("isCodeNode") && e.push(t));
|
|
1315
|
+
}), e;
|
|
1316
|
+
}, To = (n = 0, e = 100) => ({
|
|
1317
|
+
x: n * 420,
|
|
1318
|
+
y: e
|
|
1319
|
+
}), Eo = (n) => {
|
|
1320
|
+
const e = { ...n.position };
|
|
1321
|
+
return e.x -= 440, e.y += 50, e;
|
|
1322
|
+
};
|
|
1323
|
+
function _s(n, e) {
|
|
1324
|
+
return Object.fromEntries(Object.entries(n).filter(e));
|
|
1325
|
+
}
|
|
1326
|
+
function ys(n, e) {
|
|
1327
|
+
return Object.fromEntries(Object.entries(n).map(([t, s]) => [t, e(s)]));
|
|
1328
|
+
}
|
|
1329
|
+
class ce extends It {
|
|
1330
|
+
/** Create a new GraphTemplate from the nodes and connections inside the graph instance */
|
|
1331
|
+
static fromGraph(e, t) {
|
|
1332
|
+
return new ce(e.save(), t);
|
|
1333
|
+
}
|
|
1334
|
+
constructor(e, t) {
|
|
1335
|
+
super(e, t);
|
|
1336
|
+
}
|
|
1337
|
+
get shortId() {
|
|
1338
|
+
return this.id.slice(0, 6);
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* Create a new graph instance from this template
|
|
1342
|
+
* or load the state into the provided graph instance.
|
|
1343
|
+
*/
|
|
1344
|
+
createGraph(e) {
|
|
1345
|
+
const t = /* @__PURE__ */ new Map(), s = (m) => {
|
|
1346
|
+
const x = K();
|
|
1347
|
+
return t.set(m, x), x;
|
|
1348
|
+
}, o = (m) => {
|
|
1349
|
+
const x = t.get(m);
|
|
1350
|
+
if (!x) throw new Error(`Unable to create graph from template: Could not map old id ${m} to new id`);
|
|
1351
|
+
return x;
|
|
1352
|
+
}, a = (m) => ys(m, (x) => ({
|
|
1353
|
+
id: s(x.id),
|
|
1354
|
+
templateId: x.id,
|
|
1355
|
+
value: x.value
|
|
1356
|
+
})), i = this.nodes.map((m) => ({
|
|
1357
|
+
...m,
|
|
1358
|
+
id: s(m.id),
|
|
1359
|
+
inputs: a(m.inputs),
|
|
1360
|
+
outputs: a(m.outputs)
|
|
1361
|
+
})), r = this.connections.map((m) => ({
|
|
1362
|
+
id: s(m.id),
|
|
1363
|
+
from: o(m.from),
|
|
1364
|
+
to: o(m.to)
|
|
1365
|
+
})), c = this.inputs.map((m) => ({
|
|
1366
|
+
id: m.id,
|
|
1367
|
+
name: m.name,
|
|
1368
|
+
nodeId: o(m.nodeId),
|
|
1369
|
+
nodeInterfaceId: o(m.nodeInterfaceId)
|
|
1370
|
+
})), h = this.outputs.map((m) => ({
|
|
1371
|
+
id: m.id,
|
|
1372
|
+
name: m.name,
|
|
1373
|
+
nodeId: o(m.nodeId),
|
|
1374
|
+
nodeInterfaceId: o(m.nodeInterfaceId)
|
|
1375
|
+
})), g = {
|
|
1376
|
+
id: K(),
|
|
1377
|
+
nodes: i,
|
|
1378
|
+
connections: r,
|
|
1379
|
+
inputs: c,
|
|
1380
|
+
outputs: h
|
|
1381
|
+
};
|
|
1382
|
+
return e || (e = new ue(this.editor)), e.load(g).forEach((m) => console.warn(m)), e.template = this, e;
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
const Cs = (n) => !(n instanceof ue);
|
|
1386
|
+
function Is(n, e) {
|
|
1387
|
+
return { switchGraph: (s) => {
|
|
1388
|
+
let o;
|
|
1389
|
+
if (Cs(s))
|
|
1390
|
+
o = new ue(n.value), s.createGraph(o);
|
|
1391
|
+
else {
|
|
1392
|
+
if (s !== n.value.graph)
|
|
1393
|
+
throw new Error(
|
|
1394
|
+
"Can only switch using 'Graph' instance when it is the root graph. Otherwise a 'GraphTemplate' must be used."
|
|
1395
|
+
);
|
|
1396
|
+
o = s;
|
|
1397
|
+
}
|
|
1398
|
+
e.value && e.value !== n.value.graph && e.value.destroy(), o.panning = o.panning ?? s.panning ?? { x: 0, y: 0 }, o.scaling = o.scaling ?? s.scaling ?? 1, o.selectedNodes = o.selectedNodes ?? [], o.sidebar = o.sidebar ?? { visible: !1, nodeId: "", optionName: "" }, e.value = o, o.code?.engine?.runOnce(null);
|
|
1399
|
+
} };
|
|
1400
|
+
}
|
|
1401
|
+
const $o = /* @__PURE__ */ F({
|
|
1402
|
+
__name: "CodeGraphEditor",
|
|
1403
|
+
props: {
|
|
1404
|
+
viewModel: {}
|
|
1405
|
+
},
|
|
1406
|
+
setup(n) {
|
|
1407
|
+
const t = Be(n, "viewModel"), s = (o) => o.events.update.emit(null);
|
|
1408
|
+
return fe(() => {
|
|
1409
|
+
t.value.subscribe && t.value.subscribe(), t.value.engine?.start();
|
|
1410
|
+
}), ze(() => {
|
|
1411
|
+
t.value.unsubscribe && t.value.unsubscribe(), t.value.engine?.stop();
|
|
1412
|
+
}), He(t, (o, a) => {
|
|
1413
|
+
a && a.unsubscribe(), o && o.subscribe();
|
|
1414
|
+
}), (o, a) => (d(), j(w(Bt), { viewModel: t.value }, {
|
|
1415
|
+
palette: ee(() => [
|
|
1416
|
+
L(w(Ls))
|
|
1417
|
+
]),
|
|
1418
|
+
node: ee((i) => [
|
|
1419
|
+
L(w(Ps), mt(i, {
|
|
1420
|
+
onUpdate: (r) => s(i.node)
|
|
1421
|
+
}), null, 16, ["onUpdate"])
|
|
1422
|
+
]),
|
|
1423
|
+
sidebar: ee((i) => [
|
|
1424
|
+
L(w(Qs), pt(ht(i)), {
|
|
1425
|
+
codeEditor: ee(({ node: r }) => [
|
|
1426
|
+
ne(o.$slots, "sidebarCodeEditor", { node: r })
|
|
1427
|
+
]),
|
|
1428
|
+
_: 3
|
|
1429
|
+
}, 16)
|
|
1430
|
+
]),
|
|
1431
|
+
_: 3
|
|
1432
|
+
}, 8, ["viewModel"]));
|
|
1433
|
+
}
|
|
1434
|
+
}), ws = { class: "code-graph-info" }, Mo = /* @__PURE__ */ F({
|
|
1435
|
+
__name: "CodeGraphInfo",
|
|
1436
|
+
props: {
|
|
1437
|
+
viewModel: {}
|
|
1438
|
+
},
|
|
1439
|
+
setup(n) {
|
|
1440
|
+
return (e, t) => (d(), p("div", ws, [
|
|
1441
|
+
u("div", null, "Editor graph: " + G(n.viewModel.editor.graph.shortId), 1),
|
|
1442
|
+
u("div", null, "Displayed graph: " + G(n.viewModel.displayedGraph.shortId), 1),
|
|
1443
|
+
u("div", null, "Graphs: " + G(n.viewModel.editor.graphIds), 1),
|
|
1444
|
+
u("div", null, "Graph templates: " + G(n.viewModel.editor.graphTemplateIds), 1),
|
|
1445
|
+
u("div", null, "Engine status: " + G(n.viewModel.engine?.status), 1)
|
|
1446
|
+
]));
|
|
1447
|
+
}
|
|
1448
|
+
}), ks = ["id", "data-node-type"], Ns = {
|
|
1449
|
+
class: "__title-label",
|
|
1450
|
+
style: { "flex-grow": "1" }
|
|
1451
|
+
}, xs = { key: 0 }, Os = {
|
|
1452
|
+
class: "__menu",
|
|
1453
|
+
style: { display: "flex" }
|
|
1454
|
+
}, Ts = { class: "__outputs" }, Es = { key: 0 }, $s = ["id", "title"], Ms = { class: "__inputs" }, Gs = { key: 0 }, Ss = ["id", "title"], Ps = /* @__PURE__ */ F({
|
|
1455
|
+
__name: "CodeGraphNode",
|
|
1456
|
+
props: {
|
|
1457
|
+
node: {},
|
|
1458
|
+
selected: { type: Boolean, default: !1 },
|
|
1459
|
+
dragging: { type: Boolean }
|
|
1460
|
+
},
|
|
1461
|
+
emits: ["select", "start-drag", "update"],
|
|
1462
|
+
setup(n, { emit: e }) {
|
|
1463
|
+
const t = me.ContextMenu, s = me.NodeInterface, o = n, a = O(() => o.node), i = e, { viewModel: r } = oe(), { graph: c, switchGraph: h } = ge(), g = R(null), _ = R(!1), m = R(""), x = R(null), b = R(!1);
|
|
1464
|
+
let I = 0, l = 0;
|
|
1465
|
+
const f = R(!1), k = O(() => {
|
|
1466
|
+
const C = [
|
|
1467
|
+
{ value: "edit", label: "Edit" },
|
|
1468
|
+
{ value: "rename", label: "Rename" },
|
|
1469
|
+
{ value: "delete", label: "Delete" }
|
|
1470
|
+
];
|
|
1471
|
+
return o.node.type.startsWith(wt) && C.push({ value: "editSubgraph", label: "Edit Subgraph" }), C;
|
|
1472
|
+
}), y = O(() => ({
|
|
1473
|
+
"--selected": o.selected,
|
|
1474
|
+
"--dragging": o.dragging,
|
|
1475
|
+
"--two-column": !!o.node.twoColumn,
|
|
1476
|
+
"--hidden": a.value.state?.hidden
|
|
1477
|
+
})), T = O(() => ({
|
|
1478
|
+
"--reverse-y": o.node.reverseY ?? r.value.settings.nodes.reverseY
|
|
1479
|
+
})), ie = O(() => ({
|
|
1480
|
+
top: `${o.node.position?.y ?? 0}px`,
|
|
1481
|
+
left: `${o.node.position?.x ?? 0}px`,
|
|
1482
|
+
"--width": `${o.node.width ?? r.value.settings.nodes.defaultWidth}px`
|
|
1483
|
+
})), W = O(() => Object.values(o.node.inputs).filter((C) => !C.hidden)), pe = O(() => Object.values(o.node.outputs).filter((C) => !C.hidden)), re = () => {
|
|
1484
|
+
i("select");
|
|
1485
|
+
}, v = (C) => {
|
|
1486
|
+
o.selected || re(), i("start-drag", C);
|
|
1487
|
+
}, S = () => {
|
|
1488
|
+
f.value = !0;
|
|
1489
|
+
}, H = () => {
|
|
1490
|
+
const C = r.value.displayedGraph.sidebar;
|
|
1491
|
+
C.nodeId = "", C.visible = !1;
|
|
1492
|
+
}, Ne = () => {
|
|
1493
|
+
const C = r.value.displayedGraph.sidebar;
|
|
1494
|
+
C.nodeId = o.node.id, C.visible = !0;
|
|
1495
|
+
}, rt = () => {
|
|
1496
|
+
const C = r.value.displayedGraph.sidebar;
|
|
1497
|
+
C.nodeId = o.node.id;
|
|
1498
|
+
}, dt = async (C) => {
|
|
1499
|
+
switch (C) {
|
|
1500
|
+
case "edit":
|
|
1501
|
+
Ne();
|
|
1235
1502
|
break;
|
|
1236
1503
|
case "delete":
|
|
1237
|
-
|
|
1504
|
+
c.value.removeNode(o.node);
|
|
1238
1505
|
break;
|
|
1239
1506
|
case "rename":
|
|
1240
|
-
|
|
1507
|
+
m.value = o.node.title, _.value = !0, await vt(), x.value?.focus();
|
|
1241
1508
|
break;
|
|
1242
1509
|
case "editSubgraph":
|
|
1243
|
-
|
|
1510
|
+
h(o.node.template);
|
|
1244
1511
|
break;
|
|
1245
1512
|
}
|
|
1246
|
-
},
|
|
1247
|
-
a.value.title =
|
|
1248
|
-
},
|
|
1249
|
-
g.value &&
|
|
1250
|
-
},
|
|
1251
|
-
|
|
1252
|
-
},
|
|
1253
|
-
a.value.state && (a.value.state.integrated =
|
|
1254
|
-
},
|
|
1255
|
-
if (!
|
|
1256
|
-
const
|
|
1257
|
-
a.value.width = Math.max(
|
|
1258
|
-
},
|
|
1259
|
-
|
|
1513
|
+
}, xe = () => {
|
|
1514
|
+
a.value.title = m.value, _.value = !1;
|
|
1515
|
+
}, Oe = () => {
|
|
1516
|
+
g.value && r.value.hooks.renderNode.execute({ node: o.node, el: g.value });
|
|
1517
|
+
}, lt = (C) => {
|
|
1518
|
+
b.value = !0, I = o.node.width, l = C.clientX, C.preventDefault();
|
|
1519
|
+
}, Te = (C) => {
|
|
1520
|
+
a.value.state && (a.value.state.integrated = C, i("update"));
|
|
1521
|
+
}, Ee = (C) => {
|
|
1522
|
+
if (!b.value) return;
|
|
1523
|
+
const E = C.clientX - l, N = I + E / c.value.scaling, ut = r.value.settings.nodes.minWidth, ct = r.value.settings.nodes.maxWidth;
|
|
1524
|
+
a.value.width = Math.max(ut, Math.min(ct, N));
|
|
1525
|
+
}, $e = () => {
|
|
1526
|
+
b.value = !1;
|
|
1260
1527
|
};
|
|
1261
|
-
return
|
|
1262
|
-
|
|
1263
|
-
}), Oe
|
|
1264
|
-
window.removeEventListener("mousemove",
|
|
1265
|
-
}), (
|
|
1528
|
+
return fe(() => {
|
|
1529
|
+
Oe(), window.addEventListener("mousemove", Ee), window.addEventListener("mouseup", $e);
|
|
1530
|
+
}), Le(Oe), ze(() => {
|
|
1531
|
+
window.removeEventListener("mousemove", Ee), window.removeEventListener("mouseup", $e);
|
|
1532
|
+
}), (C, E) => (d(), p("div", {
|
|
1266
1533
|
id: a.value.id,
|
|
1267
1534
|
ref_key: "el",
|
|
1268
1535
|
ref: g,
|
|
1269
|
-
class:
|
|
1536
|
+
class: Y([y.value, "baklava-node"]),
|
|
1270
1537
|
"data-node-type": a.value.type,
|
|
1271
|
-
style:
|
|
1272
|
-
onPointerdown:
|
|
1538
|
+
style: ve(ie.value),
|
|
1539
|
+
onPointerdown: re
|
|
1273
1540
|
}, [
|
|
1274
|
-
|
|
1541
|
+
w(r).settings.nodes.resizable ? (d(), p("div", {
|
|
1275
1542
|
key: 0,
|
|
1276
1543
|
class: "__resize-handle",
|
|
1277
|
-
onMousedown:
|
|
1278
|
-
}, null, 32)) :
|
|
1279
|
-
|
|
1544
|
+
onMousedown: lt
|
|
1545
|
+
}, null, 32)) : M("", !0),
|
|
1546
|
+
u("div", {
|
|
1280
1547
|
class: "__title",
|
|
1281
|
-
onPointerdown:
|
|
1282
|
-
onContextmenu:
|
|
1548
|
+
onPointerdown: te(v, ["self", "stop"]),
|
|
1549
|
+
onContextmenu: te(S, ["prevent"])
|
|
1283
1550
|
}, [
|
|
1284
|
-
a.value.inputs._code ? (
|
|
1551
|
+
a.value.inputs._code ? (d(), j(w(Re), {
|
|
1285
1552
|
key: 0,
|
|
1286
1553
|
node: a.value,
|
|
1287
1554
|
intf: a.value.inputs._code,
|
|
@@ -1289,147 +1556,271 @@ const js = /* @__PURE__ */ O(Bs, [["render", zs]]), Ls = ["id", "data-node-type"
|
|
|
1289
1556
|
class: "--input",
|
|
1290
1557
|
"data-interface-type": "node",
|
|
1291
1558
|
style: { "flex-grow": "0" }
|
|
1292
|
-
}, null, 8, ["node", "intf", "title"])) :
|
|
1293
|
-
|
|
1559
|
+
}, null, 8, ["node", "intf", "title"])) : M("", !0),
|
|
1560
|
+
_.value ? de((d(), p("input", {
|
|
1294
1561
|
key: 2,
|
|
1295
1562
|
ref_key: "renameInputEl",
|
|
1296
1563
|
ref: x,
|
|
1297
|
-
"onUpdate:modelValue":
|
|
1564
|
+
"onUpdate:modelValue": E[4] || (E[4] = (N) => m.value = N),
|
|
1298
1565
|
class: "baklava-input",
|
|
1299
1566
|
placeholder: "Node Name",
|
|
1300
1567
|
style: { "flex-grow": "1" },
|
|
1301
1568
|
type: "text",
|
|
1302
|
-
onBlur:
|
|
1303
|
-
onKeydown:
|
|
1569
|
+
onBlur: xe,
|
|
1570
|
+
onKeydown: he(xe, ["enter"])
|
|
1304
1571
|
}, null, 544)), [
|
|
1305
|
-
[
|
|
1306
|
-
]) : (
|
|
1307
|
-
|
|
1308
|
-
a.value.idx > -1 ? (
|
|
1309
|
-
|
|
1572
|
+
[le, m.value]
|
|
1573
|
+
]) : (d(), p(B, { key: 1 }, [
|
|
1574
|
+
u("div", Ns, [
|
|
1575
|
+
a.value.idx > -1 ? (d(), p("span", xs, G(a.value.idx + 1) + " - ", 1)) : M("", !0),
|
|
1576
|
+
ft(G(a.value.title) + " " + G(a.value.graph.shortId) + " " + G(a.value.shortId), 1)
|
|
1310
1577
|
]),
|
|
1311
|
-
|
|
1312
|
-
a.value.isCodeNode ? (
|
|
1313
|
-
a.value.state.lockCode ? (
|
|
1578
|
+
u("div", Os, [
|
|
1579
|
+
a.value.isCodeNode ? (d(), p(B, { key: 0 }, [
|
|
1580
|
+
a.value.state.lockCode ? (d(), j(w(Kn), {
|
|
1314
1581
|
key: 0,
|
|
1315
1582
|
class: "--clickable mx-1",
|
|
1316
|
-
onClick:
|
|
1317
|
-
})) :
|
|
1318
|
-
a.value.state.integrated ? (
|
|
1583
|
+
onClick: E[0] || (E[0] = (N) => a.value.lockCode = !1)
|
|
1584
|
+
})) : M("", !0),
|
|
1585
|
+
a.value.state.integrated ? (d(), j(w(yn), {
|
|
1319
1586
|
key: 1,
|
|
1320
1587
|
class: "--clickable mx-1",
|
|
1321
|
-
onClick:
|
|
1322
|
-
})) : (
|
|
1588
|
+
onClick: E[1] || (E[1] = (N) => Te(!1))
|
|
1589
|
+
})) : (d(), j(w(us), {
|
|
1323
1590
|
key: 2,
|
|
1324
1591
|
class: "--clickable mx-1",
|
|
1325
|
-
onClick:
|
|
1592
|
+
onClick: E[2] || (E[2] = (N) => Te(!0))
|
|
1326
1593
|
})),
|
|
1327
|
-
!
|
|
1594
|
+
!w(r).displayedGraph.sidebar.visible && w(r).displayedGraph.sidebar.nodeId !== a.value.id ? (d(), j(w(Dn), {
|
|
1328
1595
|
key: 3,
|
|
1329
1596
|
class: "--clickable mx-1",
|
|
1330
|
-
onClick:
|
|
1331
|
-
})) :
|
|
1597
|
+
onClick: Ne
|
|
1598
|
+
})) : w(r).displayedGraph.sidebar.visible && w(r).displayedGraph.sidebar.nodeId !== a.value.id ? (d(), j(w(Vn), {
|
|
1332
1599
|
key: 4,
|
|
1333
1600
|
class: "--clickable mx-1",
|
|
1334
|
-
onClick:
|
|
1335
|
-
})) : (
|
|
1601
|
+
onClick: rt
|
|
1602
|
+
})) : (d(), j(w(Hn), {
|
|
1336
1603
|
key: 5,
|
|
1337
1604
|
class: "--clickable mx-1",
|
|
1338
|
-
onClick:
|
|
1605
|
+
onClick: H
|
|
1339
1606
|
}))
|
|
1340
|
-
], 64)) :
|
|
1341
|
-
|
|
1607
|
+
], 64)) : M("", !0),
|
|
1608
|
+
L(w(kn), {
|
|
1342
1609
|
class: "--clickable mx-1",
|
|
1343
|
-
onClick:
|
|
1610
|
+
onClick: S
|
|
1344
1611
|
}),
|
|
1345
|
-
|
|
1346
|
-
modelValue:
|
|
1347
|
-
"onUpdate:modelValue":
|
|
1612
|
+
L(w(t), {
|
|
1613
|
+
modelValue: f.value,
|
|
1614
|
+
"onUpdate:modelValue": E[3] || (E[3] = (N) => f.value = N),
|
|
1348
1615
|
x: 0,
|
|
1349
1616
|
y: 0,
|
|
1350
|
-
items:
|
|
1351
|
-
onClick:
|
|
1617
|
+
items: k.value,
|
|
1618
|
+
onClick: dt
|
|
1352
1619
|
}, null, 8, ["modelValue", "items"])
|
|
1353
1620
|
])
|
|
1354
1621
|
], 64)),
|
|
1355
|
-
a.value.outputs._code ? (
|
|
1622
|
+
a.value.outputs._code ? (d(), j(w(Re), {
|
|
1356
1623
|
key: 3,
|
|
1357
1624
|
node: a.value,
|
|
1358
1625
|
intf: a.value.outputs._code,
|
|
1359
1626
|
class: "--output",
|
|
1360
1627
|
title: a.value.outputs._code.value,
|
|
1361
1628
|
"data-interface-type": "node"
|
|
1362
|
-
}, null, 8, ["node", "intf", "title"])) :
|
|
1629
|
+
}, null, 8, ["node", "intf", "title"])) : M("", !0)
|
|
1363
1630
|
], 32),
|
|
1364
|
-
|
|
1365
|
-
class:
|
|
1366
|
-
onKeydown:
|
|
1631
|
+
u("div", {
|
|
1632
|
+
class: Y(["__content", T.value]),
|
|
1633
|
+
onKeydown: E[5] || (E[5] = he(te(() => {
|
|
1367
1634
|
}, ["stop"]), ["delete"])),
|
|
1368
|
-
onContextmenu:
|
|
1635
|
+
onContextmenu: E[6] || (E[6] = te(() => {
|
|
1369
1636
|
}, ["prevent"]))
|
|
1370
1637
|
}, [
|
|
1371
|
-
|
|
1372
|
-
(
|
|
1373
|
-
key:
|
|
1638
|
+
u("div", Ts, [
|
|
1639
|
+
(d(!0), p(B, null, J(pe.value, (N) => (d(), p(B, {
|
|
1640
|
+
key: N.id
|
|
1374
1641
|
}, [
|
|
1375
|
-
a.value.state?.hidden ? (
|
|
1376
|
-
|
|
1642
|
+
a.value.state?.hidden ? (d(), p("div", Es, [
|
|
1643
|
+
N.port ? (d(), p("div", {
|
|
1377
1644
|
key: 0,
|
|
1378
|
-
id:
|
|
1379
|
-
title:
|
|
1645
|
+
id: N.id,
|
|
1646
|
+
title: N.name,
|
|
1380
1647
|
class: "baklava-node-interface --output --connected"
|
|
1381
|
-
}, [...
|
|
1382
|
-
|
|
1383
|
-
])], 8,
|
|
1384
|
-
])) :
|
|
1648
|
+
}, [...E[7] || (E[7] = [
|
|
1649
|
+
u("div", { class: "__port" }, null, -1)
|
|
1650
|
+
])], 8, $s)) : M("", !0)
|
|
1651
|
+
])) : ne(C.$slots, "nodeInterface", {
|
|
1385
1652
|
key: 1,
|
|
1386
1653
|
type: "output",
|
|
1387
1654
|
node: a.value,
|
|
1388
|
-
intf:
|
|
1655
|
+
intf: N
|
|
1389
1656
|
}, () => [
|
|
1390
|
-
|
|
1657
|
+
L(w(s), {
|
|
1391
1658
|
node: a.value,
|
|
1392
|
-
intf:
|
|
1393
|
-
title:
|
|
1659
|
+
intf: N,
|
|
1660
|
+
title: N.value
|
|
1394
1661
|
}, null, 8, ["node", "intf", "title"])
|
|
1395
1662
|
])
|
|
1396
1663
|
], 64))), 128))
|
|
1397
1664
|
]),
|
|
1398
|
-
|
|
1399
|
-
(
|
|
1400
|
-
key:
|
|
1665
|
+
u("div", Ms, [
|
|
1666
|
+
(d(!0), p(B, null, J(W.value, (N) => (d(), p(B, {
|
|
1667
|
+
key: N.id
|
|
1401
1668
|
}, [
|
|
1402
|
-
a.value.state?.hidden ? (
|
|
1403
|
-
|
|
1669
|
+
a.value.state?.hidden ? (d(), p("div", Gs, [
|
|
1670
|
+
N.port ? (d(), p("div", {
|
|
1404
1671
|
key: 0,
|
|
1405
|
-
id:
|
|
1406
|
-
title:
|
|
1672
|
+
id: N.id,
|
|
1673
|
+
title: N.name,
|
|
1407
1674
|
class: "baklava-node-interface --input --connected"
|
|
1408
|
-
}, [...
|
|
1409
|
-
|
|
1410
|
-
])], 8,
|
|
1411
|
-
])) :
|
|
1675
|
+
}, [...E[8] || (E[8] = [
|
|
1676
|
+
u("div", { class: "__port" }, null, -1)
|
|
1677
|
+
])], 8, Ss)) : M("", !0)
|
|
1678
|
+
])) : ne(C.$slots, "nodeInterface", {
|
|
1412
1679
|
key: 1,
|
|
1413
1680
|
node: a.value,
|
|
1414
|
-
intf:
|
|
1681
|
+
intf: N,
|
|
1415
1682
|
type: "input"
|
|
1416
1683
|
}, () => [
|
|
1417
|
-
|
|
1684
|
+
L(w(s), {
|
|
1418
1685
|
node: a.value,
|
|
1419
|
-
intf:
|
|
1420
|
-
title:
|
|
1686
|
+
intf: N,
|
|
1687
|
+
title: N.value
|
|
1421
1688
|
}, null, 8, ["node", "intf", "title"])
|
|
1422
1689
|
])
|
|
1423
1690
|
], 64))), 128))
|
|
1424
1691
|
])
|
|
1425
1692
|
], 34)
|
|
1426
|
-
], 46,
|
|
1693
|
+
], 46, ks));
|
|
1427
1694
|
}
|
|
1428
|
-
}),
|
|
1695
|
+
}), Rs = ["id"], Vs = { class: "align-middle" }, Re = /* @__PURE__ */ F({
|
|
1696
|
+
__name: "CodeGraphNodeInterface",
|
|
1697
|
+
props: {
|
|
1698
|
+
node: {},
|
|
1699
|
+
intf: {}
|
|
1700
|
+
},
|
|
1701
|
+
setup(n) {
|
|
1702
|
+
const e = n, { viewModel: t } = oe(), { hoveredOver: s, temporaryConnection: o } = zt(), a = R(null), i = O(() => e.intf.connectionCount > 0), r = O(() => ({
|
|
1703
|
+
"--connected": i.value
|
|
1704
|
+
})), c = () => {
|
|
1705
|
+
s(e.intf);
|
|
1706
|
+
}, h = () => {
|
|
1707
|
+
s(void 0);
|
|
1708
|
+
}, g = () => {
|
|
1709
|
+
a.value && t.value.hooks.renderInterface.execute({ intf: e.intf, el: a.value });
|
|
1710
|
+
};
|
|
1711
|
+
return fe(g), Le(g), (_, m) => (d(), p("div", {
|
|
1712
|
+
id: n.intf.id,
|
|
1713
|
+
ref_key: "el",
|
|
1714
|
+
ref: a,
|
|
1715
|
+
class: Y(["baklava-node-interface", r.value])
|
|
1716
|
+
}, [
|
|
1717
|
+
n.intf.port ? (d(), p("div", {
|
|
1718
|
+
key: 0,
|
|
1719
|
+
class: Y(["__port", { "--selected": w(o)?.from === n.intf }]),
|
|
1720
|
+
onPointerover: c,
|
|
1721
|
+
onPointerout: h
|
|
1722
|
+
}, null, 34)) : M("", !0),
|
|
1723
|
+
u("span", Vs, [
|
|
1724
|
+
ne(_.$slots, "default")
|
|
1725
|
+
])
|
|
1726
|
+
], 10, Rs));
|
|
1727
|
+
}
|
|
1728
|
+
}), js = {
|
|
1729
|
+
class: "baklava-node --palette",
|
|
1730
|
+
style: { "margin-top": "-20px", "margin-bottom": "20px" }
|
|
1731
|
+
}, Bs = {
|
|
1732
|
+
key: 0,
|
|
1733
|
+
style: { display: "flex", "justify-content": "space-between" }
|
|
1734
|
+
}, zs = ["onClick"], Hs = {
|
|
1735
|
+
key: 0,
|
|
1736
|
+
style: { margin: "auto 0", "font-size": "12px" }
|
|
1737
|
+
}, Ls = /* @__PURE__ */ F({
|
|
1738
|
+
__name: "CodeNodePalette",
|
|
1739
|
+
setup(n) {
|
|
1740
|
+
const e = me.PaletteEntry, { viewModel: t } = oe(), { x: s, y: o } = Zt(), { transform: a } = Ht(), i = Lt(t), r = gt("editorEl"), c = R(""), h = R(null), g = () => c.value ? i.value.filter(
|
|
1741
|
+
(b) => b.name.toLowerCase().includes(c.value.toLowerCase()) || Object.values(b.nodeTypes).some(
|
|
1742
|
+
(I) => I.title.toLowerCase().includes(c.value.toLowerCase())
|
|
1743
|
+
)
|
|
1744
|
+
) : i.value, _ = (b) => c.value ? _s(b, (I) => {
|
|
1745
|
+
const l = I[1];
|
|
1746
|
+
return l.category.includes(c.value.toLowerCase()) || l.title?.toLowerCase().includes(c.value.toLowerCase());
|
|
1747
|
+
}) : b, m = O(() => {
|
|
1748
|
+
if (!h.value || !r?.value) return {};
|
|
1749
|
+
const { left: b, top: I } = r.value.getBoundingClientRect();
|
|
1750
|
+
return {
|
|
1751
|
+
top: `${o.value - I}px`,
|
|
1752
|
+
left: `${s.value - b}px`
|
|
1753
|
+
};
|
|
1754
|
+
}), x = (b, I) => {
|
|
1755
|
+
h.value = {
|
|
1756
|
+
type: b,
|
|
1757
|
+
nodeInformation: I
|
|
1758
|
+
};
|
|
1759
|
+
const l = () => {
|
|
1760
|
+
const f = D(new I.type());
|
|
1761
|
+
t.value.displayedGraph.addNode(f);
|
|
1762
|
+
const k = r.value.getBoundingClientRect(), [y, T] = a(s.value - k.left, o.value - k.top);
|
|
1763
|
+
f.position.x = y, f.position.y = T, h.value = null, document.removeEventListener("pointerup", l);
|
|
1764
|
+
};
|
|
1765
|
+
document.addEventListener("pointerup", l);
|
|
1766
|
+
};
|
|
1767
|
+
return (b, I) => (d(), p(B, null, [
|
|
1768
|
+
u("div", {
|
|
1769
|
+
class: Y([{ "--open": w(t).settings.palette.enabled }, "baklava-node-palette"]),
|
|
1770
|
+
onContextmenu: I[1] || (I[1] = te(() => {
|
|
1771
|
+
}, ["stop", "prevent"]))
|
|
1772
|
+
}, [
|
|
1773
|
+
u("div", js, [
|
|
1774
|
+
de(u("input", {
|
|
1775
|
+
"onUpdate:modelValue": I[0] || (I[0] = (l) => c.value = l),
|
|
1776
|
+
type: "text",
|
|
1777
|
+
class: "baklava-input",
|
|
1778
|
+
title: "Filter nodes",
|
|
1779
|
+
onKeyup: g
|
|
1780
|
+
}, null, 544), [
|
|
1781
|
+
[le, c.value]
|
|
1782
|
+
])
|
|
1783
|
+
]),
|
|
1784
|
+
(d(!0), p(B, null, J(g(), (l) => (d(), p("section", {
|
|
1785
|
+
key: l.name
|
|
1786
|
+
}, [
|
|
1787
|
+
l.name !== "default" ? (d(), p("h3", Bs, [
|
|
1788
|
+
u("div", {
|
|
1789
|
+
onClick: (f) => c.value = l.name,
|
|
1790
|
+
style: { cursor: "pointer" }
|
|
1791
|
+
}, G(l.name), 9, zs),
|
|
1792
|
+
Object.keys(_(l.nodeTypes)).length < Object.values(l.nodeTypes).length ? (d(), p("div", Hs, " ( " + G(Object.keys(_(l.nodeTypes)).length) + " / " + G(Object.values(l.nodeTypes).length) + " ) ", 1)) : M("", !0)
|
|
1793
|
+
])) : M("", !0),
|
|
1794
|
+
(d(!0), p(B, null, J(_(l.nodeTypes), (f, k) => (d(), j(w(e), {
|
|
1795
|
+
key: k,
|
|
1796
|
+
type: k,
|
|
1797
|
+
title: f.title,
|
|
1798
|
+
onPointerdown: (y) => x(k, f)
|
|
1799
|
+
}, null, 8, ["type", "title", "onPointerdown"]))), 128))
|
|
1800
|
+
]))), 128))
|
|
1801
|
+
], 34),
|
|
1802
|
+
L(bt, { name: "fade" }, {
|
|
1803
|
+
default: ee(() => [
|
|
1804
|
+
h.value ? (d(), p("div", {
|
|
1805
|
+
key: 0,
|
|
1806
|
+
class: "baklava-dragged-node",
|
|
1807
|
+
style: ve(m.value)
|
|
1808
|
+
}, [
|
|
1809
|
+
L(w(e), {
|
|
1810
|
+
type: h.value.type,
|
|
1811
|
+
title: h.value.nodeInformation.title
|
|
1812
|
+
}, null, 8, ["type", "title"])
|
|
1813
|
+
], 4)) : M("", !0)
|
|
1814
|
+
]),
|
|
1815
|
+
_: 1
|
|
1816
|
+
})
|
|
1817
|
+
], 64));
|
|
1818
|
+
}
|
|
1819
|
+
}), Us = ["title"], As = {
|
|
1429
1820
|
key: 0,
|
|
1430
1821
|
class: "__label"
|
|
1431
|
-
},
|
|
1432
|
-
__name: "
|
|
1822
|
+
}, Ve = /* @__PURE__ */ F({
|
|
1823
|
+
__name: "SidebarCheckbox",
|
|
1433
1824
|
props: {
|
|
1434
1825
|
disabled: { type: Boolean },
|
|
1435
1826
|
inversed: { type: Boolean },
|
|
@@ -1437,456 +1828,420 @@ const js = /* @__PURE__ */ O(Bs, [["render", zs]]), Ls = ["id", "data-node-type"
|
|
|
1437
1828
|
name: {}
|
|
1438
1829
|
},
|
|
1439
1830
|
emits: ["update:modelValue"],
|
|
1440
|
-
setup(
|
|
1831
|
+
setup(n, { emit: e }) {
|
|
1441
1832
|
const t = e;
|
|
1442
|
-
return (
|
|
1443
|
-
class:
|
|
1444
|
-
title:
|
|
1445
|
-
onClick: o[0] || (o[0] = (a) => t("update:modelValue", !
|
|
1833
|
+
return (s, o) => (d(), p("div", {
|
|
1834
|
+
class: Y(["baklava-checkbox", { "--checked": n.inversed ? !n.modelValue : n.modelValue, "--disabled": n.disabled }]),
|
|
1835
|
+
title: n.name,
|
|
1836
|
+
onClick: o[0] || (o[0] = (a) => t("update:modelValue", !n.modelValue))
|
|
1446
1837
|
}, [
|
|
1447
|
-
o[1] || (o[1] =
|
|
1448
|
-
|
|
1838
|
+
o[1] || (o[1] = u("div", { class: "__checkmark-container" }, [
|
|
1839
|
+
u("svg", {
|
|
1449
1840
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1450
1841
|
width: "18",
|
|
1451
1842
|
height: "18",
|
|
1452
1843
|
viewBox: "0 0 18 18"
|
|
1453
1844
|
}, [
|
|
1454
|
-
|
|
1845
|
+
u("path", {
|
|
1455
1846
|
class: "__checkmark",
|
|
1456
1847
|
d: "M 6 5 L 6 10 L 16 10",
|
|
1457
1848
|
transform: "rotate(-45 10 10)"
|
|
1458
1849
|
})
|
|
1459
1850
|
])
|
|
1460
1851
|
], -1)),
|
|
1461
|
-
|
|
1462
|
-
], 10,
|
|
1852
|
+
n.name ? (d(), p("div", As, G(n.name), 1)) : M("", !0)
|
|
1853
|
+
], 10, Us));
|
|
1463
1854
|
}
|
|
1464
|
-
}),
|
|
1855
|
+
}), Ds = { class: "__header" }, Fs = { class: "__node-name" }, Ws = { class: "__interfaces" }, Ys = { class: "__inputs" }, Ks = { style: { display: "flex" } }, Xs = { class: "__outputs" }, qs = {
|
|
1465
1856
|
key: 0,
|
|
1466
1857
|
class: "__interface"
|
|
1467
|
-
},
|
|
1858
|
+
}, Js = { style: { display: "flex" } }, Qs = /* @__PURE__ */ F({
|
|
1468
1859
|
__name: "CodeGraphSidebar",
|
|
1469
|
-
setup(
|
|
1470
|
-
const { viewModel: e } =
|
|
1471
|
-
let
|
|
1472
|
-
const
|
|
1473
|
-
const
|
|
1474
|
-
return t.value.nodes.find((
|
|
1475
|
-
}),
|
|
1860
|
+
setup(n) {
|
|
1861
|
+
const { viewModel: e } = oe(), { graph: t } = ge(), s = R(null), o = Be(e.value.settings.sidebar, "width"), a = O(() => e.value.settings.sidebar.resizable);
|
|
1862
|
+
let i = 0, r = 0;
|
|
1863
|
+
const c = O(() => {
|
|
1864
|
+
const f = t.value.sidebar.nodeId;
|
|
1865
|
+
return t.value.nodes.find((k) => k.id === f);
|
|
1866
|
+
}), h = O(() => c.value), g = O(() => ({
|
|
1476
1867
|
width: `${o.value}px`
|
|
1477
|
-
})),
|
|
1868
|
+
})), _ = O(() => h.value ? Object.values(h.value.inputs).filter((f) => f.displayInSidebar && f.component) : []), m = O(() => h.value ? Object.values(h.value.outputs).filter((f) => f.displayInSidebar && f.component) : []), x = () => {
|
|
1478
1869
|
t.value.sidebar.visible = !1;
|
|
1479
|
-
},
|
|
1480
|
-
|
|
1481
|
-
},
|
|
1482
|
-
|
|
1870
|
+
}, b = () => {
|
|
1871
|
+
c.value?.events.update.emit(null);
|
|
1872
|
+
}, I = (f) => {
|
|
1873
|
+
i = o.value, r = f.clientX, window.addEventListener("mousemove", l), window.addEventListener(
|
|
1483
1874
|
"mouseup",
|
|
1484
1875
|
() => {
|
|
1485
|
-
window.removeEventListener("mousemove",
|
|
1876
|
+
window.removeEventListener("mousemove", l);
|
|
1486
1877
|
},
|
|
1487
1878
|
{ once: !0 }
|
|
1488
1879
|
);
|
|
1489
|
-
},
|
|
1490
|
-
const
|
|
1491
|
-
let
|
|
1492
|
-
|
|
1880
|
+
}, l = (f) => {
|
|
1881
|
+
const k = s.value?.parentElement?.getBoundingClientRect().width ?? 500, y = f.clientX - r;
|
|
1882
|
+
let T = i - y;
|
|
1883
|
+
T < 300 ? T = 300 : T > 0.9 * k && (T = 0.9 * k), o.value = T;
|
|
1493
1884
|
};
|
|
1494
|
-
return (
|
|
1495
|
-
class:
|
|
1496
|
-
style:
|
|
1885
|
+
return (f, k) => (d(), p("div", {
|
|
1886
|
+
class: Y([{ "--open": w(t).sidebar.visible }, "baklava-sidebar"]),
|
|
1887
|
+
style: ve(g.value),
|
|
1497
1888
|
ref_key: "el",
|
|
1498
|
-
ref:
|
|
1889
|
+
ref: s
|
|
1499
1890
|
}, [
|
|
1500
|
-
a.value ? (
|
|
1891
|
+
a.value ? (d(), p("div", {
|
|
1501
1892
|
key: 0,
|
|
1502
1893
|
class: "__resizer",
|
|
1503
|
-
onMousedown:
|
|
1504
|
-
}, null, 32)) :
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1894
|
+
onMousedown: I
|
|
1895
|
+
}, null, 32)) : M("", !0),
|
|
1896
|
+
c.value ? (d(), p(B, { key: 1 }, [
|
|
1897
|
+
u("div", Ds, [
|
|
1898
|
+
u("button", {
|
|
1508
1899
|
tabindex: "-1",
|
|
1509
1900
|
class: "__close",
|
|
1510
1901
|
onClick: x
|
|
1511
1902
|
}, "×"),
|
|
1512
|
-
|
|
1513
|
-
|
|
1903
|
+
u("div", Fs, [
|
|
1904
|
+
u("b", null, G(c.value.title), 1)
|
|
1514
1905
|
])
|
|
1515
1906
|
]),
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
(
|
|
1519
|
-
key:
|
|
1907
|
+
u("div", Ws, [
|
|
1908
|
+
u("div", Ys, [
|
|
1909
|
+
(d(!0), p(B, null, J(_.value, (y) => (d(), p("div", {
|
|
1910
|
+
key: y.id,
|
|
1520
1911
|
class: "__interface"
|
|
1521
1912
|
}, [
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
modelValue:
|
|
1913
|
+
u("div", Ks, [
|
|
1914
|
+
L(Ve, {
|
|
1915
|
+
modelValue: y.hidden,
|
|
1525
1916
|
"onUpdate:modelValue": [
|
|
1526
|
-
(
|
|
1527
|
-
|
|
1917
|
+
(T) => y.hidden = T,
|
|
1918
|
+
k[0] || (k[0] = () => c.value?.events.update.emit(null))
|
|
1528
1919
|
],
|
|
1529
|
-
disabled: !
|
|
1920
|
+
disabled: !y.optional,
|
|
1530
1921
|
inversed: "",
|
|
1531
1922
|
style: { "padding-right": "8px" }
|
|
1532
1923
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"]),
|
|
1533
|
-
(
|
|
1534
|
-
modelValue:
|
|
1535
|
-
"onUpdate:modelValue": (
|
|
1536
|
-
node:
|
|
1537
|
-
intf:
|
|
1924
|
+
(d(), j(Me(y.component), {
|
|
1925
|
+
modelValue: y.value,
|
|
1926
|
+
"onUpdate:modelValue": (T) => y.value = T,
|
|
1927
|
+
node: c.value,
|
|
1928
|
+
intf: y,
|
|
1538
1929
|
style: { width: "100%" }
|
|
1539
1930
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
|
|
1540
1931
|
])
|
|
1541
1932
|
]))), 128))
|
|
1542
1933
|
]),
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
"onUpdate:modelValue":
|
|
1934
|
+
u("div", Xs, [
|
|
1935
|
+
h.value && h.value.state ? (d(), p("div", qs, [
|
|
1936
|
+
k[3] || (k[3] = u("label", null, "Variable name", -1)),
|
|
1937
|
+
de(u("input", {
|
|
1938
|
+
"onUpdate:modelValue": k[1] || (k[1] = (y) => h.value.state.variableName = y),
|
|
1548
1939
|
type: "text",
|
|
1549
1940
|
class: "baklava-input",
|
|
1550
1941
|
title: "Variable name",
|
|
1551
|
-
onBlur:
|
|
1552
|
-
onKeydown:
|
|
1942
|
+
onBlur: b,
|
|
1943
|
+
onKeydown: he(b, ["enter"])
|
|
1553
1944
|
}, null, 544), [
|
|
1554
|
-
[
|
|
1945
|
+
[le, h.value.state.variableName]
|
|
1555
1946
|
])
|
|
1556
|
-
])) :
|
|
1557
|
-
(
|
|
1558
|
-
key:
|
|
1947
|
+
])) : M("", !0),
|
|
1948
|
+
(d(!0), p(B, null, J(m.value, (y) => (d(), p("div", {
|
|
1949
|
+
key: y.id,
|
|
1559
1950
|
class: "__interface"
|
|
1560
1951
|
}, [
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
modelValue:
|
|
1952
|
+
u("div", Js, [
|
|
1953
|
+
L(Ve, {
|
|
1954
|
+
modelValue: y.hidden,
|
|
1564
1955
|
"onUpdate:modelValue": [
|
|
1565
|
-
(
|
|
1566
|
-
|
|
1956
|
+
(T) => y.hidden = T,
|
|
1957
|
+
k[2] || (k[2] = () => c.value?.events.update.emit(null))
|
|
1567
1958
|
],
|
|
1568
|
-
disabled: !
|
|
1959
|
+
disabled: !y.optional,
|
|
1569
1960
|
inversed: "",
|
|
1570
1961
|
style: { "padding-right": "8px" }
|
|
1571
1962
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"]),
|
|
1572
|
-
(
|
|
1573
|
-
modelValue:
|
|
1574
|
-
"onUpdate:modelValue": (
|
|
1575
|
-
node:
|
|
1576
|
-
intf:
|
|
1963
|
+
(d(), j(Me(y.component), {
|
|
1964
|
+
modelValue: y.value,
|
|
1965
|
+
"onUpdate:modelValue": (T) => y.value = T,
|
|
1966
|
+
node: c.value,
|
|
1967
|
+
intf: y,
|
|
1577
1968
|
style: { width: "100%" }
|
|
1578
1969
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
|
|
1579
1970
|
])
|
|
1580
1971
|
]))), 128))
|
|
1581
1972
|
])
|
|
1582
1973
|
]),
|
|
1583
|
-
|
|
1584
|
-
], 64)) :
|
|
1974
|
+
ne(f.$slots, "codeEditor", { node: c.value })
|
|
1975
|
+
], 64)) : M("", !0)
|
|
1585
1976
|
], 6));
|
|
1586
1977
|
}
|
|
1587
1978
|
});
|
|
1588
|
-
|
|
1589
|
-
|
|
1979
|
+
class at extends Qe {
|
|
1980
|
+
_title = "Subgraph Input";
|
|
1981
|
+
inputs = {
|
|
1982
|
+
_code: new V("", "").use($, U).setHidden(!0),
|
|
1983
|
+
name: new be("Name", "Input").setPort(!1)
|
|
1984
|
+
};
|
|
1985
|
+
outputs = {
|
|
1986
|
+
_code: new V("", "").use($, U).setHidden(!0),
|
|
1987
|
+
placeholder: new A("Connection", void 0)
|
|
1988
|
+
};
|
|
1590
1989
|
}
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
}
|
|
1602
|
-
setup(s) {
|
|
1603
|
-
const { viewModel: e } = K(), { switchGraph: t } = ae(), n = V(!1), o = b(() => s.type.startsWith(se));
|
|
1604
|
-
return { showContextMenu: n, hasContextMenu: o, contextMenuItems: [
|
|
1605
|
-
{ label: "Edit Subgraph", value: "editSubgraph" },
|
|
1606
|
-
{ label: "Delete Subgraph", value: "deleteSubgraph" }
|
|
1607
|
-
], openContextMenu: () => {
|
|
1608
|
-
n.value = !0;
|
|
1609
|
-
}, onContextMenuClick: (p) => {
|
|
1610
|
-
const _ = s.type.substring(se.length), g = e.value.editor.graphTemplates.find((I) => I.id === _);
|
|
1611
|
-
if (g)
|
|
1612
|
-
switch (p) {
|
|
1613
|
-
case "editSubgraph":
|
|
1614
|
-
t(g);
|
|
1615
|
-
break;
|
|
1616
|
-
case "deleteSubgraph":
|
|
1617
|
-
e.value.editor.removeGraphTemplate(g);
|
|
1618
|
-
break;
|
|
1619
|
-
}
|
|
1620
|
-
} };
|
|
1621
|
-
}
|
|
1622
|
-
}), dn = ["data-node-type"], ln = { class: "__title" }, un = { class: "__title-label" };
|
|
1623
|
-
function cn(s, e, t, n, o, a) {
|
|
1624
|
-
return i(), d("div", {
|
|
1625
|
-
class: "baklava-node --palette",
|
|
1626
|
-
"data-node-type": s.type
|
|
1627
|
-
}, [
|
|
1628
|
-
l("div", ln, [
|
|
1629
|
-
l("div", un, j(s.title), 1)
|
|
1630
|
-
])
|
|
1631
|
-
], 8, dn);
|
|
1990
|
+
class it extends Ze {
|
|
1991
|
+
_title = "Subgraph Output";
|
|
1992
|
+
inputs = {
|
|
1993
|
+
_code: new V("", "").use($, U).setHidden(!0),
|
|
1994
|
+
name: new be("Name", "Output").setPort(!1),
|
|
1995
|
+
placeholder: new A("Connection", void 0)
|
|
1996
|
+
};
|
|
1997
|
+
outputs = {
|
|
1998
|
+
_code: new V("", "").use($, U).setHidden(!0),
|
|
1999
|
+
output: new A("Output", void 0).setHidden(!0)
|
|
2000
|
+
};
|
|
1632
2001
|
}
|
|
1633
|
-
const
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
},
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
2002
|
+
const Zs = "CREATE_SUBGRAPH", je = [kt, Nt];
|
|
2003
|
+
function eo(n, e, t) {
|
|
2004
|
+
const s = () => n.value.selectedNodes.filter((a) => !je.includes(a.type)).length > 0, o = () => {
|
|
2005
|
+
const { viewModel: a } = oe(), i = n.value, r = n.value.editor;
|
|
2006
|
+
if (i.selectedNodes.length === 0) return;
|
|
2007
|
+
const c = i.selectedNodes.filter((v) => !je.includes(v.type)), h = c.flatMap((v) => Object.values(v.inputs)), g = c.flatMap((v) => Object.values(v.outputs)), _ = i.connections.filter(
|
|
2008
|
+
(v) => !g.includes(v.from) && h.includes(v.to)
|
|
2009
|
+
), m = i.connections.filter(
|
|
2010
|
+
(v) => g.includes(v.from) && !h.includes(v.to)
|
|
2011
|
+
), x = i.connections.filter(
|
|
2012
|
+
(v) => g.includes(v.from) && h.includes(v.to)
|
|
2013
|
+
), b = c.map((v) => v.save()), I = x.map((v) => ({
|
|
2014
|
+
id: v.id,
|
|
2015
|
+
from: v.from.id,
|
|
2016
|
+
to: v.to.id
|
|
2017
|
+
})), l = /* @__PURE__ */ new Map(), { xLeft: f, xRight: k, yTop: y } = to(c);
|
|
2018
|
+
for (const [v, S] of _.entries()) {
|
|
2019
|
+
const H = new at();
|
|
2020
|
+
H.inputs.name.value = S.to.name, b.push({
|
|
2021
|
+
...H.save(),
|
|
2022
|
+
position: { x: k - a.value.settings.nodes.defaultWidth - 100, y: y + v * 200 }
|
|
2023
|
+
}), I.push({ id: K(), from: H.outputs.placeholder.id, to: S.to.id }), l.set(S.to.id, H.graphInterfaceId);
|
|
2024
|
+
}
|
|
2025
|
+
for (const [v, S] of m.entries()) {
|
|
2026
|
+
const H = new it();
|
|
2027
|
+
H.inputs.name.value = S.from.name, b.push({
|
|
2028
|
+
...H.save(),
|
|
2029
|
+
position: { x: f + 100, y: y + v * 200 }
|
|
2030
|
+
}), I.push({ id: K(), from: S.from.id, to: H.inputs.placeholder.id }), l.set(S.from.id, H.graphInterfaceId);
|
|
2031
|
+
}
|
|
2032
|
+
const T = D(
|
|
2033
|
+
new ce(
|
|
2034
|
+
{
|
|
2035
|
+
connections: I,
|
|
2036
|
+
nodes: b,
|
|
2037
|
+
// ignored, but still providing to make TS happy
|
|
2038
|
+
inputs: [],
|
|
2039
|
+
outputs: []
|
|
2040
|
+
},
|
|
2041
|
+
r
|
|
1648
2042
|
)
|
|
1649
|
-
)
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
}, [
|
|
1692
|
-
f.name !== "default" ? (i(), d("h3", hn, [
|
|
1693
|
-
l("div", {
|
|
1694
|
-
onClick: ($) => u.value = f.name,
|
|
1695
|
-
style: { cursor: "pointer" }
|
|
1696
|
-
}, j(f.name), 9, mn),
|
|
1697
|
-
Object.keys(g(f.nodeTypes)).length < Object.values(f.nodeTypes).length ? (i(), d("div", vn, " ( " + j(Object.keys(g(f.nodeTypes)).length) + " / " + j(Object.values(f.nodeTypes).length) + " ) ", 1)) : N("", !0)
|
|
1698
|
-
])) : N("", !0),
|
|
1699
|
-
(i(!0), d(S, null, D(g(f.nodeTypes), ($, m) => (i(), E(Ne, {
|
|
1700
|
-
key: m,
|
|
1701
|
-
type: m,
|
|
1702
|
-
title: $.title,
|
|
1703
|
-
onPointerdown: (w) => L(m, $)
|
|
1704
|
-
}, null, 8, ["type", "title", "onPointerdown"]))), 128))
|
|
1705
|
-
]))), 128))
|
|
1706
|
-
], 34),
|
|
1707
|
-
z(Ct, { name: "fade" }, {
|
|
1708
|
-
default: W(() => [
|
|
1709
|
-
p.value ? (i(), d("div", {
|
|
1710
|
-
key: 0,
|
|
1711
|
-
class: "baklava-dragged-node",
|
|
1712
|
-
style: re(I.value)
|
|
1713
|
-
}, [
|
|
1714
|
-
z(Ne, {
|
|
1715
|
-
type: p.value.type,
|
|
1716
|
-
title: p.value.nodeInformation.title
|
|
1717
|
-
}, null, 8, ["type", "title"])
|
|
1718
|
-
], 4)) : N("", !0)
|
|
1719
|
-
]),
|
|
1720
|
-
_: 1
|
|
1721
|
-
})
|
|
1722
|
-
], 64));
|
|
2043
|
+
);
|
|
2044
|
+
r.addGraphTemplate(T);
|
|
2045
|
+
const ie = r.nodeTypes.get(Ue(T));
|
|
2046
|
+
if (!ie) throw new Error("Unable to create subgraph: Could not find corresponding graph node type");
|
|
2047
|
+
i.activeTransactions++;
|
|
2048
|
+
const W = D(new ie.type());
|
|
2049
|
+
i.addNode(W);
|
|
2050
|
+
const pe = Math.round(
|
|
2051
|
+
c.map((v) => v.position.x).reduce((v, S) => v + S, 0) / c.length
|
|
2052
|
+
), re = Math.round(
|
|
2053
|
+
c.map((v) => v.position.y).reduce((v, S) => v + S, 0) / c.length
|
|
2054
|
+
);
|
|
2055
|
+
W.position.x = pe, W.position.y = re, _.forEach((v) => {
|
|
2056
|
+
i.removeConnection(v), i.addConnection(v.from, W.inputs[l.get(v.to.id)]);
|
|
2057
|
+
}), m.forEach((v) => {
|
|
2058
|
+
i.removeConnection(v), i.addConnection(W.outputs[l.get(v.from.id)], v.to);
|
|
2059
|
+
}), c.forEach((v) => i.removeNode(v)), i.activeTransactions--, e.canExecuteCommand(q.SAVE_SUBGRAPH_COMMAND) && e.executeCommand(q.SAVE_SUBGRAPH_COMMAND), t(T), n.value.panning = { ...i.panning }, n.value.scaling = i.scaling;
|
|
2060
|
+
};
|
|
2061
|
+
e.registerCommand(Zs, {
|
|
2062
|
+
canExecute: s,
|
|
2063
|
+
execute: o
|
|
2064
|
+
});
|
|
2065
|
+
}
|
|
2066
|
+
function to(n) {
|
|
2067
|
+
const e = n.reduce((o, a) => {
|
|
2068
|
+
const i = a.position.x;
|
|
2069
|
+
return i < o ? i : o;
|
|
2070
|
+
}, 1 / 0), t = n.reduce((o, a) => {
|
|
2071
|
+
const i = a.position.y;
|
|
2072
|
+
return i < o ? i : o;
|
|
2073
|
+
}, 1 / 0);
|
|
2074
|
+
return { xLeft: n.reduce((o, a) => {
|
|
2075
|
+
const i = a.position.x + a.width;
|
|
2076
|
+
return i > o ? i : o;
|
|
2077
|
+
}, -1 / 0), xRight: e, yTop: t };
|
|
2078
|
+
}
|
|
2079
|
+
class no extends xt {
|
|
2080
|
+
code;
|
|
2081
|
+
graph;
|
|
2082
|
+
state;
|
|
2083
|
+
constructor(e) {
|
|
2084
|
+
super(), this.code = e, this.graph = new ue(this), this.code.registerGraph(this.graph), this.saveState();
|
|
1723
2085
|
}
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
2086
|
+
get graphIds() {
|
|
2087
|
+
const e = [];
|
|
2088
|
+
return this.graphs.forEach((t) => e.push(t.id)), e.map((t) => t.slice(0, 6)).join(", ");
|
|
2089
|
+
}
|
|
2090
|
+
get graphTemplateIds() {
|
|
2091
|
+
const e = [];
|
|
2092
|
+
return this.graphTemplates.forEach((t) => e.push(t.id)), e.map((t) => t.slice(0, 6)).join(", ");
|
|
2093
|
+
}
|
|
2094
|
+
/**
|
|
2095
|
+
* Add code graph template.
|
|
2096
|
+
* @param template code graph template
|
|
2097
|
+
*/
|
|
2098
|
+
addGraphTemplate(e) {
|
|
2099
|
+
if (this.events.beforeAddGraphTemplate.emit(e).prevented) return;
|
|
2100
|
+
this._graphTemplates.push(e), this.graphTemplateEvents.addTarget(e.events), this.graphTemplateHooks.addTarget(e.hooks);
|
|
2101
|
+
const t = mn(e);
|
|
2102
|
+
this.registerNodeType(t, { category: "Subgraphs", title: e.name }), this.events.addGraphTemplate.emit(e);
|
|
2103
|
+
}
|
|
2104
|
+
/**
|
|
2105
|
+
* Load a state
|
|
2106
|
+
* @param state State to load
|
|
2107
|
+
* @returns An array of warnings that occured during loading. If the array is empty, the state was successfully loaded.
|
|
2108
|
+
*/
|
|
2109
|
+
load(e) {
|
|
2110
|
+
try {
|
|
2111
|
+
for (super._loading = !0, e = this.hooks.load.execute(e); this.graphTemplates.length > 0; )
|
|
2112
|
+
this.removeGraphTemplate(this.graphTemplates[0]);
|
|
2113
|
+
e.graphTemplates.forEach((s) => {
|
|
2114
|
+
const o = new ce(s, this);
|
|
2115
|
+
this.addGraphTemplate(o);
|
|
2116
|
+
});
|
|
2117
|
+
const t = this.graph.load(e.graph);
|
|
2118
|
+
return this.events.loaded.emit(), t.forEach((s) => console.warn(s)), t;
|
|
2119
|
+
} finally {
|
|
2120
|
+
super._loading = !1;
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
/**
|
|
2124
|
+
* Register category module
|
|
2125
|
+
* @param category string
|
|
2126
|
+
* @param module string
|
|
2127
|
+
*/
|
|
2128
|
+
registerCategoryModule(e, t) {
|
|
2129
|
+
this.code.state.modules[e] = t;
|
|
2130
|
+
}
|
|
2131
|
+
/**
|
|
2132
|
+
* Save editor state.
|
|
2133
|
+
*/
|
|
2134
|
+
saveState() {
|
|
2135
|
+
this.state = this.save();
|
|
1754
2136
|
}
|
|
1755
|
-
});
|
|
1756
|
-
function Hn(s) {
|
|
1757
|
-
const e = mt(s?.existingEditor);
|
|
1758
|
-
return e.code = s?.code ? new s.code(e) : new Pt(e), e.editor.addGraphTemplate = function(t) {
|
|
1759
|
-
if (this.events.beforeAddGraphTemplate.emit(t).prevented)
|
|
1760
|
-
return;
|
|
1761
|
-
this._graphTemplates.push(t), this.graphTemplateEvents.addTarget(t.events), this.graphTemplateHooks.addTarget(t.hooks);
|
|
1762
|
-
const n = Rt(t);
|
|
1763
|
-
this.registerNodeType(n, { category: "Subgraphs", title: t.name }), this.events.addGraphTemplate.emit(t);
|
|
1764
|
-
}, gn(e), bn(e), e.state = q({
|
|
1765
|
-
modules: {},
|
|
1766
|
-
token: null
|
|
1767
|
-
}), e.init = () => {
|
|
1768
|
-
e.unsubscribe(), e.engine = new vt(e.editor);
|
|
1769
|
-
}, e.loadEditor = (t) => {
|
|
1770
|
-
e.engine?.pause(), e.code.clear(), e.editor.load(t), e.commandHandler.executeCommand(Z.CLEAR_CLIPBOARD_COMMAND), e.commandHandler.executeCommand(Z.CLEAR_HISTORY_COMMAND), e.engine?.resume(), e.engine?.runOnce(void 0);
|
|
1771
|
-
}, e.newGraph = () => {
|
|
1772
|
-
e.engine?.pause(), e.code.clear(), e.editor.graph.id = Te(), e.engine?.resume(), e.engine?.runOnce(void 0);
|
|
1773
|
-
}, e.subscribe = () => {
|
|
1774
|
-
e.state.token && e.unsubscribe();
|
|
1775
|
-
const t = Symbol(), n = e.displayedGraph;
|
|
1776
|
-
n.events.addNode.subscribe(t, (o) => {
|
|
1777
|
-
!o.subgraph && o.isCodeNode && (o.code = e.code);
|
|
1778
|
-
}), n.events.addConnection.subscribe(t, (o) => {
|
|
1779
|
-
const a = e.code.findNodeById(o.to.nodeId);
|
|
1780
|
-
a && a.isCodeNode && a.onConnected();
|
|
1781
|
-
const r = e.code.findNodeById(o.from.nodeId);
|
|
1782
|
-
r && r.isCodeNode && r.onConnected();
|
|
1783
|
-
}), n.events.removeConnection.subscribe(t, (o) => {
|
|
1784
|
-
const a = e.code.findNodeById(o.to.nodeId);
|
|
1785
|
-
a && a.isCodeNode && a.onUnconnected();
|
|
1786
|
-
const r = e.code.findNodeById(o.from.nodeId);
|
|
1787
|
-
r && r.isCodeNode && r.onUnconnected();
|
|
1788
|
-
}), e.engine.events.beforeRun.subscribe(t, () => {
|
|
1789
|
-
e.engine.pause(), e.code && (e.code.updateCodeNodes(), e.code.sortNodes(), e.code.updateCodeTemplates(), e.code.resetInputInterfaceScript()), e.engine.resume();
|
|
1790
|
-
}), e.engine.events.beforeNodeCalculation.subscribe(t, (o) => {
|
|
1791
|
-
e.engine.pause();
|
|
1792
|
-
const a = o.node;
|
|
1793
|
-
a.isCodeNode && (a.updateOutputNames(), a.updateConnectedInputInterfaces()), e.engine.resume();
|
|
1794
|
-
}), e.engine.events.afterRun.subscribe(t, () => {
|
|
1795
|
-
e.engine.pause(), e.code && (e.code.renderNodeCodes(), e.code.renderCode()), e.engine.resume();
|
|
1796
|
-
}), e.state.token = t;
|
|
1797
|
-
}, e.unsubscribe = () => {
|
|
1798
|
-
if (!e.state.token) return;
|
|
1799
|
-
const t = e.state.token;
|
|
1800
|
-
e.displayedGraph.events.addNode.unsubscribe(t), e.displayedGraph.events.addConnection.unsubscribe(t), e.engine.events.beforeRun.unsubscribe(t), e.engine.events.beforeNodeCalculation.unsubscribe(t), e.engine.events.afterRun.unsubscribe(t), e.state.token = null;
|
|
1801
|
-
}, e;
|
|
1802
2137
|
}
|
|
1803
|
-
|
|
1804
|
-
const e = "
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
2138
|
+
function Go(n) {
|
|
2139
|
+
const e = R(n?.code ?? new fn()), t = R(n?.existingEditor ?? new no(e.value)), s = Symbol("ViewModelToken"), o = R(null), a = _t(o), { switchGraph: i } = Is(t, o), r = O(() => a.value && a.value !== t.value.graph), c = D(Ut());
|
|
2140
|
+
c.nodes.defaultWidth = 400;
|
|
2141
|
+
const h = At(), g = Dt(a, h), _ = Ft(a, t, h), m = {
|
|
2142
|
+
/** Called whenever a node is rendered */
|
|
2143
|
+
renderNode: new Ge(null),
|
|
2144
|
+
/** Called whenever an interface is rendered */
|
|
2145
|
+
renderInterface: new Ge(null)
|
|
2146
|
+
}, x = D({
|
|
2147
|
+
clipboard: _,
|
|
2148
|
+
code: e,
|
|
2149
|
+
commandHandler: h,
|
|
2150
|
+
displayedGraph: a,
|
|
2151
|
+
editor: t,
|
|
2152
|
+
history: g,
|
|
2153
|
+
hooks: m,
|
|
2154
|
+
isSubgraph: r,
|
|
2155
|
+
settings: c,
|
|
2156
|
+
switchGraph: i
|
|
1818
2157
|
});
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
command: a,
|
|
1831
|
-
title: "Toggle minimap",
|
|
1832
|
-
// Tooltip text
|
|
1833
|
-
icon: b(() => s.settings.enableMinimap ? Os : Is)
|
|
1834
|
-
};
|
|
1835
|
-
s.settings.toolbar.commands = [t, ...ft, o, r];
|
|
1836
|
-
}, bn = (s) => {
|
|
1837
|
-
s.settings.nodes.defaultWidth = 400;
|
|
1838
|
-
};
|
|
2158
|
+
return bs(x), Wt(a, h), eo(a, h, i), Yt(a, h), Kt(a, h, i), Xt(a, h), qt(a, h, c), fs(a, h, c), vs(c), He(
|
|
2159
|
+
t,
|
|
2160
|
+
(b, I) => {
|
|
2161
|
+
I && (I.events.registerGraph.unsubscribe(s), I.graphEvents.beforeAddNode.unsubscribe(s), b.nodeHooks.beforeLoad.unsubscribe(s), b.nodeHooks.afterSave.unsubscribe(s), b.graphTemplateHooks.beforeLoad.unsubscribe(s), b.graphTemplateHooks.afterSave.unsubscribe(s), b.graph.hooks.load.unsubscribe(s), b.graph.hooks.save.unsubscribe(s)), b && (b.nodeHooks.beforeLoad.subscribe(s, (l, f) => (f.position = l.position ?? { x: 0, y: 0 }, f.width = l.width ?? c.nodes.defaultWidth, f.twoColumn = l.twoColumn ?? !1, l)), b.nodeHooks.afterSave.subscribe(s, (l, f) => (l.position = f.position, l.width = f.width, l.twoColumn = f.twoColumn, l)), b.graphTemplateHooks.beforeLoad.subscribe(s, (l, f) => (f.panning = l.panning, f.scaling = l.scaling, l)), b.graphTemplateHooks.afterSave.subscribe(s, (l, f) => (l.panning = f.panning, l.scaling = f.scaling, l)), b.graph.hooks.load.subscribe(s, (l, f) => (f.panning = l.panning, f.scaling = l.scaling, l)), b.graph.hooks.save.subscribe(s, (l, f) => (l.panning = f.panning, l.scaling = f.scaling, l)), b.graphEvents.beforeAddNode.subscribe(
|
|
2162
|
+
s,
|
|
2163
|
+
(l) => Jt(l, { defaultWidth: c.nodes.defaultWidth })
|
|
2164
|
+
), t.value.registerNodeType(at, { category: "Subgraphs" }), t.value.registerNodeType(it, { category: "Subgraphs" }), i(b.graph));
|
|
2165
|
+
},
|
|
2166
|
+
{ immediate: !0 }
|
|
2167
|
+
), x;
|
|
2168
|
+
}
|
|
1839
2169
|
export {
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
2170
|
+
We as AbstractCodeNode,
|
|
2171
|
+
et as CLEAR_ALL_COMMAND,
|
|
2172
|
+
Zs as CREATE_SUBGRAPH_COMMAND,
|
|
2173
|
+
fo as CheckboxInterface,
|
|
2174
|
+
fn as Code,
|
|
2175
|
+
vn as CodeEngine,
|
|
2176
|
+
ue as CodeGraph,
|
|
2177
|
+
$o as CodeGraphEditor,
|
|
2178
|
+
Mo as CodeGraphInfo,
|
|
2179
|
+
Qe as CodeGraphInputNode,
|
|
2180
|
+
Ps as CodeGraphNode,
|
|
2181
|
+
Re as CodeGraphNodeInterface,
|
|
2182
|
+
Ze as CodeGraphOutputNode,
|
|
2183
|
+
Qs as CodeGraphSidebar,
|
|
2184
|
+
ce as CodeGraphTemplate,
|
|
2185
|
+
_e as CodeNode,
|
|
2186
|
+
ae as CodeNodeInputInterface,
|
|
2187
|
+
V as CodeNodeInterface,
|
|
2188
|
+
ye as CodeNodeInterfaceComponent,
|
|
2189
|
+
on as CodeNodeOutputInterface,
|
|
2190
|
+
Ls as CodeNodePalette,
|
|
2191
|
+
yn as CodeVariable,
|
|
2192
|
+
kn as DotsVertical,
|
|
2193
|
+
pn as DynamicCodeNode,
|
|
2194
|
+
Se as GRAPH_INPUT_NODE_TYPE,
|
|
2195
|
+
Pe as GRAPH_OUTPUT_NODE_TYPE,
|
|
2196
|
+
vo as IntegerInterface,
|
|
2197
|
+
Tn as LayoutSidebarLeftCollapse,
|
|
2198
|
+
Gn as LayoutSidebarLeftExpand,
|
|
2199
|
+
Vn as LayoutSidebarRight,
|
|
2200
|
+
Hn as LayoutSidebarRightCollapse,
|
|
2201
|
+
Dn as LayoutSidebarRightExpand,
|
|
2202
|
+
go as ListInputInterface,
|
|
2203
|
+
Kn as LockCode,
|
|
2204
|
+
bo as NumberInterface,
|
|
2205
|
+
Qn as PlayerPlay,
|
|
2206
|
+
tt as RUN_ENGINE_COMMAND,
|
|
2207
|
+
ns as Schema,
|
|
2208
|
+
is as SchemaOff,
|
|
2209
|
+
_o as SelectInterface,
|
|
2210
|
+
Ve as SidebarCheckbox,
|
|
2211
|
+
yo as SliderInterface,
|
|
2212
|
+
at as SubgraphInputNode,
|
|
2213
|
+
it as SubgraphOutputNode,
|
|
2214
|
+
nt as TOGGLE_MINIMAP_COMMAND,
|
|
2215
|
+
st as TOGGLE_PALETTE_COMMAND,
|
|
2216
|
+
Co as TextInputInterface,
|
|
2217
|
+
cn as TextInputInterfaceComponent,
|
|
2218
|
+
Io as TextareaInputInterface,
|
|
2219
|
+
us as TransitionBottom,
|
|
2220
|
+
ms as TrashOff,
|
|
2221
|
+
wo as TupleInputInterface,
|
|
2222
|
+
mo as addDefaultInterfaceTypes,
|
|
2223
|
+
Oo as allowMultipleConnections,
|
|
2224
|
+
Ke as booleanType,
|
|
2225
|
+
mn as createCodeGraphNodeType,
|
|
2226
|
+
ko as defineCodeNode,
|
|
2227
|
+
No as defineDynamicCodeNode,
|
|
2228
|
+
sn as dictType,
|
|
2229
|
+
en as formatInputs,
|
|
2230
|
+
ot as getCodeNodes,
|
|
2231
|
+
To as getPositionAtColumn,
|
|
2232
|
+
Eo as getPositionBeforeNode,
|
|
2233
|
+
Xe as listType,
|
|
2234
|
+
Ye as loadNodeState,
|
|
1885
2235
|
U as nodeType,
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
2236
|
+
Ce as numberType,
|
|
2237
|
+
bs as registerCodeEngine,
|
|
2238
|
+
eo as registerCreateSubgraphCommand,
|
|
2239
|
+
fs as registerCustomCommands,
|
|
2240
|
+
gs as registerRunEngineCommands,
|
|
2241
|
+
tn as saveNodeState,
|
|
2242
|
+
Ie as stringType,
|
|
2243
|
+
qe as tupleType,
|
|
2244
|
+
vs as updateToolbarItems,
|
|
2245
|
+
Go as useCodeGraph,
|
|
2246
|
+
Is as useSwitchCodeGraph
|
|
1892
2247
|
};
|