@knime/scripting-editor 0.0.5 → 0.0.6
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.
|
@@ -1,13 +1,1493 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".code-editor[data-v-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.splitpanes{display:flex;width:100%;height:100%}.splitpanes--vertical{flex-direction:row}.splitpanes--horizontal{flex-direction:column}.splitpanes--dragging *{-webkit-user-select:none;-moz-user-select:none;user-select:none}.splitpanes__pane{width:100%;height:100%;overflow:hidden}.splitpanes--vertical .splitpanes__pane{transition:width .2s ease-out}.splitpanes--horizontal .splitpanes__pane{transition:height .2s ease-out}.splitpanes--dragging .splitpanes__pane{transition:none}.splitpanes__splitter{touch-action:none}.splitpanes--vertical>.splitpanes__splitter{min-width:1px;cursor:col-resize}.splitpanes--horizontal>.splitpanes__splitter{min-height:1px;cursor:row-resize}.splitpanes.default-theme .splitpanes__pane{background-color:#f2f2f2}.splitpanes.default-theme .splitpanes__splitter{background-color:#fff;box-sizing:border-box;position:relative;flex-shrink:0}.splitpanes.default-theme .splitpanes__splitter:before,.splitpanes.default-theme .splitpanes__splitter:after{content:"";position:absolute;top:50%;left:50%;background-color:#00000026;transition:background-color .3s}.splitpanes.default-theme .splitpanes__splitter:hover:before,.splitpanes.default-theme .splitpanes__splitter:hover:after{background-color:#00000040}.splitpanes.default-theme .splitpanes__splitter:first-child{cursor:auto}.default-theme.splitpanes .splitpanes .splitpanes__splitter{z-index:1}.default-theme.splitpanes--vertical>.splitpanes__splitter,.default-theme .splitpanes--vertical>.splitpanes__splitter{width:7px;border-left:1px solid #eee;margin-left:-1px}.default-theme.splitpanes--vertical>.splitpanes__splitter:before,.default-theme.splitpanes--vertical>.splitpanes__splitter:after,.default-theme .splitpanes--vertical>.splitpanes__splitter:before,.default-theme .splitpanes--vertical>.splitpanes__splitter:after{transform:translateY(-50%);width:1px;height:30px}.default-theme.splitpanes--vertical>.splitpanes__splitter:before,.default-theme .splitpanes--vertical>.splitpanes__splitter:before{margin-left:-2px}.default-theme.splitpanes--vertical>.splitpanes__splitter:after,.default-theme .splitpanes--vertical>.splitpanes__splitter:after{margin-left:1px}.default-theme.splitpanes--horizontal>.splitpanes__splitter,.default-theme .splitpanes--horizontal>.splitpanes__splitter{height:7px;border-top:1px solid #eee;margin-top:-1px}.default-theme.splitpanes--horizontal>.splitpanes__splitter:before,.default-theme.splitpanes--horizontal>.splitpanes__splitter:after,.default-theme .splitpanes--horizontal>.splitpanes__splitter:before,.default-theme .splitpanes--horizontal>.splitpanes__splitter:after{transform:translate(-50%);width:30px;height:1px}.default-theme.splitpanes--horizontal>.splitpanes__splitter:before,.default-theme .splitpanes--horizontal>.splitpanes__splitter:before{margin-top:-2px}.default-theme.splitpanes--horizontal>.splitpanes__splitter:after,.default-theme .splitpanes--horizontal>.splitpanes__splitter:after{margin-top:1px}.code-editor[data-v-2a674232]{height:100%}.layout[data-v-52dc9a8f]{--controls-height: 49px;--description-button-size: 15px;display:flex;flex-direction:column;height:calc(100vh - 15px);width:100%;border-left:1px solid var(--knime-silver-sand)}.common-splitter[data-v-52dc9a8f] .splitpanes__splitter{min-width:11px;min-height:11px;background-color:var(--knime-porcelain);background-repeat:no-repeat;background-position:center;border-color:var(--knime-silver-sand);border-style:solid}.splitpanes--vertical[data-v-52dc9a8f]>.splitpanes__splitter{border-width:0 1px}.splitpanes--horizontal[data-v-52dc9a8f]>.splitpanes__splitter{border-width:1px 0}.left-facing-splitter[data-v-52dc9a8f]>.splitpanes__splitter{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiIKICAgIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzAwMCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+CiAgPHBhdGggZD0iTTIxLjUgMjdsLTExLTExIDExLTExIi8+Cjwvc3ZnPgo=)}.right-facing-splitter[data-v-52dc9a8f]>.splitpanes__splitter{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiIKICAgIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzAwMCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+CiAgPHBhdGggZD0iTTEwLjUgNWwxMSAxMS0xMSAxMSIvPgo8L3N2Zz4K)}.down-facing-splitter[data-v-52dc9a8f]>.splitpanes__splitter{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiIKICAgIHN0cm9rZT0iIzAwMCIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+CiAgPHBhdGggZD0iTTI4LjcgOS43TDE2IDIyLjMgMy4zIDkuNyIvPgo8L3N2Zz4K)}.up-facing-splitter[data-v-52dc9a8f]>.splitpanes__splitter{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiIKICAgIHN0cm9rZT0iIzAwMCIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+CiAgPHBhdGggZD0iTTI4LjcgOS43TDE2IDIyLjMgMy4zIDkuNyIvPgo8L3N2Zz4K);transform:scaleY(-1)}.splitpanes__pane[data-v-52dc9a8f]{transition:none 0s ease 0s;transition:initial}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
+
var J = Object.defineProperty;
|
|
3
|
+
var W = (e, t, i) => t in e ? J(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
4
|
+
var f = (e, t, i) => (W(e, typeof t != "symbol" ? t + "" : t, i), i);
|
|
5
|
+
import { h as X, openBlock as D, createElementBlock as N, normalizeStyle as K, renderSlot as y, defineComponent as q, ref as Y, onMounted as Q, onUnmounted as Z, resolveComponent as x, createVNode as p, normalizeClass as M, withCtx as m } from "vue";
|
|
6
|
+
import * as C from "monaco-editor";
|
|
7
|
+
const ee = {
|
|
8
|
+
name: "splitpanes",
|
|
9
|
+
emits: ["ready", "resize", "resized", "pane-click", "pane-maximize", "pane-add", "pane-remove", "splitter-click"],
|
|
6
10
|
props: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
horizontal: { type: Boolean },
|
|
12
|
+
pushOtherPanes: { type: Boolean, default: !0 },
|
|
13
|
+
dblClickSplitter: { type: Boolean, default: !0 },
|
|
14
|
+
rtl: { type: Boolean, default: !1 },
|
|
15
|
+
firstSplitter: { type: Boolean }
|
|
16
|
+
},
|
|
17
|
+
provide() {
|
|
18
|
+
return {
|
|
19
|
+
requestUpdate: this.requestUpdate,
|
|
20
|
+
onPaneAdd: this.onPaneAdd,
|
|
21
|
+
onPaneRemove: this.onPaneRemove,
|
|
22
|
+
onPaneClick: this.onPaneClick
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
data: () => ({
|
|
26
|
+
container: null,
|
|
27
|
+
ready: !1,
|
|
28
|
+
panes: [],
|
|
29
|
+
touch: {
|
|
30
|
+
mouseDown: !1,
|
|
31
|
+
dragging: !1,
|
|
32
|
+
activeSplitter: null
|
|
33
|
+
},
|
|
34
|
+
splitterTaps: {
|
|
35
|
+
splitter: null,
|
|
36
|
+
timeoutId: null
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
39
|
+
computed: {
|
|
40
|
+
panesCount() {
|
|
41
|
+
return this.panes.length;
|
|
42
|
+
},
|
|
43
|
+
indexedPanes() {
|
|
44
|
+
return this.panes.reduce((e, t) => (e[t.id] = t) && e, {});
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
methods: {
|
|
48
|
+
updatePaneComponents() {
|
|
49
|
+
this.panes.forEach((e) => {
|
|
50
|
+
e.update && e.update({
|
|
51
|
+
[this.horizontal ? "height" : "width"]: `${this.indexedPanes[e.id].size}%`
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
bindEvents() {
|
|
56
|
+
document.addEventListener("mousemove", this.onMouseMove, { passive: !1 }), document.addEventListener("mouseup", this.onMouseUp), "ontouchstart" in window && (document.addEventListener("touchmove", this.onMouseMove, { passive: !1 }), document.addEventListener("touchend", this.onMouseUp));
|
|
57
|
+
},
|
|
58
|
+
unbindEvents() {
|
|
59
|
+
document.removeEventListener("mousemove", this.onMouseMove, { passive: !1 }), document.removeEventListener("mouseup", this.onMouseUp), "ontouchstart" in window && (document.removeEventListener("touchmove", this.onMouseMove, { passive: !1 }), document.removeEventListener("touchend", this.onMouseUp));
|
|
60
|
+
},
|
|
61
|
+
onMouseDown(e, t) {
|
|
62
|
+
this.bindEvents(), this.touch.mouseDown = !0, this.touch.activeSplitter = t;
|
|
63
|
+
},
|
|
64
|
+
onMouseMove(e) {
|
|
65
|
+
this.touch.mouseDown && (e.preventDefault(), this.touch.dragging = !0, this.calculatePanesSize(this.getCurrentMouseDrag(e)), this.$emit("resize", this.panes.map((t) => ({ min: t.min, max: t.max, size: t.size }))));
|
|
66
|
+
},
|
|
67
|
+
onMouseUp() {
|
|
68
|
+
this.touch.dragging && this.$emit("resized", this.panes.map((e) => ({ min: e.min, max: e.max, size: e.size }))), this.touch.mouseDown = !1, setTimeout(() => {
|
|
69
|
+
this.touch.dragging = !1, this.unbindEvents();
|
|
70
|
+
}, 100);
|
|
71
|
+
},
|
|
72
|
+
onSplitterClick(e, t) {
|
|
73
|
+
"ontouchstart" in window && (e.preventDefault(), this.dblClickSplitter && (this.splitterTaps.splitter === t ? (clearTimeout(this.splitterTaps.timeoutId), this.splitterTaps.timeoutId = null, this.onSplitterDblClick(e, t), this.splitterTaps.splitter = null) : (this.splitterTaps.splitter = t, this.splitterTaps.timeoutId = setTimeout(() => {
|
|
74
|
+
this.splitterTaps.splitter = null;
|
|
75
|
+
}, 500)))), this.touch.dragging || this.$emit("splitter-click", this.panes[t]);
|
|
76
|
+
},
|
|
77
|
+
onSplitterDblClick(e, t) {
|
|
78
|
+
let i = 0;
|
|
79
|
+
this.panes = this.panes.map((n, s) => (n.size = s === t ? n.max : n.min, s !== t && (i += n.min), n)), this.panes[t].size -= i, this.$emit("pane-maximize", this.panes[t]), this.$emit("resized", this.panes.map((n) => ({ min: n.min, max: n.max, size: n.size })));
|
|
80
|
+
},
|
|
81
|
+
onPaneClick(e, t) {
|
|
82
|
+
this.$emit("pane-click", this.indexedPanes[t]);
|
|
83
|
+
},
|
|
84
|
+
getCurrentMouseDrag(e) {
|
|
85
|
+
const t = this.container.getBoundingClientRect(), { clientX: i, clientY: n } = "ontouchstart" in window && e.touches ? e.touches[0] : e;
|
|
86
|
+
return {
|
|
87
|
+
x: i - t.left,
|
|
88
|
+
y: n - t.top
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
getCurrentDragPercentage(e) {
|
|
92
|
+
e = e[this.horizontal ? "y" : "x"];
|
|
93
|
+
const t = this.container[this.horizontal ? "clientHeight" : "clientWidth"];
|
|
94
|
+
return this.rtl && !this.horizontal && (e = t - e), e * 100 / t;
|
|
95
|
+
},
|
|
96
|
+
calculatePanesSize(e) {
|
|
97
|
+
const t = this.touch.activeSplitter;
|
|
98
|
+
let i = {
|
|
99
|
+
prevPanesSize: this.sumPrevPanesSize(t),
|
|
100
|
+
nextPanesSize: this.sumNextPanesSize(t),
|
|
101
|
+
prevReachedMinPanes: 0,
|
|
102
|
+
nextReachedMinPanes: 0
|
|
103
|
+
};
|
|
104
|
+
const n = 0 + (this.pushOtherPanes ? 0 : i.prevPanesSize), s = 100 - (this.pushOtherPanes ? 0 : i.nextPanesSize), a = Math.max(Math.min(this.getCurrentDragPercentage(e), s), n);
|
|
105
|
+
let r = [t, t + 1], o = this.panes[r[0]] || null, l = this.panes[r[1]] || null;
|
|
106
|
+
const u = o.max < 100 && a >= o.max + i.prevPanesSize, d = l.max < 100 && a <= 100 - (l.max + this.sumNextPanesSize(t + 1));
|
|
107
|
+
if (u || d) {
|
|
108
|
+
u ? (o.size = o.max, l.size = Math.max(100 - o.max - i.prevPanesSize - i.nextPanesSize, 0)) : (o.size = Math.max(100 - l.max - i.prevPanesSize - this.sumNextPanesSize(t + 1), 0), l.size = l.max);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (this.pushOtherPanes) {
|
|
112
|
+
const h = this.doPushOtherPanes(i, a);
|
|
113
|
+
if (!h)
|
|
114
|
+
return;
|
|
115
|
+
({ sums: i, panesToResize: r } = h), o = this.panes[r[0]] || null, l = this.panes[r[1]] || null;
|
|
116
|
+
}
|
|
117
|
+
o !== null && (o.size = Math.min(Math.max(a - i.prevPanesSize - i.prevReachedMinPanes, o.min), o.max)), l !== null && (l.size = Math.min(Math.max(100 - a - i.nextPanesSize - i.nextReachedMinPanes, l.min), l.max));
|
|
118
|
+
},
|
|
119
|
+
doPushOtherPanes(e, t) {
|
|
120
|
+
const i = this.touch.activeSplitter, n = [i, i + 1];
|
|
121
|
+
return t < e.prevPanesSize + this.panes[n[0]].min && (n[0] = this.findPrevExpandedPane(i).index, e.prevReachedMinPanes = 0, n[0] < i && this.panes.forEach((s, a) => {
|
|
122
|
+
a > n[0] && a <= i && (s.size = s.min, e.prevReachedMinPanes += s.min);
|
|
123
|
+
}), e.prevPanesSize = this.sumPrevPanesSize(n[0]), n[0] === void 0) ? (e.prevReachedMinPanes = 0, this.panes[0].size = this.panes[0].min, this.panes.forEach((s, a) => {
|
|
124
|
+
a > 0 && a <= i && (s.size = s.min, e.prevReachedMinPanes += s.min);
|
|
125
|
+
}), this.panes[n[1]].size = 100 - e.prevReachedMinPanes - this.panes[0].min - e.prevPanesSize - e.nextPanesSize, null) : t > 100 - e.nextPanesSize - this.panes[n[1]].min && (n[1] = this.findNextExpandedPane(i).index, e.nextReachedMinPanes = 0, n[1] > i + 1 && this.panes.forEach((s, a) => {
|
|
126
|
+
a > i && a < n[1] && (s.size = s.min, e.nextReachedMinPanes += s.min);
|
|
127
|
+
}), e.nextPanesSize = this.sumNextPanesSize(n[1] - 1), n[1] === void 0) ? (e.nextReachedMinPanes = 0, this.panes[this.panesCount - 1].size = this.panes[this.panesCount - 1].min, this.panes.forEach((s, a) => {
|
|
128
|
+
a < this.panesCount - 1 && a >= i + 1 && (s.size = s.min, e.nextReachedMinPanes += s.min);
|
|
129
|
+
}), this.panes[n[0]].size = 100 - e.prevPanesSize - e.nextReachedMinPanes - this.panes[this.panesCount - 1].min - e.nextPanesSize, null) : { sums: e, panesToResize: n };
|
|
130
|
+
},
|
|
131
|
+
sumPrevPanesSize(e) {
|
|
132
|
+
return this.panes.reduce((t, i, n) => t + (n < e ? i.size : 0), 0);
|
|
133
|
+
},
|
|
134
|
+
sumNextPanesSize(e) {
|
|
135
|
+
return this.panes.reduce((t, i, n) => t + (n > e + 1 ? i.size : 0), 0);
|
|
136
|
+
},
|
|
137
|
+
findPrevExpandedPane(e) {
|
|
138
|
+
return [...this.panes].reverse().find((t) => t.index < e && t.size > t.min) || {};
|
|
139
|
+
},
|
|
140
|
+
findNextExpandedPane(e) {
|
|
141
|
+
return this.panes.find((t) => t.index > e + 1 && t.size > t.min) || {};
|
|
142
|
+
},
|
|
143
|
+
checkSplitpanesNodes() {
|
|
144
|
+
Array.from(this.container.children).forEach((e) => {
|
|
145
|
+
const t = e.classList.contains("splitpanes__pane"), i = e.classList.contains("splitpanes__splitter");
|
|
146
|
+
!t && !i && (e.parentNode.removeChild(e), console.warn("Splitpanes: Only <pane> elements are allowed at the root of <splitpanes>. One of your DOM nodes was removed."));
|
|
147
|
+
});
|
|
10
148
|
},
|
|
149
|
+
addSplitter(e, t, i = !1) {
|
|
150
|
+
const n = e - 1, s = document.createElement("div");
|
|
151
|
+
s.classList.add("splitpanes__splitter"), i || (s.onmousedown = (a) => this.onMouseDown(a, n), typeof window < "u" && "ontouchstart" in window && (s.ontouchstart = (a) => this.onMouseDown(a, n)), s.onclick = (a) => this.onSplitterClick(a, n + 1)), this.dblClickSplitter && (s.ondblclick = (a) => this.onSplitterDblClick(a, n + 1)), t.parentNode.insertBefore(s, t);
|
|
152
|
+
},
|
|
153
|
+
removeSplitter(e) {
|
|
154
|
+
e.onmousedown = void 0, e.onclick = void 0, e.ondblclick = void 0, e.parentNode.removeChild(e);
|
|
155
|
+
},
|
|
156
|
+
redoSplitters() {
|
|
157
|
+
const e = Array.from(this.container.children);
|
|
158
|
+
e.forEach((i) => {
|
|
159
|
+
i.className.includes("splitpanes__splitter") && this.removeSplitter(i);
|
|
160
|
+
});
|
|
161
|
+
let t = 0;
|
|
162
|
+
e.forEach((i) => {
|
|
163
|
+
i.className.includes("splitpanes__pane") && (!t && this.firstSplitter ? this.addSplitter(t, i, !0) : t && this.addSplitter(t, i), t++);
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
requestUpdate({ target: e, ...t }) {
|
|
167
|
+
const i = this.indexedPanes[e._.uid];
|
|
168
|
+
Object.entries(t).forEach(([n, s]) => i[n] = s);
|
|
169
|
+
},
|
|
170
|
+
onPaneAdd(e) {
|
|
171
|
+
let t = -1;
|
|
172
|
+
Array.from(e.$el.parentNode.children).some((s) => (s.className.includes("splitpanes__pane") && t++, s === e.$el));
|
|
173
|
+
const i = parseFloat(e.minSize), n = parseFloat(e.maxSize);
|
|
174
|
+
this.panes.splice(t, 0, {
|
|
175
|
+
id: e._.uid,
|
|
176
|
+
index: t,
|
|
177
|
+
min: isNaN(i) ? 0 : i,
|
|
178
|
+
max: isNaN(n) ? 100 : n,
|
|
179
|
+
size: e.size === null ? null : parseFloat(e.size),
|
|
180
|
+
givenSize: e.size,
|
|
181
|
+
update: e.update
|
|
182
|
+
}), this.panes.forEach((s, a) => s.index = a), this.ready && this.$nextTick(() => {
|
|
183
|
+
this.redoSplitters(), this.resetPaneSizes({ addedPane: this.panes[t] }), this.$emit("pane-add", { index: t, panes: this.panes.map((s) => ({ min: s.min, max: s.max, size: s.size })) });
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
onPaneRemove(e) {
|
|
187
|
+
const t = this.panes.findIndex((n) => n.id === e._.uid), i = this.panes.splice(t, 1)[0];
|
|
188
|
+
this.panes.forEach((n, s) => n.index = s), this.$nextTick(() => {
|
|
189
|
+
this.redoSplitters(), this.resetPaneSizes({ removedPane: { ...i, index: t } }), this.$emit("pane-remove", { removed: i, panes: this.panes.map((n) => ({ min: n.min, max: n.max, size: n.size })) });
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
resetPaneSizes(e = {}) {
|
|
193
|
+
!e.addedPane && !e.removedPane ? this.initialPanesSizing() : this.panes.some((t) => t.givenSize !== null || t.min || t.max < 100) ? this.equalizeAfterAddOrRemove(e) : this.equalize(), this.ready && this.$emit("resized", this.panes.map((t) => ({ min: t.min, max: t.max, size: t.size })));
|
|
194
|
+
},
|
|
195
|
+
equalize() {
|
|
196
|
+
const e = 100 / this.panesCount;
|
|
197
|
+
let t = 0;
|
|
198
|
+
const i = [], n = [];
|
|
199
|
+
this.panes.forEach((s) => {
|
|
200
|
+
s.size = Math.max(Math.min(e, s.max), s.min), t -= s.size, s.size >= s.max && i.push(s.id), s.size <= s.min && n.push(s.id);
|
|
201
|
+
}), t > 0.1 && this.readjustSizes(t, i, n);
|
|
202
|
+
},
|
|
203
|
+
initialPanesSizing() {
|
|
204
|
+
let e = 100;
|
|
205
|
+
const t = [], i = [];
|
|
206
|
+
let n = 0;
|
|
207
|
+
this.panes.forEach((a) => {
|
|
208
|
+
e -= a.size, a.size !== null && n++, a.size >= a.max && t.push(a.id), a.size <= a.min && i.push(a.id);
|
|
209
|
+
});
|
|
210
|
+
let s = 100;
|
|
211
|
+
e > 0.1 && (this.panes.forEach((a) => {
|
|
212
|
+
a.size === null && (a.size = Math.max(Math.min(e / (this.panesCount - n), a.max), a.min)), s -= a.size;
|
|
213
|
+
}), s > 0.1 && this.readjustSizes(e, t, i));
|
|
214
|
+
},
|
|
215
|
+
equalizeAfterAddOrRemove({ addedPane: e, removedPane: t } = {}) {
|
|
216
|
+
let i = 100 / this.panesCount, n = 0;
|
|
217
|
+
const s = [], a = [];
|
|
218
|
+
e && e.givenSize !== null && (i = (100 - e.givenSize) / (this.panesCount - 1)), this.panes.forEach((r) => {
|
|
219
|
+
n -= r.size, r.size >= r.max && s.push(r.id), r.size <= r.min && a.push(r.id);
|
|
220
|
+
}), !(Math.abs(n) < 0.1) && (this.panes.forEach((r) => {
|
|
221
|
+
e && e.givenSize !== null && e.id === r.id || (r.size = Math.max(Math.min(i, r.max), r.min)), n -= r.size, r.size >= r.max && s.push(r.id), r.size <= r.min && a.push(r.id);
|
|
222
|
+
}), n > 0.1 && this.readjustSizes(n, s, a));
|
|
223
|
+
},
|
|
224
|
+
readjustSizes(e, t, i) {
|
|
225
|
+
let n;
|
|
226
|
+
e > 0 ? n = e / (this.panesCount - t.length) : n = e / (this.panesCount - i.length), this.panes.forEach((s, a) => {
|
|
227
|
+
if (e > 0 && !t.includes(s.id)) {
|
|
228
|
+
const r = Math.max(Math.min(s.size + n, s.max), s.min), o = r - s.size;
|
|
229
|
+
e -= o, s.size = r;
|
|
230
|
+
} else if (!i.includes(s.id)) {
|
|
231
|
+
const r = Math.max(Math.min(s.size + n, s.max), s.min), o = r - s.size;
|
|
232
|
+
e -= o, s.size = r;
|
|
233
|
+
}
|
|
234
|
+
s.update({
|
|
235
|
+
[this.horizontal ? "height" : "width"]: `${this.indexedPanes[s.id].size}%`
|
|
236
|
+
});
|
|
237
|
+
}), Math.abs(e) > 0.1 && this.$nextTick(() => {
|
|
238
|
+
this.ready && console.warn("Splitpanes: Could not resize panes correctly due to their constraints.");
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
watch: {
|
|
243
|
+
panes: {
|
|
244
|
+
deep: !0,
|
|
245
|
+
immediate: !1,
|
|
246
|
+
handler() {
|
|
247
|
+
this.updatePaneComponents();
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
horizontal() {
|
|
251
|
+
this.updatePaneComponents();
|
|
252
|
+
},
|
|
253
|
+
firstSplitter() {
|
|
254
|
+
this.redoSplitters();
|
|
255
|
+
},
|
|
256
|
+
dblClickSplitter(e) {
|
|
257
|
+
[...this.container.querySelectorAll(".splitpanes__splitter")].forEach((t, i) => {
|
|
258
|
+
t.ondblclick = e ? (n) => this.onSplitterDblClick(n, i) : void 0;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
beforeUnmount() {
|
|
263
|
+
this.ready = !1;
|
|
264
|
+
},
|
|
265
|
+
mounted() {
|
|
266
|
+
this.container = this.$refs.container, this.checkSplitpanesNodes(), this.redoSplitters(), this.resetPaneSizes(), this.$emit("ready"), this.ready = !0;
|
|
267
|
+
},
|
|
268
|
+
render() {
|
|
269
|
+
return X(
|
|
270
|
+
"div",
|
|
271
|
+
{
|
|
272
|
+
ref: "container",
|
|
273
|
+
class: [
|
|
274
|
+
"splitpanes",
|
|
275
|
+
`splitpanes--${this.horizontal ? "horizontal" : "vertical"}`,
|
|
276
|
+
{
|
|
277
|
+
"splitpanes--dragging": this.touch.dragging
|
|
278
|
+
}
|
|
279
|
+
]
|
|
280
|
+
},
|
|
281
|
+
this.$slots.default()
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
}, te = (e, t) => {
|
|
285
|
+
const i = e.__vccOpts || e;
|
|
286
|
+
for (const [n, s] of t)
|
|
287
|
+
i[n] = s;
|
|
288
|
+
return i;
|
|
289
|
+
}, ne = {
|
|
290
|
+
name: "pane",
|
|
291
|
+
inject: ["requestUpdate", "onPaneAdd", "onPaneRemove", "onPaneClick"],
|
|
292
|
+
props: {
|
|
293
|
+
size: { type: [Number, String], default: null },
|
|
294
|
+
minSize: { type: [Number, String], default: 0 },
|
|
295
|
+
maxSize: { type: [Number, String], default: 100 }
|
|
296
|
+
},
|
|
297
|
+
data: () => ({
|
|
298
|
+
style: {}
|
|
299
|
+
}),
|
|
300
|
+
mounted() {
|
|
301
|
+
this.onPaneAdd(this);
|
|
302
|
+
},
|
|
303
|
+
beforeUnmount() {
|
|
304
|
+
this.onPaneRemove(this);
|
|
305
|
+
},
|
|
306
|
+
methods: {
|
|
307
|
+
update(e) {
|
|
308
|
+
this.style = e;
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
computed: {
|
|
312
|
+
sizeNumber() {
|
|
313
|
+
return this.size || this.size === 0 ? parseFloat(this.size) : null;
|
|
314
|
+
},
|
|
315
|
+
minSizeNumber() {
|
|
316
|
+
return parseFloat(this.minSize);
|
|
317
|
+
},
|
|
318
|
+
maxSizeNumber() {
|
|
319
|
+
return parseFloat(this.maxSize);
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
watch: {
|
|
323
|
+
sizeNumber(e) {
|
|
324
|
+
this.requestUpdate({ target: this, size: e });
|
|
325
|
+
},
|
|
326
|
+
minSizeNumber(e) {
|
|
327
|
+
this.requestUpdate({ target: this, min: e });
|
|
328
|
+
},
|
|
329
|
+
maxSizeNumber(e) {
|
|
330
|
+
this.requestUpdate({ target: this, max: e });
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
function ie(e, t, i, n, s, a) {
|
|
335
|
+
return D(), N("div", {
|
|
336
|
+
class: "splitpanes__pane",
|
|
337
|
+
onClick: t[0] || (t[0] = (r) => a.onPaneClick(r, e._.uid)),
|
|
338
|
+
style: K(e.style)
|
|
339
|
+
}, [
|
|
340
|
+
y(e.$slots, "default")
|
|
341
|
+
], 4);
|
|
342
|
+
}
|
|
343
|
+
const se = /* @__PURE__ */ te(ne, [["render", ie]]);
|
|
344
|
+
var g;
|
|
345
|
+
(function(e) {
|
|
346
|
+
e.ERROR = "error", e.WARN = "warn";
|
|
347
|
+
})(g || (g = {}));
|
|
348
|
+
class ae {
|
|
349
|
+
/**
|
|
350
|
+
* @param {ExtensionConfig} extensionConfig - the extension configuration for the associated UI Extension.
|
|
351
|
+
* @param {CallableService} callableService - the environment-specific "call service" API method.
|
|
352
|
+
* @param {CallableService} pushEvent - the environment-specific "push event" API method.
|
|
353
|
+
*/
|
|
354
|
+
constructor(t = null, i = null, n = null) {
|
|
355
|
+
this.extensionConfig = t, this.callableService = i, this.callablePushEvent = n, this.eventCallbacksMap = /* @__PURE__ */ new Map();
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Public service call wrapper with full error handling which can be used by subclasses/typed service
|
|
359
|
+
* implementations.
|
|
360
|
+
*
|
|
361
|
+
* @param {ServiceParameters} serviceParams - service parameters for the service call.
|
|
362
|
+
* @returns {Promise<CallServiceResponse>} - resolved promise containing error or result depending on response
|
|
363
|
+
* success.
|
|
364
|
+
*/
|
|
365
|
+
async callService(t) {
|
|
366
|
+
if (!this.extensionConfig) {
|
|
367
|
+
const a = this.createAlert({
|
|
368
|
+
subtitle: "Missing extension config",
|
|
369
|
+
message: "Cannot call service without extension config"
|
|
370
|
+
});
|
|
371
|
+
return this.sendError(a), Promise.resolve({});
|
|
372
|
+
}
|
|
373
|
+
if (!this.callableService) {
|
|
374
|
+
const a = this.createAlert({
|
|
375
|
+
message: "Callable service is not available",
|
|
376
|
+
subtitle: "Service not found"
|
|
377
|
+
});
|
|
378
|
+
return this.sendError(a), Promise.resolve({});
|
|
379
|
+
}
|
|
380
|
+
const i = await this.executeServiceCall(t), { error: n, result: s } = i || {};
|
|
381
|
+
return n && this.sendError(n), Promise.resolve({ result: s });
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Inner service call wrapper which can be overridden by subclasses which require specific behavior (e.g. iframes).
|
|
385
|
+
* Default behavior is to use the member callable service directly.
|
|
386
|
+
*
|
|
387
|
+
* @param {ServiceParameters} serviceParams - parameters for the service call.
|
|
388
|
+
* @returns {Promise} - rejected or resolved depending on response success.
|
|
389
|
+
*/
|
|
390
|
+
executeServiceCall(t) {
|
|
391
|
+
return this.callableService(...t);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Register a callback method which returns relevant data to provide when "applying" client-side state
|
|
395
|
+
* changes to the framework (i.e. when settings change and should be persisted).
|
|
396
|
+
*
|
|
397
|
+
* @param {Function} callback - method which returns any data needed by the framework to persist the client-
|
|
398
|
+
* side state.
|
|
399
|
+
* @returns {undefined}
|
|
400
|
+
*/
|
|
401
|
+
registerDataGetter(t) {
|
|
402
|
+
this.dataGetter = t;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* A framework method to get any data which is needed for state persistence. Not intended to be called directly
|
|
406
|
+
* by a UI Extension implementation, this method is exposed for lifecycle management by the framework.
|
|
407
|
+
*
|
|
408
|
+
* @returns {any | null} optionally returns data needed to persist client side state if a
|
|
409
|
+
* {@see KnimeService.dataGetter} has been registered. If no data getter is present,
|
|
410
|
+
* returns {@type null}.
|
|
411
|
+
*/
|
|
412
|
+
getData() {
|
|
413
|
+
return Promise.resolve(typeof this.dataGetter == "function" ? this.dataGetter() : null);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* To be called by the parent application to sent an event to all services. Calls registered callbacks by
|
|
417
|
+
* event type.
|
|
418
|
+
* @param {Event} event - event object, which is provided by backend implementation.
|
|
419
|
+
* @returns {void}
|
|
420
|
+
*/
|
|
421
|
+
onServiceEvent(t) {
|
|
422
|
+
(this.eventCallbacksMap.get(t.eventType) || []).forEach((n) => {
|
|
423
|
+
n(t);
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Registers callback that will be triggered on received events.
|
|
428
|
+
* @param {EventTypes} eventType - event type that callback should be registered for.
|
|
429
|
+
* @param {function} callback - callback that should be called on received events, will be called with {Event} param
|
|
430
|
+
* @returns {void}
|
|
431
|
+
*/
|
|
432
|
+
addEventCallback(t, i) {
|
|
433
|
+
this.eventCallbacksMap.set(t, [
|
|
434
|
+
...this.eventCallbacksMap.get(t) || [],
|
|
435
|
+
i
|
|
436
|
+
]);
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Unregisters previously registered callback for events.
|
|
440
|
+
* @param {EventTypes} eventType - event type that matches registered callback event type.
|
|
441
|
+
* @param {function} callback - previously registered callback.
|
|
442
|
+
* @returns {void}
|
|
443
|
+
*/
|
|
444
|
+
removeEventCallback(t, i) {
|
|
445
|
+
this.eventCallbacksMap.set(t, (this.eventCallbacksMap.get(t) || []).filter((n) => n !== i));
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Unregisters all previously registered event callbacks of provided event type.
|
|
449
|
+
* @param {string} eventType - event type that matches registered callbacks event type.
|
|
450
|
+
* @returns {void}
|
|
451
|
+
*/
|
|
452
|
+
resetEventCallbacksByType(t) {
|
|
453
|
+
this.eventCallbacksMap.set(t, []);
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Unregisters all previously registered event callbacks of all event types.
|
|
457
|
+
* @returns {void}
|
|
458
|
+
*/
|
|
459
|
+
resetEventCallbacks() {
|
|
460
|
+
this.eventCallbacksMap.clear();
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Public push event wrapper with error handling. This broadcasts an event or event
|
|
464
|
+
* via the callable function provided during instantiation.
|
|
465
|
+
*
|
|
466
|
+
* @param {Event} event - the event payload.
|
|
467
|
+
* @returns {any} - the result of the callable function.
|
|
468
|
+
*/
|
|
469
|
+
pushEvent(t) {
|
|
470
|
+
if (!this.extensionConfig) {
|
|
471
|
+
const i = this.createAlert({
|
|
472
|
+
subtitle: "Missing extension config",
|
|
473
|
+
message: "Cannot push event without extension config"
|
|
474
|
+
});
|
|
475
|
+
return this.sendError(i), Promise.resolve({});
|
|
476
|
+
}
|
|
477
|
+
if (!this.callablePushEvent) {
|
|
478
|
+
const i = this.createAlert({
|
|
479
|
+
subtitle: "Push event failed",
|
|
480
|
+
message: "Push event is not available"
|
|
481
|
+
});
|
|
482
|
+
return this.sendError(i), Promise.resolve({});
|
|
483
|
+
}
|
|
484
|
+
return this.callablePushEvent(Object.assign({ callerId: this.serviceId }, t));
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Pushes error to framework to be displayed to the user.
|
|
488
|
+
*
|
|
489
|
+
* @param {Alert} alert - the error alert.
|
|
490
|
+
* @returns {void}
|
|
491
|
+
*/
|
|
492
|
+
sendError(t) {
|
|
493
|
+
this.callablePushEvent ? this.callablePushEvent({
|
|
494
|
+
callerId: this.serviceId,
|
|
495
|
+
alert: t,
|
|
496
|
+
type: "alert"
|
|
497
|
+
}) : console.error(t);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Pushes warning to framework to be displayed to the user.
|
|
501
|
+
*
|
|
502
|
+
* @param {Alert} alert - the warning alert.
|
|
503
|
+
* @returns {void}
|
|
504
|
+
*/
|
|
505
|
+
sendWarning(t) {
|
|
506
|
+
this.callablePushEvent ? this.callablePushEvent({
|
|
507
|
+
callerId: this.serviceId,
|
|
508
|
+
alert: t,
|
|
509
|
+
type: "alert"
|
|
510
|
+
}) : console.warn(t);
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Helper method to create framework compatible {@see Alert} from the available information.
|
|
514
|
+
*
|
|
515
|
+
* @param {Object} alertParams - optional parameters for the formatted alert.
|
|
516
|
+
* @returns {Alert} the properly formatted alert.
|
|
517
|
+
*/
|
|
518
|
+
createAlert(t) {
|
|
519
|
+
var i, n;
|
|
520
|
+
const { type: s = g.ERROR, message: a, code: r, subtitle: o } = t;
|
|
521
|
+
return {
|
|
522
|
+
nodeId: ((i = this.extensionConfig) === null || i === void 0 ? void 0 : i.nodeId) || "MISSING",
|
|
523
|
+
nodeInfo: ((n = this.extensionConfig) === null || n === void 0 ? void 0 : n.nodeInfo) || {},
|
|
524
|
+
type: s,
|
|
525
|
+
message: a,
|
|
526
|
+
code: r,
|
|
527
|
+
subtitle: o
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Creates an instance ID from a @type {KnimeService}. This ID unique among node instances in a workflow but shared
|
|
532
|
+
* between KnimeService instances instantiated by the same node instance (i.e. between sessions, refreshes, reloads,
|
|
533
|
+
* etc.).
|
|
534
|
+
*
|
|
535
|
+
* @param {KnimeService} knimeService - the service from which to derive an ID.
|
|
536
|
+
* @returns {String} the id derived from the provided service.
|
|
537
|
+
*/
|
|
538
|
+
get serviceId() {
|
|
539
|
+
const { nodeId: t, projectId: i, workflowId: n, extensionType: s } = this.extensionConfig || {};
|
|
540
|
+
return `${t}.${i}.${n}.${s}`;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
var _;
|
|
544
|
+
(function(e) {
|
|
545
|
+
e.CALL_NODE_DATA_SERVICE = "NodeService.callNodeDataService", e.CALL_NODE_SELECTION_SERVICE = "NodeService.updateDataPointSelection";
|
|
546
|
+
})(_ || (_ = {}));
|
|
547
|
+
var b;
|
|
548
|
+
(function(e) {
|
|
549
|
+
e.INITIAL_DATA = "initial_data", e.DATA = "data", e.APPLY_DATA = "apply_data";
|
|
550
|
+
})(b || (b = {}));
|
|
551
|
+
var A;
|
|
552
|
+
(function(e) {
|
|
553
|
+
e.ADD = "ADD", e.REMOVE = "REMOVE", e.REPLACE = "REPLACE";
|
|
554
|
+
})(A || (A = {}));
|
|
555
|
+
var I;
|
|
556
|
+
(function(e) {
|
|
557
|
+
e.DIALOG = "dialog", e.VIEW = "view";
|
|
558
|
+
})(I || (I = {}));
|
|
559
|
+
var w;
|
|
560
|
+
(function(e) {
|
|
561
|
+
e.DataEvent = "DataEvent", e.SelectionEvent = "SelectionEvent";
|
|
562
|
+
})(w || (w = {}));
|
|
563
|
+
var $;
|
|
564
|
+
(function(e) {
|
|
565
|
+
e.HTML = "HTML", e.VUE_COMPONENT_LIB = "VUE_COMPONENT_LIB";
|
|
566
|
+
})($ || ($ = {}));
|
|
567
|
+
let T = 0;
|
|
568
|
+
const O = () => (T += 1, T), re = "2.0", F = (e, t = []) => ({
|
|
569
|
+
jsonrpc: re,
|
|
570
|
+
method: e,
|
|
571
|
+
params: t,
|
|
572
|
+
id: O()
|
|
573
|
+
}), j = 160;
|
|
574
|
+
class oe {
|
|
575
|
+
/**
|
|
576
|
+
* @param {KnimeService<T> | IFrameKnimeService} knimeService - knimeService instance which is used to communicate
|
|
577
|
+
* with the framework.
|
|
578
|
+
*/
|
|
579
|
+
constructor(t) {
|
|
580
|
+
this.knimeService = t;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Calls the node data service with optional request body. The service to call is specified by the service type
|
|
584
|
+
* and needs to correspond directly to a {@see DataServiceType} supported by the node.
|
|
585
|
+
*
|
|
586
|
+
* @param {DataServiceType} dataServiceType - the data service type.
|
|
587
|
+
* @param {string} [request] - an optional request payload.
|
|
588
|
+
* @returns {Promise} rejected or resolved depending on backend response.
|
|
589
|
+
*/
|
|
590
|
+
callDataService(t, i = "") {
|
|
591
|
+
return this.knimeService.callService([
|
|
592
|
+
_.CALL_NODE_DATA_SERVICE,
|
|
593
|
+
t,
|
|
594
|
+
i
|
|
595
|
+
]).then((n) => typeof n == "string" && n !== "" ? JSON.parse(n) : n);
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Retrieves the initial data for the client-side UI Extension implementation from either the local configuration
|
|
599
|
+
* (if it exists) or by fetching the data from the node DataService implementation.
|
|
600
|
+
*
|
|
601
|
+
* @returns {Promise} node initial data provided by the local configuration or by fetching from the DataService.
|
|
602
|
+
*/
|
|
603
|
+
async initialData() {
|
|
604
|
+
var t, i;
|
|
605
|
+
let n;
|
|
606
|
+
!((t = this.knimeService.extensionConfig) === null || t === void 0) && t.initialData ? n = await Promise.resolve((i = this.knimeService.extensionConfig) === null || i === void 0 ? void 0 : i.initialData) : n = await this.callDataService(b.INITIAL_DATA), typeof n == "string" && (n = JSON.parse(n));
|
|
607
|
+
const { result: s, warningMessages: a, userError: r, internalError: o } = n || {};
|
|
608
|
+
return (r || o) && this.handleError(r || o), a && this.handleWarnings(a), Promise.resolve(s);
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* The state of the settings in a coexisting dialog (if any) when the extension is first loaded.
|
|
612
|
+
* More precisely, this is the state of the settings on the last clean state of the dialog before
|
|
613
|
+
* the initialization of the knime service.
|
|
614
|
+
* It is null if there is no dialog or there was no such state before the initialization.
|
|
615
|
+
* In particular it is null if the knime service of the view and the dialog are consturcted at the same time.
|
|
616
|
+
* @returns {DialogSettings | null} the initial dialog state
|
|
617
|
+
*/
|
|
618
|
+
getDialogSettings() {
|
|
619
|
+
var t;
|
|
620
|
+
return ((t = this.knimeService.extensionConfig) === null || t === void 0 ? void 0 : t.dialogSettings) || null;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Retrieve data from the node using the {@see DataServiceType.DATA} api. Different method names can be registered
|
|
624
|
+
* with the data service in the node implementation to provide targets (specified by the {@param method}). Any
|
|
625
|
+
* optional parameter will be provided directly to the data service target and can be used to specify the nature of
|
|
626
|
+
* the data returned.
|
|
627
|
+
*
|
|
628
|
+
* @param {Object} params - parameter options.
|
|
629
|
+
* @param {string} [params.method] - optional target method in the node's DataService implementation
|
|
630
|
+
* (default 'getData').
|
|
631
|
+
* @param {any} [params.options] - optional options that should be passed to called method.
|
|
632
|
+
* @returns {Promise} rejected or resolved depending on backend response.
|
|
633
|
+
*/
|
|
634
|
+
async data(t = {}) {
|
|
635
|
+
const i = await this.callDataService(b.DATA, JSON.stringify(F(t.method || "getData", t.options)));
|
|
636
|
+
let n = (i == null ? void 0 : i.result) || {};
|
|
637
|
+
typeof n == "string" && (n = JSON.parse(n));
|
|
638
|
+
const { error: s, warningMessages: a, result: r } = n;
|
|
639
|
+
return s && this.handleError(Object.assign(Object.assign({}, s.data || {}), s)), a && this.handleWarnings(a), Promise.resolve(r);
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Sends the current client-side data to the backend to be persisted. A data getter method which returns the
|
|
643
|
+
* data to be applied/saved should be registered *prior* to invoking this method. If none is registered, a
|
|
644
|
+
* default payload of "null" will be sent instead.
|
|
645
|
+
*
|
|
646
|
+
* @returns {Promise} rejected or resolved depending on backend response.
|
|
647
|
+
*/
|
|
648
|
+
async applyData() {
|
|
649
|
+
const t = await this.knimeService.getData();
|
|
650
|
+
return this.callDataService(b.APPLY_DATA, t);
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Registers a function with the framework is used to provide the current state of the client-side UI Extension.
|
|
654
|
+
*
|
|
655
|
+
* @param {Function} callback - function which provides the current client side state when invoked.
|
|
656
|
+
* @returns {undefined}
|
|
657
|
+
*/
|
|
658
|
+
registerDataGetter(t) {
|
|
659
|
+
this.knimeService.registerDataGetter(() => JSON.stringify(t()));
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Adds callback that will be triggered when data changes.
|
|
663
|
+
* @param {Function} callback - called on data change.
|
|
664
|
+
* @param {Event} response - the data update event object.
|
|
665
|
+
* @returns {void}
|
|
666
|
+
*/
|
|
667
|
+
addOnDataChangeCallback(t) {
|
|
668
|
+
this.knimeService.addEventCallback(w.DataEvent, t);
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Publish a data update event to other UIExtensions registered in the current page.
|
|
672
|
+
* @param {any} data - the data to send.
|
|
673
|
+
* @returns {void}
|
|
674
|
+
*/
|
|
675
|
+
publishData(t) {
|
|
676
|
+
this.knimeService.pushEvent({
|
|
677
|
+
event: { data: t, eventType: w.DataEvent }
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
handleError(t = {}) {
|
|
681
|
+
const { details: i = "", stackTrace: n = "", typeName: s = "", message: a = "", code: r } = t;
|
|
682
|
+
let o = "", l = "";
|
|
683
|
+
if (a && (a.length <= j ? o = a : l = a), s && (o ? l = s : o = s), i && (l = l ? `${l}
|
|
684
|
+
|
|
685
|
+
${i}` : i), Array.isArray(n)) {
|
|
686
|
+
const u = n.join(`
|
|
687
|
+
`);
|
|
688
|
+
l = l ? `${l}
|
|
689
|
+
|
|
690
|
+
${u}` : u;
|
|
691
|
+
}
|
|
692
|
+
l = l.trim(), this.knimeService.sendError(this.knimeService.createAlert({
|
|
693
|
+
subtitle: o || "Something went wrong",
|
|
694
|
+
message: l || "No further information available. Please check the workflow configuration.",
|
|
695
|
+
type: g.ERROR,
|
|
696
|
+
code: r
|
|
697
|
+
}));
|
|
698
|
+
}
|
|
699
|
+
handleWarnings(t) {
|
|
700
|
+
let i;
|
|
701
|
+
const n = t == null ? void 0 : t.join(`
|
|
702
|
+
|
|
703
|
+
`);
|
|
704
|
+
(t == null ? void 0 : t.length) > 1 ? i = `${t == null ? void 0 : t.length} messages` : (n == null ? void 0 : n.length) > j && (i = "Expand for details"), this.knimeService.sendWarning(this.knimeService.createAlert({
|
|
705
|
+
type: g.WARN,
|
|
706
|
+
message: n,
|
|
707
|
+
subtitle: i
|
|
708
|
+
}));
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
const E = "knimeUIExtension", U = 1e4, le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
712
|
+
__proto__: null,
|
|
713
|
+
UI_EXT_POST_MESSAGE_PREFIX: E,
|
|
714
|
+
UI_EXT_POST_MESSAGE_TIMEOUT: U
|
|
715
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
716
|
+
class v extends ae {
|
|
717
|
+
constructor() {
|
|
718
|
+
super(), this.pendingServiceCalls = /* @__PURE__ */ new Map(), this.initializationPromise = new Promise((t) => {
|
|
719
|
+
this.initializationPromiseResolve = t;
|
|
720
|
+
}), this.extensionConfig && this.initializationPromiseResolve(), this.callableService = this.executeServiceCall, this.callablePushEvent = v.iframePushEvent, this.boundOnMessageFromParent = this.onMessageFromParent.bind(this), window.addEventListener("message", this.boundOnMessageFromParent), v.postMessage({ messageType: "ready" });
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Needs to be awaited before the service is ready to be used.
|
|
724
|
+
* @returns {void}
|
|
725
|
+
*/
|
|
726
|
+
async waitForInitialization() {
|
|
727
|
+
await this.initializationPromise;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Called when a new message is received, identifies and handles it if type is supported.
|
|
731
|
+
* @param {MessageEvent} event - postMessage event that is sent by parent window with event type and payload.
|
|
732
|
+
* @returns {void}
|
|
733
|
+
*/
|
|
734
|
+
onMessageFromParent(t) {
|
|
735
|
+
var i, n;
|
|
736
|
+
const { data: s } = t;
|
|
737
|
+
if (!(!((i = s.type) === null || i === void 0) && i.startsWith(E)))
|
|
738
|
+
return;
|
|
739
|
+
switch ((n = s.type) === null || n === void 0 ? void 0 : n.replace(`${E}:`, "")) {
|
|
740
|
+
case "init":
|
|
741
|
+
this.onInit(s);
|
|
742
|
+
break;
|
|
743
|
+
case "callServiceResponse":
|
|
744
|
+
this.onCallServiceResponse(s);
|
|
745
|
+
break;
|
|
746
|
+
case "serviceEvent":
|
|
747
|
+
this.onServiceEvent(s.payload);
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
onInit(t) {
|
|
752
|
+
this.extensionConfig = t.payload, this.initializationPromiseResolve();
|
|
753
|
+
}
|
|
754
|
+
onCallServiceResponse(t) {
|
|
755
|
+
const { payload: { response: i, requestId: n } } = t, s = this.pendingServiceCalls.get(n);
|
|
756
|
+
if (s) {
|
|
757
|
+
s.resolve(i), this.pendingServiceCalls.delete(n);
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
const a = this.createAlert({
|
|
761
|
+
code: "404",
|
|
762
|
+
subtitle: "Request not found",
|
|
763
|
+
type: g.ERROR,
|
|
764
|
+
message: `Received callService response for non-existing pending request with id ${n}`
|
|
765
|
+
});
|
|
766
|
+
this.sendError(a);
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Overrides method of KnimeService to implement how request should be processed in IFrame environment.
|
|
770
|
+
* @param {ServiceParameters} serviceParams - parameters for the service call.
|
|
771
|
+
* @returns {Promise<string>} - promise that resolves with response from the service call string or error message.
|
|
772
|
+
*/
|
|
773
|
+
executeServiceCall(t) {
|
|
774
|
+
let i;
|
|
775
|
+
const n = O(), s = new Promise((a, r) => {
|
|
776
|
+
this.pendingServiceCalls.set(n, { resolve: a, reject: r }), i = setTimeout(() => {
|
|
777
|
+
const o = this.createAlert({
|
|
778
|
+
code: "408",
|
|
779
|
+
subtitle: "Request Timeout",
|
|
780
|
+
type: g.ERROR,
|
|
781
|
+
message: `Request with id ${n} aborted due to timeout.`
|
|
782
|
+
});
|
|
783
|
+
this.sendError(o), a(JSON.stringify({ error: o }));
|
|
784
|
+
}, U);
|
|
785
|
+
});
|
|
786
|
+
return s.then(() => {
|
|
787
|
+
clearTimeout(i);
|
|
788
|
+
}), v.postMessage({
|
|
789
|
+
payload: { requestId: n, serviceParams: t },
|
|
790
|
+
messageType: "callService"
|
|
791
|
+
}), s;
|
|
792
|
+
}
|
|
793
|
+
static postMessage(t) {
|
|
794
|
+
const { payload: i, messageType: n } = t;
|
|
795
|
+
window.parent.postMessage({ type: `${E}:${n}`, payload: i }, "*");
|
|
796
|
+
}
|
|
797
|
+
static iframePushEvent(t) {
|
|
798
|
+
return v.postMessage({
|
|
799
|
+
payload: { event: t },
|
|
800
|
+
messageType: "event"
|
|
801
|
+
}), Promise.resolve();
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Should be called before destroying IFrameKnimeService, to remove event listeners from window object,
|
|
805
|
+
* preventing memory leaks and unexpected behavior.
|
|
806
|
+
* @returns {void}
|
|
807
|
+
*/
|
|
808
|
+
destroy() {
|
|
809
|
+
window.removeEventListener("message", this.boundOnMessageFromParent);
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Called when an image has been generated. Posts the generated image to the parent via an 'imageGenerated' message.
|
|
813
|
+
*
|
|
814
|
+
* @param {string} generatedImage - the generated PNG image (as string)
|
|
815
|
+
* @returns {void}
|
|
816
|
+
*/
|
|
817
|
+
static imageGenerated(t) {
|
|
818
|
+
v.postMessage({
|
|
819
|
+
payload: t,
|
|
820
|
+
messageType: "imageGenerated"
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
const ce = ({ viewVariables: e = {}, modelVariables: t = {} } = {}) => {
|
|
825
|
+
const i = (n, s, a = {}) => n ? Object.entries(n).reduce((r, [o, l]) => l.leaf ? (r[s ? `${s}.${o}` : o] = l, r) : i(l, `${s}${o === "value" ? "" : `.${o}`}`, r), a) : {};
|
|
826
|
+
return Object.assign(Object.assign({}, i(e, "view")), i(t, "model"));
|
|
827
|
+
};
|
|
828
|
+
class ue {
|
|
829
|
+
/**
|
|
830
|
+
* @param {KnimeService<T> | IFrameKnimeService} knimeService - knimeService instance which is used to communicate
|
|
831
|
+
* with the framework.
|
|
832
|
+
*/
|
|
833
|
+
constructor(t) {
|
|
834
|
+
this.knimeService = t;
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* @returns {FlowVariableSettings | null} - maps of model and view flow variables settings.
|
|
838
|
+
*/
|
|
839
|
+
async getFlowVariableSettings() {
|
|
840
|
+
var t;
|
|
841
|
+
const i = await Promise.resolve(((t = this.knimeService.extensionConfig) === null || t === void 0 ? void 0 : t.flowVariableSettings) || {});
|
|
842
|
+
return ce(i);
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* @returns {boolean} - true, if the node this dialog belongs to also has a node view, otherwise false
|
|
846
|
+
*/
|
|
847
|
+
hasNodeView() {
|
|
848
|
+
var t;
|
|
849
|
+
return (t = this.knimeService.extensionConfig) === null || t === void 0 ? void 0 : t.hasNodeView;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
var L;
|
|
853
|
+
(function(e) {
|
|
854
|
+
e.NUMERIC = "NUMERIC", e.NOMINAL = "NOMINAL";
|
|
855
|
+
})(L || (L = {}));
|
|
856
|
+
var he = {
|
|
857
|
+
aliceblue: [240, 248, 255],
|
|
858
|
+
antiquewhite: [250, 235, 215],
|
|
859
|
+
aqua: [0, 255, 255],
|
|
860
|
+
aquamarine: [127, 255, 212],
|
|
861
|
+
azure: [240, 255, 255],
|
|
862
|
+
beige: [245, 245, 220],
|
|
863
|
+
bisque: [255, 228, 196],
|
|
864
|
+
black: [0, 0, 0],
|
|
865
|
+
blanchedalmond: [255, 235, 205],
|
|
866
|
+
blue: [0, 0, 255],
|
|
867
|
+
blueviolet: [138, 43, 226],
|
|
868
|
+
brown: [165, 42, 42],
|
|
869
|
+
burlywood: [222, 184, 135],
|
|
870
|
+
cadetblue: [95, 158, 160],
|
|
871
|
+
chartreuse: [127, 255, 0],
|
|
872
|
+
chocolate: [210, 105, 30],
|
|
873
|
+
coral: [255, 127, 80],
|
|
874
|
+
cornflowerblue: [100, 149, 237],
|
|
875
|
+
cornsilk: [255, 248, 220],
|
|
876
|
+
crimson: [220, 20, 60],
|
|
877
|
+
cyan: [0, 255, 255],
|
|
878
|
+
darkblue: [0, 0, 139],
|
|
879
|
+
darkcyan: [0, 139, 139],
|
|
880
|
+
darkgoldenrod: [184, 134, 11],
|
|
881
|
+
darkgray: [169, 169, 169],
|
|
882
|
+
darkgreen: [0, 100, 0],
|
|
883
|
+
darkgrey: [169, 169, 169],
|
|
884
|
+
darkkhaki: [189, 183, 107],
|
|
885
|
+
darkmagenta: [139, 0, 139],
|
|
886
|
+
darkolivegreen: [85, 107, 47],
|
|
887
|
+
darkorange: [255, 140, 0],
|
|
888
|
+
darkorchid: [153, 50, 204],
|
|
889
|
+
darkred: [139, 0, 0],
|
|
890
|
+
darksalmon: [233, 150, 122],
|
|
891
|
+
darkseagreen: [143, 188, 143],
|
|
892
|
+
darkslateblue: [72, 61, 139],
|
|
893
|
+
darkslategray: [47, 79, 79],
|
|
894
|
+
darkslategrey: [47, 79, 79],
|
|
895
|
+
darkturquoise: [0, 206, 209],
|
|
896
|
+
darkviolet: [148, 0, 211],
|
|
897
|
+
deeppink: [255, 20, 147],
|
|
898
|
+
deepskyblue: [0, 191, 255],
|
|
899
|
+
dimgray: [105, 105, 105],
|
|
900
|
+
dimgrey: [105, 105, 105],
|
|
901
|
+
dodgerblue: [30, 144, 255],
|
|
902
|
+
firebrick: [178, 34, 34],
|
|
903
|
+
floralwhite: [255, 250, 240],
|
|
904
|
+
forestgreen: [34, 139, 34],
|
|
905
|
+
fuchsia: [255, 0, 255],
|
|
906
|
+
gainsboro: [220, 220, 220],
|
|
907
|
+
ghostwhite: [248, 248, 255],
|
|
908
|
+
gold: [255, 215, 0],
|
|
909
|
+
goldenrod: [218, 165, 32],
|
|
910
|
+
gray: [128, 128, 128],
|
|
911
|
+
green: [0, 128, 0],
|
|
912
|
+
greenyellow: [173, 255, 47],
|
|
913
|
+
grey: [128, 128, 128],
|
|
914
|
+
honeydew: [240, 255, 240],
|
|
915
|
+
hotpink: [255, 105, 180],
|
|
916
|
+
indianred: [205, 92, 92],
|
|
917
|
+
indigo: [75, 0, 130],
|
|
918
|
+
ivory: [255, 255, 240],
|
|
919
|
+
khaki: [240, 230, 140],
|
|
920
|
+
lavender: [230, 230, 250],
|
|
921
|
+
lavenderblush: [255, 240, 245],
|
|
922
|
+
lawngreen: [124, 252, 0],
|
|
923
|
+
lemonchiffon: [255, 250, 205],
|
|
924
|
+
lightblue: [173, 216, 230],
|
|
925
|
+
lightcoral: [240, 128, 128],
|
|
926
|
+
lightcyan: [224, 255, 255],
|
|
927
|
+
lightgoldenrodyellow: [250, 250, 210],
|
|
928
|
+
lightgray: [211, 211, 211],
|
|
929
|
+
lightgreen: [144, 238, 144],
|
|
930
|
+
lightgrey: [211, 211, 211],
|
|
931
|
+
lightpink: [255, 182, 193],
|
|
932
|
+
lightsalmon: [255, 160, 122],
|
|
933
|
+
lightseagreen: [32, 178, 170],
|
|
934
|
+
lightskyblue: [135, 206, 250],
|
|
935
|
+
lightslategray: [119, 136, 153],
|
|
936
|
+
lightslategrey: [119, 136, 153],
|
|
937
|
+
lightsteelblue: [176, 196, 222],
|
|
938
|
+
lightyellow: [255, 255, 224],
|
|
939
|
+
lime: [0, 255, 0],
|
|
940
|
+
limegreen: [50, 205, 50],
|
|
941
|
+
linen: [250, 240, 230],
|
|
942
|
+
magenta: [255, 0, 255],
|
|
943
|
+
maroon: [128, 0, 0],
|
|
944
|
+
mediumaquamarine: [102, 205, 170],
|
|
945
|
+
mediumblue: [0, 0, 205],
|
|
946
|
+
mediumorchid: [186, 85, 211],
|
|
947
|
+
mediumpurple: [147, 112, 219],
|
|
948
|
+
mediumseagreen: [60, 179, 113],
|
|
949
|
+
mediumslateblue: [123, 104, 238],
|
|
950
|
+
mediumspringgreen: [0, 250, 154],
|
|
951
|
+
mediumturquoise: [72, 209, 204],
|
|
952
|
+
mediumvioletred: [199, 21, 133],
|
|
953
|
+
midnightblue: [25, 25, 112],
|
|
954
|
+
mintcream: [245, 255, 250],
|
|
955
|
+
mistyrose: [255, 228, 225],
|
|
956
|
+
moccasin: [255, 228, 181],
|
|
957
|
+
navajowhite: [255, 222, 173],
|
|
958
|
+
navy: [0, 0, 128],
|
|
959
|
+
oldlace: [253, 245, 230],
|
|
960
|
+
olive: [128, 128, 0],
|
|
961
|
+
olivedrab: [107, 142, 35],
|
|
962
|
+
orange: [255, 165, 0],
|
|
963
|
+
orangered: [255, 69, 0],
|
|
964
|
+
orchid: [218, 112, 214],
|
|
965
|
+
palegoldenrod: [238, 232, 170],
|
|
966
|
+
palegreen: [152, 251, 152],
|
|
967
|
+
paleturquoise: [175, 238, 238],
|
|
968
|
+
palevioletred: [219, 112, 147],
|
|
969
|
+
papayawhip: [255, 239, 213],
|
|
970
|
+
peachpuff: [255, 218, 185],
|
|
971
|
+
peru: [205, 133, 63],
|
|
972
|
+
pink: [255, 192, 203],
|
|
973
|
+
plum: [221, 160, 221],
|
|
974
|
+
powderblue: [176, 224, 230],
|
|
975
|
+
purple: [128, 0, 128],
|
|
976
|
+
rebeccapurple: [102, 51, 153],
|
|
977
|
+
red: [255, 0, 0],
|
|
978
|
+
rosybrown: [188, 143, 143],
|
|
979
|
+
royalblue: [65, 105, 225],
|
|
980
|
+
saddlebrown: [139, 69, 19],
|
|
981
|
+
salmon: [250, 128, 114],
|
|
982
|
+
sandybrown: [244, 164, 96],
|
|
983
|
+
seagreen: [46, 139, 87],
|
|
984
|
+
seashell: [255, 245, 238],
|
|
985
|
+
sienna: [160, 82, 45],
|
|
986
|
+
silver: [192, 192, 192],
|
|
987
|
+
skyblue: [135, 206, 235],
|
|
988
|
+
slateblue: [106, 90, 205],
|
|
989
|
+
slategray: [112, 128, 144],
|
|
990
|
+
slategrey: [112, 128, 144],
|
|
991
|
+
snow: [255, 250, 250],
|
|
992
|
+
springgreen: [0, 255, 127],
|
|
993
|
+
steelblue: [70, 130, 180],
|
|
994
|
+
tan: [210, 180, 140],
|
|
995
|
+
teal: [0, 128, 128],
|
|
996
|
+
thistle: [216, 191, 216],
|
|
997
|
+
tomato: [255, 99, 71],
|
|
998
|
+
turquoise: [64, 224, 208],
|
|
999
|
+
violet: [238, 130, 238],
|
|
1000
|
+
wheat: [245, 222, 179],
|
|
1001
|
+
white: [255, 255, 255],
|
|
1002
|
+
whitesmoke: [245, 245, 245],
|
|
1003
|
+
yellow: [255, 255, 0],
|
|
1004
|
+
yellowgreen: [154, 205, 50]
|
|
1005
|
+
};
|
|
1006
|
+
const z = he, V = {};
|
|
1007
|
+
for (const e of Object.keys(z))
|
|
1008
|
+
V[z[e]] = e;
|
|
1009
|
+
const c = {
|
|
1010
|
+
rgb: { channels: 3, labels: "rgb" },
|
|
1011
|
+
hsl: { channels: 3, labels: "hsl" },
|
|
1012
|
+
hsv: { channels: 3, labels: "hsv" },
|
|
1013
|
+
hwb: { channels: 3, labels: "hwb" },
|
|
1014
|
+
cmyk: { channels: 4, labels: "cmyk" },
|
|
1015
|
+
xyz: { channels: 3, labels: "xyz" },
|
|
1016
|
+
lab: { channels: 3, labels: "lab" },
|
|
1017
|
+
lch: { channels: 3, labels: "lch" },
|
|
1018
|
+
hex: { channels: 1, labels: ["hex"] },
|
|
1019
|
+
keyword: { channels: 1, labels: ["keyword"] },
|
|
1020
|
+
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
1021
|
+
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
1022
|
+
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
1023
|
+
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
1024
|
+
gray: { channels: 1, labels: ["gray"] }
|
|
1025
|
+
};
|
|
1026
|
+
var B = c;
|
|
1027
|
+
for (const e of Object.keys(c)) {
|
|
1028
|
+
if (!("channels" in c[e]))
|
|
1029
|
+
throw new Error("missing channels property: " + e);
|
|
1030
|
+
if (!("labels" in c[e]))
|
|
1031
|
+
throw new Error("missing channel labels property: " + e);
|
|
1032
|
+
if (c[e].labels.length !== c[e].channels)
|
|
1033
|
+
throw new Error("channel and label counts mismatch: " + e);
|
|
1034
|
+
const { channels: t, labels: i } = c[e];
|
|
1035
|
+
delete c[e].channels, delete c[e].labels, Object.defineProperty(c[e], "channels", { value: t }), Object.defineProperty(c[e], "labels", { value: i });
|
|
1036
|
+
}
|
|
1037
|
+
c.rgb.hsl = function(e) {
|
|
1038
|
+
const t = e[0] / 255, i = e[1] / 255, n = e[2] / 255, s = Math.min(t, i, n), a = Math.max(t, i, n), r = a - s;
|
|
1039
|
+
let o, l;
|
|
1040
|
+
a === s ? o = 0 : t === a ? o = (i - n) / r : i === a ? o = 2 + (n - t) / r : n === a && (o = 4 + (t - i) / r), o = Math.min(o * 60, 360), o < 0 && (o += 360);
|
|
1041
|
+
const u = (s + a) / 2;
|
|
1042
|
+
return a === s ? l = 0 : u <= 0.5 ? l = r / (a + s) : l = r / (2 - a - s), [o, l * 100, u * 100];
|
|
1043
|
+
};
|
|
1044
|
+
c.rgb.hsv = function(e) {
|
|
1045
|
+
let t, i, n, s, a;
|
|
1046
|
+
const r = e[0] / 255, o = e[1] / 255, l = e[2] / 255, u = Math.max(r, o, l), d = u - Math.min(r, o, l), h = function(H) {
|
|
1047
|
+
return (u - H) / 6 / d + 1 / 2;
|
|
1048
|
+
};
|
|
1049
|
+
return d === 0 ? (s = 0, a = 0) : (a = d / u, t = h(r), i = h(o), n = h(l), r === u ? s = n - i : o === u ? s = 1 / 3 + t - n : l === u && (s = 2 / 3 + i - t), s < 0 ? s += 1 : s > 1 && (s -= 1)), [
|
|
1050
|
+
s * 360,
|
|
1051
|
+
a * 100,
|
|
1052
|
+
u * 100
|
|
1053
|
+
];
|
|
1054
|
+
};
|
|
1055
|
+
c.rgb.hwb = function(e) {
|
|
1056
|
+
const t = e[0], i = e[1];
|
|
1057
|
+
let n = e[2];
|
|
1058
|
+
const s = c.rgb.hsl(e)[0], a = 1 / 255 * Math.min(t, Math.min(i, n));
|
|
1059
|
+
return n = 1 - 1 / 255 * Math.max(t, Math.max(i, n)), [s, a * 100, n * 100];
|
|
1060
|
+
};
|
|
1061
|
+
c.rgb.cmyk = function(e) {
|
|
1062
|
+
const t = e[0] / 255, i = e[1] / 255, n = e[2] / 255, s = Math.min(1 - t, 1 - i, 1 - n), a = (1 - t - s) / (1 - s) || 0, r = (1 - i - s) / (1 - s) || 0, o = (1 - n - s) / (1 - s) || 0;
|
|
1063
|
+
return [a * 100, r * 100, o * 100, s * 100];
|
|
1064
|
+
};
|
|
1065
|
+
function de(e, t) {
|
|
1066
|
+
return (e[0] - t[0]) ** 2 + (e[1] - t[1]) ** 2 + (e[2] - t[2]) ** 2;
|
|
1067
|
+
}
|
|
1068
|
+
c.rgb.keyword = function(e) {
|
|
1069
|
+
const t = V[e];
|
|
1070
|
+
if (t)
|
|
1071
|
+
return t;
|
|
1072
|
+
let i = 1 / 0, n;
|
|
1073
|
+
for (const s of Object.keys(z)) {
|
|
1074
|
+
const a = z[s], r = de(e, a);
|
|
1075
|
+
r < i && (i = r, n = s);
|
|
1076
|
+
}
|
|
1077
|
+
return n;
|
|
1078
|
+
};
|
|
1079
|
+
c.keyword.rgb = function(e) {
|
|
1080
|
+
return z[e];
|
|
1081
|
+
};
|
|
1082
|
+
c.rgb.xyz = function(e) {
|
|
1083
|
+
let t = e[0] / 255, i = e[1] / 255, n = e[2] / 255;
|
|
1084
|
+
t = t > 0.04045 ? ((t + 0.055) / 1.055) ** 2.4 : t / 12.92, i = i > 0.04045 ? ((i + 0.055) / 1.055) ** 2.4 : i / 12.92, n = n > 0.04045 ? ((n + 0.055) / 1.055) ** 2.4 : n / 12.92;
|
|
1085
|
+
const s = t * 0.4124 + i * 0.3576 + n * 0.1805, a = t * 0.2126 + i * 0.7152 + n * 0.0722, r = t * 0.0193 + i * 0.1192 + n * 0.9505;
|
|
1086
|
+
return [s * 100, a * 100, r * 100];
|
|
1087
|
+
};
|
|
1088
|
+
c.rgb.lab = function(e) {
|
|
1089
|
+
const t = c.rgb.xyz(e);
|
|
1090
|
+
let i = t[0], n = t[1], s = t[2];
|
|
1091
|
+
i /= 95.047, n /= 100, s /= 108.883, i = i > 8856e-6 ? i ** (1 / 3) : 7.787 * i + 16 / 116, n = n > 8856e-6 ? n ** (1 / 3) : 7.787 * n + 16 / 116, s = s > 8856e-6 ? s ** (1 / 3) : 7.787 * s + 16 / 116;
|
|
1092
|
+
const a = 116 * n - 16, r = 500 * (i - n), o = 200 * (n - s);
|
|
1093
|
+
return [a, r, o];
|
|
1094
|
+
};
|
|
1095
|
+
c.hsl.rgb = function(e) {
|
|
1096
|
+
const t = e[0] / 360, i = e[1] / 100, n = e[2] / 100;
|
|
1097
|
+
let s, a, r;
|
|
1098
|
+
if (i === 0)
|
|
1099
|
+
return r = n * 255, [r, r, r];
|
|
1100
|
+
n < 0.5 ? s = n * (1 + i) : s = n + i - n * i;
|
|
1101
|
+
const o = 2 * n - s, l = [0, 0, 0];
|
|
1102
|
+
for (let u = 0; u < 3; u++)
|
|
1103
|
+
a = t + 1 / 3 * -(u - 1), a < 0 && a++, a > 1 && a--, 6 * a < 1 ? r = o + (s - o) * 6 * a : 2 * a < 1 ? r = s : 3 * a < 2 ? r = o + (s - o) * (2 / 3 - a) * 6 : r = o, l[u] = r * 255;
|
|
1104
|
+
return l;
|
|
1105
|
+
};
|
|
1106
|
+
c.hsl.hsv = function(e) {
|
|
1107
|
+
const t = e[0];
|
|
1108
|
+
let i = e[1] / 100, n = e[2] / 100, s = i;
|
|
1109
|
+
const a = Math.max(n, 0.01);
|
|
1110
|
+
n *= 2, i *= n <= 1 ? n : 2 - n, s *= a <= 1 ? a : 2 - a;
|
|
1111
|
+
const r = (n + i) / 2, o = n === 0 ? 2 * s / (a + s) : 2 * i / (n + i);
|
|
1112
|
+
return [t, o * 100, r * 100];
|
|
1113
|
+
};
|
|
1114
|
+
c.hsv.rgb = function(e) {
|
|
1115
|
+
const t = e[0] / 60, i = e[1] / 100;
|
|
1116
|
+
let n = e[2] / 100;
|
|
1117
|
+
const s = Math.floor(t) % 6, a = t - Math.floor(t), r = 255 * n * (1 - i), o = 255 * n * (1 - i * a), l = 255 * n * (1 - i * (1 - a));
|
|
1118
|
+
switch (n *= 255, s) {
|
|
1119
|
+
case 0:
|
|
1120
|
+
return [n, l, r];
|
|
1121
|
+
case 1:
|
|
1122
|
+
return [o, n, r];
|
|
1123
|
+
case 2:
|
|
1124
|
+
return [r, n, l];
|
|
1125
|
+
case 3:
|
|
1126
|
+
return [r, o, n];
|
|
1127
|
+
case 4:
|
|
1128
|
+
return [l, r, n];
|
|
1129
|
+
case 5:
|
|
1130
|
+
return [n, r, o];
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
c.hsv.hsl = function(e) {
|
|
1134
|
+
const t = e[0], i = e[1] / 100, n = e[2] / 100, s = Math.max(n, 0.01);
|
|
1135
|
+
let a, r;
|
|
1136
|
+
r = (2 - i) * n;
|
|
1137
|
+
const o = (2 - i) * s;
|
|
1138
|
+
return a = i * s, a /= o <= 1 ? o : 2 - o, a = a || 0, r /= 2, [t, a * 100, r * 100];
|
|
1139
|
+
};
|
|
1140
|
+
c.hwb.rgb = function(e) {
|
|
1141
|
+
const t = e[0] / 360;
|
|
1142
|
+
let i = e[1] / 100, n = e[2] / 100;
|
|
1143
|
+
const s = i + n;
|
|
1144
|
+
let a;
|
|
1145
|
+
s > 1 && (i /= s, n /= s);
|
|
1146
|
+
const r = Math.floor(6 * t), o = 1 - n;
|
|
1147
|
+
a = 6 * t - r, r & 1 && (a = 1 - a);
|
|
1148
|
+
const l = i + a * (o - i);
|
|
1149
|
+
let u, d, h;
|
|
1150
|
+
switch (r) {
|
|
1151
|
+
default:
|
|
1152
|
+
case 6:
|
|
1153
|
+
case 0:
|
|
1154
|
+
u = o, d = l, h = i;
|
|
1155
|
+
break;
|
|
1156
|
+
case 1:
|
|
1157
|
+
u = l, d = o, h = i;
|
|
1158
|
+
break;
|
|
1159
|
+
case 2:
|
|
1160
|
+
u = i, d = o, h = l;
|
|
1161
|
+
break;
|
|
1162
|
+
case 3:
|
|
1163
|
+
u = i, d = l, h = o;
|
|
1164
|
+
break;
|
|
1165
|
+
case 4:
|
|
1166
|
+
u = l, d = i, h = o;
|
|
1167
|
+
break;
|
|
1168
|
+
case 5:
|
|
1169
|
+
u = o, d = i, h = l;
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
return [u * 255, d * 255, h * 255];
|
|
1173
|
+
};
|
|
1174
|
+
c.cmyk.rgb = function(e) {
|
|
1175
|
+
const t = e[0] / 100, i = e[1] / 100, n = e[2] / 100, s = e[3] / 100, a = 1 - Math.min(1, t * (1 - s) + s), r = 1 - Math.min(1, i * (1 - s) + s), o = 1 - Math.min(1, n * (1 - s) + s);
|
|
1176
|
+
return [a * 255, r * 255, o * 255];
|
|
1177
|
+
};
|
|
1178
|
+
c.xyz.rgb = function(e) {
|
|
1179
|
+
const t = e[0] / 100, i = e[1] / 100, n = e[2] / 100;
|
|
1180
|
+
let s, a, r;
|
|
1181
|
+
return s = t * 3.2406 + i * -1.5372 + n * -0.4986, a = t * -0.9689 + i * 1.8758 + n * 0.0415, r = t * 0.0557 + i * -0.204 + n * 1.057, s = s > 31308e-7 ? 1.055 * s ** (1 / 2.4) - 0.055 : s * 12.92, a = a > 31308e-7 ? 1.055 * a ** (1 / 2.4) - 0.055 : a * 12.92, r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92, s = Math.min(Math.max(0, s), 1), a = Math.min(Math.max(0, a), 1), r = Math.min(Math.max(0, r), 1), [s * 255, a * 255, r * 255];
|
|
1182
|
+
};
|
|
1183
|
+
c.xyz.lab = function(e) {
|
|
1184
|
+
let t = e[0], i = e[1], n = e[2];
|
|
1185
|
+
t /= 95.047, i /= 100, n /= 108.883, t = t > 8856e-6 ? t ** (1 / 3) : 7.787 * t + 16 / 116, i = i > 8856e-6 ? i ** (1 / 3) : 7.787 * i + 16 / 116, n = n > 8856e-6 ? n ** (1 / 3) : 7.787 * n + 16 / 116;
|
|
1186
|
+
const s = 116 * i - 16, a = 500 * (t - i), r = 200 * (i - n);
|
|
1187
|
+
return [s, a, r];
|
|
1188
|
+
};
|
|
1189
|
+
c.lab.xyz = function(e) {
|
|
1190
|
+
const t = e[0], i = e[1], n = e[2];
|
|
1191
|
+
let s, a, r;
|
|
1192
|
+
a = (t + 16) / 116, s = i / 500 + a, r = a - n / 200;
|
|
1193
|
+
const o = a ** 3, l = s ** 3, u = r ** 3;
|
|
1194
|
+
return a = o > 8856e-6 ? o : (a - 16 / 116) / 7.787, s = l > 8856e-6 ? l : (s - 16 / 116) / 7.787, r = u > 8856e-6 ? u : (r - 16 / 116) / 7.787, s *= 95.047, a *= 100, r *= 108.883, [s, a, r];
|
|
1195
|
+
};
|
|
1196
|
+
c.lab.lch = function(e) {
|
|
1197
|
+
const t = e[0], i = e[1], n = e[2];
|
|
1198
|
+
let s;
|
|
1199
|
+
s = Math.atan2(n, i) * 360 / 2 / Math.PI, s < 0 && (s += 360);
|
|
1200
|
+
const r = Math.sqrt(i * i + n * n);
|
|
1201
|
+
return [t, r, s];
|
|
1202
|
+
};
|
|
1203
|
+
c.lch.lab = function(e) {
|
|
1204
|
+
const t = e[0], i = e[1], s = e[2] / 360 * 2 * Math.PI, a = i * Math.cos(s), r = i * Math.sin(s);
|
|
1205
|
+
return [t, a, r];
|
|
1206
|
+
};
|
|
1207
|
+
c.rgb.ansi16 = function(e, t = null) {
|
|
1208
|
+
const [i, n, s] = e;
|
|
1209
|
+
let a = t === null ? c.rgb.hsv(e)[2] : t;
|
|
1210
|
+
if (a = Math.round(a / 50), a === 0)
|
|
1211
|
+
return 30;
|
|
1212
|
+
let r = 30 + (Math.round(s / 255) << 2 | Math.round(n / 255) << 1 | Math.round(i / 255));
|
|
1213
|
+
return a === 2 && (r += 60), r;
|
|
1214
|
+
};
|
|
1215
|
+
c.hsv.ansi16 = function(e) {
|
|
1216
|
+
return c.rgb.ansi16(c.hsv.rgb(e), e[2]);
|
|
1217
|
+
};
|
|
1218
|
+
c.rgb.ansi256 = function(e) {
|
|
1219
|
+
const t = e[0], i = e[1], n = e[2];
|
|
1220
|
+
return t === i && i === n ? t < 8 ? 16 : t > 248 ? 231 : Math.round((t - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(t / 255 * 5) + 6 * Math.round(i / 255 * 5) + Math.round(n / 255 * 5);
|
|
1221
|
+
};
|
|
1222
|
+
c.ansi16.rgb = function(e) {
|
|
1223
|
+
let t = e % 10;
|
|
1224
|
+
if (t === 0 || t === 7)
|
|
1225
|
+
return e > 50 && (t += 3.5), t = t / 10.5 * 255, [t, t, t];
|
|
1226
|
+
const i = (~~(e > 50) + 1) * 0.5, n = (t & 1) * i * 255, s = (t >> 1 & 1) * i * 255, a = (t >> 2 & 1) * i * 255;
|
|
1227
|
+
return [n, s, a];
|
|
1228
|
+
};
|
|
1229
|
+
c.ansi256.rgb = function(e) {
|
|
1230
|
+
if (e >= 232) {
|
|
1231
|
+
const a = (e - 232) * 10 + 8;
|
|
1232
|
+
return [a, a, a];
|
|
1233
|
+
}
|
|
1234
|
+
e -= 16;
|
|
1235
|
+
let t;
|
|
1236
|
+
const i = Math.floor(e / 36) / 5 * 255, n = Math.floor((t = e % 36) / 6) / 5 * 255, s = t % 6 / 5 * 255;
|
|
1237
|
+
return [i, n, s];
|
|
1238
|
+
};
|
|
1239
|
+
c.rgb.hex = function(e) {
|
|
1240
|
+
const i = (((Math.round(e[0]) & 255) << 16) + ((Math.round(e[1]) & 255) << 8) + (Math.round(e[2]) & 255)).toString(16).toUpperCase();
|
|
1241
|
+
return "000000".substring(i.length) + i;
|
|
1242
|
+
};
|
|
1243
|
+
c.hex.rgb = function(e) {
|
|
1244
|
+
const t = e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
1245
|
+
if (!t)
|
|
1246
|
+
return [0, 0, 0];
|
|
1247
|
+
let i = t[0];
|
|
1248
|
+
t[0].length === 3 && (i = i.split("").map((o) => o + o).join(""));
|
|
1249
|
+
const n = parseInt(i, 16), s = n >> 16 & 255, a = n >> 8 & 255, r = n & 255;
|
|
1250
|
+
return [s, a, r];
|
|
1251
|
+
};
|
|
1252
|
+
c.rgb.hcg = function(e) {
|
|
1253
|
+
const t = e[0] / 255, i = e[1] / 255, n = e[2] / 255, s = Math.max(Math.max(t, i), n), a = Math.min(Math.min(t, i), n), r = s - a;
|
|
1254
|
+
let o, l;
|
|
1255
|
+
return r < 1 ? o = a / (1 - r) : o = 0, r <= 0 ? l = 0 : s === t ? l = (i - n) / r % 6 : s === i ? l = 2 + (n - t) / r : l = 4 + (t - i) / r, l /= 6, l %= 1, [l * 360, r * 100, o * 100];
|
|
1256
|
+
};
|
|
1257
|
+
c.hsl.hcg = function(e) {
|
|
1258
|
+
const t = e[1] / 100, i = e[2] / 100, n = i < 0.5 ? 2 * t * i : 2 * t * (1 - i);
|
|
1259
|
+
let s = 0;
|
|
1260
|
+
return n < 1 && (s = (i - 0.5 * n) / (1 - n)), [e[0], n * 100, s * 100];
|
|
1261
|
+
};
|
|
1262
|
+
c.hsv.hcg = function(e) {
|
|
1263
|
+
const t = e[1] / 100, i = e[2] / 100, n = t * i;
|
|
1264
|
+
let s = 0;
|
|
1265
|
+
return n < 1 && (s = (i - n) / (1 - n)), [e[0], n * 100, s * 100];
|
|
1266
|
+
};
|
|
1267
|
+
c.hcg.rgb = function(e) {
|
|
1268
|
+
const t = e[0] / 360, i = e[1] / 100, n = e[2] / 100;
|
|
1269
|
+
if (i === 0)
|
|
1270
|
+
return [n * 255, n * 255, n * 255];
|
|
1271
|
+
const s = [0, 0, 0], a = t % 1 * 6, r = a % 1, o = 1 - r;
|
|
1272
|
+
let l = 0;
|
|
1273
|
+
switch (Math.floor(a)) {
|
|
1274
|
+
case 0:
|
|
1275
|
+
s[0] = 1, s[1] = r, s[2] = 0;
|
|
1276
|
+
break;
|
|
1277
|
+
case 1:
|
|
1278
|
+
s[0] = o, s[1] = 1, s[2] = 0;
|
|
1279
|
+
break;
|
|
1280
|
+
case 2:
|
|
1281
|
+
s[0] = 0, s[1] = 1, s[2] = r;
|
|
1282
|
+
break;
|
|
1283
|
+
case 3:
|
|
1284
|
+
s[0] = 0, s[1] = o, s[2] = 1;
|
|
1285
|
+
break;
|
|
1286
|
+
case 4:
|
|
1287
|
+
s[0] = r, s[1] = 0, s[2] = 1;
|
|
1288
|
+
break;
|
|
1289
|
+
default:
|
|
1290
|
+
s[0] = 1, s[1] = 0, s[2] = o;
|
|
1291
|
+
}
|
|
1292
|
+
return l = (1 - i) * n, [
|
|
1293
|
+
(i * s[0] + l) * 255,
|
|
1294
|
+
(i * s[1] + l) * 255,
|
|
1295
|
+
(i * s[2] + l) * 255
|
|
1296
|
+
];
|
|
1297
|
+
};
|
|
1298
|
+
c.hcg.hsv = function(e) {
|
|
1299
|
+
const t = e[1] / 100, i = e[2] / 100, n = t + i * (1 - t);
|
|
1300
|
+
let s = 0;
|
|
1301
|
+
return n > 0 && (s = t / n), [e[0], s * 100, n * 100];
|
|
1302
|
+
};
|
|
1303
|
+
c.hcg.hsl = function(e) {
|
|
1304
|
+
const t = e[1] / 100, n = e[2] / 100 * (1 - t) + 0.5 * t;
|
|
1305
|
+
let s = 0;
|
|
1306
|
+
return n > 0 && n < 0.5 ? s = t / (2 * n) : n >= 0.5 && n < 1 && (s = t / (2 * (1 - n))), [e[0], s * 100, n * 100];
|
|
1307
|
+
};
|
|
1308
|
+
c.hcg.hwb = function(e) {
|
|
1309
|
+
const t = e[1] / 100, i = e[2] / 100, n = t + i * (1 - t);
|
|
1310
|
+
return [e[0], (n - t) * 100, (1 - n) * 100];
|
|
1311
|
+
};
|
|
1312
|
+
c.hwb.hcg = function(e) {
|
|
1313
|
+
const t = e[1] / 100, n = 1 - e[2] / 100, s = n - t;
|
|
1314
|
+
let a = 0;
|
|
1315
|
+
return s < 1 && (a = (n - s) / (1 - s)), [e[0], s * 100, a * 100];
|
|
1316
|
+
};
|
|
1317
|
+
c.apple.rgb = function(e) {
|
|
1318
|
+
return [e[0] / 65535 * 255, e[1] / 65535 * 255, e[2] / 65535 * 255];
|
|
1319
|
+
};
|
|
1320
|
+
c.rgb.apple = function(e) {
|
|
1321
|
+
return [e[0] / 255 * 65535, e[1] / 255 * 65535, e[2] / 255 * 65535];
|
|
1322
|
+
};
|
|
1323
|
+
c.gray.rgb = function(e) {
|
|
1324
|
+
return [e[0] / 100 * 255, e[0] / 100 * 255, e[0] / 100 * 255];
|
|
1325
|
+
};
|
|
1326
|
+
c.gray.hsl = function(e) {
|
|
1327
|
+
return [0, 0, e[0]];
|
|
1328
|
+
};
|
|
1329
|
+
c.gray.hsv = c.gray.hsl;
|
|
1330
|
+
c.gray.hwb = function(e) {
|
|
1331
|
+
return [0, 100, e[0]];
|
|
1332
|
+
};
|
|
1333
|
+
c.gray.cmyk = function(e) {
|
|
1334
|
+
return [0, 0, 0, e[0]];
|
|
1335
|
+
};
|
|
1336
|
+
c.gray.lab = function(e) {
|
|
1337
|
+
return [e[0], 0, 0];
|
|
1338
|
+
};
|
|
1339
|
+
c.gray.hex = function(e) {
|
|
1340
|
+
const t = Math.round(e[0] / 100 * 255) & 255, n = ((t << 16) + (t << 8) + t).toString(16).toUpperCase();
|
|
1341
|
+
return "000000".substring(n.length) + n;
|
|
1342
|
+
};
|
|
1343
|
+
c.rgb.gray = function(e) {
|
|
1344
|
+
return [(e[0] + e[1] + e[2]) / 3 / 255 * 100];
|
|
1345
|
+
};
|
|
1346
|
+
const k = B;
|
|
1347
|
+
function pe() {
|
|
1348
|
+
const e = {}, t = Object.keys(k);
|
|
1349
|
+
for (let i = t.length, n = 0; n < i; n++)
|
|
1350
|
+
e[t[n]] = {
|
|
1351
|
+
// http://jsperf.com/1-vs-infinity
|
|
1352
|
+
// micro-opt, but this is simple.
|
|
1353
|
+
distance: -1,
|
|
1354
|
+
parent: null
|
|
1355
|
+
};
|
|
1356
|
+
return e;
|
|
1357
|
+
}
|
|
1358
|
+
function me(e) {
|
|
1359
|
+
const t = pe(), i = [e];
|
|
1360
|
+
for (t[e].distance = 0; i.length; ) {
|
|
1361
|
+
const n = i.pop(), s = Object.keys(k[n]);
|
|
1362
|
+
for (let a = s.length, r = 0; r < a; r++) {
|
|
1363
|
+
const o = s[r], l = t[o];
|
|
1364
|
+
l.distance === -1 && (l.distance = t[n].distance + 1, l.parent = n, i.unshift(o));
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
return t;
|
|
1368
|
+
}
|
|
1369
|
+
function fe(e, t) {
|
|
1370
|
+
return function(i) {
|
|
1371
|
+
return t(e(i));
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
function ve(e, t) {
|
|
1375
|
+
const i = [t[e].parent, e];
|
|
1376
|
+
let n = k[t[e].parent][e], s = t[e].parent;
|
|
1377
|
+
for (; t[s].parent; )
|
|
1378
|
+
i.unshift(t[s].parent), n = fe(k[t[s].parent][s], n), s = t[s].parent;
|
|
1379
|
+
return n.conversion = i, n;
|
|
1380
|
+
}
|
|
1381
|
+
var ge = function(e) {
|
|
1382
|
+
const t = me(e), i = {}, n = Object.keys(t);
|
|
1383
|
+
for (let s = n.length, a = 0; a < s; a++) {
|
|
1384
|
+
const r = n[a];
|
|
1385
|
+
t[r].parent !== null && (i[r] = ve(r, t));
|
|
1386
|
+
}
|
|
1387
|
+
return i;
|
|
1388
|
+
};
|
|
1389
|
+
const R = B, Se = ge, S = {}, be = Object.keys(R);
|
|
1390
|
+
function ze(e) {
|
|
1391
|
+
const t = function(...i) {
|
|
1392
|
+
const n = i[0];
|
|
1393
|
+
return n == null ? n : (n.length > 1 && (i = n), e(i));
|
|
1394
|
+
};
|
|
1395
|
+
return "conversion" in e && (t.conversion = e.conversion), t;
|
|
1396
|
+
}
|
|
1397
|
+
function Pe(e) {
|
|
1398
|
+
const t = function(...i) {
|
|
1399
|
+
const n = i[0];
|
|
1400
|
+
if (n == null)
|
|
1401
|
+
return n;
|
|
1402
|
+
n.length > 1 && (i = n);
|
|
1403
|
+
const s = e(i);
|
|
1404
|
+
if (typeof s == "object")
|
|
1405
|
+
for (let a = s.length, r = 0; r < a; r++)
|
|
1406
|
+
s[r] = Math.round(s[r]);
|
|
1407
|
+
return s;
|
|
1408
|
+
};
|
|
1409
|
+
return "conversion" in e && (t.conversion = e.conversion), t;
|
|
1410
|
+
}
|
|
1411
|
+
be.forEach((e) => {
|
|
1412
|
+
S[e] = {}, Object.defineProperty(S[e], "channels", { value: R[e].channels }), Object.defineProperty(S[e], "labels", { value: R[e].labels });
|
|
1413
|
+
const t = Se(e);
|
|
1414
|
+
Object.keys(t).forEach((n) => {
|
|
1415
|
+
const s = t[n];
|
|
1416
|
+
S[e][n] = Pe(s), S[e][n].raw = ze(s);
|
|
1417
|
+
});
|
|
1418
|
+
});
|
|
1419
|
+
Object.assign({
|
|
1420
|
+
generateRequestId: O,
|
|
1421
|
+
createJsonRpcRequest: F
|
|
1422
|
+
}, le);
|
|
1423
|
+
class ye {
|
|
1424
|
+
constructor() {
|
|
1425
|
+
f(this, "_knimeService");
|
|
1426
|
+
f(this, "_jsonDataService");
|
|
1427
|
+
f(this, "_dialogService");
|
|
1428
|
+
f(this, "_settings", null);
|
|
1429
|
+
f(this, "_eventHandlers", {});
|
|
1430
|
+
f(this, "_runEventPoller", !0);
|
|
1431
|
+
const t = async () => {
|
|
1432
|
+
const s = new v();
|
|
1433
|
+
return await s.waitForInitialization(), s;
|
|
1434
|
+
};
|
|
1435
|
+
this._knimeService = t();
|
|
1436
|
+
const i = async () => {
|
|
1437
|
+
const s = await this._knimeService, a = new oe(s);
|
|
1438
|
+
return a.registerDataGetter(() => this._settings), a;
|
|
1439
|
+
};
|
|
1440
|
+
this._jsonDataService = i();
|
|
1441
|
+
const n = async () => {
|
|
1442
|
+
const s = await this._knimeService;
|
|
1443
|
+
return new ue(s);
|
|
1444
|
+
};
|
|
1445
|
+
this._dialogService = n(), this.eventPoller();
|
|
1446
|
+
}
|
|
1447
|
+
async eventPoller() {
|
|
1448
|
+
for (; this._runEventPoller; ) {
|
|
1449
|
+
const t = await this.sendToService("getEvent");
|
|
1450
|
+
if (t)
|
|
1451
|
+
if (t.type in this._eventHandlers)
|
|
1452
|
+
this._eventHandlers[t.type](t.data);
|
|
1453
|
+
else
|
|
1454
|
+
throw new Error(
|
|
1455
|
+
`Got unexpected event from Java with type ${t.type}`
|
|
1456
|
+
);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
stopEventPoller() {
|
|
1460
|
+
this._runEventPoller = !1;
|
|
1461
|
+
}
|
|
1462
|
+
async sendToService(t, i) {
|
|
1463
|
+
return (await this._jsonDataService).data({
|
|
1464
|
+
method: t,
|
|
1465
|
+
options: i
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
async getInitialSettings() {
|
|
1469
|
+
return (await this._jsonDataService).initialData();
|
|
1470
|
+
}
|
|
1471
|
+
async getFlowVariableSettings() {
|
|
1472
|
+
return (await this._dialogService).getFlowVariableSettings();
|
|
1473
|
+
}
|
|
1474
|
+
async saveSettings(t) {
|
|
1475
|
+
this._settings = t, (await this._jsonDataService).applyData();
|
|
1476
|
+
}
|
|
1477
|
+
registerEventHandler(t, i) {
|
|
1478
|
+
this._eventHandlers[t] = i;
|
|
1479
|
+
}
|
|
1480
|
+
registerLanguageServerEventHandler(t) {
|
|
1481
|
+
this.registerEventHandler("language-server", t);
|
|
1482
|
+
}
|
|
1483
|
+
registerConsoleEventHandler(t) {
|
|
1484
|
+
this.registerEventHandler("console", t);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
let P;
|
|
1488
|
+
const Ee = (e) => (typeof P > "u" && (typeof e > "u" ? P = new ye() : P = e), P), we = /* @__PURE__ */ q({
|
|
1489
|
+
__name: "CodeEditor",
|
|
1490
|
+
props: {
|
|
11
1491
|
language: {
|
|
12
1492
|
type: String,
|
|
13
1493
|
default: null
|
|
@@ -18,19 +1498,22 @@ const p = /* @__PURE__ */ l({
|
|
|
18
1498
|
}
|
|
19
1499
|
},
|
|
20
1500
|
emits: ["monaco-created"],
|
|
21
|
-
setup(
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
1501
|
+
setup(e, { emit: t }) {
|
|
1502
|
+
const i = e;
|
|
1503
|
+
let n, s;
|
|
1504
|
+
const a = Y(null);
|
|
1505
|
+
return Q(async () => {
|
|
1506
|
+
if (a.value === null)
|
|
25
1507
|
throw new Error(
|
|
26
1508
|
"Editor reference is null. This is an implementation error"
|
|
27
1509
|
);
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
i.
|
|
32
|
-
|
|
33
|
-
|
|
1510
|
+
const r = (await Ee().getInitialSettings()).script;
|
|
1511
|
+
n = C.editor.createModel(
|
|
1512
|
+
r,
|
|
1513
|
+
i.language,
|
|
1514
|
+
C.Uri.parse(`inmemory://${i.fileName}`)
|
|
1515
|
+
), s = C.editor.create(a.value, {
|
|
1516
|
+
model: n,
|
|
34
1517
|
glyphMargin: !1,
|
|
35
1518
|
lightbulb: {
|
|
36
1519
|
enabled: !0
|
|
@@ -39,21 +1522,223 @@ const p = /* @__PURE__ */ l({
|
|
|
39
1522
|
automaticLayout: !0,
|
|
40
1523
|
scrollBeyondLastLine: !0,
|
|
41
1524
|
fixedOverflowWidgets: !0
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
|
|
1525
|
+
}), t("monaco-created", { editor: s, editorModel: n });
|
|
1526
|
+
}), Z(() => {
|
|
1527
|
+
typeof n < "u" && n.dispose(), typeof s < "u" && s.dispose();
|
|
1528
|
+
}), (r, o) => (D(), N("div", {
|
|
45
1529
|
ref_key: "editorRef",
|
|
46
|
-
ref:
|
|
1530
|
+
ref: a,
|
|
47
1531
|
class: "code-editor"
|
|
48
1532
|
}, null, 512));
|
|
49
1533
|
}
|
|
50
1534
|
});
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
for (const [
|
|
54
|
-
|
|
55
|
-
return
|
|
56
|
-
},
|
|
1535
|
+
const G = (e, t) => {
|
|
1536
|
+
const i = e.__vccOpts || e;
|
|
1537
|
+
for (const [n, s] of t)
|
|
1538
|
+
i[n] = s;
|
|
1539
|
+
return i;
|
|
1540
|
+
}, ke = /* @__PURE__ */ G(we, [["__scopeId", "data-v-2a674232"]]), xe = q({
|
|
1541
|
+
name: "ScriptingEditor",
|
|
1542
|
+
components: {
|
|
1543
|
+
Splitpanes: ee,
|
|
1544
|
+
Pane: se,
|
|
1545
|
+
CodeEditor: ke
|
|
1546
|
+
},
|
|
1547
|
+
props: {
|
|
1548
|
+
language: {
|
|
1549
|
+
type: String,
|
|
1550
|
+
default: null
|
|
1551
|
+
},
|
|
1552
|
+
fileName: {
|
|
1553
|
+
type: String,
|
|
1554
|
+
default: null
|
|
1555
|
+
},
|
|
1556
|
+
rightPaneLayout: {
|
|
1557
|
+
type: String,
|
|
1558
|
+
default: "fixed"
|
|
1559
|
+
}
|
|
1560
|
+
},
|
|
1561
|
+
emits: ["monaco-created"],
|
|
1562
|
+
data() {
|
|
1563
|
+
return {
|
|
1564
|
+
currentPaneSizes: {
|
|
1565
|
+
left: 20,
|
|
1566
|
+
right: 25,
|
|
1567
|
+
bottom: 30
|
|
1568
|
+
},
|
|
1569
|
+
initialPaneSizes: {
|
|
1570
|
+
left: 20,
|
|
1571
|
+
right: 25,
|
|
1572
|
+
bottom: 30
|
|
1573
|
+
},
|
|
1574
|
+
previousPaneSizes: {
|
|
1575
|
+
left: 20,
|
|
1576
|
+
right: 25,
|
|
1577
|
+
bottom: 30
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
},
|
|
1581
|
+
computed: {
|
|
1582
|
+
usedMainPaneSize() {
|
|
1583
|
+
return 100 - this.currentPaneSizes.left;
|
|
1584
|
+
},
|
|
1585
|
+
usedHorizontalCodeEditorPaneSize() {
|
|
1586
|
+
return 100 - this.currentPaneSizes.right;
|
|
1587
|
+
},
|
|
1588
|
+
usedVerticalCodeEditorPaneSize() {
|
|
1589
|
+
return 100 - this.currentPaneSizes.bottom;
|
|
1590
|
+
},
|
|
1591
|
+
isLeftPaneCollapsed() {
|
|
1592
|
+
return this.currentPaneSizes.left === 0;
|
|
1593
|
+
},
|
|
1594
|
+
isRightPaneCollapsed() {
|
|
1595
|
+
return this.currentPaneSizes.right === 0;
|
|
1596
|
+
},
|
|
1597
|
+
isBottomPaneCollapsed() {
|
|
1598
|
+
return this.currentPaneSizes.bottom === 0;
|
|
1599
|
+
}
|
|
1600
|
+
},
|
|
1601
|
+
methods: {
|
|
1602
|
+
collapsePane(e) {
|
|
1603
|
+
let t = this.currentPaneSizes[e] === 0 ? this.previousPaneSizes[e] : 0;
|
|
1604
|
+
e === "left" && this.updateRightPane(t), this.resizePane(t, e);
|
|
1605
|
+
},
|
|
1606
|
+
resizePane(e, t, i = !0) {
|
|
1607
|
+
this.currentPaneSizes[t] = e, i && this.updatePreviousPaneSize(t);
|
|
1608
|
+
},
|
|
1609
|
+
updatePreviousPaneSize(e) {
|
|
1610
|
+
this.currentPaneSizes[e] <= 0 || (this.previousPaneSizes[e] = this.currentPaneSizes[e]);
|
|
1611
|
+
},
|
|
1612
|
+
updateRightPane(e) {
|
|
1613
|
+
if (this.rightPaneLayout !== "fixed" || this.currentPaneSizes.right <= 0)
|
|
1614
|
+
return;
|
|
1615
|
+
const t = 100 - e, n = (100 - this.currentPaneSizes.left) * (this.previousPaneSizes.right / 100) / t * 100;
|
|
1616
|
+
this.resizePane(n, "right", !1);
|
|
1617
|
+
},
|
|
1618
|
+
onMonacoCreated({
|
|
1619
|
+
editor: e,
|
|
1620
|
+
editorModel: t
|
|
1621
|
+
}) {
|
|
1622
|
+
this.$emit("monaco-created", { editor: e, editorModel: t });
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
});
|
|
1626
|
+
const Me = { class: "layout" };
|
|
1627
|
+
function Ce(e, t, i, n, s, a) {
|
|
1628
|
+
const r = x("pane"), o = x("CodeEditor"), l = x("splitpanes");
|
|
1629
|
+
return D(), N("div", Me, [
|
|
1630
|
+
p(l, {
|
|
1631
|
+
ref: "mainSplitpane",
|
|
1632
|
+
class: M(["common-splitter unset-transition", {
|
|
1633
|
+
"left-facing-splitter": !e.isLeftPaneCollapsed,
|
|
1634
|
+
"right-facing-splitter": e.isLeftPaneCollapsed
|
|
1635
|
+
}]),
|
|
1636
|
+
"dbl-click-splitter": !1,
|
|
1637
|
+
onSplitterClick: t[4] || (t[4] = (u) => {
|
|
1638
|
+
e.collapsePane("left"), e.updatePreviousPaneSize("right");
|
|
1639
|
+
}),
|
|
1640
|
+
onResize: t[5] || (t[5] = (u) => e.updateRightPane(u[0].size)),
|
|
1641
|
+
onResized: t[6] || (t[6] = (u) => {
|
|
1642
|
+
e.resizePane(u[0].size, "left"), e.updatePreviousPaneSize("right");
|
|
1643
|
+
})
|
|
1644
|
+
}, {
|
|
1645
|
+
default: m(() => [
|
|
1646
|
+
p(r, {
|
|
1647
|
+
ref: "leftPane",
|
|
1648
|
+
size: e.currentPaneSizes.left
|
|
1649
|
+
}, {
|
|
1650
|
+
default: m(() => [
|
|
1651
|
+
y(e.$slots, "leftPane", {}, void 0, !0)
|
|
1652
|
+
]),
|
|
1653
|
+
_: 3
|
|
1654
|
+
}, 8, ["size"]),
|
|
1655
|
+
p(r, {
|
|
1656
|
+
ref: "mainPane",
|
|
1657
|
+
size: e.usedMainPaneSize,
|
|
1658
|
+
"min-size": "40"
|
|
1659
|
+
}, {
|
|
1660
|
+
default: m(() => [
|
|
1661
|
+
p(l, {
|
|
1662
|
+
ref: "horizontalSplitpane",
|
|
1663
|
+
horizontal: "",
|
|
1664
|
+
class: M(["common-splitter", {
|
|
1665
|
+
"down-facing-splitter": !e.isBottomPaneCollapsed,
|
|
1666
|
+
"up-facing-splitter": e.isBottomPaneCollapsed
|
|
1667
|
+
}]),
|
|
1668
|
+
"dbl-click-splitter": !1,
|
|
1669
|
+
onSplitterClick: t[2] || (t[2] = (u) => e.collapsePane("bottom")),
|
|
1670
|
+
onResized: t[3] || (t[3] = (u) => e.resizePane(u[1].size, "bottom"))
|
|
1671
|
+
}, {
|
|
1672
|
+
default: m(() => [
|
|
1673
|
+
p(r, {
|
|
1674
|
+
ref: "topPane",
|
|
1675
|
+
size: e.usedVerticalCodeEditorPaneSize,
|
|
1676
|
+
"min-size": "20"
|
|
1677
|
+
}, {
|
|
1678
|
+
default: m(() => [
|
|
1679
|
+
p(l, {
|
|
1680
|
+
ref: "verticalSplitpane",
|
|
1681
|
+
class: M(["common-splitter unset-transition", {
|
|
1682
|
+
"left-facing-splitter": e.isRightPaneCollapsed,
|
|
1683
|
+
"right-facing-splitter": !e.isRightPaneCollapsed
|
|
1684
|
+
}]),
|
|
1685
|
+
"dbl-click-splitter": !1,
|
|
1686
|
+
onSplitterClick: t[0] || (t[0] = (u) => e.collapsePane("right")),
|
|
1687
|
+
onResized: t[1] || (t[1] = (u) => e.resizePane(u[1].size, "right"))
|
|
1688
|
+
}, {
|
|
1689
|
+
default: m(() => [
|
|
1690
|
+
p(r, {
|
|
1691
|
+
ref: "editorPane",
|
|
1692
|
+
size: e.usedHorizontalCodeEditorPaneSize,
|
|
1693
|
+
"min-size": "25"
|
|
1694
|
+
}, {
|
|
1695
|
+
default: m(() => [
|
|
1696
|
+
p(o, {
|
|
1697
|
+
language: e.language,
|
|
1698
|
+
"file-name": e.fileName,
|
|
1699
|
+
onMonacoCreated: e.onMonacoCreated
|
|
1700
|
+
}, null, 8, ["language", "file-name", "onMonacoCreated"])
|
|
1701
|
+
]),
|
|
1702
|
+
_: 1
|
|
1703
|
+
}, 8, ["size"]),
|
|
1704
|
+
p(r, {
|
|
1705
|
+
ref: "rightPane",
|
|
1706
|
+
size: e.currentPaneSizes.right
|
|
1707
|
+
}, {
|
|
1708
|
+
default: m(() => [
|
|
1709
|
+
y(e.$slots, "rightPane", {}, void 0, !0)
|
|
1710
|
+
]),
|
|
1711
|
+
_: 3
|
|
1712
|
+
}, 8, ["size"])
|
|
1713
|
+
]),
|
|
1714
|
+
_: 3
|
|
1715
|
+
}, 8, ["class"])
|
|
1716
|
+
]),
|
|
1717
|
+
_: 3
|
|
1718
|
+
}, 8, ["size"]),
|
|
1719
|
+
p(r, {
|
|
1720
|
+
ref: "bottomPane",
|
|
1721
|
+
size: e.currentPaneSizes.bottom
|
|
1722
|
+
}, {
|
|
1723
|
+
default: m(() => [
|
|
1724
|
+
y(e.$slots, "bottomPane", {}, void 0, !0)
|
|
1725
|
+
]),
|
|
1726
|
+
_: 3
|
|
1727
|
+
}, 8, ["size"])
|
|
1728
|
+
]),
|
|
1729
|
+
_: 3
|
|
1730
|
+
}, 8, ["class"])
|
|
1731
|
+
]),
|
|
1732
|
+
_: 3
|
|
1733
|
+
}, 8, ["size"])
|
|
1734
|
+
]),
|
|
1735
|
+
_: 3
|
|
1736
|
+
}, 8, ["class"])
|
|
1737
|
+
]);
|
|
1738
|
+
}
|
|
1739
|
+
const De = /* @__PURE__ */ G(xe, [["render", Ce], ["__scopeId", "data-v-52dc9a8f"]]);
|
|
57
1740
|
export {
|
|
58
|
-
|
|
1741
|
+
ke as CodeEditor,
|
|
1742
|
+
De as ScriptingEditor,
|
|
1743
|
+
Ee as getScriptingService
|
|
59
1744
|
};
|