windmill-components 1.35.42 → 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 +19 -19
- package/components/ArgInput.svelte.d.ts +1 -1
- package/components/DisplayResult.svelte +73 -67
- package/components/Editor.svelte +177 -164
- package/components/Editor.svelte.d.ts +4 -2
- 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/InputTransformForm.svelte +87 -106
- 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 +3 -1
- 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 +4 -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/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 +65 -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
|
@@ -83,7 +83,7 @@ function fileChanged(e, cb) {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
function validateInput(pattern, v) {
|
|
86
|
-
if (required && (v == undefined || v == null)) {
|
|
86
|
+
if (required && (v == undefined || v == null || v === '')) {
|
|
87
87
|
error = 'This field is required';
|
|
88
88
|
valid = false;
|
|
89
89
|
}
|
|
@@ -108,8 +108,11 @@ function testRegex(pattern, value) {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
$: {
|
|
111
|
-
if (value == undefined) {
|
|
111
|
+
if (value == undefined || value == null) {
|
|
112
112
|
value = defaultValue;
|
|
113
|
+
if ((defaultValue === undefined || defaultValue === null) && inputCat === 'string') {
|
|
114
|
+
value = '';
|
|
115
|
+
}
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
export let inputCat = 'string';
|
|
@@ -156,25 +159,19 @@ $: inputCat = computeInputCat(type, format, itemsType?.type, enum_, contentEncod
|
|
|
156
159
|
</div>
|
|
157
160
|
{/if}
|
|
158
161
|
</div>
|
|
159
|
-
<span class="text-2xs">
|
|
162
|
+
<span class="text-2xs">Input preview:</span>
|
|
160
163
|
{/if}
|
|
161
164
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
<div class="text-right text-xs {error === '' ? 'text-white' : 'font-bold text-red-600'}">
|
|
168
|
-
{error === '' ? '...' : error}
|
|
169
|
-
</div>
|
|
170
|
-
{:else}
|
|
171
|
-
<div class="mt-1" />
|
|
172
|
-
{/if}
|
|
173
|
-
</div>
|
|
165
|
+
{#if description}
|
|
166
|
+
<div class="text-sm italic pb-1">
|
|
167
|
+
{description}
|
|
168
|
+
</div>
|
|
169
|
+
{/if}
|
|
174
170
|
|
|
175
171
|
<div class="flex space-x-1">
|
|
176
172
|
{#if inputCat == 'number'}
|
|
177
173
|
<input
|
|
174
|
+
on:focus
|
|
178
175
|
{disabled}
|
|
179
176
|
type="number"
|
|
180
177
|
class={valid
|
|
@@ -199,7 +196,7 @@ $: inputCat = computeInputCat(type, format, itemsType?.type, enum_, contentEncod
|
|
|
199
196
|
{:else if inputCat == 'list'}
|
|
200
197
|
<div>
|
|
201
198
|
<div>
|
|
202
|
-
{#each value ?? [] as v}
|
|
199
|
+
{#each value ?? [] as v, i}
|
|
203
200
|
<div class="flex flex-row max-w-md mt-1">
|
|
204
201
|
{#if itemsType?.type == 'number'}
|
|
205
202
|
<input type="number" bind:value={v} />
|
|
@@ -207,7 +204,7 @@ $: inputCat = computeInputCat(type, format, itemsType?.type, enum_, contentEncod
|
|
|
207
204
|
<input
|
|
208
205
|
type="file"
|
|
209
206
|
class="my-6"
|
|
210
|
-
on:change={(x) => fileChanged(x, (val) => (
|
|
207
|
+
on:change={(x) => fileChanged(x, (val) => (value[i] = val))}
|
|
211
208
|
multiple={false}
|
|
212
209
|
/>
|
|
213
210
|
{:else}
|
|
@@ -319,7 +316,7 @@ $: inputCat = computeInputCat(type, format, itemsType?.type, enum_, contentEncod
|
|
|
319
316
|
/>
|
|
320
317
|
{/if}
|
|
321
318
|
{#if !required && inputCat != 'resource-object'}
|
|
322
|
-
<Tooltip placement="bottom" content="Reset to default value">
|
|
319
|
+
<!-- <Tooltip placement="bottom" content="Reset to default value">
|
|
323
320
|
<Button
|
|
324
321
|
on:click={() => (value = undefined)}
|
|
325
322
|
{disabled}
|
|
@@ -329,9 +326,12 @@ $: inputCat = computeInputCat(type, format, itemsType?.type, enum_, contentEncod
|
|
|
329
326
|
>
|
|
330
327
|
<Icon data={faArrowRotateLeft} />
|
|
331
328
|
</Button>
|
|
332
|
-
</Tooltip>
|
|
329
|
+
</Tooltip> -->
|
|
333
330
|
{/if}
|
|
334
331
|
<slot name="actions" />
|
|
335
332
|
</div>
|
|
333
|
+
<div class="text-right text-xs {error === '' ? 'text-white' : 'font-bold text-red-600'}">
|
|
334
|
+
{error === '' ? '...' : error}
|
|
335
|
+
</div>
|
|
336
336
|
</div>
|
|
337
337
|
</div>
|
|
@@ -47,74 +47,80 @@ function inferResultKind(result) {
|
|
|
47
47
|
}
|
|
48
48
|
</script>
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
{#if
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
<div>
|
|
51
|
+
{#if result}
|
|
52
|
+
{#if typeof result == 'object' && Object.keys(result).length > 0}
|
|
53
|
+
<div>
|
|
54
|
+
The result keys are: <b>{truncate(Object.keys(result).join(', '), 50)}</b>
|
|
55
|
+
</div>{/if}{#if resultKind == 'table-col'}
|
|
56
|
+
<div class="grid grid-flow-col-dense border border-gray-200 rounded-md ">
|
|
57
|
+
{#each Object.keys(result) as col}
|
|
58
|
+
<div class="flex flex-col max-h-40 min-w-full overflow-auto">
|
|
59
|
+
<div
|
|
60
|
+
class="px-12 text-left uppercase border-b bg-gray-50 overflow-hidden rounded-t-md "
|
|
61
|
+
>
|
|
62
|
+
{col}
|
|
63
|
+
</div>
|
|
64
|
+
{#if Array.isArray(result[col])}
|
|
65
|
+
{#each result[col] as item}
|
|
66
|
+
<div class="px-12 text-left whitespace-nowrap">
|
|
67
|
+
{typeof item === 'string' ? item : JSON.stringify(item)}
|
|
68
|
+
</div>
|
|
69
|
+
{/each}
|
|
70
|
+
{/if}
|
|
61
71
|
</div>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
{/each}
|
|
73
|
+
</div>
|
|
74
|
+
{:else if resultKind == 'table-row'}<div
|
|
75
|
+
class="grid grid-flow-col-dense border border-gray-200 rounded-md "
|
|
76
|
+
>
|
|
77
|
+
<TableCustom>
|
|
78
|
+
<tbody slot="body">
|
|
79
|
+
{#each asListOfList(result) as row}
|
|
80
|
+
<tr>
|
|
81
|
+
{#each row as v}
|
|
82
|
+
<td>{truncate(JSON.stringify(v), 200) ?? ''}</td>
|
|
83
|
+
{/each}
|
|
84
|
+
</tr>
|
|
67
85
|
{/each}
|
|
68
|
-
|
|
69
|
-
</
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
</tbody>
|
|
87
|
+
</TableCustom>
|
|
88
|
+
</div>
|
|
89
|
+
{:else if resultKind == 'png'}
|
|
90
|
+
<div class="h-full">
|
|
91
|
+
Result is an image: <img
|
|
92
|
+
alt="png rendered"
|
|
93
|
+
class="w-auto h-full"
|
|
94
|
+
src="data:image/png;base64,{result.png}"
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
{:else if resultKind == 'jpeg'}
|
|
98
|
+
<div class="h-full">
|
|
99
|
+
Result is an image: <img
|
|
100
|
+
alt="jpeg rendered"
|
|
101
|
+
class="w-auto h-full"
|
|
102
|
+
src="data:image/jpeg;base64,{result.jpeg}"
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
{:else if resultKind == 'gif'}
|
|
106
|
+
<div class="h-full">
|
|
107
|
+
Result is an image: <img
|
|
108
|
+
alt="gif rendered"
|
|
109
|
+
class="w-auto h-full"
|
|
110
|
+
src="data:image/gif;base64,{result.gif}"
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
{:else if resultKind == 'file'}
|
|
114
|
+
<div>
|
|
115
|
+
Result is a file: <a
|
|
116
|
+
download="windmill.file"
|
|
117
|
+
href="data:application/octet-stream;base64,{result.file}">Download</a
|
|
118
|
+
>
|
|
119
|
+
</div>
|
|
120
|
+
{:else}<Highlight
|
|
121
|
+
language={json}
|
|
122
|
+
code={JSON.stringify(result, null, 4).replace(/\\n/g, '\n')}
|
|
93
123
|
/>
|
|
94
|
-
|
|
95
|
-
{:else if resultKind == 'jpeg'}
|
|
96
|
-
<div class="h-full">
|
|
97
|
-
Result is an image: <img
|
|
98
|
-
alt="jpeg rendered"
|
|
99
|
-
class="w-auto h-full"
|
|
100
|
-
src="data:image/jpeg;base64,{result.jpeg}"
|
|
101
|
-
/>
|
|
102
|
-
</div>
|
|
103
|
-
{:else if resultKind == 'gif'}
|
|
104
|
-
<div class="h-full">
|
|
105
|
-
Result is an image: <img
|
|
106
|
-
alt="gif rendered"
|
|
107
|
-
class="w-auto h-full"
|
|
108
|
-
src="data:image/gif;base64,{result.gif}"
|
|
109
|
-
/>
|
|
110
|
-
</div>
|
|
111
|
-
{:else if resultKind == 'file'}
|
|
112
|
-
<div>
|
|
113
|
-
Result is a file: <a
|
|
114
|
-
download="windmill.file"
|
|
115
|
-
href="data:application/octet-stream;base64,{result.file}">Download</a
|
|
116
|
-
>
|
|
117
|
-
</div>
|
|
118
|
-
{:else}<Highlight language={json} code={JSON.stringify(result, null, 4).replace(/\\n/g, '\n')} />
|
|
124
|
+
{/if}
|
|
119
125
|
{/if}
|
|
120
|
-
|
|
126
|
+
</div>
|
package/components/Editor.svelte
CHANGED
|
@@ -22,13 +22,17 @@ import getMessageServiceOverride from 'vscode/service-override/messages';
|
|
|
22
22
|
import { StandaloneServices } from 'vscode/services';
|
|
23
23
|
import { DENO_INIT_CODE_CLEAR, PYTHON_INIT_CODE_CLEAR } from '../script_helpers';
|
|
24
24
|
import { createHash as randomHash, editorConfig, langToExt, updateOptions } from '../editorUtils';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
try {
|
|
26
|
+
StandaloneServices.initialize({
|
|
27
|
+
...getMessageServiceOverride(document.body)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
console.error(e);
|
|
32
|
+
}
|
|
28
33
|
let divEl = null;
|
|
29
34
|
let editor;
|
|
30
|
-
export let
|
|
31
|
-
export let lang = deno ? 'typescript' : 'python';
|
|
35
|
+
export let lang;
|
|
32
36
|
export let code = '';
|
|
33
37
|
export let hash = randomHash();
|
|
34
38
|
export let cmdEnterAction = undefined;
|
|
@@ -108,87 +112,87 @@ let command = undefined;
|
|
|
108
112
|
let monacoServices = undefined;
|
|
109
113
|
export async function reloadWebsocket() {
|
|
110
114
|
await closeWebsockets();
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
})
|
|
130
|
-
},
|
|
131
|
-
markdown: {
|
|
132
|
-
isTrusted: true
|
|
133
|
-
},
|
|
134
|
-
// workspaceFolder: { uri: Uri.parse(`/tmp/${name}`), name: 'tmp', index: 0 },
|
|
135
|
-
initializationOptions,
|
|
136
|
-
middleware: {
|
|
137
|
-
workspace: {
|
|
138
|
-
configuration: (params, token, configuration) => {
|
|
139
|
-
return [
|
|
140
|
-
{
|
|
141
|
-
enable: true
|
|
142
|
-
}
|
|
143
|
-
];
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
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
|
+
})
|
|
147
133
|
},
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
134
|
+
markdown: {
|
|
135
|
+
isTrusted: true
|
|
136
|
+
},
|
|
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
|
+
}
|
|
151
148
|
}
|
|
152
149
|
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
console.error(err);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
socket.onClose((_code, _reason) => {
|
|
176
|
-
websocketAlive[name] = false;
|
|
177
|
-
});
|
|
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 () => {
|
|
178
169
|
try {
|
|
179
|
-
console.log('
|
|
180
|
-
|
|
170
|
+
console.log('CLOSE');
|
|
171
|
+
websocketAlive[name] = false;
|
|
172
|
+
await languageClient.stop();
|
|
181
173
|
}
|
|
182
174
|
catch (err) {
|
|
183
|
-
console.log('err at client');
|
|
184
175
|
console.error(err);
|
|
185
|
-
throw new Error(err);
|
|
186
176
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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 {
|
|
192
196
|
command = vscode.commands.registerCommand('deno.cache', (uris = []) => {
|
|
193
197
|
languageClient.sendRequest(new RequestType('deno/cache'), {
|
|
194
198
|
referrer: { uri },
|
|
@@ -196,90 +200,92 @@ export async function reloadWebsocket() {
|
|
|
196
200
|
});
|
|
197
201
|
});
|
|
198
202
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
catch (err) {
|
|
203
|
-
console.error(`connection to ${name} language server failed`);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (deno) {
|
|
207
|
-
await connectToLanguageServer(`wss://${$page.url.host}/ws/deno`, 'deno', {
|
|
208
|
-
certificateStores: null,
|
|
209
|
-
enablePaths: [],
|
|
210
|
-
config: null,
|
|
211
|
-
importMap: null,
|
|
212
|
-
internalDebug: false,
|
|
213
|
-
lint: false,
|
|
214
|
-
path: null,
|
|
215
|
-
tlsCertificate: null,
|
|
216
|
-
unsafelyIgnoreCertificateErrors: null,
|
|
217
|
-
unstable: true,
|
|
218
|
-
enable: true,
|
|
219
|
-
cache: null,
|
|
220
|
-
codeLens: {
|
|
221
|
-
implementations: true,
|
|
222
|
-
references: true
|
|
223
|
-
},
|
|
224
|
-
suggest: {
|
|
225
|
-
autoImports: true,
|
|
226
|
-
completeFunctionCalls: false,
|
|
227
|
-
names: true,
|
|
228
|
-
paths: true,
|
|
229
|
-
imports: {
|
|
230
|
-
autoDiscover: true,
|
|
231
|
-
hosts: {
|
|
232
|
-
'https://deno.land': true
|
|
233
|
-
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
console.error(err);
|
|
234
205
|
}
|
|
235
206
|
}
|
|
236
|
-
|
|
207
|
+
websocketAlive[name] = true;
|
|
208
|
+
};
|
|
237
209
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
executionEnvironments: [
|
|
241
|
-
{
|
|
242
|
-
root: '/tmp/pyright',
|
|
243
|
-
pythonVersion: '3.7',
|
|
244
|
-
pythonPlatform: 'platform',
|
|
245
|
-
extraPaths: []
|
|
246
|
-
}
|
|
247
|
-
]
|
|
248
|
-
});
|
|
249
|
-
connectToLanguageServer(`wss://${$page.url.host}/ws/black`, 'black', {
|
|
250
|
-
formatters: {
|
|
251
|
-
black: {
|
|
252
|
-
command: 'black',
|
|
253
|
-
args: ['--quiet', '-']
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
formatFiletypes: {
|
|
257
|
-
python: 'black'
|
|
258
|
-
}
|
|
259
|
-
});
|
|
210
|
+
catch (err) {
|
|
211
|
+
console.error(`connection to ${name} language server failed`);
|
|
260
212
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
|
278
241
|
}
|
|
279
242
|
}
|
|
280
243
|
}
|
|
281
|
-
}
|
|
244
|
+
});
|
|
282
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
|
+
});
|
|
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);
|
|
283
289
|
}
|
|
284
290
|
async function closeWebsockets() {
|
|
285
291
|
command && command.dispose();
|
|
@@ -326,21 +332,17 @@ async function loadMonaco() {
|
|
|
326
332
|
});
|
|
327
333
|
editor.onDidFocusEditorText(() => {
|
|
328
334
|
dispatch('focus');
|
|
329
|
-
if (
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
reloadWebsocket();
|
|
335
|
-
}
|
|
335
|
+
if (!websocketAlive.black &&
|
|
336
|
+
!websocketAlive.deno &&
|
|
337
|
+
!websocketAlive.pyright &&
|
|
338
|
+
!websocketInterval) {
|
|
339
|
+
reloadWebsocket();
|
|
336
340
|
}
|
|
337
341
|
});
|
|
338
342
|
editor.onDidBlurEditorText(() => {
|
|
339
343
|
dispatch('blur');
|
|
340
344
|
});
|
|
341
|
-
|
|
342
|
-
reloadWebsocket();
|
|
343
|
-
}
|
|
345
|
+
reloadWebsocket();
|
|
344
346
|
return () => {
|
|
345
347
|
try {
|
|
346
348
|
closeWebsockets();
|
|
@@ -351,6 +353,17 @@ async function loadMonaco() {
|
|
|
351
353
|
}
|
|
352
354
|
};
|
|
353
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
|
+
}
|
|
354
367
|
onMount(() => {
|
|
355
368
|
if (browser) {
|
|
356
369
|
loadMonaco().then((x) => (disposeMethod = x));
|