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