@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.
Files changed (47) hide show
  1. package/dist/code-graph.css +1 -11
  2. package/dist/code-graph.js +875 -1266
  3. package/dist/code-graph.umd.cjs +1 -1833
  4. package/dist/{lib/index.d.ts → index.d.ts} +1 -0
  5. package/dist/interfaceTypes/default.d.ts +8 -0
  6. package/dist/interfaceTypes/index.d.ts +1 -0
  7. package/package.json +2 -2
  8. /package/dist/{lib/code.d.ts → code.d.ts} +0 -0
  9. /package/dist/{lib/codeNode → codeNode}/codeNode.d.ts +0 -0
  10. /package/dist/{lib/codeNode → codeNode}/defineCodeNode.d.ts +0 -0
  11. /package/dist/{lib/codeNode → codeNode}/dynamicCodeNode.d.ts +0 -0
  12. /package/dist/{lib/codeNode → codeNode}/index.d.ts +0 -0
  13. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/baseNumericInterface.d.ts +0 -0
  14. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/button/buttonInterface.d.ts +0 -0
  15. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/checkbox/checkboxInterface.d.ts +0 -0
  16. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/codeInput/codeInputInterface.d.ts +0 -0
  17. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/codeNode/CodeNodeInterface.vue.d.ts +0 -0
  18. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/codeNode/codeNodeInterface.d.ts +0 -0
  19. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/codeOutput/codeOutputInterface.d.ts +0 -0
  20. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/index.d.ts +0 -0
  21. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/integer/integerInterface.d.ts +0 -0
  22. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/number/numberInterface.d.ts +0 -0
  23. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/select/selectInterface.d.ts +0 -0
  24. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/slider/sliderInterface.d.ts +0 -0
  25. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/text/textInterface.d.ts +0 -0
  26. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/textInput/textInputInterface.d.ts +0 -0
  27. /package/dist/{lib/codeNodeInterfaces → codeNodeInterfaces}/textareaInput/textareaInputInterface.d.ts +0 -0
  28. /package/dist/{lib/components → components}/CodeGraphEditor.vue.d.ts +0 -0
  29. /package/dist/{lib/components → components}/index.d.ts +0 -0
  30. /package/dist/{lib/components → components}/node/CodeGraphNode.vue.d.ts +0 -0
  31. /package/dist/{lib/components → components}/nodeInterface/CodeGraphNodeInterface.vue.d.ts +0 -0
  32. /package/dist/{lib/components → components}/nodePalette/CodeNodePalette.vue.d.ts +0 -0
  33. /package/dist/{lib/components → components}/nodePalette/PaletteEntry.vue.d.ts +0 -0
  34. /package/dist/{lib/components → components}/sidebar/Checkbox.vue.d.ts +0 -0
  35. /package/dist/{lib/components → components}/sidebar/CodeGraphSidebar.vue.d.ts +0 -0
  36. /package/dist/{lib/icons → icons}/LayoutSidebarLeftCollapse.vue.d.ts +0 -0
  37. /package/dist/{lib/icons → icons}/LayoutSidebarLeftExpand.vue.d.ts +0 -0
  38. /package/dist/{lib/icons → icons}/LayoutSidebarRight.vue.d.ts +0 -0
  39. /package/dist/{lib/icons → icons}/LayoutSidebarRightCollapse.vue.d.ts +0 -0
  40. /package/dist/{lib/icons → icons}/LayoutSidebarRightExpand.vue.d.ts +0 -0
  41. /package/dist/{lib/icons → icons}/Schema.vue.d.ts +0 -0
  42. /package/dist/{lib/icons → icons}/SchemaOff.vue.d.ts +0 -0
  43. /package/dist/{lib/icons → icons}/TrashOff.vue.d.ts +0 -0
  44. /package/dist/{lib/icons → icons}/VerticalDots.vue.d.ts +0 -0
  45. /package/dist/{lib/icons → icons}/index.d.ts +0 -0
  46. /package/dist/{lib/settings.d.ts → settings.d.ts} +0 -0
  47. /package/dist/{lib/viewModel.d.ts → viewModel.d.ts} +0 -0
