windmill-components 1.35.42 → 1.36.0
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/AppConnect.svelte +85 -59
- package/components/ArgInput.svelte +50 -33
- package/components/ArgInput.svelte.d.ts +1 -1
- package/components/Button.svelte +15 -48
- package/components/Button.svelte.d.ts +1 -1
- package/components/CronInput.svelte +1 -1
- package/components/DisplayResult.svelte +75 -67
- package/components/Dropdown.svelte +9 -7
- package/components/Editor.svelte +187 -178
- package/components/Editor.svelte.d.ts +4 -2
- package/components/EditorBar.svelte +135 -98
- package/components/EditorBar.svelte.d.ts +2 -1
- package/components/FlowBuilder.svelte +115 -134
- package/components/FlowJobResult.svelte +4 -5
- package/components/FlowModulesViewer.svelte +89 -7
- package/components/FlowModulesViewer.svelte.d.ts +1 -0
- package/components/FlowPreviewContent.svelte +88 -27
- package/components/FlowPreviewContent.svelte.d.ts +1 -1
- package/components/FlowStatusViewer.svelte +39 -24
- package/components/FlowStatusViewer.svelte.d.ts +0 -1
- package/components/FlowViewer.svelte +17 -11
- package/components/GroupModal.svelte +10 -1
- package/components/HighlightCode.svelte +22 -0
- package/components/HighlightCode.svelte.d.ts +17 -0
- package/components/IconedPath.svelte +9 -7
- package/components/InputTransformForm.svelte +97 -115
- package/components/InputTransformForm.svelte.d.ts +0 -1
- package/components/InputTransformsViewer.svelte +1 -1
- package/components/InviteGlobalUser.svelte +8 -8
- package/components/InviteUser.svelte +9 -9
- package/components/ItemPicker.svelte +37 -30
- package/components/ItemPicker.svelte.d.ts +2 -1
- package/components/JobStatus.svelte +2 -1
- package/components/LogViewer.svelte +23 -0
- package/components/LogViewer.svelte.d.ts +19 -0
- package/components/ModulePreview.svelte +107 -0
- package/components/ModulePreview.svelte.d.ts +24 -0
- package/components/Path.svelte +1 -1
- package/components/RadioButton.svelte +3 -2
- package/components/ResourceEditor.svelte +22 -34
- package/components/ResourceTypePicker.svelte +23 -34
- package/components/RunForm.svelte +34 -31
- package/components/RunForm.svelte.d.ts +6 -2
- package/components/SchemaEditor.svelte +19 -11
- package/components/SchemaForm.svelte +3 -3
- package/components/SchemaForm.svelte.d.ts +1 -1
- package/components/SchemaModal.svelte +18 -7
- package/components/ScriptBuilder.svelte +99 -83
- package/components/ScriptBuilder.svelte.d.ts +2 -4
- package/components/ScriptEditor.svelte +71 -143
- package/components/ScriptEditor.svelte.d.ts +0 -5
- package/components/ScriptPicker.svelte +24 -14
- package/components/ScriptPicker.svelte.d.ts +2 -1
- package/components/ScriptSchema.svelte +8 -11
- package/components/ScriptSchema.svelte.d.ts +0 -1
- package/components/ShareModal.svelte +6 -6
- package/components/SharedBadge.svelte +5 -13
- package/components/SimpleEditor.svelte +14 -10
- package/components/StringTypeNarrowing.svelte +24 -30
- package/components/TestJobLoader.svelte +106 -0
- package/components/TestJobLoader.svelte.d.ts +26 -0
- package/components/Tooltip.svelte +3 -2
- package/components/VariableEditor.svelte +15 -24
- package/components/common/actionRow/ActionRow.svelte +31 -0
- package/components/common/actionRow/ActionRow.svelte.d.ts +22 -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 +76 -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 +110 -0
- package/components/common/button/Button.svelte.d.ts +39 -0
- package/components/common/button/model.d.ts +6 -0
- package/components/common/button/model.js +1 -0
- package/components/common/confirmationModal/ConfirmationModal.svelte +72 -0
- package/components/common/confirmationModal/ConfirmationModal.svelte.d.ts +23 -0
- package/components/common/confirmationModal/UnsavedConfirmationModal.svelte +41 -0
- package/components/common/confirmationModal/UnsavedConfirmationModal.svelte.d.ts +14 -0
- package/components/common/confirmationModal/dirtyStore.d.ts +1 -0
- package/components/common/confirmationModal/dirtyStore.js +2 -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 -6
- 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 +25 -0
- package/components/flows/content/FlowEditorPanel.svelte.d.ts +16 -0
- package/components/flows/content/FlowFailureModule.svelte +15 -0
- package/components/flows/content/FlowFailureModule.svelte.d.ts +14 -0
- package/components/flows/content/FlowInput.svelte +26 -0
- package/components/flows/{FlowInput.svelte.d.ts → content/FlowInput.svelte.d.ts} +0 -0
- package/components/flows/content/FlowInputs.svelte +91 -0
- package/components/flows/{FlowInputs.svelte.d.ts → content/FlowInputs.svelte.d.ts} +1 -0
- package/components/flows/content/FlowLoop.svelte +168 -0
- package/components/flows/content/FlowLoop.svelte.d.ts +18 -0
- package/components/flows/content/FlowLoopWrapper.svelte +9 -0
- package/components/flows/content/FlowLoopWrapper.svelte.d.ts +14 -0
- package/components/flows/content/FlowModule.svelte +211 -0
- package/components/flows/content/FlowModule.svelte.d.ts +29 -0
- package/components/flows/content/FlowModuleEarlyStop.svelte +76 -0
- package/components/flows/content/FlowModuleEarlyStop.svelte.d.ts +17 -0
- package/components/flows/content/FlowModuleHeader.svelte +157 -0
- package/components/flows/{FlowModuleHeader.svelte.d.ts → content/FlowModuleHeader.svelte.d.ts} +5 -3
- package/components/flows/content/FlowModuleScript.svelte +21 -0
- package/components/flows/content/FlowModuleScript.svelte.d.ts +17 -0
- package/components/flows/content/FlowModuleSuspend.svelte +27 -0
- package/components/flows/content/FlowModuleSuspend.svelte.d.ts +17 -0
- package/components/flows/content/FlowModuleWrapper.svelte +45 -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 +17 -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 +78 -0
- package/components/flows/{FlowSettings.svelte.d.ts → content/FlowSettings.svelte.d.ts} +2 -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 +16 -14
- package/components/flows/flowStateUtils.js +81 -73
- package/components/flows/flowStore.js +7 -4
- package/components/flows/header/FlowImportExportMenu.svelte +55 -0
- package/components/flows/header/FlowImportExportMenu.svelte.d.ts +14 -0
- package/components/flows/header/FlowPreviewButtons.svelte +57 -0
- package/components/flows/header/FlowPreviewButtons.svelte.d.ts +14 -0
- package/components/flows/map/FlowErrorHandlerItem.svelte +60 -0
- package/components/flows/map/FlowErrorHandlerItem.svelte.d.ts +14 -0
- package/components/flows/map/FlowModuleSchemaItem.svelte +80 -0
- package/components/flows/map/FlowModuleSchemaItem.svelte.d.ts +32 -0
- package/components/flows/map/FlowModuleSchemaMap.svelte +241 -0
- package/components/flows/map/FlowModuleSchemaMap.svelte.d.ts +20 -0
- package/components/flows/pickers/PickHubScript.svelte +5 -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 +44 -0
- package/components/flows/propPicker/PropPickerWrapper.svelte.d.ts +33 -0
- package/components/flows/scheduleUtils.d.ts +0 -1
- package/components/flows/scheduleUtils.js +0 -1
- package/components/flows/types.d.ts +8 -0
- package/components/flows/types.js +1 -0
- package/components/flows/utils.d.ts +3 -1
- package/components/flows/utils.js +26 -10
- package/components/icons/AirtableIcon.svelte +1 -1
- package/components/icons/DiscordIcon.svelte +1 -1
- package/components/icons/GCloudIcon.svelte +1 -1
- package/components/icons/GItlabIcon.svelte +1 -1
- package/components/icons/GSheetsIcon.svelte +1 -1
- package/components/icons/GcalIcon.svelte +1 -1
- package/components/icons/GdriveIcon.svelte +1 -1
- package/components/icons/GithubIcon.svelte +1 -1
- package/components/icons/GmailIcon.svelte +1 -1
- package/components/icons/HatIcon.svelte +19 -0
- package/components/icons/HatIcon.svelte.d.ts +16 -0
- package/components/icons/MastodonIcon.svelte +1 -1
- package/components/icons/MatrixIcon.svelte +1 -1
- package/components/icons/PostgresIcon.svelte +1 -1
- package/components/icons/S3Icon.svelte +1 -1
- package/components/icons/Slack.svelte +1 -1
- package/components/icons/TogglIcon.svelte +8 -46
- package/components/jobs/JobDetail.svelte +1 -1
- 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 +18 -12
- package/components/propertyPicker/ObjectViewer.svelte.d.ts +1 -0
- package/components/propertyPicker/PropPicker.svelte +108 -11
- 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 +3 -0
- package/editorUtils.js +1 -0
- package/gen/core/OpenAPI.js +1 -1
- package/gen/index.d.ts +1 -0
- package/gen/models/CompletedJob.d.ts +2 -1
- package/gen/models/CompletedJob.js +1 -0
- package/gen/models/FlowModule.d.ts +3 -0
- package/gen/models/FlowStatus.d.ts +3 -0
- package/gen/models/FlowStatusModule.d.ts +1 -1
- 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/Retry.d.ts +11 -0
- package/gen/models/Retry.js +4 -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 +71 -38
- package/script_helpers.d.ts +8 -2
- package/script_helpers.js +88 -16
- package/stores.d.ts +1 -1
- package/utils.d.ts +8 -6
- package/utils.js +57 -21
- 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/FlowInputs.svelte +0 -65
- 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
|
@@ -4,6 +4,7 @@ import TableCustom from './TableCustom.svelte';
|
|
|
4
4
|
import { truncate } from '../utils';
|
|
5
5
|
export let result;
|
|
6
6
|
let resultKind = inferResultKind(result);
|
|
7
|
+
let forceJson = false;
|
|
7
8
|
function isRectangularArray(obj) {
|
|
8
9
|
if (!Array.isArray(obj) || obj.length == 0) {
|
|
9
10
|
return false;
|
|
@@ -40,6 +41,9 @@ function inferResultKind(result) {
|
|
|
40
41
|
else if (keys.length == 1 && keys[0] == 'file') {
|
|
41
42
|
return 'file';
|
|
42
43
|
}
|
|
44
|
+
else if (keys.length == 1 && keys[0] == 'error') {
|
|
45
|
+
return 'error';
|
|
46
|
+
}
|
|
43
47
|
}
|
|
44
48
|
catch (err) { }
|
|
45
49
|
}
|
|
@@ -47,74 +51,78 @@ function inferResultKind(result) {
|
|
|
47
51
|
}
|
|
48
52
|
</script>
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
{#if
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
<div class="inline-highlight">
|
|
55
|
+
{#if result}
|
|
56
|
+
{#if resultKind && resultKind != 'json'}
|
|
57
|
+
<div class="mb-2 text-gray-500 text-sm bg-gray-50/20">
|
|
58
|
+
as JSON <input type="checkbox" bind:checked={forceJson} /></div
|
|
59
|
+
>{/if}{#if typeof result == 'object' && Object.keys(result).length > 0}<div
|
|
60
|
+
class="mb-2 text-gray-700"
|
|
61
|
+
>The result keys are: <b>{truncate(Object.keys(result).join(', '), 50)}</b></div
|
|
62
|
+
>{/if}{#if !forceJson && resultKind == 'table-col'}<div
|
|
63
|
+
class="grid grid-flow-col-dense border border-gray-200 rounded-md "
|
|
64
|
+
>
|
|
65
|
+
{#each Object.keys(result) as col}
|
|
66
|
+
<div class="flex flex-col max-h-40 min-w-full overflow-auto">
|
|
67
|
+
<div
|
|
68
|
+
class="px-12 text-left uppercase border-b bg-gray-50 overflow-hidden rounded-t-md "
|
|
69
|
+
>
|
|
70
|
+
{col}
|
|
71
|
+
</div>
|
|
72
|
+
{#if Array.isArray(result[col])}
|
|
73
|
+
{#each result[col] as item}
|
|
74
|
+
<div class="px-12 text-left whitespace-nowrap">
|
|
75
|
+
{typeof item === 'string' ? item : JSON.stringify(item)}
|
|
76
|
+
</div>
|
|
77
|
+
{/each}
|
|
78
|
+
{/if}
|
|
61
79
|
</div>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
80
|
+
{/each}
|
|
81
|
+
</div>
|
|
82
|
+
{:else if !forceJson && resultKind == 'table-row'}<div
|
|
83
|
+
class="grid grid-flow-col-dense border border-gray-200 rounded-md "
|
|
84
|
+
>
|
|
85
|
+
<TableCustom>
|
|
86
|
+
<tbody slot="body">
|
|
87
|
+
{#each asListOfList(result) as row}
|
|
88
|
+
<tr>
|
|
89
|
+
{#each row as v}
|
|
90
|
+
<td>{truncate(JSON.stringify(v), 200) ?? ''}</td>
|
|
91
|
+
{/each}
|
|
92
|
+
</tr>
|
|
67
93
|
{/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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
class="w-auto h-full"
|
|
100
|
-
src="data:image/jpeg;base64,{result.jpeg}"
|
|
94
|
+
</tbody>
|
|
95
|
+
</TableCustom>
|
|
96
|
+
</div>
|
|
97
|
+
{:else if !forceJson && resultKind == 'png'}
|
|
98
|
+
<div class="h-full"
|
|
99
|
+
><img alt="png rendered" class="w-auto h-full" src="data:image/png;base64,{result.png}" />
|
|
100
|
+
</div>
|
|
101
|
+
{:else if !forceJson && resultKind == 'jpeg'}
|
|
102
|
+
<div class="h-full"
|
|
103
|
+
><img
|
|
104
|
+
alt="jpeg rendered"
|
|
105
|
+
class="w-auto h-full"
|
|
106
|
+
src="data:image/jpeg;base64,{result.jpeg}"
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
{:else if !forceJson && resultKind == 'gif'}
|
|
110
|
+
<div class="h-full"
|
|
111
|
+
><img alt="gif rendered" class="w-auto h-full" src="data:image/gif;base64,{result.gif}" />
|
|
112
|
+
</div>
|
|
113
|
+
{:else if !forceJson && resultKind == 'file'}
|
|
114
|
+
<div
|
|
115
|
+
><a download="windmill.file" href="data:application/octet-stream;base64,{result.file}"
|
|
116
|
+
>Download</a
|
|
117
|
+
>
|
|
118
|
+
</div>
|
|
119
|
+
{:else if !forceJson && resultKind == 'error'}<div
|
|
120
|
+
><pre class="text-sm text-red-500">{result.error}</pre>
|
|
121
|
+
</div>
|
|
122
|
+
{:else}<Highlight
|
|
123
|
+
language={json}
|
|
124
|
+
code={JSON.stringify(result, null, 4).replace(/\\n/g, '\n')}
|
|
101
125
|
/>
|
|
102
|
-
|
|
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')} />
|
|
126
|
+
{/if}
|
|
119
127
|
{/if}
|
|
120
|
-
|
|
128
|
+
</div>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { createEventDispatcher } from 'svelte';
|
|
3
3
|
import Icon from 'svelte-awesome';
|
|
4
4
|
import { faEllipsisH } from '@fortawesome/free-solid-svg-icons';
|
|
5
|
+
import { Button } from './common';
|
|
5
6
|
let open = false;
|
|
6
7
|
export let dropdownItems;
|
|
7
8
|
export let name = undefined;
|
|
@@ -20,15 +21,16 @@ function handleClickOutsideMenu(event) {
|
|
|
20
21
|
</script>
|
|
21
22
|
|
|
22
23
|
<div
|
|
23
|
-
class="ml-
|
|
24
|
+
class="ml-2 {relative ? 'relative' : ''} {$$props.class}"
|
|
24
25
|
use:clickOutside
|
|
25
26
|
on:click_outside={handleClickOutsideMenu}
|
|
26
27
|
>
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
<Button
|
|
29
|
+
color="light"
|
|
30
|
+
size="xs"
|
|
30
31
|
aria-expanded="false"
|
|
31
32
|
aria-haspopup="true"
|
|
33
|
+
btnClasses="!text-blue-500 bg-transparent"
|
|
32
34
|
on:click={openMenu}
|
|
33
35
|
>
|
|
34
36
|
{#if !name}
|
|
@@ -36,7 +38,7 @@ function handleClickOutsideMenu(event) {
|
|
|
36
38
|
{:else}
|
|
37
39
|
{name}
|
|
38
40
|
{/if}
|
|
39
|
-
</
|
|
41
|
+
</Button>
|
|
40
42
|
<div
|
|
41
43
|
class="flex flex-col z-50 origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg py-1 bg-white ring-1 ring-black ring-opacity-5 focus:outline-none {open
|
|
42
44
|
? 'visible'
|
|
@@ -48,10 +50,10 @@ function handleClickOutsideMenu(event) {
|
|
|
48
50
|
{#each dropdownItems as item, i}
|
|
49
51
|
{#if item.action}
|
|
50
52
|
<button
|
|
51
|
-
on:click={() => {
|
|
53
|
+
on:click={(event) => {
|
|
52
54
|
if (!item.disabled) {
|
|
53
55
|
open = false
|
|
54
|
-
item.action && item.action()
|
|
56
|
+
item.action && item.action(event)
|
|
55
57
|
dispatch('click', { item: item?.eventName })
|
|
56
58
|
}
|
|
57
59
|
}}
|
package/components/Editor.svelte
CHANGED
|
@@ -22,13 +22,18 @@ 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
|
+
import { dirtyStore } from './common/confirmationModal/dirtyStore';
|
|
26
|
+
try {
|
|
27
|
+
StandaloneServices.initialize({
|
|
28
|
+
...getMessageServiceOverride(document.body)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
console.error(e);
|
|
33
|
+
}
|
|
28
34
|
let divEl = null;
|
|
29
35
|
let editor;
|
|
30
|
-
export let
|
|
31
|
-
export let lang = deno ? 'typescript' : 'python';
|
|
36
|
+
export let lang;
|
|
32
37
|
export let code = '';
|
|
33
38
|
export let hash = randomHash();
|
|
34
39
|
export let cmdEnterAction = undefined;
|
|
@@ -108,87 +113,87 @@ let command = undefined;
|
|
|
108
113
|
let monacoServices = undefined;
|
|
109
114
|
export async function reloadWebsocket() {
|
|
110
115
|
await closeWebsockets();
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
}
|
|
116
|
+
const { MonacoLanguageClient } = await import('monaco-languageclient');
|
|
117
|
+
const { CloseAction, ErrorAction } = await import('vscode-languageclient');
|
|
118
|
+
const { toSocket, WebSocketMessageReader, WebSocketMessageWriter } = await import('vscode-ws-jsonrpc');
|
|
119
|
+
const vscode = await import('vscode');
|
|
120
|
+
const { RequestType } = await import('vscode-jsonrpc');
|
|
121
|
+
// install Monaco language client services
|
|
122
|
+
const { MonacoServices } = await import('monaco-languageclient');
|
|
123
|
+
monacoServices = MonacoServices.install();
|
|
124
|
+
function createLanguageClient(transports, name, initializationOptions) {
|
|
125
|
+
const client = new MonacoLanguageClient({
|
|
126
|
+
name: name,
|
|
127
|
+
clientOptions: {
|
|
128
|
+
documentSelector: [lang],
|
|
129
|
+
errorHandler: {
|
|
130
|
+
error: () => ({ action: ErrorAction.Continue }),
|
|
131
|
+
closed: () => ({
|
|
132
|
+
action: CloseAction.Restart
|
|
133
|
+
})
|
|
134
|
+
},
|
|
135
|
+
markdown: {
|
|
136
|
+
isTrusted: true
|
|
147
137
|
},
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
138
|
+
// workspaceFolder: { uri: Uri.parse(`/tmp/${name}`), name: 'tmp', index: 0 },
|
|
139
|
+
initializationOptions,
|
|
140
|
+
middleware: {
|
|
141
|
+
workspace: {
|
|
142
|
+
configuration: (params, token, configuration) => {
|
|
143
|
+
return [
|
|
144
|
+
{
|
|
145
|
+
enable: true
|
|
146
|
+
}
|
|
147
|
+
];
|
|
148
|
+
}
|
|
151
149
|
}
|
|
152
150
|
}
|
|
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
|
-
});
|
|
151
|
+
},
|
|
152
|
+
connectionProvider: {
|
|
153
|
+
get: () => {
|
|
154
|
+
return Promise.resolve(transports);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
return client;
|
|
159
|
+
}
|
|
160
|
+
async function connectToLanguageServer(url, name, options) {
|
|
161
|
+
try {
|
|
162
|
+
const webSocket = new WebSocket(url);
|
|
163
|
+
webSocket.onopen = async () => {
|
|
164
|
+
const socket = toSocket(webSocket);
|
|
165
|
+
const reader = new WebSocketMessageReader(socket);
|
|
166
|
+
const writer = new WebSocketMessageWriter(socket);
|
|
167
|
+
const languageClient = createLanguageClient({ reader, writer }, name, options);
|
|
168
|
+
websockets.push([languageClient, webSocket]);
|
|
169
|
+
reader.onClose(async () => {
|
|
178
170
|
try {
|
|
179
|
-
console.log('
|
|
180
|
-
|
|
171
|
+
console.log('CLOSE');
|
|
172
|
+
websocketAlive[name] = false;
|
|
173
|
+
await languageClient.stop();
|
|
181
174
|
}
|
|
182
175
|
catch (err) {
|
|
183
|
-
console.log('err at client');
|
|
184
176
|
console.error(err);
|
|
185
|
-
throw new Error(err);
|
|
186
177
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
178
|
+
});
|
|
179
|
+
socket.onClose((_code, _reason) => {
|
|
180
|
+
websocketAlive[name] = false;
|
|
181
|
+
});
|
|
182
|
+
try {
|
|
183
|
+
console.log('started client');
|
|
184
|
+
await languageClient.start();
|
|
185
|
+
}
|
|
186
|
+
catch (err) {
|
|
187
|
+
console.log('err at client');
|
|
188
|
+
console.error(err);
|
|
189
|
+
throw new Error(err);
|
|
190
|
+
}
|
|
191
|
+
lastWsAttempt = new Date();
|
|
192
|
+
nbWsAttempt = 0;
|
|
193
|
+
if (name == 'deno') {
|
|
194
|
+
command && command.dispose();
|
|
195
|
+
command = undefined;
|
|
196
|
+
try {
|
|
192
197
|
command = vscode.commands.registerCommand('deno.cache', (uris = []) => {
|
|
193
198
|
languageClient.sendRequest(new RequestType('deno/cache'), {
|
|
194
199
|
referrer: { uri },
|
|
@@ -196,90 +201,92 @@ export async function reloadWebsocket() {
|
|
|
196
201
|
});
|
|
197
202
|
});
|
|
198
203
|
}
|
|
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
|
-
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
console.error(err);
|
|
234
206
|
}
|
|
235
207
|
}
|
|
236
|
-
|
|
208
|
+
websocketAlive[name] = true;
|
|
209
|
+
};
|
|
237
210
|
}
|
|
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
|
-
});
|
|
211
|
+
catch (err) {
|
|
212
|
+
console.error(`connection to ${name} language server failed`);
|
|
260
213
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
214
|
+
}
|
|
215
|
+
if (lang == 'typescript') {
|
|
216
|
+
await connectToLanguageServer(`wss://${$page.url.host}/ws/deno`, 'deno', {
|
|
217
|
+
certificateStores: null,
|
|
218
|
+
enablePaths: [],
|
|
219
|
+
config: null,
|
|
220
|
+
importMap: null,
|
|
221
|
+
internalDebug: false,
|
|
222
|
+
lint: false,
|
|
223
|
+
path: null,
|
|
224
|
+
tlsCertificate: null,
|
|
225
|
+
unsafelyIgnoreCertificateErrors: null,
|
|
226
|
+
unstable: true,
|
|
227
|
+
enable: true,
|
|
228
|
+
cache: null,
|
|
229
|
+
codeLens: {
|
|
230
|
+
implementations: true,
|
|
231
|
+
references: true
|
|
232
|
+
},
|
|
233
|
+
suggest: {
|
|
234
|
+
autoImports: true,
|
|
235
|
+
completeFunctionCalls: false,
|
|
236
|
+
names: true,
|
|
237
|
+
paths: true,
|
|
238
|
+
imports: {
|
|
239
|
+
autoDiscover: true,
|
|
240
|
+
hosts: {
|
|
241
|
+
'https://deno.land': true
|
|
278
242
|
}
|
|
279
243
|
}
|
|
280
244
|
}
|
|
281
|
-
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
else if (lang === 'python') {
|
|
248
|
+
await connectToLanguageServer(`wss://${$page.url.host}/ws/pyright`, 'pyright', {
|
|
249
|
+
executionEnvironments: [
|
|
250
|
+
{
|
|
251
|
+
root: '/tmp/pyright',
|
|
252
|
+
pythonVersion: '3.7',
|
|
253
|
+
pythonPlatform: 'platform',
|
|
254
|
+
extraPaths: []
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
});
|
|
258
|
+
connectToLanguageServer(`wss://${$page.url.host}/ws/black`, 'black', {
|
|
259
|
+
formatters: {
|
|
260
|
+
black: {
|
|
261
|
+
command: 'black',
|
|
262
|
+
args: ['--quiet', '-']
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
formatFiletypes: {
|
|
266
|
+
python: 'black'
|
|
267
|
+
}
|
|
268
|
+
});
|
|
282
269
|
}
|
|
270
|
+
websocketInterval && clearInterval(websocketInterval);
|
|
271
|
+
websocketInterval = setInterval(() => {
|
|
272
|
+
if (document.visibilityState == 'visible') {
|
|
273
|
+
if (!lastWsAttempt ||
|
|
274
|
+
(new Date().getTime() - lastWsAttempt.getTime() > 60000 && nbWsAttempt < 2)) {
|
|
275
|
+
if (!websocketAlive.black && !websocketAlive.deno && !websocketAlive.pyright) {
|
|
276
|
+
console.log('reconnecting to language servers');
|
|
277
|
+
lastWsAttempt = new Date();
|
|
278
|
+
nbWsAttempt++;
|
|
279
|
+
reloadWebsocket();
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
if (nbWsAttempt >= 2) {
|
|
283
|
+
sendUserToast('Giving up on establishing smart assistant connection', true);
|
|
284
|
+
clearInterval(websocketInterval);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}, 5000);
|
|
283
290
|
}
|
|
284
291
|
async function closeWebsockets() {
|
|
285
292
|
command && command.dispose();
|
|
@@ -306,18 +313,9 @@ async function loadMonaco() {
|
|
|
306
313
|
const model = monaco.editor.createModel(code, lang, monaco.Uri.parse(uri));
|
|
307
314
|
model.updateOptions(updateOptions);
|
|
308
315
|
editor = monaco.editor.create(divEl, editorConfig(model, code, lang, automaticLayout));
|
|
309
|
-
if (shouldBindKey) {
|
|
310
|
-
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, function () {
|
|
311
|
-
format();
|
|
312
|
-
});
|
|
313
|
-
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, function () {
|
|
314
|
-
if (cmdEnterAction) {
|
|
315
|
-
cmdEnterAction();
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
316
|
let timeoutModel = undefined;
|
|
320
317
|
editor.onDidChangeModelContent((event) => {
|
|
318
|
+
$dirtyStore = true;
|
|
321
319
|
timeoutModel && clearTimeout(timeoutModel);
|
|
322
320
|
timeoutModel = setTimeout(() => {
|
|
323
321
|
code = getCode();
|
|
@@ -326,21 +324,25 @@ async function loadMonaco() {
|
|
|
326
324
|
});
|
|
327
325
|
editor.onDidFocusEditorText(() => {
|
|
328
326
|
dispatch('focus');
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
327
|
+
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, function () {
|
|
328
|
+
code = getCode();
|
|
329
|
+
shouldBindKey && format && format();
|
|
330
|
+
});
|
|
331
|
+
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, function () {
|
|
332
|
+
code = getCode();
|
|
333
|
+
shouldBindKey && cmdEnterAction && cmdEnterAction();
|
|
334
|
+
});
|
|
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));
|
|
@@ -362,10 +375,6 @@ onDestroy(() => {
|
|
|
362
375
|
});
|
|
363
376
|
</script>
|
|
364
377
|
|
|
365
|
-
<!-- <button class="default-button px-6 max-h-8" type="button" on:click={format}>
|
|
366
|
-
Format (CtrlCmd + S)
|
|
367
|
-
</button> -->
|
|
368
|
-
|
|
369
378
|
<div bind:this={divEl} class={$$props.class} />
|
|
370
379
|
|
|
371
380
|
<style>
|