windmill-components 1.28.7 → 1.35.1
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/common.d.ts +3 -0
- package/components/AppConnect.svelte +29 -13
- package/components/ArgInput.svelte +25 -14
- package/components/ArgInput.svelte.d.ts +4 -0
- package/components/CenteredPage.svelte +2 -2
- package/components/DisplayResult.svelte +3 -3
- package/components/Editor.svelte +70 -78
- package/components/Editor.svelte.d.ts +3 -0
- package/components/EditorBar.svelte +57 -38
- package/components/FlowBuilder.svelte +39 -33
- package/components/FlowEditor.svelte +17 -58
- package/components/FlowJobResult.svelte +16 -16
- package/components/FlowModulesViewer.svelte +97 -0
- package/components/FlowModulesViewer.svelte.d.ts +17 -0
- package/components/FlowPreview.svelte +46 -66
- package/components/FlowPreview.svelte.d.ts +2 -4
- package/components/FlowPreviewContent.svelte +59 -44
- package/components/FlowPreviewContent.svelte.d.ts +0 -1
- package/components/FlowStatusViewer.svelte +104 -204
- package/components/FlowStatusViewer.svelte.d.ts +7 -4
- package/components/FlowViewer.svelte +60 -156
- package/components/FlowViewer.svelte.d.ts +0 -1
- package/components/IconedPath.svelte +12 -0
- package/components/IconedPath.svelte.d.ts +16 -0
- package/components/IconedResourceType.svelte +24 -5
- package/components/IconedResourceType.svelte.d.ts +1 -0
- package/components/InputTransformForm.svelte +9 -8
- package/components/InputTransformForm.svelte.d.ts +1 -1
- package/components/InviteGlobalUser.svelte +1 -1
- package/components/ItemPicker.svelte +6 -1
- package/components/JobStatus.svelte +1 -1
- package/components/ModuleStep.svelte +74 -94
- package/components/ModuleStep.svelte.d.ts +7 -2
- package/components/Multiselect.svelte +1 -1
- package/components/Path.svelte +62 -40
- package/components/Path.svelte.d.ts +2 -0
- package/components/ProgressBar.svelte +31 -0
- package/components/ProgressBar.svelte.d.ts +17 -0
- package/components/ProgressBarPart.svelte +20 -0
- package/components/ProgressBarPart.svelte.d.ts +20 -0
- package/components/ResourceEditor.svelte +2 -1
- package/components/ResourcePicker.svelte +9 -0
- package/components/SchemaForm.svelte +9 -4
- package/components/SchemaForm.svelte.d.ts +1 -1
- package/components/SchemaModal.svelte +20 -3
- package/components/SchemaViewer.svelte +58 -68
- package/components/ScriptBuilder.svelte +145 -122
- package/components/ScriptBuilder.svelte.d.ts +1 -0
- package/components/ScriptEditor.svelte +118 -339
- package/components/ScriptEditor.svelte.d.ts +0 -2
- package/components/ScriptSchema.svelte +45 -44
- package/components/SharedBadge.svelte +8 -3
- package/components/VariableEditor.svelte +1 -1
- package/components/common/drawer/Drawer.svelte +108 -0
- package/components/common/drawer/Drawer.svelte.d.ts +23 -0
- package/components/common/drawer/DrawerContent.svelte +19 -0
- package/components/common/drawer/DrawerContent.svelte.d.ts +20 -0
- package/components/common/menu/Menu.svelte +57 -0
- package/components/common/menu/Menu.svelte.d.ts +23 -0
- package/components/common/menu/MenuItem.svelte +9 -0
- package/components/common/menu/MenuItem.svelte.d.ts +27 -0
- package/components/common/tabs/Tab.svelte +17 -0
- package/components/common/tabs/Tab.svelte.d.ts +18 -0
- package/components/common/tabs/TabContent.svelte +12 -0
- package/components/common/tabs/TabContent.svelte.d.ts +19 -0
- package/components/common/tabs/Tabs.svelte +20 -0
- package/components/common/tabs/Tabs.svelte.d.ts +24 -0
- package/components/flows/CopyFirstStepSchema.svelte +4 -3
- package/components/flows/DynamicInputHelpBox.svelte +6 -4
- package/components/flows/DynamicInputHelpBox.svelte.d.ts +1 -1
- package/components/flows/FlowBox.svelte +15 -2
- package/components/flows/FlowBox.svelte.d.ts +14 -14
- package/components/flows/FlowBoxHeader.svelte +10 -3
- package/components/flows/FlowBoxHeader.svelte.d.ts +3 -0
- package/components/flows/FlowInput.svelte +14 -12
- package/components/flows/FlowInputs.svelte +55 -35
- package/components/flows/FlowInputs.svelte.d.ts +3 -1
- package/components/flows/FlowModuleHeader.svelte +69 -54
- package/components/flows/FlowModuleHeader.svelte.d.ts +6 -6
- package/components/flows/FlowSettings.svelte +72 -91
- package/components/flows/FlowSettings.svelte.d.ts +0 -1
- package/components/flows/FlowTimeline.svelte +169 -0
- package/components/flows/FlowTimeline.svelte.d.ts +21 -0
- package/components/flows/flowState.d.ts +14 -0
- package/components/flows/flowState.js +52 -0
- package/components/flows/flowStateUtils.d.ts +37 -0
- package/components/flows/flowStateUtils.js +220 -0
- package/components/flows/flowStore.d.ts +1 -16
- package/components/flows/flowStore.js +26 -203
- package/components/flows/pickers/FlowScriptPicker.svelte +5 -9
- package/components/flows/pickers/FlowScriptPicker.svelte.d.ts +0 -1
- package/components/flows/pickers/PickHubScript.svelte +1 -1
- package/components/flows/pickers/PickHubScript.svelte.d.ts +1 -1
- package/components/flows/pickers/PickScript.svelte +1 -1
- package/components/flows/pickers/PickScript.svelte.d.ts +1 -1
- package/components/flows/scheduleUtils.d.ts +7 -0
- package/components/flows/scheduleUtils.js +21 -0
- package/components/flows/stepOpenedStore.d.ts +1 -0
- package/components/flows/stepOpenedStore.js +6 -0
- package/components/flows/utils.d.ts +6 -13
- package/components/flows/utils.js +47 -119
- package/components/icons/DiscordIcon.svelte +16 -0
- package/components/icons/DiscordIcon.svelte.d.ts +17 -0
- package/components/icons/GithubIcon.svelte +17 -0
- package/components/icons/GithubIcon.svelte.d.ts +17 -0
- package/components/icons/HttpIcon.svelte +21 -0
- package/components/icons/HttpIcon.svelte.d.ts +17 -0
- package/components/icons/MastodonIcon.svelte +16 -0
- package/components/icons/MastodonIcon.svelte.d.ts +17 -0
- package/components/icons/MatrixIcon.svelte +16 -0
- package/components/icons/MatrixIcon.svelte.d.ts +17 -0
- package/components/icons/S3Icon.svelte +16 -0
- package/components/icons/S3Icon.svelte.d.ts +17 -0
- package/components/icons/WindmillIcon.svelte +68 -0
- package/components/icons/WindmillIcon.svelte.d.ts +17 -0
- package/components/jobs/JobDetail.svelte +176 -0
- package/components/jobs/JobDetail.svelte.d.ts +17 -0
- package/components/landing/FlowGettingStarted.svelte +95 -0
- package/components/landing/FlowGettingStarted.svelte.d.ts +19 -0
- package/components/landing/FlowLandingBox.svelte +69 -0
- package/components/landing/FlowLandingBox.svelte.d.ts +17 -0
- package/components/landing/RessourceGettingStarted.svelte +51 -0
- package/components/landing/RessourceGettingStarted.svelte.d.ts +19 -0
- package/components/landing/ScriptBox.svelte +81 -0
- package/components/landing/ScriptBox.svelte.d.ts +17 -0
- package/components/landing/ScriptGettingStarted.svelte +93 -0
- package/components/landing/ScriptGettingStarted.svelte.d.ts +19 -0
- package/components/preview/FlowPreviewStatus.svelte +28 -0
- package/components/preview/FlowPreviewStatus.svelte.d.ts +17 -0
- package/components/propertyPicker/ObjectViewer.svelte +13 -13
- package/components/propertyPicker/utils.js +3 -2
- package/components/script_editor/LogPanel.svelte +172 -0
- package/components/script_editor/LogPanel.svelte.d.ts +22 -0
- package/components/sidebar/MenuLink.svelte +49 -0
- package/components/sidebar/MenuLink.svelte.d.ts +21 -0
- package/components/sidebar/SidebarContent.svelte +55 -0
- package/components/sidebar/SidebarContent.svelte.d.ts +16 -0
- package/components/sidebar/UserMenu.svelte +62 -0
- package/components/sidebar/UserMenu.svelte.d.ts +16 -0
- package/components/sidebar/WorkspaceMenu.svelte +66 -0
- package/components/sidebar/WorkspaceMenu.svelte.d.ts +16 -0
- package/gen/core/OpenAPI.js +1 -1
- package/gen/core/request.js +1 -0
- package/gen/models/FlowModule.d.ts +5 -3
- package/gen/models/ForloopFlow.d.ts +2 -2
- package/gen/models/MainArgSignature.d.ts +14 -3
- package/gen/services/JobService.d.ts +10 -2
- package/gen/services/JobService.js +4 -2
- package/gen/services/ScriptService.d.ts +22 -6
- package/gen/services/ScriptService.js +32 -2
- package/infer.js +47 -24
- package/logout.js +1 -1
- package/package.json +58 -23
- package/script_helpers.d.ts +4 -1
- package/script_helpers.js +68 -17
- package/stores.d.ts +0 -2
- package/stores.js +0 -4
- package/utils.d.ts +5 -2
- package/utils.js +36 -5
package/common.d.ts
CHANGED
|
@@ -149,6 +149,13 @@ async function back() {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
const dispatch = createEventDispatcher();
|
|
152
|
+
$: isGoogleSignin =
|
|
153
|
+
step == 1 &&
|
|
154
|
+
(resource_type == 'google' ||
|
|
155
|
+
resource_type == 'gmail' ||
|
|
156
|
+
resource_type == 'gcal' ||
|
|
157
|
+
resource_type == 'gdrive' ||
|
|
158
|
+
resource_type == 'gsheets');
|
|
152
159
|
</script>
|
|
153
160
|
|
|
154
161
|
<Modal
|
|
@@ -161,20 +168,21 @@ const dispatch = createEventDispatcher();
|
|
|
161
168
|
loadResources()
|
|
162
169
|
}}
|
|
163
170
|
>
|
|
164
|
-
<div slot="title">Connect an
|
|
171
|
+
<div slot="title">Connect an API</div>
|
|
165
172
|
<div slot="content">
|
|
166
173
|
{#if step == 1}
|
|
167
174
|
{#if resource_type && !connects[resource_type] && !connectsManual.find((x) => x[0] == resource_type)}
|
|
168
175
|
<div class="bg-red-100 border-l-4 border-red-600 text-orange-700 p-4" role="alert">
|
|
169
|
-
<p class="font-bold">No
|
|
176
|
+
<p class="font-bold">No API integration for {resource_type}</p>
|
|
170
177
|
<p>
|
|
171
|
-
The resource type "{resource_type}" seems to not have an
|
|
172
|
-
create this resource manually by closing this modal and pressing: "Add a
|
|
173
|
-
can also contribute to windmill and add it as an
|
|
178
|
+
The resource type "{resource_type}" seems to not have an OAuth API integration. You can
|
|
179
|
+
still create this resource manually by closing this modal and pressing: "Add a
|
|
180
|
+
resource". You can also contribute to windmill and add it as an API integration if
|
|
181
|
+
relevant.
|
|
174
182
|
</p>
|
|
175
183
|
</div>
|
|
176
184
|
{/if}
|
|
177
|
-
<PageHeader title="OAuth
|
|
185
|
+
<PageHeader title="OAuth APIs" />
|
|
178
186
|
<div class="grid sm:grid-cols-2 md:grid-cols-3 gap-x-2 gap-y-1 items-center mb-2">
|
|
179
187
|
{#each Object.entries(connects).sort((a, b) => a[0].localeCompare(b[0])) as [key, values]}
|
|
180
188
|
<button
|
|
@@ -213,11 +221,11 @@ const dispatch = createEventDispatcher();
|
|
|
213
221
|
><span class="ml-2">{(scopes ?? []).length} item{(scopes ?? []).length > 1 ? 's' : ''}</span
|
|
214
222
|
>
|
|
215
223
|
{:else}
|
|
216
|
-
<p class="italic text-sm">Pick an OAuth
|
|
224
|
+
<p class="italic text-sm">Pick an OAuth API and customize the scopes here</p>
|
|
217
225
|
{/if}
|
|
218
226
|
<PageHeader title="Extra Params" primary={false} />
|
|
219
227
|
{#if !manual && resource_type != ''}
|
|
220
|
-
{#each extra_params as [k, v]
|
|
228
|
+
{#each extra_params as [k, v]}
|
|
221
229
|
<div class="flex flex-row max-w-md">
|
|
222
230
|
<input type="text" bind:value={k} />
|
|
223
231
|
<input type="text" bind:value={v} />
|
|
@@ -240,9 +248,9 @@ const dispatch = createEventDispatcher();
|
|
|
240
248
|
>{(extra_params ?? []).length} item{(extra_params ?? []).length > 1 ? 's' : ''}</span
|
|
241
249
|
>
|
|
242
250
|
{:else}
|
|
243
|
-
<p class="italic text-sm">Pick an OAuth
|
|
251
|
+
<p class="italic text-sm">Pick an OAuth API and customize the extra parameters here</p>
|
|
244
252
|
{/if}
|
|
245
|
-
<PageHeader title="Non OAuth
|
|
253
|
+
<PageHeader title="Non OAuth APIs" />
|
|
246
254
|
<div class="grid sm:grid-cols-2 md:grid-cols-3 gap-x-2 gap-y-1 items-center mb-2">
|
|
247
255
|
{#each connectsManual as [key, instructions]}
|
|
248
256
|
<button
|
|
@@ -297,7 +305,7 @@ const dispatch = createEventDispatcher();
|
|
|
297
305
|
<span class="font-mono">`$var:${path}`</span>). You can refer to this resource anywhere
|
|
298
306
|
this token is required. A script can use the resource type
|
|
299
307
|
<span class="font-mono">{resource_type}</span> as a type parameter to restrict the kind of
|
|
300
|
-
tokens it accepts to this
|
|
308
|
+
tokens it accepts to this api.
|
|
301
309
|
</li>
|
|
302
310
|
</ul>
|
|
303
311
|
{/if}
|
|
@@ -307,13 +315,21 @@ const dispatch = createEventDispatcher();
|
|
|
307
315
|
<button class="default-button px-4 py-2 font-semibold" on:click={back}>Back</button>
|
|
308
316
|
{/if}
|
|
309
317
|
<button
|
|
310
|
-
class=
|
|
318
|
+
class={isGoogleSignin ? '' : 'default-button px-4 py-2 font-semibold'}
|
|
311
319
|
class:default-button-disabled={(step == 1 && resource_type == '') ||
|
|
312
320
|
(step == 2 && value == '') ||
|
|
313
321
|
(step == 3 && pathError != '')}
|
|
314
322
|
on:click={next}
|
|
315
323
|
>
|
|
316
|
-
{
|
|
324
|
+
{#if isGoogleSignin}
|
|
325
|
+
<img src="/google_signin.png" alt="Google sign-in" />
|
|
326
|
+
{:else if step == 1 && !manual}
|
|
327
|
+
Connect
|
|
328
|
+
{:else if step == 3}
|
|
329
|
+
Add resource
|
|
330
|
+
{:else}
|
|
331
|
+
Next
|
|
332
|
+
{/if}
|
|
317
333
|
</button>
|
|
318
334
|
</div>
|
|
319
335
|
</Modal>
|
|
@@ -10,6 +10,7 @@ import ObjectResourceInput from './ObjectResourceInput.svelte';
|
|
|
10
10
|
import ObjectTypeNarrowing from './ObjectTypeNarrowing.svelte';
|
|
11
11
|
import ResourcePicker from './ResourcePicker.svelte';
|
|
12
12
|
import StringTypeNarrowing from './StringTypeNarrowing.svelte';
|
|
13
|
+
import SchemaForm from './SchemaForm.svelte';
|
|
13
14
|
export let label = '';
|
|
14
15
|
export let value;
|
|
15
16
|
export let defaultValue = undefined;
|
|
@@ -27,6 +28,7 @@ export let disabled = false;
|
|
|
27
28
|
export let editableSchema = false;
|
|
28
29
|
export let itemsType = undefined;
|
|
29
30
|
export let displayHeader = true;
|
|
31
|
+
export let properties = undefined;
|
|
30
32
|
let seeEditable = enum_ != undefined || pattern != undefined;
|
|
31
33
|
const dispatch = createEventDispatcher();
|
|
32
34
|
$: minHeight = `${1 + minRows * 1.2}em`;
|
|
@@ -55,10 +57,10 @@ $: {
|
|
|
55
57
|
defaultValue && recomputeRowSize(JSON.stringify(defaultValue, null, 4));
|
|
56
58
|
}
|
|
57
59
|
function recomputeRowSize(str) {
|
|
58
|
-
if (
|
|
59
|
-
minRows =
|
|
60
|
+
if (type == 'string') {
|
|
61
|
+
minRows = str.split('\n').length;
|
|
60
62
|
}
|
|
61
|
-
if (type != 'string') {
|
|
63
|
+
else if (type != 'string') {
|
|
62
64
|
minRows = Math.max(minRows, Math.min(str.split(/\r\n|\r|\n/).length + 1, maxRows));
|
|
63
65
|
}
|
|
64
66
|
}
|
|
@@ -244,16 +246,25 @@ $: inputCat = computeInputCat(type, format, itemsType?.type, enum_, contentEncod
|
|
|
244
246
|
{:else if inputCat == 'resource-object'}
|
|
245
247
|
<ObjectResourceInput {format} bind:value />
|
|
246
248
|
{:else if inputCat == 'object'}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
249
|
+
{#if properties && Object.keys(properties).length > 0}
|
|
250
|
+
<div class="p-4 pl-8 border rounded w-full">
|
|
251
|
+
<SchemaForm
|
|
252
|
+
schema={{ properties, $schema: '', required: [], type: 'object' }}
|
|
253
|
+
bind:args={value}
|
|
254
|
+
/>
|
|
255
|
+
</div>
|
|
256
|
+
{:else}
|
|
257
|
+
<textarea
|
|
258
|
+
{disabled}
|
|
259
|
+
style="min-height: {minHeight}; max-height: {maxHeight}"
|
|
260
|
+
on:input={async () => recomputeRowSize(rawValue ?? '')}
|
|
261
|
+
class="col-span-10 {valid
|
|
262
|
+
? ''
|
|
263
|
+
: 'border border-red-700 border-opacity-30 focus:border-red-700 focus:border-opacity-30 bg-red-100'}"
|
|
264
|
+
placeholder={defaultValue ? JSON.stringify(defaultValue, null, 4) : ''}
|
|
265
|
+
bind:value={rawValue}
|
|
266
|
+
/>
|
|
267
|
+
{/if}
|
|
257
268
|
{:else if inputCat == 'enum'}
|
|
258
269
|
<select {disabled} class="px-6" bind:value>
|
|
259
270
|
{#each enum_ ?? [] as e}
|
|
@@ -270,7 +281,7 @@ $: inputCat = computeInputCat(type, format, itemsType?.type, enum_, contentEncod
|
|
|
270
281
|
bind:this={editor}
|
|
271
282
|
lang="sql"
|
|
272
283
|
bind:code={value}
|
|
273
|
-
class="
|
|
284
|
+
class="few-lines-editor"
|
|
274
285
|
on:change={async () => {
|
|
275
286
|
dispatch('input', { rawValue: value, isRaw: false })
|
|
276
287
|
}}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import { type InputCat } from '../utils';
|
|
3
3
|
import Editor from './Editor.svelte';
|
|
4
|
+
import type { SchemaProperty } from '../common';
|
|
4
5
|
declare const __propDef: {
|
|
5
6
|
props: {
|
|
6
7
|
label?: string | undefined;
|
|
@@ -23,6 +24,9 @@ declare const __propDef: {
|
|
|
23
24
|
contentEncoding?: "base64" | undefined;
|
|
24
25
|
} | undefined;
|
|
25
26
|
displayHeader?: boolean | undefined;
|
|
27
|
+
properties?: {
|
|
28
|
+
[name: string]: SchemaProperty;
|
|
29
|
+
} | undefined;
|
|
26
30
|
editor?: Editor | undefined;
|
|
27
31
|
evalValueToRaw?: (() => void) | undefined;
|
|
28
32
|
inputCat?: InputCat | undefined;
|
|
@@ -49,7 +49,7 @@ function inferResultKind(result) {
|
|
|
49
49
|
|
|
50
50
|
{#if result}
|
|
51
51
|
{#if typeof result == 'object' && Object.keys(result).length > 0}<div>
|
|
52
|
-
The result keys are: <b>{Object.keys(result).join(', ')}</b>
|
|
52
|
+
The result keys are: <b>{truncate(Object.keys(result).join(', '), 50)}</b>
|
|
53
53
|
</div>
|
|
54
54
|
{/if}
|
|
55
55
|
{#if resultKind == 'table-col'}
|
|
@@ -74,10 +74,10 @@ function inferResultKind(result) {
|
|
|
74
74
|
>
|
|
75
75
|
<TableCustom>
|
|
76
76
|
<tbody slot="body">
|
|
77
|
-
{#each asListOfList(
|
|
77
|
+
{#each asListOfList(result) as row}
|
|
78
78
|
<tr>
|
|
79
79
|
{#each row as v}
|
|
80
|
-
<td>{truncate(v, 200) ?? ''}</td>
|
|
80
|
+
<td>{truncate(JSON.stringify(v), 200) ?? ''}</td>
|
|
81
81
|
{/each}
|
|
82
82
|
</tr>
|
|
83
83
|
{/each}
|
package/components/Editor.svelte
CHANGED
|
@@ -1,32 +1,24 @@
|
|
|
1
1
|
<script context="module">import * as monaco from 'monaco-editor';
|
|
2
|
-
|
|
3
|
-
monaco.languages.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
aliases: ['python'],
|
|
7
|
-
mimetypes: ['application/text']
|
|
2
|
+
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
|
3
|
+
target: monaco.languages.typescript.ScriptTarget.Latest,
|
|
4
|
+
allowNonTsExtensions: true,
|
|
5
|
+
noLib: true
|
|
8
6
|
});
|
|
9
|
-
monaco.languages.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
mimetypes: ['application/text']
|
|
7
|
+
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
|
|
8
|
+
target: monaco.languages.typescript.ScriptTarget.Latest,
|
|
9
|
+
allowNonTsExtensions: true,
|
|
10
|
+
noLib: true
|
|
14
11
|
});
|
|
15
|
-
monaco.languages.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}))
|
|
26
|
-
: []
|
|
27
|
-
};
|
|
28
|
-
},
|
|
29
|
-
freeInlineCompletions: () => { }
|
|
12
|
+
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
13
|
+
noSemanticValidation: true,
|
|
14
|
+
noSuggestionDiagnostics: true,
|
|
15
|
+
noSyntaxValidation: true
|
|
16
|
+
});
|
|
17
|
+
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
|
|
18
|
+
validate: true,
|
|
19
|
+
allowComments: false,
|
|
20
|
+
schemas: [],
|
|
21
|
+
enableSchemaRequest: true
|
|
30
22
|
});
|
|
31
23
|
</script>
|
|
32
24
|
|
|
@@ -36,10 +28,11 @@ import { sendUserToast } from '../utils';
|
|
|
36
28
|
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
|
37
29
|
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
|
38
30
|
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
|
39
|
-
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
|
40
31
|
import { buildWorkerDefinition } from 'monaco-editor-workers';
|
|
41
|
-
import {
|
|
32
|
+
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
|
42
33
|
import getMessageServiceOverride from 'vscode/service-override/messages';
|
|
34
|
+
import { StandaloneServices } from 'vscode/services';
|
|
35
|
+
import { DENO_INIT_CODE_CLEAR, PYTHON_INIT_CODE_CLEAR } from '../script_helpers';
|
|
43
36
|
StandaloneServices.initialize({
|
|
44
37
|
...getMessageServiceOverride(document.body)
|
|
45
38
|
});
|
|
@@ -55,6 +48,7 @@ export let automaticLayout = true;
|
|
|
55
48
|
export let websocketAlive = { pyright: false, black: false, deno: false };
|
|
56
49
|
export let extraLib = '';
|
|
57
50
|
export let extraLibPath = '';
|
|
51
|
+
export let shouldBindKey = true;
|
|
58
52
|
let websockets = [];
|
|
59
53
|
let websocketInterval;
|
|
60
54
|
let lastWsAttempt = new Date();
|
|
@@ -84,7 +78,7 @@ if (browser) {
|
|
|
84
78
|
}
|
|
85
79
|
}
|
|
86
80
|
export function getCode() {
|
|
87
|
-
return editor?.getValue();
|
|
81
|
+
return editor?.getValue() ?? '';
|
|
88
82
|
}
|
|
89
83
|
export function insertAtCursor(code) {
|
|
90
84
|
if (editor) {
|
|
@@ -115,21 +109,33 @@ export function insertAtBeginning(code) {
|
|
|
115
109
|
}
|
|
116
110
|
}
|
|
117
111
|
export function setCode(ncode) {
|
|
112
|
+
code = ncode;
|
|
118
113
|
if (editor) {
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
code = ncode;
|
|
114
|
+
editor.setValue(ncode);
|
|
123
115
|
}
|
|
124
116
|
}
|
|
125
117
|
function format() {
|
|
126
118
|
if (editor) {
|
|
119
|
+
code = getCode();
|
|
127
120
|
editor.getAction('editor.action.formatDocument').run();
|
|
128
121
|
if (formatAction) {
|
|
129
122
|
formatAction();
|
|
130
123
|
}
|
|
131
124
|
}
|
|
132
125
|
}
|
|
126
|
+
export async function clearContent() {
|
|
127
|
+
if (editor) {
|
|
128
|
+
if (lang == 'typescript') {
|
|
129
|
+
setCode(DENO_INIT_CODE_CLEAR);
|
|
130
|
+
}
|
|
131
|
+
else if (lang == 'python') {
|
|
132
|
+
setCode(PYTHON_INIT_CODE_CLEAR);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
setCode('');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
133
139
|
let command = undefined;
|
|
134
140
|
let monacoServices = undefined;
|
|
135
141
|
export async function reloadWebsocket() {
|
|
@@ -286,9 +292,10 @@ export async function reloadWebsocket() {
|
|
|
286
292
|
}
|
|
287
293
|
websocketInterval && clearInterval(websocketInterval);
|
|
288
294
|
websocketInterval = setInterval(() => {
|
|
295
|
+
console.log(websocketInterval, document.visibilityState, new Date().getTime() - lastWsAttempt.getTime(), nbWsAttempt);
|
|
289
296
|
if (document.visibilityState == 'visible') {
|
|
290
297
|
if (!lastWsAttempt ||
|
|
291
|
-
(
|
|
298
|
+
(new Date().getTime() - lastWsAttempt.getTime() > 60000 && nbWsAttempt < 2)) {
|
|
292
299
|
if (!websocketAlive.black && !websocketAlive.deno && !websocketAlive.pyright) {
|
|
293
300
|
console.log('reconnecting to language servers');
|
|
294
301
|
lastWsAttempt = new Date();
|
|
@@ -351,60 +358,45 @@ async function loadMonaco() {
|
|
|
351
358
|
enabled: true
|
|
352
359
|
}
|
|
353
360
|
});
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
cmdEnterAction
|
|
360
|
-
|
|
361
|
-
|
|
361
|
+
if (shouldBindKey) {
|
|
362
|
+
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, function () {
|
|
363
|
+
format();
|
|
364
|
+
});
|
|
365
|
+
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, function () {
|
|
366
|
+
if (cmdEnterAction) {
|
|
367
|
+
cmdEnterAction();
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
let timeoutModel = undefined;
|
|
362
372
|
editor.onDidChangeModelContent((event) => {
|
|
363
|
-
|
|
373
|
+
timeoutModel && clearTimeout(timeoutModel);
|
|
374
|
+
timeoutModel = setTimeout(() => {
|
|
375
|
+
code = getCode();
|
|
376
|
+
}, 500);
|
|
364
377
|
dispatch('change');
|
|
365
378
|
});
|
|
366
379
|
editor.onDidFocusEditorText(() => {
|
|
367
380
|
dispatch('focus');
|
|
381
|
+
if (deno || lang == 'typescript') {
|
|
382
|
+
if (!websocketAlive.black &&
|
|
383
|
+
!websocketAlive.deno &&
|
|
384
|
+
!websocketAlive.pyright &&
|
|
385
|
+
!websocketInterval) {
|
|
386
|
+
reloadWebsocket();
|
|
387
|
+
}
|
|
388
|
+
}
|
|
368
389
|
});
|
|
369
390
|
editor.onDidBlurEditorText(() => {
|
|
370
391
|
dispatch('blur');
|
|
371
392
|
});
|
|
372
|
-
if (lang == '
|
|
373
|
-
monaco.languages.
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
validate: true,
|
|
378
|
-
allowComments: false,
|
|
379
|
-
schemas: [],
|
|
380
|
-
enableSchemaRequest: true
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
else if (lang == 'javascript' || lang == 'typescript') {
|
|
384
|
-
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
|
385
|
-
target: monaco.languages.typescript.ScriptTarget.Latest,
|
|
386
|
-
allowNonTsExtensions: true,
|
|
387
|
-
noLib: true
|
|
388
|
-
});
|
|
389
|
-
if (lang == 'typescript') {
|
|
390
|
-
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
|
|
391
|
-
target: monaco.languages.typescript.ScriptTarget.Latest,
|
|
392
|
-
allowNonTsExtensions: true,
|
|
393
|
-
noLib: true
|
|
394
|
-
});
|
|
395
|
-
if (deno) {
|
|
396
|
-
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
397
|
-
noSemanticValidation: true,
|
|
398
|
-
noSuggestionDiagnostics: true,
|
|
399
|
-
noSyntaxValidation: true
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
if (lang == 'javascript') {
|
|
404
|
-
if (extraLib != '' && extraLibPath != '') {
|
|
405
|
-
monaco.languages.typescript.javascriptDefaults.addExtraLib(extraLib, extraLibPath);
|
|
393
|
+
if (lang == 'javascript' && extraLib != '' && extraLibPath != '') {
|
|
394
|
+
monaco.languages.typescript.javascriptDefaults.setExtraLibs([
|
|
395
|
+
{
|
|
396
|
+
content: extraLib,
|
|
397
|
+
filePath: extraLibPath
|
|
406
398
|
}
|
|
407
|
-
|
|
399
|
+
]);
|
|
408
400
|
}
|
|
409
401
|
if (lang == 'python' || deno) {
|
|
410
402
|
reloadWebsocket();
|
|
@@ -16,10 +16,12 @@ declare const __propDef: {
|
|
|
16
16
|
} | undefined;
|
|
17
17
|
extraLib?: string | undefined;
|
|
18
18
|
extraLibPath?: string | undefined;
|
|
19
|
+
shouldBindKey?: boolean | undefined;
|
|
19
20
|
getCode?: (() => string) | undefined;
|
|
20
21
|
insertAtCursor?: ((code: string) => void) | undefined;
|
|
21
22
|
insertAtBeginning?: ((code: string) => void) | undefined;
|
|
22
23
|
setCode?: ((ncode: string) => void) | undefined;
|
|
24
|
+
clearContent?: (() => Promise<void>) | undefined;
|
|
23
25
|
reloadWebsocket?: (() => Promise<void>) | undefined;
|
|
24
26
|
};
|
|
25
27
|
events: {
|
|
@@ -39,6 +41,7 @@ export default class Editor extends SvelteComponentTyped<EditorProps, EditorEven
|
|
|
39
41
|
get insertAtCursor(): (code: string) => void;
|
|
40
42
|
get insertAtBeginning(): (code: string) => void;
|
|
41
43
|
get setCode(): (ncode: string) => void;
|
|
44
|
+
get clearContent(): () => Promise<void>;
|
|
42
45
|
get reloadWebsocket(): () => Promise<void>;
|
|
43
46
|
}
|
|
44
47
|
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<script>import { ResourceService, ScriptService, VariableService } from '../gen';
|
|
2
2
|
import { getScriptByPath, loadHubScripts, sendUserToast } from '../utils';
|
|
3
|
-
import {
|
|
3
|
+
import { faCode, faCube, faFile, faRotate, faRotateLeft } from '@fortawesome/free-solid-svg-icons';
|
|
4
4
|
import Icon from 'svelte-awesome';
|
|
5
5
|
import { hubScripts, workspaceStore } from '../stores';
|
|
6
|
-
import { Button } from 'flowbite-svelte';
|
|
7
6
|
import { Highlight } from 'svelte-highlight';
|
|
8
7
|
import { python, typescript } from 'svelte-highlight/languages';
|
|
9
8
|
import ItemPicker from './ItemPicker.svelte';
|
|
@@ -84,7 +83,7 @@ async function loadScripts() {
|
|
|
84
83
|
if (lang == 'deno') {
|
|
85
84
|
if (!editor.getCode().includes('import * as wmill from')) {
|
|
86
85
|
editor.insertAtBeginning(
|
|
87
|
-
`import * as wmill from 'https://deno.land/x/windmill@v${__pkg__.version}/
|
|
86
|
+
`import * as wmill from 'https://deno.land/x/windmill@v${__pkg__.version}/mod.ts'\n`
|
|
88
87
|
)
|
|
89
88
|
}
|
|
90
89
|
editor.insertAtCursor(`(await wmill.getVariable('${path}'))`)
|
|
@@ -123,7 +122,7 @@ async function loadScripts() {
|
|
|
123
122
|
if (lang == 'deno') {
|
|
124
123
|
if (!editor.getCode().includes('import * as wmill from')) {
|
|
125
124
|
editor.insertAtBeginning(
|
|
126
|
-
`import * as wmill from 'https://deno.land/x/windmill@v${__pkg__.version}/
|
|
125
|
+
`import * as wmill from 'https://deno.land/x/windmill@v${__pkg__.version}/mod.ts'\n`
|
|
127
126
|
)
|
|
128
127
|
}
|
|
129
128
|
editor.insertAtCursor(`(await wmill.getResource('${path}'))`)
|
|
@@ -157,59 +156,79 @@ async function loadScripts() {
|
|
|
157
156
|
</ItemPicker>
|
|
158
157
|
|
|
159
158
|
<ResourceEditor bind:this={resourceEditor} on:refresh={resourcePicker.openModal} />
|
|
160
|
-
|
|
161
159
|
<VariableEditor bind:this={variableEditor} on:create={variablePicker.openModal} />
|
|
162
160
|
|
|
163
|
-
<div class="flex
|
|
164
|
-
<div
|
|
165
|
-
<
|
|
166
|
-
|
|
167
|
-
|
|
161
|
+
<div class="flex divide-x items-center">
|
|
162
|
+
<div>
|
|
163
|
+
<button
|
|
164
|
+
type="button"
|
|
165
|
+
class="mr-1 bg-white rounded-md items-center flex hover:bg-gray-100 font-medium text-xs p-2"
|
|
168
166
|
on:click={() => {
|
|
169
167
|
variablePicker.openModal()
|
|
170
168
|
}}
|
|
171
169
|
>
|
|
172
|
-
<Icon data={
|
|
173
|
-
|
|
174
|
-
</
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
170
|
+
<Icon data={faFile} class="h-4 w-4 mr-2" />
|
|
171
|
+
Insert variable
|
|
172
|
+
</button>
|
|
173
|
+
</div>
|
|
174
|
+
<div>
|
|
175
|
+
<button
|
|
176
|
+
type="button"
|
|
177
|
+
class="mx-1 bg-white rounded-md items-center flex hover:bg-gray-100 font-medium text-xs p-2"
|
|
179
178
|
on:click={() => {
|
|
180
179
|
resourcePicker.openModal()
|
|
181
180
|
}}
|
|
182
181
|
>
|
|
183
|
-
<Icon data={
|
|
184
|
-
|
|
185
|
-
</
|
|
182
|
+
<Icon data={faCube} class="h-4 w-4 mr-2" />
|
|
183
|
+
Insert resource
|
|
184
|
+
</button>
|
|
185
|
+
</div>
|
|
186
186
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
<div>
|
|
188
|
+
<button
|
|
189
|
+
type="button"
|
|
190
|
+
class="mx-1 bg-white rounded-md items-center flex hover:bg-gray-100 font-medium text-xs p-2"
|
|
190
191
|
on:click={() => {
|
|
191
192
|
scriptPicker.openModal()
|
|
192
193
|
}}
|
|
193
194
|
>
|
|
194
|
-
<Icon data={
|
|
195
|
-
|
|
196
|
-
</
|
|
195
|
+
<Icon data={faCode} class="h-4 w-4 mr-2" />
|
|
196
|
+
Search script
|
|
197
|
+
</button>
|
|
197
198
|
</div>
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
|
|
200
|
+
<div>
|
|
201
|
+
<button
|
|
202
|
+
type="button"
|
|
203
|
+
class="mx-1 bg-white rounded-md items-center flex hover:bg-gray-100 font-medium text-xs p-2"
|
|
204
|
+
on:click={() => {
|
|
205
|
+
editor.clearContent()
|
|
206
|
+
}}
|
|
207
|
+
>
|
|
208
|
+
<Icon data={faRotateLeft} class="h-4 w-4 mr-2" />
|
|
209
|
+
Reset content
|
|
210
|
+
</button>
|
|
211
|
+
</div>
|
|
212
|
+
<div>
|
|
213
|
+
<button
|
|
214
|
+
type="button"
|
|
215
|
+
class="ml-1 bg-white rounded-md items-center flex hover:bg-gray-100 font-medium text-xs p-2"
|
|
202
216
|
on:click={() => {
|
|
203
217
|
editor.reloadWebsocket()
|
|
204
218
|
}}
|
|
205
219
|
>
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
220
|
+
<Icon data={faRotate} class="h-4 w-4 mr-2" />
|
|
221
|
+
|
|
222
|
+
Reload assistants
|
|
223
|
+
<span class="ml-1">
|
|
224
|
+
{#if lang == 'deno'}
|
|
225
|
+
(<span class={websocketAlive.deno ? 'text-green-600' : 'text-red-700'}>Deno</span>)
|
|
226
|
+
{:else if lang == 'python3'}
|
|
227
|
+
(<span class={websocketAlive.pyright ? 'text-green-600' : 'text-red-700'}>Pyright</span>
|
|
228
|
+
|
|
229
|
+
<span class={websocketAlive.black ? 'text-green-600' : 'text-red-700'}>Black</span>)
|
|
230
|
+
{/if}
|
|
231
|
+
</span>
|
|
232
|
+
</button>
|
|
214
233
|
</div>
|
|
215
234
|
</div>
|