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