@knime/scripting-editor 0.0.140 → 0.0.141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-bar-bOf3ch8A.js +339 -0
- package/dist/{ai-bar-C6bsfpXA.js → dist-Df9f7fVO.js} +3726 -4062
- package/dist/loading.js +11 -7
- package/dist/main.js +554 -553
- package/dist/parameters.js +10 -10
- package/package.json +1 -1
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { g as e } from "./dist-Df9f7fVO.js";
|
|
2
|
+
import { n as t, r as n, t as r } from "./knime-io-B5eFG9KP.js";
|
|
3
|
+
import { KdsCodeEditor as i, setupMonacoEnvironment as a } from "@knime/kds-code-editor";
|
|
4
|
+
import { computed as o, getCurrentInstance as s, h as c, nextTick as l, onMounted as u, onUnmounted as d, reactive as f, readonly as p, ref as m, render as h, shallowRef as g, watch as _ } from "vue";
|
|
5
|
+
import * as v from "monaco-editor";
|
|
6
|
+
import { AlertingService as ee, DialogService as te, JsonDataService as ne, ThemeService as y, getInitialDarkMode as b } from "@knime/ui-extension-service";
|
|
7
|
+
//#region src/editor.ts
|
|
8
|
+
a();
|
|
9
|
+
var x = {
|
|
10
|
+
glyphMargin: !1,
|
|
11
|
+
lightbulb: { enabled: v.editor.ShowLightbulbIconMode.OnCode },
|
|
12
|
+
scrollBeyondLastLine: !0,
|
|
13
|
+
suggest: {
|
|
14
|
+
showWords: !1,
|
|
15
|
+
snippetsPreventQuickSuggestions: !1
|
|
16
|
+
},
|
|
17
|
+
lineDecorationsWidth: "0.0ch"
|
|
18
|
+
}, re = {
|
|
19
|
+
minimap: { enabled: !1 },
|
|
20
|
+
automaticLayout: !0,
|
|
21
|
+
fixedOverflowWidgets: !0,
|
|
22
|
+
fontFamily: "\"Roboto Mono\", serif",
|
|
23
|
+
fontWeight: "400",
|
|
24
|
+
lineNumbersMinChars: 3,
|
|
25
|
+
scrollbar: { alwaysConsumeMouseWheel: !1 },
|
|
26
|
+
...x,
|
|
27
|
+
renderOverviewRuler: !1,
|
|
28
|
+
overviewRulerBorder: !1,
|
|
29
|
+
originalEditable: !1
|
|
30
|
+
}, ie = "Script", S = (e, t) => t === void 0 ? e === "plaintext" ? ie : e.toUpperCase() : t, C = /* @__PURE__ */ new WeakMap(), w = (e) => {
|
|
31
|
+
let t = C.get(e);
|
|
32
|
+
if (t !== void 0) {
|
|
33
|
+
if (t > 1) {
|
|
34
|
+
C.set(e, t - 1);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
C.delete(e), e.dispose();
|
|
38
|
+
}
|
|
39
|
+
}, T = (e) => {
|
|
40
|
+
if ("editorModel" in e) return {
|
|
41
|
+
model: e.editorModel,
|
|
42
|
+
release: () => {}
|
|
43
|
+
};
|
|
44
|
+
let t = v.Uri.parse(`inmemory://model/${e.fileName}`), n = v.editor.getModel(t), r = n ?? v.editor.createModel("", e.language, t), i = C.get(r);
|
|
45
|
+
return (!n || i !== void 0) && C.set(r, (i ?? 0) + 1), {
|
|
46
|
+
model: r,
|
|
47
|
+
release: () => w(r)
|
|
48
|
+
};
|
|
49
|
+
}, E = (e) => {
|
|
50
|
+
let t = m(e.getValue()), n = e.onDidChangeContent(() => {
|
|
51
|
+
t.value = e.getValue();
|
|
52
|
+
});
|
|
53
|
+
return d(() => n.dispose()), {
|
|
54
|
+
text: o({
|
|
55
|
+
get: () => t.value,
|
|
56
|
+
set: (t) => {
|
|
57
|
+
e.pushStackElement(), e.pushEditOperations([], [{
|
|
58
|
+
range: e.getFullModelRange(),
|
|
59
|
+
text: t
|
|
60
|
+
}], () => null);
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
setInitialText: (t) => e.setValue(t)
|
|
64
|
+
};
|
|
65
|
+
}, D = (e) => {
|
|
66
|
+
if (e.value === void 0) throw Error("Could not create code editor because no element was provided.");
|
|
67
|
+
}, ae = (e, t) => () => {
|
|
68
|
+
e.value && e.value.dispose();
|
|
69
|
+
for (let e of t) e.isAttachedToEditor() || e.dispose();
|
|
70
|
+
}, oe = (e) => (t, n) => {
|
|
71
|
+
if (e.value?.getOption(v.editor.EditorOption.readOnly)) return;
|
|
72
|
+
let r = [];
|
|
73
|
+
n && !e.value?.getModel()?.getValue().includes(n) && r.push({
|
|
74
|
+
range: new v.Selection(1, 1, 1, 1),
|
|
75
|
+
text: `${n}\n`,
|
|
76
|
+
forceMoveMarkers: !0
|
|
77
|
+
}), r.push({
|
|
78
|
+
range: e.value?.getSelection(),
|
|
79
|
+
text: t,
|
|
80
|
+
forceMoveMarkers: !0
|
|
81
|
+
}), e.value?.getModel()?.pushEditOperations([], r, () => null), e.value?.getModel()?.pushStackElement();
|
|
82
|
+
}, se = (e) => (t) => {
|
|
83
|
+
if (e.value?.getOption(v.editor.EditorOption.readOnly)) return;
|
|
84
|
+
let n = [{
|
|
85
|
+
range: e.value?.getSelection(),
|
|
86
|
+
text: t,
|
|
87
|
+
forceMoveMarkers: !0
|
|
88
|
+
}];
|
|
89
|
+
e.value?.getModel()?.pushEditOperations([], n, () => null), e.value?.getModel()?.pushStackElement();
|
|
90
|
+
}, O = (e, t, n, { selection: r, selectedLines: i }) => {
|
|
91
|
+
let a = e.getModel();
|
|
92
|
+
a !== t && (e.setModel(t), a?.dispose()), e.updateOptions({
|
|
93
|
+
...x,
|
|
94
|
+
...n.extraEditorOptions ?? {}
|
|
95
|
+
}), e.onDidChangeCursorSelection((e) => {
|
|
96
|
+
r.value = t.getValueInRange(e.selection), i.value = t.getValueInRange({
|
|
97
|
+
startLineNumber: e.selection.startLineNumber,
|
|
98
|
+
startColumn: 0,
|
|
99
|
+
endLineNumber: e.selection.endLineNumber,
|
|
100
|
+
endColumn: t.getLineLastNonWhitespaceColumn(e.selection.endLineNumber)
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}, k = (e) => {
|
|
104
|
+
let t = g(), { model: n, release: r } = T(e), i = m(""), a = m("");
|
|
105
|
+
return {
|
|
106
|
+
editor: t,
|
|
107
|
+
editorModel: n,
|
|
108
|
+
releaseEditorModel: r,
|
|
109
|
+
selection: i,
|
|
110
|
+
selectedLines: a,
|
|
111
|
+
returnValue: {
|
|
112
|
+
editor: t,
|
|
113
|
+
editorModel: n,
|
|
114
|
+
selection: p(i),
|
|
115
|
+
selectedLines: p(a),
|
|
116
|
+
insertColumnReference: oe(t),
|
|
117
|
+
insertText: se(t),
|
|
118
|
+
...E(n)
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}, A = (e) => {
|
|
122
|
+
let { editor: t, editorModel: n, releaseEditorModel: r, selection: a, selectedLines: o, returnValue: f } = k(e), p = s()?.appContext ?? null;
|
|
123
|
+
return u(() => {
|
|
124
|
+
D(e.container);
|
|
125
|
+
let r = c(i, {
|
|
126
|
+
overviewRuler: !0,
|
|
127
|
+
language: n.getLanguageId(),
|
|
128
|
+
languageLabel: S(n.getLanguageId(), e.languageLabel),
|
|
129
|
+
onVnodeMounted: () => {
|
|
130
|
+
let i = r.component.exposed.getEditor();
|
|
131
|
+
O(i, n, e, {
|
|
132
|
+
selection: a,
|
|
133
|
+
selectedLines: o
|
|
134
|
+
}), t.value = i;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
r.appContext = p, h(r, e.container.value);
|
|
138
|
+
}), d(() => {
|
|
139
|
+
e.container.value && h(null, e.container.value), l(r);
|
|
140
|
+
}), f;
|
|
141
|
+
}, ce = (e, t) => {
|
|
142
|
+
let { editor: n, editorModel: r, releaseEditorModel: i, selection: a, selectedLines: s, returnValue: c } = k(t), l = o(() => ({
|
|
143
|
+
modelValue: c.text.value,
|
|
144
|
+
language: r.getLanguageId(),
|
|
145
|
+
languageLabel: S(r.getLanguageId(), t.languageLabel),
|
|
146
|
+
overviewRuler: !0
|
|
147
|
+
}));
|
|
148
|
+
return _(e, (e) => {
|
|
149
|
+
let i = e?.getEditor();
|
|
150
|
+
if (!i) {
|
|
151
|
+
n.value = void 0, a.value = "", s.value = "";
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
i !== n.value && (O(i, r, t, {
|
|
155
|
+
selection: a,
|
|
156
|
+
selectedLines: s
|
|
157
|
+
}), n.value = i);
|
|
158
|
+
}, { immediate: !0 }), d(() => {
|
|
159
|
+
i();
|
|
160
|
+
}), {
|
|
161
|
+
...c,
|
|
162
|
+
kdsCodeEditorProps: l
|
|
163
|
+
};
|
|
164
|
+
}, le = (e) => {
|
|
165
|
+
let t = g(), n = e.originalModel, r = v.editor.createModel("", n.getLanguageId(), v.Uri.parse(`inmemory://model/${e.modifiedFileName}`)), i = {
|
|
166
|
+
original: n,
|
|
167
|
+
modified: r
|
|
168
|
+
};
|
|
169
|
+
u(() => {
|
|
170
|
+
D(e.container), t.value = v.editor.createDiffEditor(e.container.value, {
|
|
171
|
+
...re,
|
|
172
|
+
...e.extraEditorOptions ?? {}
|
|
173
|
+
}), t.value.setModel(i);
|
|
174
|
+
}), d(ae(t, [n, r]));
|
|
175
|
+
let { text: a, setInitialText: o } = E(r);
|
|
176
|
+
return {
|
|
177
|
+
editor: t,
|
|
178
|
+
editorModel: i,
|
|
179
|
+
modifiedText: a,
|
|
180
|
+
setInitialModifiedText: o
|
|
181
|
+
};
|
|
182
|
+
}, j = g(), M = () => j, N = (e) => {
|
|
183
|
+
let t = A(e);
|
|
184
|
+
return j.value = t, t;
|
|
185
|
+
}, P = {
|
|
186
|
+
useCodeEditor: A,
|
|
187
|
+
useDiffEditor: le,
|
|
188
|
+
useKdsCodeEditor: ce,
|
|
189
|
+
useMainCodeEditorStore: M
|
|
190
|
+
}, F = {
|
|
191
|
+
writeln: (e) => consola.error("Console not yet initialized", e),
|
|
192
|
+
write: (e) => consola.error("Console not yet initialized", e),
|
|
193
|
+
clear: () => consola.error("Console not yet initialized")
|
|
194
|
+
}, I = (e) => {
|
|
195
|
+
F = e;
|
|
196
|
+
}, L = m("small"), R = class {
|
|
197
|
+
jsonDataService;
|
|
198
|
+
_eventHandlers = {};
|
|
199
|
+
constructor(e) {
|
|
200
|
+
this.jsonDataService = e, this.startPolling().catch(() => {});
|
|
201
|
+
}
|
|
202
|
+
async startPolling() {
|
|
203
|
+
for (;;) {
|
|
204
|
+
let e = await this.jsonDataService.data({ method: "ScriptingService.getEvent" });
|
|
205
|
+
if (e) {
|
|
206
|
+
if (e.type in this._eventHandlers) this._eventHandlers[e.type](e.data);
|
|
207
|
+
else throw Error(`Got unexpected event from Java with type ${e.type}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
registerEventHandler(e, t) {
|
|
212
|
+
this._eventHandlers[e] = t;
|
|
213
|
+
}
|
|
214
|
+
}, z = class {
|
|
215
|
+
jsonDataService;
|
|
216
|
+
alertingService;
|
|
217
|
+
eventPoller;
|
|
218
|
+
constructor(e, t) {
|
|
219
|
+
this.jsonDataService = e, this.alertingService = t, this.eventPoller = new R(this.jsonDataService);
|
|
220
|
+
}
|
|
221
|
+
sendToService(e, t) {
|
|
222
|
+
return this.jsonDataService.data({
|
|
223
|
+
method: `ScriptingService.${e}`,
|
|
224
|
+
options: t
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
callRpcMethod(e) {
|
|
228
|
+
return this.jsonDataService.data(e);
|
|
229
|
+
}
|
|
230
|
+
getOutputPreviewTableInitialData() {
|
|
231
|
+
return this.jsonDataService.data({ method: "OutputPreviewTableInitialDataRpcSupplier.getInitialData" });
|
|
232
|
+
}
|
|
233
|
+
registerEventHandler(e, t) {
|
|
234
|
+
this.eventPoller.registerEventHandler(e, t);
|
|
235
|
+
}
|
|
236
|
+
async connectToLanguageServer(e) {
|
|
237
|
+
let i = e ?? M().value?.editorModel;
|
|
238
|
+
if (i === void 0) throw Error("Editor model has not yet been initialized");
|
|
239
|
+
let a = await this.sendToService("connectToLanguageServer");
|
|
240
|
+
if (a.status === "RUNNING") return n.create(i, new r((e) => this.registerEventHandler("language-server", e)), new t((e) => this.sendToService("sendLanguageServerMessage", [e])));
|
|
241
|
+
throw Error(a.message ?? "Starting the language server failed");
|
|
242
|
+
}
|
|
243
|
+
async isCallKnimeUiApiAvailable(e) {
|
|
244
|
+
let t = this.jsonDataService.baseService;
|
|
245
|
+
return t !== null && (await t.callKnimeUiApi("PortService.getPortView", {
|
|
246
|
+
nodeId: e.nodeId,
|
|
247
|
+
portIdx: e.portIdx,
|
|
248
|
+
viewIdx: e.portViewConfigs[0]?.portViewIdx
|
|
249
|
+
})).isSome;
|
|
250
|
+
}
|
|
251
|
+
isKaiEnabled() {
|
|
252
|
+
return this.sendToService("isKaiEnabled");
|
|
253
|
+
}
|
|
254
|
+
isLoggedIntoHub() {
|
|
255
|
+
return this.sendToService("isLoggedIntoHub");
|
|
256
|
+
}
|
|
257
|
+
getAiDisclaimer() {
|
|
258
|
+
return this.sendToService("getAiDisclaimer");
|
|
259
|
+
}
|
|
260
|
+
getAiUsage() {
|
|
261
|
+
return this.sendToService("getAiUsage");
|
|
262
|
+
}
|
|
263
|
+
sendAlert(e) {
|
|
264
|
+
this.alertingService?.sendAlert(e);
|
|
265
|
+
}
|
|
266
|
+
}, B = class {
|
|
267
|
+
initialSettings;
|
|
268
|
+
settingsInitialData;
|
|
269
|
+
dialogService;
|
|
270
|
+
jsonDataService;
|
|
271
|
+
constructor(e, t, n, r) {
|
|
272
|
+
if (this.initialSettings = e, this.settingsInitialData = t, this.dialogService = n, this.jsonDataService = r, e === void 0 && t === void 0) throw Error("Either initialSettings or settingsInitialData must be provided");
|
|
273
|
+
if (e !== void 0 && t !== void 0) throw Error("Cannot provide both initialSettings and settingsInitialData");
|
|
274
|
+
}
|
|
275
|
+
getSettings() {
|
|
276
|
+
return this.initialSettings;
|
|
277
|
+
}
|
|
278
|
+
getSettingsInitialData() {
|
|
279
|
+
return this.settingsInitialData;
|
|
280
|
+
}
|
|
281
|
+
registerSettingsGetterForApply(e) {
|
|
282
|
+
this.dialogService.setApplyListener(async () => {
|
|
283
|
+
let t = e();
|
|
284
|
+
try {
|
|
285
|
+
return await this.jsonDataService.applyData(t), { isApplied: !0 };
|
|
286
|
+
} catch (e) {
|
|
287
|
+
return consola.warn("Failed to apply settings", e), { isApplied: !1 };
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
registerSettings(e) {
|
|
292
|
+
return this.dialogService.registerSettings(e);
|
|
293
|
+
}
|
|
294
|
+
}, V = (e, t) => {
|
|
295
|
+
let n = G().mainScriptConfigKey ?? "script";
|
|
296
|
+
if (!t) return { data: { model: { [n]: e.script } } };
|
|
297
|
+
if (t.data.model === void 0) throw Error("Could not find model settings in core dialog settings to update script.");
|
|
298
|
+
return t.data.model[n] = e.script, t;
|
|
299
|
+
}, H, U = () => H, W, G = () => W, K, ue = () => K, de = async () => {
|
|
300
|
+
let { preferredMode: t } = e(), n = (e) => {
|
|
301
|
+
t.value = e ? "dark" : "light";
|
|
302
|
+
};
|
|
303
|
+
n(b());
|
|
304
|
+
let r = await ne.getInstance(), i = await te.getInstance();
|
|
305
|
+
H = new z(r, await ee.getInstance());
|
|
306
|
+
let a = await r.initialData();
|
|
307
|
+
W = a.initialData, K = new B(a.settings, a.settingsInitialData ? JSON.parse(a.settingsInitialData) : void 0, i, r), L.value = i.getInitialDisplayMode(), i.addOnDisplayModeChangeCallback(({ mode: e }) => {
|
|
308
|
+
L.value = e;
|
|
309
|
+
}), (await y.getInstance()).addOnDarkModeChangeCallback(n), Z();
|
|
310
|
+
}, fe = (e) => {
|
|
311
|
+
e.scriptingService && (H = e.scriptingService), e.initialData && (W = e.initialData), e.settingsService && (K = e.settingsService), e.displayMode && (L.value = e.displayMode), Z();
|
|
312
|
+
}, pe = () => {
|
|
313
|
+
U().registerEventHandler("console", F.write);
|
|
314
|
+
}, q = f({}), me = () => q, he = () => {
|
|
315
|
+
q.promptResponse !== void 0 && delete q.promptResponse;
|
|
316
|
+
}, ge = (e, t = null) => {
|
|
317
|
+
let n = window?.localStorage?.getItem(e);
|
|
318
|
+
if (n === null) return t;
|
|
319
|
+
try {
|
|
320
|
+
return JSON.parse(n);
|
|
321
|
+
} catch {
|
|
322
|
+
return consola.warn(`Could not parse "${e}" from local storage.`), t;
|
|
323
|
+
}
|
|
324
|
+
}, _e = (e, t) => {
|
|
325
|
+
window?.localStorage?.setItem(e, JSON.stringify(t));
|
|
326
|
+
}, J = () => {
|
|
327
|
+
let e = G().kAiConfig.hubId ?? "";
|
|
328
|
+
return `ai-disclaimer-do-not-show-again-${encodeURIComponent(e.trim().toLowerCase())}`;
|
|
329
|
+
}, Y = (e) => {
|
|
330
|
+
_e(J(), e);
|
|
331
|
+
}, X = m(!0), Z = () => {
|
|
332
|
+
X.value = !ge(J(), !1);
|
|
333
|
+
}, Q = g(), $ = (e) => {
|
|
334
|
+
Q.value = e;
|
|
335
|
+
};
|
|
336
|
+
_(() => M().value, $);
|
|
337
|
+
var ve = m([]), ye = m({ type: "UNKNOWN" });
|
|
338
|
+
//#endregion
|
|
339
|
+
export { F as _, Y as a, N as b, me as c, ue as d, de as f, L as g, V as h, $ as i, G as l, fe as m, he as n, X as o, pe as p, ve as r, ye as s, Q as t, U as u, I as v, M as x, P as y };
|