windmill-components 1.35.1 → 1.35.43
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/components/ArgInput.svelte +21 -21
- package/components/ArgInput.svelte.d.ts +3 -3
- package/components/DisplayResult.svelte +73 -67
- package/components/Editor.svelte +184 -246
- package/components/Editor.svelte.d.ts +4 -4
- package/components/EditorBar.svelte +58 -45
- package/components/EditorBar.svelte.d.ts +2 -1
- package/components/FlowBuilder.svelte +113 -121
- package/components/FlowJobResult.svelte +4 -5
- package/components/FlowModulesViewer.svelte +89 -7
- package/components/FlowModulesViewer.svelte.d.ts +1 -0
- package/components/FlowPreviewContent.svelte +56 -15
- package/components/FlowPreviewContent.svelte.d.ts +1 -1
- package/components/FlowStatusViewer.svelte +42 -24
- package/components/FlowStatusViewer.svelte.d.ts +0 -1
- package/components/FlowViewer.svelte +7 -3
- package/components/HighlightCode.svelte +21 -0
- package/components/HighlightCode.svelte.d.ts +17 -0
- package/components/IconedPath.svelte +9 -7
- package/components/IconedResourceType.svelte +1 -1
- package/components/InputTransformForm.svelte +88 -107
- package/components/InputTransformForm.svelte.d.ts +0 -1
- package/components/ItemPicker.svelte +2 -2
- package/components/LogViewer.svelte +23 -0
- package/components/LogViewer.svelte.d.ts +19 -0
- package/components/ModulePreview.svelte +108 -0
- package/components/ModulePreview.svelte.d.ts +24 -0
- package/components/RunForm.svelte +29 -18
- package/components/RunForm.svelte.d.ts +6 -2
- package/components/SchemaEditor.svelte +5 -3
- package/components/SchemaForm.svelte +0 -2
- package/components/SchemaForm.svelte.d.ts +0 -1
- package/components/ScriptBuilder.svelte +77 -66
- package/components/ScriptBuilder.svelte.d.ts +2 -4
- package/components/ScriptEditor.svelte +69 -142
- package/components/ScriptEditor.svelte.d.ts +0 -5
- package/components/ScriptPicker.svelte +3 -3
- package/components/ScriptPicker.svelte.d.ts +2 -1
- package/components/SharedBadge.svelte +5 -13
- package/components/SimpleEditor.svelte +147 -0
- package/components/SimpleEditor.svelte.d.ts +35 -0
- package/components/TestJobLoader.svelte +98 -0
- package/components/TestJobLoader.svelte.d.ts +26 -0
- package/components/Tooltip.svelte +2 -1
- package/components/common/actionRow/ActionRow.svelte +26 -0
- package/components/common/actionRow/ActionRow.svelte.d.ts +21 -0
- package/components/common/alert/Alert.svelte +53 -0
- package/components/common/alert/Alert.svelte.d.ts +20 -0
- package/components/common/alert/model.d.ts +1 -0
- package/components/common/alert/model.js +1 -0
- package/components/common/badge/Badge.svelte +82 -0
- package/components/common/badge/Badge.svelte.d.ts +28 -0
- package/components/common/badge/model.d.ts +8 -0
- package/components/common/badge/model.js +1 -0
- package/components/common/button/Button.svelte +107 -0
- package/components/common/button/Button.svelte.d.ts +37 -0
- package/components/common/button/model.d.ts +6 -0
- package/components/common/button/model.js +1 -0
- package/components/common/confirmationModal/ConfirmationModal.svelte +55 -0
- package/components/common/confirmationModal/ConfirmationModal.svelte.d.ts +23 -0
- package/components/common/drawer/Drawer.svelte +3 -0
- package/components/common/drawer/Drawer.svelte.d.ts +2 -0
- package/components/common/index.d.ts +14 -0
- package/components/common/index.js +14 -0
- package/components/common/tabs/TabContent.svelte +3 -2
- package/components/common/tabs/TabContent.svelte.d.ts +1 -0
- package/components/common/tabs/Tabs.svelte +8 -1
- package/components/common/tabs/Tabs.svelte.d.ts +2 -0
- package/components/common/toggleButton/ToggleButton.svelte +20 -0
- package/components/common/toggleButton/ToggleButton.svelte.d.ts +19 -0
- package/components/common/toggleButton/ToggleButtonGroup.svelte +33 -0
- package/components/common/toggleButton/ToggleButtonGroup.svelte.d.ts +24 -0
- package/components/flows/FlowEditor.svelte +30 -0
- package/components/{FlowEditor.svelte.d.ts → flows/FlowEditor.svelte.d.ts} +1 -8
- package/components/flows/common/FlowCard.svelte +9 -0
- package/components/flows/common/FlowCard.svelte.d.ts +21 -0
- package/components/flows/common/FlowCardHeader.svelte +39 -0
- package/components/flows/common/FlowCardHeader.svelte.d.ts +20 -0
- package/components/flows/content/CopyFirstStepSchema.svelte +13 -0
- package/components/flows/{CopyFirstStepSchema.svelte.d.ts → content/CopyFirstStepSchema.svelte.d.ts} +0 -0
- package/components/flows/{DynamicInputHelpBox.svelte → content/DynamicInputHelpBox.svelte} +0 -0
- package/components/flows/{DynamicInputHelpBox.svelte.d.ts → content/DynamicInputHelpBox.svelte.d.ts} +0 -0
- package/components/flows/content/FlowEditorPanel.svelte +26 -0
- package/components/flows/content/FlowEditorPanel.svelte.d.ts +14 -0
- package/components/flows/content/FlowFailureModule.svelte +17 -0
- package/components/flows/content/FlowFailureModule.svelte.d.ts +14 -0
- package/components/flows/content/FlowInput.svelte +22 -0
- package/components/flows/{FlowInput.svelte.d.ts → content/FlowInput.svelte.d.ts} +0 -0
- package/components/flows/{FlowInputs.svelte → content/FlowInputs.svelte} +24 -13
- package/components/flows/{FlowInputs.svelte.d.ts → content/FlowInputs.svelte.d.ts} +0 -0
- package/components/flows/content/FlowLoop.svelte +38 -0
- package/components/flows/content/FlowLoop.svelte.d.ts +14 -0
- package/components/flows/content/FlowModule.svelte +190 -0
- package/components/flows/content/FlowModule.svelte.d.ts +29 -0
- package/components/flows/content/FlowModuleAdvancedSettings.svelte +64 -0
- package/components/flows/content/FlowModuleAdvancedSettings.svelte.d.ts +17 -0
- package/components/flows/content/FlowModuleHeader.svelte +68 -0
- package/components/flows/{FlowModuleHeader.svelte.d.ts → content/FlowModuleHeader.svelte.d.ts} +2 -3
- package/components/flows/content/FlowModuleScript.svelte +21 -0
- package/components/flows/content/FlowModuleScript.svelte.d.ts +17 -0
- package/components/flows/content/FlowModuleWrapper.svelte +47 -0
- package/components/flows/content/FlowModuleWrapper.svelte.d.ts +14 -0
- package/components/flows/content/FlowRetries.svelte +80 -0
- package/components/flows/content/FlowRetries.svelte.d.ts +14 -0
- package/components/flows/content/FlowSchedules.svelte +18 -0
- package/components/flows/content/FlowSchedules.svelte.d.ts +14 -0
- package/components/flows/content/FlowSettings.svelte +51 -0
- package/components/flows/{FlowSettings.svelte.d.ts → content/FlowSettings.svelte.d.ts} +1 -6
- package/components/flows/content/RemoveStepConfirmationModal.svelte +32 -0
- package/components/flows/content/RemoveStepConfirmationModal.svelte.d.ts +19 -0
- package/components/flows/flowState.d.ts +8 -7
- package/components/flows/flowState.js +25 -46
- package/components/flows/flowStateUtils.d.ts +15 -13
- package/components/flows/flowStateUtils.js +80 -72
- package/components/flows/flowStore.js +7 -4
- package/components/flows/header/FlowEditorHeader.svelte +23 -0
- package/components/flows/header/FlowEditorHeader.svelte.d.ts +14 -0
- package/components/flows/header/FlowImportExportMenu.svelte +56 -0
- package/components/flows/header/FlowImportExportMenu.svelte.d.ts +14 -0
- package/components/flows/header/FlowPreviewButtons.svelte +49 -0
- package/components/flows/header/FlowPreviewButtons.svelte.d.ts +14 -0
- package/components/flows/header/FlowStatus.svelte +36 -0
- package/components/flows/header/FlowStatus.svelte.d.ts +14 -0
- package/components/flows/map/FlowErrorHandlerItem.svelte +54 -0
- package/components/flows/map/FlowErrorHandlerItem.svelte.d.ts +14 -0
- package/components/flows/map/FlowModuleSchemaItem.svelte +58 -0
- package/components/flows/map/FlowModuleSchemaItem.svelte.d.ts +27 -0
- package/components/flows/map/FlowModuleSchemaMap.svelte +161 -0
- package/components/flows/map/FlowModuleSchemaMap.svelte.d.ts +20 -0
- package/components/flows/pickers/PickHubScript.svelte +4 -3
- package/components/flows/pickers/PickHubScript.svelte.d.ts +2 -1
- package/components/flows/pickers/PickScript.svelte +4 -12
- package/components/flows/pickers/PickScript.svelte.d.ts +1 -1
- package/components/flows/propPicker/PropPickerWrapper.svelte +42 -0
- package/components/flows/propPicker/PropPickerWrapper.svelte.d.ts +31 -0
- package/components/flows/scheduleUtils.d.ts +0 -1
- package/components/flows/scheduleUtils.js +0 -1
- package/components/flows/types.d.ts +9 -0
- package/components/flows/types.js +1 -0
- package/components/flows/utils.d.ts +1 -1
- package/components/flows/utils.js +8 -11
- package/components/icons/HatIcon.svelte +19 -0
- package/components/icons/HatIcon.svelte.d.ts +16 -0
- package/components/landing/FlowGettingStarted.svelte +22 -68
- package/components/landing/FlowLandingBox.svelte +1 -1
- package/components/landing/RessourceGettingStarted.svelte +7 -37
- package/components/landing/ScriptBox.svelte +33 -60
- package/components/landing/ScriptGettingStarted.svelte +23 -69
- package/components/propertyPicker/ObjectViewer.svelte +16 -7
- package/components/propertyPicker/PropPicker.svelte +38 -12
- package/components/propertyPicker/WarningMessage.svelte +2 -15
- package/components/script_editor/LogPanel.svelte +108 -119
- package/components/script_editor/LogPanel.svelte.d.ts +2 -0
- package/components/sidebar/SidebarContent.svelte +2 -2
- package/editorUtils.d.ts +25 -0
- package/editorUtils.js +43 -0
- package/gen/models/CompletedJob.d.ts +2 -1
- package/gen/models/CompletedJob.js +1 -0
- package/gen/models/FlowModule.d.ts +1 -0
- package/gen/models/FlowStatus.d.ts +3 -0
- package/gen/models/FlowStatusModule.d.ts +1 -1
- package/gen/models/FlowValue.d.ts +11 -0
- package/gen/models/Preview.d.ts +2 -1
- package/gen/models/Preview.js +1 -0
- package/gen/models/QueuedJob.d.ts +2 -1
- package/gen/models/QueuedJob.js +1 -0
- package/gen/models/RawScript.d.ts +2 -1
- package/gen/models/RawScript.js +1 -0
- package/gen/models/Script.d.ts +9 -2
- package/gen/models/Script.js +8 -0
- package/gen/services/JobService.d.ts +40 -0
- package/gen/services/JobService.js +70 -0
- package/gen/services/ScriptService.d.ts +14 -3
- package/gen/services/ScriptService.js +13 -0
- package/infer.d.ts +1 -1
- package/infer.js +6 -1
- package/package.json +67 -35
- package/script_helpers.d.ts +5 -2
- package/script_helpers.js +41 -13
- package/stores.d.ts +1 -1
- package/utils.d.ts +6 -4
- package/utils.js +27 -4
- package/components/FlowEditor.svelte +0 -55
- package/components/FlowPreview.svelte +0 -107
- package/components/FlowPreview.svelte.d.ts +0 -23
- package/components/ModuleStep.svelte +0 -131
- package/components/ModuleStep.svelte.d.ts +0 -25
- package/components/flows/CopyFirstStepSchema.svelte +0 -13
- package/components/flows/FlowBox.svelte +0 -16
- package/components/flows/FlowBox.svelte.d.ts +0 -23
- package/components/flows/FlowBoxHeader.svelte +0 -16
- package/components/flows/FlowBoxHeader.svelte.d.ts +0 -21
- package/components/flows/FlowInput.svelte +0 -22
- package/components/flows/FlowModuleHeader.svelte +0 -109
- package/components/flows/FlowSettings.svelte +0 -165
- package/components/flows/FlowTimeline.svelte +0 -169
- package/components/flows/FlowTimeline.svelte.d.ts +0 -21
- package/components/flows/stepOpenedStore.d.ts +0 -1
- package/components/flows/stepOpenedStore.js +0 -6
- package/components/propertyPicker/OverlayPropertyPicker.svelte +0 -69
- package/components/propertyPicker/OverlayPropertyPicker.svelte.d.ts +0 -24
package/components/Editor.svelte
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
<script context="module">import * as monaco from 'monaco-editor';
|
|
2
|
-
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
|
3
|
-
target: monaco.languages.typescript.ScriptTarget.Latest,
|
|
4
|
-
allowNonTsExtensions: true,
|
|
5
|
-
noLib: true
|
|
6
|
-
});
|
|
7
2
|
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
|
|
8
3
|
target: monaco.languages.typescript.ScriptTarget.Latest,
|
|
9
4
|
allowNonTsExtensions: true,
|
|
@@ -14,40 +9,36 @@ monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
|
14
9
|
noSuggestionDiagnostics: true,
|
|
15
10
|
noSyntaxValidation: true
|
|
16
11
|
});
|
|
17
|
-
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
|
|
18
|
-
validate: true,
|
|
19
|
-
allowComments: false,
|
|
20
|
-
schemas: [],
|
|
21
|
-
enableSchemaRequest: true
|
|
22
|
-
});
|
|
23
12
|
</script>
|
|
24
13
|
|
|
25
14
|
<script>import { browser, dev } from '$app/env';
|
|
26
15
|
import { page } from '$app/stores';
|
|
27
16
|
import { sendUserToast } from '../utils';
|
|
28
17
|
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
|
29
|
-
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
|
30
18
|
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
|
31
19
|
import { buildWorkerDefinition } from 'monaco-editor-workers';
|
|
32
20
|
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
|
33
21
|
import getMessageServiceOverride from 'vscode/service-override/messages';
|
|
34
22
|
import { StandaloneServices } from 'vscode/services';
|
|
35
23
|
import { DENO_INIT_CODE_CLEAR, PYTHON_INIT_CODE_CLEAR } from '../script_helpers';
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
import { createHash as randomHash, editorConfig, langToExt, updateOptions } from '../editorUtils';
|
|
25
|
+
try {
|
|
26
|
+
StandaloneServices.initialize({
|
|
27
|
+
...getMessageServiceOverride(document.body)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
console.error(e);
|
|
32
|
+
}
|
|
39
33
|
let divEl = null;
|
|
40
34
|
let editor;
|
|
41
|
-
export let
|
|
42
|
-
export let lang = deno ? 'typescript' : 'python';
|
|
35
|
+
export let lang;
|
|
43
36
|
export let code = '';
|
|
44
|
-
export let hash = (
|
|
37
|
+
export let hash = randomHash();
|
|
45
38
|
export let cmdEnterAction = undefined;
|
|
46
39
|
export let formatAction = undefined;
|
|
47
40
|
export let automaticLayout = true;
|
|
48
41
|
export let websocketAlive = { pyright: false, black: false, deno: false };
|
|
49
|
-
export let extraLib = '';
|
|
50
|
-
export let extraLibPath = '';
|
|
51
42
|
export let shouldBindKey = true;
|
|
52
43
|
let websockets = [];
|
|
53
44
|
let websocketInterval;
|
|
@@ -64,10 +55,7 @@ if (browser) {
|
|
|
64
55
|
// @ts-ignore
|
|
65
56
|
self.MonacoEnvironment = {
|
|
66
57
|
getWorker: function (_moduleId, label) {
|
|
67
|
-
if (label === '
|
|
68
|
-
return new jsonWorker();
|
|
69
|
-
}
|
|
70
|
-
else if (label === 'typescript' || label === 'javascript') {
|
|
58
|
+
if (label === 'typescript' || label === 'javascript') {
|
|
71
59
|
return new tsWorker();
|
|
72
60
|
}
|
|
73
61
|
else {
|
|
@@ -85,22 +73,6 @@ export function insertAtCursor(code) {
|
|
|
85
73
|
editor.trigger('keyboard', 'type', { text: code });
|
|
86
74
|
}
|
|
87
75
|
}
|
|
88
|
-
function langToExt(lang) {
|
|
89
|
-
switch (lang) {
|
|
90
|
-
case 'typescript':
|
|
91
|
-
return 'ts';
|
|
92
|
-
case 'python':
|
|
93
|
-
return 'py';
|
|
94
|
-
case 'javascript':
|
|
95
|
-
return 'js';
|
|
96
|
-
case 'json':
|
|
97
|
-
return 'json';
|
|
98
|
-
case 'sql':
|
|
99
|
-
return 'sql';
|
|
100
|
-
default:
|
|
101
|
-
return 'unknown';
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
76
|
export function insertAtBeginning(code) {
|
|
105
77
|
if (editor) {
|
|
106
78
|
const range = { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 };
|
|
@@ -140,87 +112,87 @@ let command = undefined;
|
|
|
140
112
|
let monacoServices = undefined;
|
|
141
113
|
export async function reloadWebsocket() {
|
|
142
114
|
await closeWebsockets();
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
isTrusted: true
|
|
165
|
-
},
|
|
166
|
-
// workspaceFolder: { uri: Uri.parse(`/tmp/${name}`), name: 'tmp', index: 0 },
|
|
167
|
-
initializationOptions,
|
|
168
|
-
middleware: {
|
|
169
|
-
workspace: {
|
|
170
|
-
configuration: (params, token, configuration) => {
|
|
171
|
-
return [
|
|
172
|
-
{
|
|
173
|
-
enable: true
|
|
174
|
-
}
|
|
175
|
-
];
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
115
|
+
const { MonacoLanguageClient } = await import('monaco-languageclient');
|
|
116
|
+
const { CloseAction, ErrorAction } = await import('vscode-languageclient');
|
|
117
|
+
const { toSocket, WebSocketMessageReader, WebSocketMessageWriter } = await import('vscode-ws-jsonrpc');
|
|
118
|
+
const vscode = await import('vscode');
|
|
119
|
+
const { RequestType } = await import('vscode-jsonrpc');
|
|
120
|
+
// install Monaco language client services
|
|
121
|
+
const { MonacoServices } = await import('monaco-languageclient');
|
|
122
|
+
monacoServices = MonacoServices.install();
|
|
123
|
+
function createLanguageClient(transports, name, initializationOptions) {
|
|
124
|
+
const client = new MonacoLanguageClient({
|
|
125
|
+
name: name,
|
|
126
|
+
clientOptions: {
|
|
127
|
+
documentSelector: [lang],
|
|
128
|
+
errorHandler: {
|
|
129
|
+
error: () => ({ action: ErrorAction.Continue }),
|
|
130
|
+
closed: () => ({
|
|
131
|
+
action: CloseAction.Restart
|
|
132
|
+
})
|
|
133
|
+
},
|
|
134
|
+
markdown: {
|
|
135
|
+
isTrusted: true
|
|
179
136
|
},
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
137
|
+
// workspaceFolder: { uri: Uri.parse(`/tmp/${name}`), name: 'tmp', index: 0 },
|
|
138
|
+
initializationOptions,
|
|
139
|
+
middleware: {
|
|
140
|
+
workspace: {
|
|
141
|
+
configuration: (params, token, configuration) => {
|
|
142
|
+
return [
|
|
143
|
+
{
|
|
144
|
+
enable: true
|
|
145
|
+
}
|
|
146
|
+
];
|
|
147
|
+
}
|
|
183
148
|
}
|
|
184
149
|
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
console.error(err);
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
socket.onClose((_code, _reason) => {
|
|
208
|
-
websocketAlive[name] = false;
|
|
209
|
-
});
|
|
150
|
+
},
|
|
151
|
+
connectionProvider: {
|
|
152
|
+
get: () => {
|
|
153
|
+
return Promise.resolve(transports);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return client;
|
|
158
|
+
}
|
|
159
|
+
async function connectToLanguageServer(url, name, options) {
|
|
160
|
+
try {
|
|
161
|
+
const webSocket = new WebSocket(url);
|
|
162
|
+
webSocket.onopen = async () => {
|
|
163
|
+
const socket = toSocket(webSocket);
|
|
164
|
+
const reader = new WebSocketMessageReader(socket);
|
|
165
|
+
const writer = new WebSocketMessageWriter(socket);
|
|
166
|
+
const languageClient = createLanguageClient({ reader, writer }, name, options);
|
|
167
|
+
websockets.push([languageClient, webSocket]);
|
|
168
|
+
reader.onClose(async () => {
|
|
210
169
|
try {
|
|
211
|
-
console.log('
|
|
212
|
-
|
|
170
|
+
console.log('CLOSE');
|
|
171
|
+
websocketAlive[name] = false;
|
|
172
|
+
await languageClient.stop();
|
|
213
173
|
}
|
|
214
174
|
catch (err) {
|
|
215
|
-
console.log('err at client');
|
|
216
175
|
console.error(err);
|
|
217
|
-
throw new Error(err);
|
|
218
176
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
177
|
+
});
|
|
178
|
+
socket.onClose((_code, _reason) => {
|
|
179
|
+
websocketAlive[name] = false;
|
|
180
|
+
});
|
|
181
|
+
try {
|
|
182
|
+
console.log('started client');
|
|
183
|
+
await languageClient.start();
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
console.log('err at client');
|
|
187
|
+
console.error(err);
|
|
188
|
+
throw new Error(err);
|
|
189
|
+
}
|
|
190
|
+
lastWsAttempt = new Date();
|
|
191
|
+
nbWsAttempt = 0;
|
|
192
|
+
if (name == 'deno') {
|
|
193
|
+
command && command.dispose();
|
|
194
|
+
command = undefined;
|
|
195
|
+
try {
|
|
224
196
|
command = vscode.commands.registerCommand('deno.cache', (uris = []) => {
|
|
225
197
|
languageClient.sendRequest(new RequestType('deno/cache'), {
|
|
226
198
|
referrer: { uri },
|
|
@@ -228,90 +200,92 @@ export async function reloadWebsocket() {
|
|
|
228
200
|
});
|
|
229
201
|
});
|
|
230
202
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
catch (err) {
|
|
235
|
-
console.error(`connection to ${name} language server failed`);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if (deno) {
|
|
239
|
-
await connectToLanguageServer(`wss://${$page.url.host}/ws/deno`, 'deno', {
|
|
240
|
-
certificateStores: null,
|
|
241
|
-
enablePaths: [],
|
|
242
|
-
config: null,
|
|
243
|
-
importMap: null,
|
|
244
|
-
internalDebug: false,
|
|
245
|
-
lint: false,
|
|
246
|
-
path: null,
|
|
247
|
-
tlsCertificate: null,
|
|
248
|
-
unsafelyIgnoreCertificateErrors: null,
|
|
249
|
-
unstable: true,
|
|
250
|
-
enable: true,
|
|
251
|
-
cache: null,
|
|
252
|
-
codeLens: {
|
|
253
|
-
implementations: true,
|
|
254
|
-
references: true
|
|
255
|
-
},
|
|
256
|
-
suggest: {
|
|
257
|
-
autoImports: true,
|
|
258
|
-
completeFunctionCalls: false,
|
|
259
|
-
names: true,
|
|
260
|
-
paths: true,
|
|
261
|
-
imports: {
|
|
262
|
-
autoDiscover: true,
|
|
263
|
-
hosts: {
|
|
264
|
-
'https://deno.land': true
|
|
265
|
-
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
console.error(err);
|
|
266
205
|
}
|
|
267
206
|
}
|
|
268
|
-
|
|
207
|
+
websocketAlive[name] = true;
|
|
208
|
+
};
|
|
269
209
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
executionEnvironments: [
|
|
273
|
-
{
|
|
274
|
-
root: '/tmp/pyright',
|
|
275
|
-
pythonVersion: '3.7',
|
|
276
|
-
pythonPlatform: 'platform',
|
|
277
|
-
extraPaths: []
|
|
278
|
-
}
|
|
279
|
-
]
|
|
280
|
-
});
|
|
281
|
-
connectToLanguageServer(`wss://${$page.url.host}/ws/black`, 'black', {
|
|
282
|
-
formatters: {
|
|
283
|
-
black: {
|
|
284
|
-
command: 'black',
|
|
285
|
-
args: ['--quiet', '-']
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
formatFiletypes: {
|
|
289
|
-
python: 'black'
|
|
290
|
-
}
|
|
291
|
-
});
|
|
210
|
+
catch (err) {
|
|
211
|
+
console.error(`connection to ${name} language server failed`);
|
|
292
212
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
213
|
+
}
|
|
214
|
+
if (lang == 'typescript') {
|
|
215
|
+
await connectToLanguageServer(`wss://${$page.url.host}/ws/deno`, 'deno', {
|
|
216
|
+
certificateStores: null,
|
|
217
|
+
enablePaths: [],
|
|
218
|
+
config: null,
|
|
219
|
+
importMap: null,
|
|
220
|
+
internalDebug: false,
|
|
221
|
+
lint: false,
|
|
222
|
+
path: null,
|
|
223
|
+
tlsCertificate: null,
|
|
224
|
+
unsafelyIgnoreCertificateErrors: null,
|
|
225
|
+
unstable: true,
|
|
226
|
+
enable: true,
|
|
227
|
+
cache: null,
|
|
228
|
+
codeLens: {
|
|
229
|
+
implementations: true,
|
|
230
|
+
references: true
|
|
231
|
+
},
|
|
232
|
+
suggest: {
|
|
233
|
+
autoImports: true,
|
|
234
|
+
completeFunctionCalls: false,
|
|
235
|
+
names: true,
|
|
236
|
+
paths: true,
|
|
237
|
+
imports: {
|
|
238
|
+
autoDiscover: true,
|
|
239
|
+
hosts: {
|
|
240
|
+
'https://deno.land': true
|
|
310
241
|
}
|
|
311
242
|
}
|
|
312
243
|
}
|
|
313
|
-
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
else if (lang === 'python') {
|
|
247
|
+
await connectToLanguageServer(`wss://${$page.url.host}/ws/pyright`, 'pyright', {
|
|
248
|
+
executionEnvironments: [
|
|
249
|
+
{
|
|
250
|
+
root: '/tmp/pyright',
|
|
251
|
+
pythonVersion: '3.7',
|
|
252
|
+
pythonPlatform: 'platform',
|
|
253
|
+
extraPaths: []
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
});
|
|
257
|
+
connectToLanguageServer(`wss://${$page.url.host}/ws/black`, 'black', {
|
|
258
|
+
formatters: {
|
|
259
|
+
black: {
|
|
260
|
+
command: 'black',
|
|
261
|
+
args: ['--quiet', '-']
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
formatFiletypes: {
|
|
265
|
+
python: 'black'
|
|
266
|
+
}
|
|
267
|
+
});
|
|
314
268
|
}
|
|
269
|
+
websocketInterval && clearInterval(websocketInterval);
|
|
270
|
+
websocketInterval = setInterval(() => {
|
|
271
|
+
if (document.visibilityState == 'visible') {
|
|
272
|
+
if (!lastWsAttempt ||
|
|
273
|
+
(new Date().getTime() - lastWsAttempt.getTime() > 60000 && nbWsAttempt < 2)) {
|
|
274
|
+
if (!websocketAlive.black && !websocketAlive.deno && !websocketAlive.pyright) {
|
|
275
|
+
console.log('reconnecting to language servers');
|
|
276
|
+
lastWsAttempt = new Date();
|
|
277
|
+
nbWsAttempt++;
|
|
278
|
+
reloadWebsocket();
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
if (nbWsAttempt >= 2) {
|
|
282
|
+
sendUserToast('Giving up on establishing smart assistant connection', true);
|
|
283
|
+
clearInterval(websocketInterval);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}, 5000);
|
|
315
289
|
}
|
|
316
290
|
async function closeWebsockets() {
|
|
317
291
|
command && command.dispose();
|
|
@@ -336,28 +310,8 @@ async function closeWebsockets() {
|
|
|
336
310
|
}
|
|
337
311
|
async function loadMonaco() {
|
|
338
312
|
const model = monaco.editor.createModel(code, lang, monaco.Uri.parse(uri));
|
|
339
|
-
model.updateOptions(
|
|
340
|
-
editor = monaco.editor.create(divEl,
|
|
341
|
-
model: model,
|
|
342
|
-
value: code,
|
|
343
|
-
language: lang,
|
|
344
|
-
automaticLayout,
|
|
345
|
-
readOnly: false,
|
|
346
|
-
fixedOverflowWidgets: true,
|
|
347
|
-
autoDetectHighContrast: true,
|
|
348
|
-
//lineNumbers: 'off',
|
|
349
|
-
//lineDecorationsWidth: 0,
|
|
350
|
-
lineNumbersMinChars: 4,
|
|
351
|
-
lineNumbers: (ln) => '<span class="pr-4 text-gray-400">' + ln + '</span>',
|
|
352
|
-
folding: false,
|
|
353
|
-
scrollBeyondLastLine: false,
|
|
354
|
-
minimap: {
|
|
355
|
-
enabled: false
|
|
356
|
-
},
|
|
357
|
-
lightbulb: {
|
|
358
|
-
enabled: true
|
|
359
|
-
}
|
|
360
|
-
});
|
|
313
|
+
model.updateOptions(updateOptions);
|
|
314
|
+
editor = monaco.editor.create(divEl, editorConfig(model, code, lang, automaticLayout));
|
|
361
315
|
if (shouldBindKey) {
|
|
362
316
|
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, function () {
|
|
363
317
|
format();
|
|
@@ -378,29 +332,17 @@ async function loadMonaco() {
|
|
|
378
332
|
});
|
|
379
333
|
editor.onDidFocusEditorText(() => {
|
|
380
334
|
dispatch('focus');
|
|
381
|
-
if (
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
reloadWebsocket();
|
|
387
|
-
}
|
|
335
|
+
if (!websocketAlive.black &&
|
|
336
|
+
!websocketAlive.deno &&
|
|
337
|
+
!websocketAlive.pyright &&
|
|
338
|
+
!websocketInterval) {
|
|
339
|
+
reloadWebsocket();
|
|
388
340
|
}
|
|
389
341
|
});
|
|
390
342
|
editor.onDidBlurEditorText(() => {
|
|
391
343
|
dispatch('blur');
|
|
392
344
|
});
|
|
393
|
-
|
|
394
|
-
monaco.languages.typescript.javascriptDefaults.setExtraLibs([
|
|
395
|
-
{
|
|
396
|
-
content: extraLib,
|
|
397
|
-
filePath: extraLibPath
|
|
398
|
-
}
|
|
399
|
-
]);
|
|
400
|
-
}
|
|
401
|
-
if (lang == 'python' || deno) {
|
|
402
|
-
reloadWebsocket();
|
|
403
|
-
}
|
|
345
|
+
reloadWebsocket();
|
|
404
346
|
return () => {
|
|
405
347
|
try {
|
|
406
348
|
closeWebsockets();
|
|
@@ -411,6 +353,17 @@ async function loadMonaco() {
|
|
|
411
353
|
}
|
|
412
354
|
};
|
|
413
355
|
}
|
|
356
|
+
export function addAction(id, label, callback, keybindings = []) {
|
|
357
|
+
editor.addAction({
|
|
358
|
+
id,
|
|
359
|
+
label,
|
|
360
|
+
keybindings,
|
|
361
|
+
contextMenuGroupId: 'navigation',
|
|
362
|
+
run: function (editor) {
|
|
363
|
+
callback(editor);
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}
|
|
414
367
|
onMount(() => {
|
|
415
368
|
if (browser) {
|
|
416
369
|
loadMonaco().then((x) => (disposeMethod = x));
|
|
@@ -433,20 +386,5 @@ onDestroy(() => {
|
|
|
433
386
|
padding-left: 0px;
|
|
434
387
|
padding-right: 0px;
|
|
435
388
|
/* stylelint-disable-next-line unit-allowed-list */
|
|
436
|
-
height: 80vh
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
.small-editor {
|
|
440
|
-
/* stylelint-disable-next-line unit-allowed-list */
|
|
441
|
-
height: 26vh;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
.few-lines-editor {
|
|
445
|
-
/* stylelint-disable-next-line unit-allowed-list */
|
|
446
|
-
height: 80px;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
.two-lines-editor {
|
|
450
|
-
/* stylelint-disable-next-line unit-allowed-list */
|
|
451
|
-
height: 40px;
|
|
452
|
-
}</style>
|
|
389
|
+
height: 80vh
|
|
390
|
+
}</style>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import * as monaco from 'monaco-editor';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
[x: string]: any;
|
|
5
|
-
|
|
6
|
-
lang?: string | undefined;
|
|
6
|
+
lang: 'typescript' | 'python' | 'go';
|
|
7
7
|
code?: string | undefined;
|
|
8
8
|
hash?: string | undefined;
|
|
9
9
|
cmdEnterAction?: (() => void) | undefined;
|
|
@@ -14,8 +14,6 @@ declare const __propDef: {
|
|
|
14
14
|
black: boolean;
|
|
15
15
|
deno: boolean;
|
|
16
16
|
} | undefined;
|
|
17
|
-
extraLib?: string | undefined;
|
|
18
|
-
extraLibPath?: string | undefined;
|
|
19
17
|
shouldBindKey?: boolean | undefined;
|
|
20
18
|
getCode?: (() => string) | undefined;
|
|
21
19
|
insertAtCursor?: ((code: string) => void) | undefined;
|
|
@@ -23,6 +21,7 @@ declare const __propDef: {
|
|
|
23
21
|
setCode?: ((ncode: string) => void) | undefined;
|
|
24
22
|
clearContent?: (() => Promise<void>) | undefined;
|
|
25
23
|
reloadWebsocket?: (() => Promise<void>) | undefined;
|
|
24
|
+
addAction?: ((id: string, label: string, callback: (editor: monaco.editor.IStandaloneCodeEditor) => void, keybindings?: number[]) => void) | undefined;
|
|
26
25
|
};
|
|
27
26
|
events: {
|
|
28
27
|
change: CustomEvent<any>;
|
|
@@ -43,5 +42,6 @@ export default class Editor extends SvelteComponentTyped<EditorProps, EditorEven
|
|
|
43
42
|
get setCode(): (ncode: string) => void;
|
|
44
43
|
get clearContent(): () => Promise<void>;
|
|
45
44
|
get reloadWebsocket(): () => Promise<void>;
|
|
45
|
+
get addAction(): (id: string, label: string, callback: (editor: monaco.editor.IStandaloneCodeEditor) => void, keybindings?: number[]) => void;
|
|
46
46
|
}
|
|
47
47
|
export {};
|