@@ -1,25 +1,21 @@
1
- import { AbstractNode, NodeInterfaceType, NodeInterface, ButtonInterfaceComponent, CheckboxInterfaceComponent, IntegerInterfaceComponent, NumberInterfaceComponent, SelectInterfaceComponent, SliderInterfaceComponent, TextInputInterfaceComponent, TextareaInputInterfaceComponent, setType, allowMultipleConnections, IntegerInterface as IntegerInterface$1, TextInputInterface as TextInputInterface$1, displayInSidebar, sortTopologically, useViewModel, useTemporaryConnection, Components, useGraph, GRAPH_NODE_TYPE_PREFIX, useTransform, useNodeCategories, BaklavaEditor, DEFAULT_TOOLBAR_COMMANDS, useBaklava, DependencyEngine, applyResult } from "baklavajs";
2
- import { ButtonInterfaceComponent as ButtonInterfaceComponent2, CheckboxInterfaceComponent as CheckboxInterfaceComponent2, IntegerInterfaceComponent as IntegerInterfaceComponent2, NumberInterfaceComponent as NumberInterfaceComponent2, SelectInterfaceComponent as SelectInterfaceComponent2, SliderInterfaceComponent as SliderInterfaceComponent2, TextInputInterfaceComponent as TextInputInterfaceComponent2, TextareaInputInterfaceComponent as TextareaInputInterfaceComponent2 } from "baklavajs";
3
- import mustache from "mustache";
4
- import { reactive, defineComponent, createElementBlock, openBlock, toDisplayString, markRaw, ref, computed, onMounted, onUpdated, normalizeClass, createCommentVNode, createElementVNode, unref, renderSlot, createStaticVNode, onBeforeUnmount, normalizeStyle, withModifiers, createBlock, withDirectives, Fragment, createTextVNode, createVNode, withKeys, vModelText, renderList, nextTick, toRef, resolveDynamicComponent, inject, Transition, withCtx, onUnmounted, normalizeProps, guardReactiveProps, mergeProps } from "vue";
5
- import toposort from "toposort";
6
- import { v4 } from "uuid";
7
- import { usePointer } from "@vueuse/core";
8
- class AbstractCodeNode extends AbstractNode {
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 = true;
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: false,
22
- integrated: false,
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((node) => !node.state.integrated).indexOf(this) ?? -1;
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(type) {
52
- let nodeIds = [];
53
- if (type !== "inputs") {
54
- const targets = this.graph?.connections.filter((c) => c.from.name !== "_node").filter((c) => c.from.nodeId === this.id).map((c) => c.to.nodeId);
55
- if (targets) nodeIds = nodeIds.concat(targets);
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 (type !== "outputs") {
58
- const sources = this.graph?.connections.filter((c) => c.from.name !== "_node").filter((c) => c.to.nodeId === this.id).map((c) => c.from.nodeId);
59
- if (sources) nodeIds = nodeIds.concat(sources);
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
- if (!nodeIds || nodeIds.length == 0) return [];
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(code) {
65
- this.code = 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 inputs = {};
72
- Object.keys(this.inputs).forEach((intfKey) => {
73
- if (intfKey === "_node") return;
74
- const intf = this.inputs[intfKey];
75
- const value = intf.isString ? `'${intf.value}'` : intf.value;
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 outputs = {};
79
- Object.keys(this.outputs).forEach((intfKey) => {
80
- if (intfKey === "_node") return;
81
- const intf = this.outputs[intfKey];
82
- const value = intf.isString ? `'${intf.value}'` : intf.value;
83
- if (intf && intf.state) outputs[intfKey] = value;
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
- if (this.outputs.code) this.outputs.code.name = this.variableName;
80
+ this.outputs.code && (this.outputs.code.name = this.variableName);
90
81
  }
91
82
  }
92
- class CodeNode extends AbstractCodeNode {
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(state) {
102
- super.load(state);
103
- loadNodeState(this.graph, state);
92
+ load(e) {
93
+ super.load(e), xe(this.graph, e);
104
94
  }
105
95
  save() {
106
- const state = super.save();
107
- saveNodeState(this.graph, state);
108
- return state;
109
- }
110
- updateModules(modules) {
111
- if (modules) {
112
- this.state.modules = modules;
113
- } else if (this.type.includes(".")) {
114
- const modules2 = this.type.split(".");
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 loadNodeState = (graph, nodeState) => {
120
- if (!graph) return;
121
- const node = graph.findNodeById(nodeState.id);
122
- if (!node || node.subgraph) return;
123
- const codeNode = node;
124
- if (codeNode.state) {
125
- codeNode.state.integrated = nodeState.integrated;
126
- codeNode.state.modules = nodeState.modules;
127
- codeNode.state.props = nodeState.props;
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
- Object.entries(nodeState.outputs).forEach(([outputKey, outputItem]) => {
152
- if (outputKey === "_node") return;
153
- if (codeNode.outputs[outputKey]) outputItem.hidden = codeNode.outputs[outputKey].hidden;
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 NodeInterfaceType("boolean");
157
- new NodeInterfaceType("dict");
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(__props) {
169
- return (_ctx, _cache) => {
170
- return openBlock(), createElementBlock("div", {
171
- title: _ctx.intf.state?.script
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 CodeNodeInterface extends NodeInterface {
177
- optional = false;
141
+ class M extends Ue {
142
+ optional = !1;
178
143
  code;
179
144
  state;
180
- constructor(name, value) {
181
- super(name, value);
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 ButtonInterface extends CodeNodeInterface {
199
- component = markRaw(ButtonInterfaceComponent);
161
+ class Ws extends M {
162
+ component = $(je);
200
163
  callback;
201
- constructor(name, callback) {
202
- super(name, void 0);
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 CheckboxInterface extends CodeNodeInterface {
208
- component = markRaw(CheckboxInterfaceComponent);
168
+ class Xs extends M {
169
+ component = $(Re);
209
170
  }
210
- class BaseNumericInterface extends CodeNodeInterface {
171
+ class ie extends M {
211
172
  min;
212
173
  max;
213
- constructor(name, value, min, max) {
214
- super(name, value);
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(v) {
219
- return (this.min === void 0 || v >= this.min) && (this.max === void 0 || v <= this.max);
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 IntegerInterface extends BaseNumericInterface {
223
- component = markRaw(IntegerInterfaceComponent);
224
- validate(v) {
225
- return Number.isInteger(v) && super.validate(v);
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 CodeInputInterface extends CodeNodeInterface {
229
- isCodeInput = true;
230
- constructor(name = "", value) {
231
- super(name, value);
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 CodeOutputInterface extends CodeNodeInterface {
236
- isCodeOutput = true;
237
- constructor(name = "", value = "") {
238
- super(name, value);
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(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 NumberInterface extends BaseNumericInterface {
253
- component = markRaw(NumberInterfaceComponent);
208
+ class qs extends ie {
209
+ component = $(De);
254
210
  }
255
- class SelectInterface extends CodeNodeInterface {
256
- component = markRaw(SelectInterfaceComponent);
211
+ class Qs extends M {
212
+ component = $(Ae);
257
213
  items;
258
- constructor(name, value, items) {
259
- super(name, value);
260
- this.items = items;
214
+ constructor(e, t, s) {
215
+ super(e, t), this.items = s;
261
216
  }
262
217
  }
263
- class SliderInterface extends BaseNumericInterface {
264
- component = markRaw(SliderInterfaceComponent);
218
+ class Zs extends ie {
219
+ component = $(He);
265
220
  min;
266
221
  max;
267
- constructor(name, value, min, max) {
268
- super(name, value, min, max);
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 TextInterface extends CodeNodeInterface {
274
- component = markRaw(TextInputInterfaceComponent);
275
- constructor(name, value) {
276
- super(name, value);
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 TextInputInterface extends CodeNodeInterface {
281
- isString = true;
282
- component = markRaw(TextInputInterfaceComponent);
232
+ class en extends M {
233
+ isString = !0;
234
+ component = $(ge);
283
235
  }
284
- class TextareaInputInterface extends CodeNodeInterface {
285
- component = markRaw(TextareaInputInterfaceComponent);
236
+ class tn extends M {
237
+ component = $(Fe);
286
238
  }
287
- function defineCodeNode(definition) {
288
- return class extends CodeNode {
289
- type = definition.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 CodeNodeInterface("", []).use(setType, nodeType).use(allowMultipleConnections).setHidden(true)
301
- );
302
- this.addOutput(
247
+ new M("", []).use(j, H).use(Y).setHidden(!0)
248
+ ), this.addOutput(
303
249
  "_node",
304
- new CodeNodeInterface("", []).use(setType, nodeType).use(allowMultipleConnections).setHidden(true)
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 = definition.calculate ? (inputs, globalValues) => ({
311
- ...definition.calculate.call(this, inputs, globalValues),
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
- definition.onPlaced?.call(this);
258
+ o.onPlaced?.call(this);
316
259
  }
317
260
  onDestroy() {
318
- definition.onDestroy?.call(this);
261
+ o.onDestroy?.call(this);
319
262
  }
320
263
  onCodeUpdate() {
321
- definition.onCodeUpdate?.call(this);
264
+ o.onCodeUpdate?.call(this);
322
265
  }
323
- executeFactory(type, factory) {
324
- Object.keys(factory || {}).forEach((k) => {
325
- const intf = factory[k]();
326
- if (type === "input") {
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 DynamicCodeNode extends CodeNode {
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 defineDynamicCodeNode(definition) {
346
- return class extends DynamicCodeNode {
347
- type = definition.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 = false;
352
- staticInputKeys = Object.keys(definition.inputs ?? {});
353
- staticOutputKeys = Object.keys(definition.outputs ?? {});
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 CodeNodeInterface("", []).use(setType, nodeType).use(allowMultipleConnections).setHidden(true)
363
- );
364
- this.addOutput(
296
+ new M("", []).use(j, H).use(Y).setHidden(!0)
297
+ ), this.addOutput(
365
298
  "_node",
366
- new CodeNodeInterface("", []).use(setType, nodeType).use(allowMultipleConnections).setHidden(true)
367
- );
368
- this.staticInputKeys.push("_node");
369
- this.staticOutputKeys.push("_node");
370
- this.executeFactory("input", definition.inputs);
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, (data) => {
382
- if (!data) return;
383
- if (data.type === "input" && this.staticInputKeys.includes(data.name) || data.type === "output" && this.staticOutputKeys.includes(data.name)) {
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
- definition.onDestroy?.call(this);
311
+ o.onDestroy?.call(this);
392
312
  }
393
313
  onCodeUpdate() {
394
- definition.onCodeUpdate?.call(this);
314
+ o.onCodeUpdate?.call(this);
395
315
  }
396
- load(state) {
397
- this.preventUpdate = true;
398
- this.hooks.beforeLoad.execute(state);
399
- this.id = state.id;
400
- this.title = state.title;
401
- for (const k of this.staticInputKeys) {
402
- this.inputs[k].load(state.inputs[k]);
403
- this.inputs[k].nodeId = this.id;
404
- if (k === "_node") continue;
405
- this.inputs[k].hidden = state.inputs[k].hidden;
406
- }
407
- for (const k of this.staticOutputKeys) {
408
- this.outputs[k].load(state.outputs[k]);
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
- inputInterface.use(displayInSidebar, true);
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
- if (this.inputs[k]) {
430
- this.inputs[k].load(state.inputs[k]);
431
- this.inputs[k].nodeId = this.id;
432
- }
433
- }
434
- for (const k of Object.keys(state.outputs)) {
435
- if (this.staticOutputKeys.includes(k)) continue;
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
- if (this.graph) this.graph.activeTransactions++;
452
- const inputValues = this.getStaticValues(this.staticInputKeys, this.inputs);
453
- const outputValues = this.getStaticValues(this.staticOutputKeys, this.outputs);
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(keys, interfaces) {
460
- const values = {};
461
- for (const k of keys) {
462
- values[k] = interfaces[k].value;
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(type, newInterfaces, forceUpdates) {
467
- const staticKeys = type === "input" ? this.staticInputKeys : this.staticOutputKeys;
468
- const currentInterfaces = type === "input" ? this.inputs : this.outputs;
469
- for (const k of Object.keys(currentInterfaces)) {
470
- if (staticKeys.includes(k) || newInterfaces[k] && !forceUpdates.includes(k)) continue;
471
- if (type === "input") {
472
- this.removeInput(k);
473
- } else {
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(type, factory) {
488
- Object.keys(factory || {}).forEach((k) => {
489
- const intf = factory[k]();
490
- if (type === "input") {
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 Code {
372
+ class It {
500
373
  _id;
501
374
  _viewModel;
502
375
  _state;
503
- constructor(viewModel) {
504
- this._id = v4();
505
- this._viewModel = viewModel;
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 getCodeNodes(this.graph);
386
+ return Z(this.graph);
516
387
  }
517
388
  get connections() {
518
389
  return this.graph.connections;
519
390
  }
520
- set connections(values) {
521
- this.graph._connections = values;
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 categories = [];
531
- this.codeNodes.filter((node) => node.state.modules?.length > 0).forEach((node) => {
532
- categories = categories.concat(node.state.modules);
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((node) => node.id);
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(values) {
545
- this.graph._nodes = values;
412
+ set nodes(e) {
413
+ this.graph._nodes = e;
546
414
  }
547
415
  get scriptedCodeNodes() {
548
- return getCodeNodes(this.graph).filter(
549
- (codeNode) => codeNode.state?.script.length > 0
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((node) => !node.state?.hidden);
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(node, props) {
570
- if (!node.code) node.code = this;
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 = (node, position = { x: 0, y: 0 }, props) => {
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(from, to) {
592
- if (from.name !== "_node") from.hidden = false;
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(id) {
604
- return this.graph.findNodeById(id);
462
+ findNodeById(e) {
463
+ return this.graph.findNodeById(e);
605
464
  }
606
- findNodeByType(nodeType2) {
607
- return this.codeNodes.find((codeNode) => codeNode.type === nodeType2);
465
+ findNodeByType(e) {
466
+ return this.codeNodes.find((t) => t.type === e);
608
467
  }
609
- getNodesBySameType(type) {
610
- return this.codeNodes.filter((codeNode) => codeNode.type === type);
468
+ getNodesBySameType(e) {
469
+ return this.codeNodes.filter((t) => t.type === e);
611
470
  }
612
- getNodesBySameVariableNames(variableName) {
471
+ getNodesBySameVariableNames(e) {
613
472
  return this.codeNodes.filter(
614
- (codeNode) => codeNode.state.variableName === variableName
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(from, to) {
482
+ hasConnection(e, t) {
624
483
  return this.connections.some(
625
- (connection) => connection.from.id === from.id && connection.to.id === to.id
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(resolve) {
632
- resolve.then((template) => {
633
- this._state.template = template.default ?? "";
490
+ loadTemplate(e) {
491
+ e.then((t) => {
492
+ this._state.template = t.default ?? "";
634
493
  });
635
494
  }
636
495
  onCodeUpdate() {
637
- this.codeNodes.forEach((codeNode) => codeNode.onCodeUpdate());
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(connection) {
644
- this.graph.removeConnection(connection);
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(codeNode) {
651
- this.graph.removeNode(codeNode);
509
+ removeNode(e) {
510
+ this.graph.removeNode(e);
652
511
  }
653
512
  /**
654
513
  * Render node codes.
655
514
  */
656
515
  renderNodeCodes() {
657
- if (this.codeNodes.length === 0) return;
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 = mustache.render(this.state.template || "", this);
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
- if (this.state.autosort) this.sortNodes();
672
- const editorState = this.viewModel.editor.save();
673
- editorState.graph.id = this.id;
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(nodeStates) {
682
- nodeStates.forEach((nodeState, nodeIdx) => {
683
- const node = this.nodes[nodeIdx];
684
- Object.entries(nodeState.inputs).forEach(([inputKey]) => {
685
- if (nodeState.inputs && node.inputs[inputKey]) nodeState.inputs[inputKey].hidden = node.inputs[inputKey].hidden;
686
- });
687
- Object.entries(nodeState.outputs).forEach(([outputKey]) => {
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) return;
698
- try {
699
- const edges = this.connections.map((connection) => [
700
- connection.to.nodeId,
701
- connection.from.nodeId
702
- ]);
703
- let nodeIds = [...this.nodeIds];
704
- nodeIds.reverse();
705
- nodeIds = toposort.array(nodeIds, edges);
706
- nodeIds.reverse();
707
- const unconnected = this.graph.nodes.map((node) => node.id).filter((nodeId) => !nodeIds.includes(nodeId));
708
- nodeIds = nodeIds.concat(unconnected);
709
- const nodes = nodeIds.map((nodeId) => this.findNodeById(nodeId));
710
- if (nodes) this.nodes = nodes;
711
- } catch {
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((codeNode) => codeNode.updateOutputVariableName());
568
+ this.codeNodes.forEach((e) => e.updateOutputVariableName());
717
569
  }
718
570
  }
719
- const getCodeNodes = (graph) => {
720
- let nodes = [];
721
- graph.nodes.forEach((node) => {
722
- if (node.subgraph) {
723
- nodes = nodes.concat(getCodeNodes(node.subgraph));
724
- } else if (node.isCodeNode) {
725
- nodes.push(node);
726
- }
727
- });
728
- return nodes;
729
- };
730
- const getPositionAtColumn = (col = 0, offset = 100) => {
731
- const width = 350;
732
- const padding = 70;
733
- return {
734
- x: col * (width + padding),
735
- y: offset
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(__props) {
765
- const props = __props;
766
- const { viewModel } = useViewModel();
767
- const { hoveredOver, temporaryConnection } = useTemporaryConnection();
768
- const el = ref(null);
769
- const isConnected = computed(() => props.intf.connectionCount > 0);
770
- const classes = computed(() => ({
771
- "--connected": isConnected.value
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
- const onRender = () => {
780
- if (el.value) {
781
- viewModel.value.hooks.renderInterface.execute({ intf: props.intf, el: el.value });
782
- }
783
- };
784
- onMounted(onRender);
785
- onUpdated(onRender);
786
- return (_ctx, _cache) => {
787
- return openBlock(), createElementBlock("div", {
788
- id: _ctx.intf.id,
789
- ref_key: "el",
790
- ref: el,
791
- class: normalizeClass(["baklava-node-interface", classes.value])
792
- }, [
793
- _ctx.intf.port ? (openBlock(), createElementBlock("div", {
794
- key: 0,
795
- class: normalizeClass(["__port", { "--selected": unref(temporaryConnection)?.from === _ctx.intf }]),
796
- onPointerover: startHover,
797
- onPointerout: endHover
798
- }, null, 34)) : createCommentVNode("", true),
799
- createElementVNode("span", _hoisted_2$5, [
800
- renderSlot(_ctx.$slots, "default")
801
- ])
802
- ], 10, _hoisted_1$e);
803
- };
804
- }
805
- });
806
- const _export_sfc = (sfc, props) => {
807
- const target = sfc.__vccOpts || sfc;
808
- for (const [key, val] of props) {
809
- target[key] = val;
810
- }
811
- return target;
812
- };
813
- const _sfc_main$e = {};
814
- const _hoisted_1$d = {
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 _sfc_render$9(_ctx, _cache) {
823
- return openBlock(), createElementBlock("svg", _hoisted_1$d, [..._cache[0] || (_cache[0] = [
824
- createElementVNode("path", {
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
- createElementVNode("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)
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 LayoutSidebarLeftCollapse = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
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 _sfc_render$8(_ctx, _cache) {
843
- return openBlock(), createElementBlock("svg", _hoisted_1$c, [..._cache[0] || (_cache[0] = [
844
- createElementVNode("path", {
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
- createElementVNode("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)
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 LayoutSidebarLeftExpand = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
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 _sfc_render$7(_ctx, _cache) {
863
- return openBlock(), createElementBlock("svg", _hoisted_1$b, [..._cache[0] || (_cache[0] = [
864
- createElementVNode("path", {
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
- createElementVNode("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)
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 LayoutSidebarRight = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
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 _sfc_render$6(_ctx, _cache) {
883
- return openBlock(), createElementBlock("svg", _hoisted_1$a, [..._cache[0] || (_cache[0] = [
884
- createElementVNode("path", {
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
- createElementVNode("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)
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 LayoutSidebarRightCollapse = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$6]]);
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 _sfc_render$5(_ctx, _cache) {
903
- return openBlock(), createElementBlock("svg", _hoisted_1$9, [..._cache[0] || (_cache[0] = [
904
- createElementVNode("path", {
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
- createElementVNode("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)
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 LayoutSidebarRightExpand = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$5]]);
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 _sfc_render$4(_ctx, _cache) {
927
- return openBlock(), createElementBlock("svg", _hoisted_1$8, [..._cache[0] || (_cache[0] = [
928
- createStaticVNode('<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)
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 Schema = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$4]]);
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 _sfc_render$3(_ctx, _cache) {
946
- return openBlock(), createElementBlock("svg", _hoisted_1$7, [..._cache[0] || (_cache[0] = [
947
- createStaticVNode('<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)
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 SchemaOff = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$3]]);
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 _sfc_render$2(_ctx, _cache) {
965
- return openBlock(), createElementBlock("svg", _hoisted_1$6, [..._cache[0] || (_cache[0] = [
966
- createStaticVNode('<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)
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 TrashOff = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$2]]);
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 _sfc_render$1(_ctx, _cache) {
984
- return openBlock(), createElementBlock("svg", _hoisted_1$5, [..._cache[0] || (_cache[0] = [
985
- createElementVNode("path", {
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
- createElementVNode("circle", {
789
+ l("circle", {
991
790
  cx: "12",
992
791
  cy: "12",
993
792
  r: "1"
994
793
  }, null, -1),
995
- createElementVNode("circle", {
794
+ l("circle", {
996
795
  cx: "12",
997
796
  cy: "19",
998
797
  r: "1"
999
798
  }, null, -1),
1000
- createElementVNode("circle", {
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 VerticalDots = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$1]]);
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: { "display": "flex" }
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: false },
816
+ selected: { type: Boolean, default: !1 },
1029
817
  dragging: { type: Boolean }
1030
818
  },
1031
819
  emits: ["select", "start-drag", "update"],
1032
- setup(__props, { emit: __emit }) {
1033
- const ContextMenu = Components.ContextMenu;
1034
- const NodeInterface2 = Components.NodeInterface;
1035
- const props = __props;
1036
- const node = computed(() => props.node);
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
- if (props.node.type.startsWith(GRAPH_NODE_TYPE_PREFIX)) {
1055
- items.push({ value: "editSubgraph", label: "Edit Subgraph" });
1056
- }
1057
- return items;
1058
- });
1059
- const classes = computed(() => ({
1060
- "--selected": props.selected,
1061
- "--dragging": props.dragging,
1062
- "--two-column": !!props.node.twoColumn,
1063
- "--hidden": node.value.state?.hidden
1064
- }));
1065
- const classesContent = computed(() => ({
1066
- "--reverse-y": props.node.reverseY ?? viewModel.value.settings.nodes.reverseY
1067
- }));
1068
- const styles = computed(() => ({
1069
- "top": `${props.node.position?.y ?? 0}px`,
1070
- "left": `${props.node.position?.x ?? 0}px`,
1071
- "--width": `${props.node.width ?? viewModel.value.settings.nodes.defaultWidth}px`
1072
- }));
1073
- const displayedInputs = computed(() => Object.values(props.node.inputs).filter((ni) => !ni.hidden));
1074
- const displayedOutputs = computed(() => Object.values(props.node.outputs).filter((ni) => !ni.hidden));
1075
- const select = () => {
1076
- emit("select");
1077
- };
1078
- const startDrag = (ev) => {
1079
- if (!props.selected) {
1080
- select();
1081
- }
1082
- emit("start-drag", ev);
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
- openSidebar();
859
+ de();
1105
860
  break;
1106
861
  case "delete":
1107
- graph.value.removeNode(props.node);
862
+ h.value.removeNode(n.node);
1108
863
  break;
1109
864
  case "rename":
1110
- tempName.value = props.node.title;
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
- switchGraph(props.node.template);
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
- const doneRenaming = () => {
1121
- props.node.title = tempName.value;
1122
- renaming.value = false;
1123
- };
1124
- const onRender = () => {
1125
- if (el.value) {
1126
- viewModel.value.hooks.renderNode.execute({ node: props.node, el: el.value });
1127
- }
1128
- };
1129
- const startResize = (ev) => {
1130
- isResizing.value = true;
1131
- resizeStartWidth = props.node.width;
1132
- resizeStartMouseX = ev.clientX;
1133
- ev.preventDefault();
1134
- };
1135
- const doResize = (ev) => {
1136
- if (!isResizing.value) return;
1137
- const deltaX = ev.clientX - resizeStartMouseX;
1138
- const newWidth = resizeStartWidth + deltaX / graph.value.scaling;
1139
- const minWidth = viewModel.value.settings.nodes.minWidth;
1140
- const maxWidth = viewModel.value.settings.nodes.maxWidth;
1141
- props.node.width = Math.max(minWidth, Math.min(maxWidth, newWidth));
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
- unref(viewModel).settings.nodes.resizable ? (openBlock(), createElementBlock("div", {
907
+ a.value.inputs._node ? (i(), V(me, {
1167
908
  key: 0,
1168
- class: "__resize-handle",
1169
- onMousedown: startResize
1170
- }, null, 32)) : createCommentVNode("", true),
1171
- createElementVNode("div", {
1172
- class: "__title",
1173
- onPointerdown: withModifiers(startDrag, ["self", "stop"]),
1174
- onContextmenu: withModifiers(openContextMenu, ["prevent"])
1175
- }, [
1176
- node.value.inputs._node ? (openBlock(), createBlock(_sfc_main$f, {
1177
- key: 0,
1178
- node: node.value,
1179
- intf: node.value.inputs._node,
1180
- class: "--input",
1181
- "data-interface-type": "node",
1182
- style: { "flex-grow": "0" }
1183
- }, null, 8, ["node", "intf"])) : createCommentVNode("", true),
1184
- !renaming.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1185
- createElementVNode("div", _hoisted_2$4, [
1186
- node.value.idx > -1 ? (openBlock(), createElementBlock("span", _hoisted_3$2, toDisplayString(node.value.idx + 1) + " - ", 1)) : createCommentVNode("", true),
1187
- createTextVNode(toDisplayString(node.value.title) + " (" + toDisplayString(node.value.shortId) + ") ", 1)
1188
- ]),
1189
- createElementVNode("div", _hoisted_4$1, [
1190
- !node.value.subgraph ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
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
- createElementVNode("div", _hoisted_8, [
1276
- (openBlock(true), createElementBlock(Fragment, null, renderList(displayedInputs.value, (input) => {
1277
- return openBlock(), createElementBlock(Fragment, {
1278
- key: input.id
1279
- }, [
1280
- node.value.state?.hidden ? (openBlock(), createElementBlock("div", _hoisted_9, [
1281
- input.port ? (openBlock(), createElementBlock("div", {
1282
- key: 0,
1283
- id: input.id,
1284
- title: input.name,
1285
- class: "baklava-node-interface --input --connected"
1286
- }, [..._cache[5] || (_cache[5] = [
1287
- createElementVNode("div", { class: "__port" }, null, -1)
1288
- ])], 8, _hoisted_10)) : createCommentVNode("", true)
1289
- ])) : renderSlot(_ctx.$slots, "nodeInterface", {
1290
- key: 1,
1291
- node: node.value,
1292
- intf: input,
1293
- type: "input"
1294
- }, () => [
1295
- createVNode(unref(NodeInterface2), {
1296
- node: node.value,
1297
- intf: input,
1298
- title: input.name
1299
- }, null, 8, ["node", "intf", "title"])
1300
- ])
1301
- ], 64);
1302
- }), 128))
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
- ], 34)
1305
- ], 46, _hoisted_1$4);
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(__props, { emit: __emit }) {
1323
- const emit = __emit;
1324
- return (_ctx, _cache) => {
1325
- return openBlock(), createElementBlock("div", {
1326
- class: normalizeClass(["baklava-checkbox", { "--checked": _ctx.inversed ? !_ctx.modelValue : _ctx.modelValue }]),
1327
- title: _ctx.name,
1328
- onClick: _cache[0] || (_cache[0] = ($event) => emit("update:modelValue", !_ctx.modelValue))
1329
- }, [
1330
- _cache[1] || (_cache[1] = createElementVNode("div", { class: "__checkmark-container" }, [
1331
- createElementVNode("svg", {
1332
- xmlns: "http://www.w3.org/2000/svg",
1333
- width: "18",
1334
- height: "18",
1335
- viewBox: "0 0 18 18"
1336
- }, [
1337
- createElementVNode("path", {
1338
- class: "__checkmark",
1339
- d: "M 6 5 L 6 10 L 16 10",
1340
- transform: "rotate(-45 10 10)"
1341
- })
1342
- ])
1343
- ], -1)),
1344
- _ctx.name ? (openBlock(), createElementBlock("div", _hoisted_2$3, toDisplayString(_ctx.name), 1)) : createCommentVNode("", true)
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(__props) {
1359
- const { viewModel } = useViewModel();
1360
- const { graph } = useGraph();
1361
- const el = ref(null);
1362
- const width = toRef(viewModel.value.settings.sidebar, "width");
1363
- const resizable = computed(() => viewModel.value.settings.sidebar.resizable);
1364
- let resizeStartWidth = 0;
1365
- let resizeStartMouseX = 0;
1366
- const node = computed(() => {
1367
- const id = graph.value.sidebar.nodeId;
1368
- return graph.value.nodes.find((x) => x.id === id);
1369
- });
1370
- const codeNode = computed(() => node.value);
1371
- const styles = computed(() => ({
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", onMouseMove);
1090
+ window.removeEventListener("mousemove", g);
1393
1091
  },
1394
- { once: true }
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
- const onMouseMove = (event) => {
1398
- const maxwidth = el.value?.parentElement?.getBoundingClientRect().width ?? 500;
1399
- const deltaX = event.clientX - resizeStartMouseX;
1400
- let newWidth = resizeStartWidth - deltaX;
1401
- if (newWidth < 300) {
1402
- newWidth = 300;
1403
- } else if (newWidth > 0.9 * maxwidth) {
1404
- newWidth = 0.9 * maxwidth;
1405
- }
1406
- width.value = newWidth;
1407
- };
1408
- return (_ctx, _cache) => {
1409
- return openBlock(), createElementBlock("div", {
1410
- ref_key: "el",
1411
- ref: el,
1412
- class: normalizeClass(["baklava-sidebar", { "--open": unref(graph).sidebar.visible }]),
1413
- style: normalizeStyle(styles.value)
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
- resizable.value ? (openBlock(), createElementBlock("div", {
1416
- key: 0,
1417
- class: "__resizer",
1418
- onMousedown: startResize
1419
- }, null, 32)) : createCommentVNode("", true),
1420
- createElementVNode("div", _hoisted_1$2, [
1421
- createElementVNode("button", {
1422
- tabindex: "-1",
1423
- class: "__close",
1424
- onClick: close
1425
- }, "×"),
1426
- createElementVNode("div", _hoisted_2$2, [
1427
- createElementVNode("b", null, toDisplayString(node.value ? node.value.title : ""), 1)
1428
- ])
1429
- ]),
1430
- (openBlock(true), createElementBlock(Fragment, null, renderList(displayedInterfaces.value, (intf) => {
1431
- return openBlock(), createElementBlock("div", {
1432
- key: intf.id,
1433
- class: "__interface"
1434
- }, [
1435
- createElementVNode("div", _hoisted_3$1, [
1436
- createVNode(_sfc_main$4, {
1437
- modelValue: intf.hidden,
1438
- "onUpdate:modelValue": [
1439
- ($event) => intf.hidden = $event,
1440
- _cache[0] || (_cache[0] = () => node.value?.events.update.emit(null))
1441
- ],
1442
- inversed: "",
1443
- style: { "margin-right": "8px" }
1444
- }, null, 8, ["modelValue", "onUpdate:modelValue"]),
1445
- (openBlock(), createBlock(resolveDynamicComponent(intf.component), {
1446
- modelValue: intf.value,
1447
- "onUpdate:modelValue": ($event) => intf.value = $event,
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: true
1162
+ required: !0
1477
1163
  },
1478
1164
  title: {
1479
1165
  type: String,
1480
- required: true
1166
+ required: !0
1481
1167
  }
1482
1168
  },
1483
- setup(props) {
1484
- const { viewModel } = useViewModel();
1485
- const { switchGraph } = useGraph();
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
- const openContextMenu = () => {
1493
- showContextMenu.value = true;
1494
- };
1495
- const onContextMenuClick = (action) => {
1496
- const graphTemplateId = props.type.substring(GRAPH_NODE_TYPE_PREFIX.length);
1497
- const graphTemplate = viewModel.value.editor.graphTemplates.find((gt) => gt.id === graphTemplateId);
1498
- if (!graphTemplate) {
1499
- return;
1500
- }
1501
- switch (action) {
1502
- case "editSubgraph":
1503
- switchGraph(graphTemplate);
1504
- break;
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
- const _hoisted_1$1 = ["data-node-type"];
1514
- const _hoisted_2$1 = { class: "__title" };
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": _ctx.type
1193
+ "data-node-type": o.type
1520
1194
  }, [
1521
- createElementVNode("div", _hoisted_2$1, [
1522
- createElementVNode("div", _hoisted_3, toDisplayString(_ctx.title), 1)
1195
+ l("div", Ss, [
1196
+ l("div", zs, L(o.title), 1)
1523
1197
  ])
1524
- ], 8, _hoisted_1$1);
1198
+ ], 8, Ts);
1525
1199
  }
1526
- const PaletteEntry = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render]]);
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(__props) {
1535
- const { viewModel } = useViewModel();
1536
- const { x: mouseX, y: mouseY } = usePointer();
1537
- const { transform } = useTransform();
1538
- const categories = useNodeCategories(viewModel);
1539
- const editorEl = inject("editorEl");
1540
- const searchQuery = ref("");
1541
- const draggedNode = ref(null);
1542
- const filterCategoryBySearch = (categories2) => {
1543
- if (searchQuery.value) {
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: `${mouseY.value - top}px`,
1565
- left: `${mouseX.value - left}px`
1216
+ top: `${s.value - m}px`,
1217
+ left: `${t.value - y}px`
1566
1218
  };
1567
- });
1568
- const onDragStart = (type, nodeInformation) => {
1569
- draggedNode.value = {
1570
- type,
1571
- nodeInformation
1219
+ }), B = (y, m) => {
1220
+ h.value = {
1221
+ type: y,
1222
+ nodeInformation: m
1572
1223
  };
1573
- const onDragEnd = () => {
1574
- const instance = reactive(new nodeInformation.type());
1575
- viewModel.value.displayedGraph.addNode(instance);
1576
- const rect = editorEl.value.getBoundingClientRect();
1577
- const [x, y] = transform(mouseX.value - rect.left, mouseY.value - rect.top);
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", onDragEnd);
1230
+ document.addEventListener("pointerup", g);
1584
1231
  };
1585
- return (_ctx, _cache) => {
1586
- return openBlock(), createElementBlock(Fragment, null, [
1587
- createElementVNode("div", {
1588
- class: normalizeClass(["baklava-node-palette", { "--open": unref(viewModel).settings.palette.enabled }]),
1589
- onContextmenu: _cache[1] || (_cache[1] = withModifiers(() => {
1590
- }, ["stop", "prevent"]))
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
- createElementVNode("div", _hoisted_1, [
1593
- withDirectives(createElementVNode("input", {
1594
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchQuery.value = $event),
1595
- type: "text",
1596
- class: "baklava-input",
1597
- title: "Filter node types"
1598
- }, null, 512), [
1599
- [vModelText, searchQuery.value]
1600
- ])
1601
- ]),
1602
- (openBlock(true), createElementBlock(Fragment, null, renderList(filterCategoryBySearch(unref(categories)), (c) => {
1603
- return openBlock(), createElementBlock("section", {
1604
- key: c.name
1605
- }, [
1606
- c.name !== "default" ? (openBlock(), createElementBlock("h3", _hoisted_2, toDisplayString(c.name), 1)) : createCommentVNode("", true),
1607
- (openBlock(true), createElementBlock(Fragment, null, renderList(filterNodesBySearch(c.nodeTypes), (ni, nt) => {
1608
- return openBlock(), createBlock(PaletteEntry, {
1609
- key: nt,
1610
- type: nt,
1611
- title: ni.title,
1612
- onPointerdown: ($event) => onDragStart(nt, ni)
1613
- }, null, 8, ["type", "title", "onPointerdown"]);
1614
- }), 128))
1615
- ]);
1616
- }), 128))
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(__props) {
1643
- const props = __props;
1644
- const viewModel = toRef(props, "viewModel");
1645
- const onUpdate = (node) => node.events.update.emit(null);
1646
- onMounted(() => {
1647
- viewModel.value.subscribe();
1648
- viewModel.value.engine.start();
1649
- });
1650
- onUnmounted(() => {
1651
- viewModel.value.unsubscribe();
1652
- viewModel.value.engine.stop();
1653
- });
1654
- return (_ctx, _cache) => {
1655
- return openBlock(), createBlock(unref(BaklavaEditor), { "view-model": viewModel.value }, {
1656
- palette: withCtx(() => [
1657
- createVNode(_sfc_main$1)
1658
- ]),
1659
- node: withCtx((nodeProps) => [
1660
- createVNode(_sfc_main$5, mergeProps(nodeProps, {
1661
- onUpdate: ($event) => onUpdate(nodeProps.node)
1662
- }), null, 16, ["onUpdate"])
1663
- ]),
1664
- sidebar: withCtx((nodeProps) => [
1665
- createVNode(_sfc_main$3, normalizeProps(guardReactiveProps(nodeProps)), null, 16)
1666
- ]),
1667
- _: 1
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 CLEAR_ALL_COMMAND = "CLEAR_ALL";
1679
- viewModel.commandHandler.registerCommand(CLEAR_ALL_COMMAND, {
1680
- execute: () => viewModel.displayedGraph.nodes.forEach((node) => viewModel.displayedGraph.removeNode(node)),
1681
- canExecute: () => viewModel.displayedGraph.nodes.length > 0
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 TOGGLE_MINIMAP_COMMAND = "TOGGLE_MINIMAP";
1684
- viewModel.commandHandler.registerCommand(TOGGLE_MINIMAP_COMMAND, {
1685
- execute: () => viewModel.settings.enableMinimap = !viewModel.settings.enableMinimap,
1686
- canExecute: () => viewModel.displayedGraph.nodes.length > 1
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: TOGGLE_PALETTE_COMMAND,
1320
+ command: e,
1691
1321
  title: "Toggle palette",
1692
1322
  // Tooltip text
1693
- icon: computed(() => viewModel.settings.palette.enabled ? LayoutSidebarLeftCollapse : LayoutSidebarLeftExpand)
1323
+ icon: f(() => o.settings.palette.enabled ? St : Lt)
1694
1324
  },
1695
- ...DEFAULT_TOOLBAR_COMMANDS,
1325
+ ...et,
1696
1326
  {
1697
- command: CLEAR_ALL_COMMAND,
1327
+ command: t,
1698
1328
  title: "Clear all",
1699
1329
  // Tooltip text
1700
- icon: TrashOff
1330
+ icon: is
1701
1331
  },
1702
1332
  {
1703
- command: TOGGLE_MINIMAP_COMMAND,
1333
+ command: s,
1704
1334
  title: "Toggle minimap",
1705
1335
  // Tooltip text
1706
- icon: computed(() => viewModel.settings.enableMinimap ? SchemaOff : Schema)
1336
+ icon: f(() => o.settings.enableMinimap ? ss : Zt)
1707
1337
  }
1708
1338
  ];
1709
- };
1710
- const DEFAULT_SETTINGS = {
1711
- enableMinimap: false,
1339
+ }, W = {
1340
+ enableMinimap: !1,
1712
1341
  toolbar: {
1713
- enabled: true
1342
+ enabled: !0
1714
1343
  },
1715
1344
  palette: {
1716
- enabled: true
1345
+ enabled: !0
1717
1346
  },
1718
1347
  sidebar: {
1719
- enabled: true,
1720
- resizable: true,
1348
+ enabled: !0,
1349
+ resizable: !0,
1721
1350
  width: 350
1722
1351
  },
1723
- displayValueOnHover: false
1352
+ displayValueOnHover: !1
1724
1353
  };
1725
- function useCodeGraph(props) {
1726
- const viewModel = useBaklava(props?.existingEditor);
1727
- viewModel.code = props?.code ? new props.code(viewModel) : new Code(viewModel);
1728
- addToolbarCommands(viewModel);
1729
- const settings = {};
1730
- Object.keys(DEFAULT_SETTINGS).forEach((K) => {
1731
- settings[K] = typeof DEFAULT_SETTINGS[K] === "object" ? { ...viewModel.settings[K], ...DEFAULT_SETTINGS[K] } : DEFAULT_SETTINGS[K];
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
- viewModel.engine = new DependencyEngine(viewModel.editor);
1740
- viewModel.subscribe = () => {
1741
- if (viewModel.state.token) viewModel.unsubscribe();
1742
- const token = Symbol();
1743
- viewModel.displayedGraph.events.addNode.subscribe(token, (node) => node.code = viewModel.code);
1744
- viewModel.engine.events.beforeRun.subscribe(token, () => {
1745
- viewModel.engine.pause();
1746
- if (viewModel.code) {
1747
- viewModel.code.onCodeUpdate();
1748
- viewModel.code.sortNodes();
1749
- viewModel.code.updateOutputVariableNames();
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
- ButtonInterfaceComponent2 as ButtonInterfaceComponent,
1779
- CheckboxInterface,
1780
- CheckboxInterfaceComponent2 as CheckboxInterfaceComponent,
1781
- Code,
1782
- _sfc_main as CodeGraphEditor,
1783
- CodeInputInterface,
1784
- CodeNode,
1785
- CodeNodeInterface,
1786
- CodeOutputInterface,
1787
- DEFAULT_SETTINGS,
1788
- DynamicCodeNode,
1789
- IntegerInterface,
1790
- IntegerInterfaceComponent2 as IntegerInterfaceComponent,
1791
- NumberInterface,
1792
- NumberInterfaceComponent2 as NumberInterfaceComponent,
1793
- SelectInterface,
1794
- SelectInterfaceComponent2 as SelectInterfaceComponent,
1795
- SliderInterface,
1796
- SliderInterfaceComponent2 as SliderInterfaceComponent,
1797
- TextInputInterface,
1798
- TextInputInterfaceComponent2 as TextInputInterfaceComponent,
1799
- TextInterface,
1800
- TextareaInputInterface,
1801
- TextareaInputInterfaceComponent2 as TextareaInputInterfaceComponent,
1802
- addToolbarCommands,
1803
- defineCodeNode,
1804
- defineDynamicCodeNode,
1805
- getCodeNodes,
1806
- getPositionAtColumn,
1807
- getPositionBeforeNode,
1808
- loadNodeState,
1809
- saveNodeState,
1810
- transferCodeScript,
1811
- useCodeGraph
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
  };