@flowdrop/flowdrop 2.17.0 → 2.18.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/CHANGELOG.md +15 -0
- package/dist/api/enhanced-client.d.ts +3 -1
- package/dist/api/enhanced-client.js +4 -2
- package/dist/commands/executor.js +9 -0
- package/dist/commands/storeIntegration.svelte.js +6 -0
- package/dist/commands/types.d.ts +8 -0
- package/dist/components/App.svelte +209 -106
- package/dist/components/App.svelte.d.ts +29 -0
- package/dist/components/FlowDropZone.svelte +7 -1
- package/dist/components/FlowDropZone.svelte.d.ts +5 -0
- package/dist/components/ImpactConfirm.svelte +246 -33
- package/dist/components/ImpactConfirm.svelte.d.ts +13 -3
- package/dist/components/Input.svelte +8 -2
- package/dist/components/LockBanner.svelte +76 -0
- package/dist/components/LockBanner.svelte.d.ts +14 -0
- package/dist/components/LockFence.svelte +33 -0
- package/dist/components/LockFence.svelte.d.ts +19 -0
- package/dist/components/Navbar.svelte +35 -6
- package/dist/components/Navbar.svelte.d.ts +6 -0
- package/dist/components/RunBar.svelte +16 -4
- package/dist/components/Textarea.svelte +7 -1
- package/dist/components/WorkflowEditor.svelte +32 -9
- package/dist/components/WorkflowInterfaceEditor.svelte +3 -0
- package/dist/components/WorkflowInterfaceEntryCard.svelte +21 -4
- package/dist/components/WorkflowPlaygroundSettings.svelte +9 -1
- package/dist/components/form/FieldFactory.svelte +13 -6
- package/dist/components/form/FormArray.svelte +0 -1
- package/dist/components/form/FormArrayRows.svelte +4 -4
- package/dist/components/form/FormCodeEditor.svelte +18 -2
- package/dist/components/form/FormMarkdownEditor.svelte +22 -8
- package/dist/components/form/FormTemplateEditor.svelte +17 -1
- package/dist/components/form/readOnly.d.ts +13 -0
- package/dist/components/form/readOnly.js +18 -0
- package/dist/components/nodes/CaptionNode.svelte +1 -0
- package/dist/components/primitives/Checkbox.svelte +5 -1
- package/dist/components/primitives/Select.svelte +6 -1
- package/dist/components/primitives/Switch.svelte +5 -1
- package/dist/editor/index.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/messages/defaults.d.ts +45 -0
- package/dist/messages/defaults.js +51 -3
- package/dist/openapi/v1/openapi.yaml +492 -0
- package/dist/registry/nodeComponentRegistry.d.ts +5 -0
- package/dist/schemas/v1/workflow.schema.json +2 -0
- package/dist/services/globalSave.d.ts +17 -0
- package/dist/services/globalSave.js +166 -6
- package/dist/services/impactGate.d.ts +7 -3
- package/dist/services/impactGate.js +9 -7
- package/dist/services/impactService.d.ts +18 -1
- package/dist/services/impactService.js +93 -7
- package/dist/services/runsService.d.ts +9 -0
- package/dist/services/runsService.js +13 -0
- package/dist/services/workflowLaunchService.d.ts +6 -0
- package/dist/services/workflowLaunchService.js +2 -0
- package/dist/stores/historyStore.svelte.d.ts +12 -2
- package/dist/stores/historyStore.svelte.js +25 -2
- package/dist/stores/instanceContainer.svelte.d.ts +7 -0
- package/dist/stores/instanceContainer.svelte.js +10 -0
- package/dist/stores/lockStore.svelte.d.ts +39 -0
- package/dist/stores/lockStore.svelte.js +109 -0
- package/dist/stores/runController.svelte.d.ts +2 -0
- package/dist/stores/runController.svelte.js +27 -11
- package/dist/stores/workflowStore.svelte.d.ts +7 -1
- package/dist/stores/workflowStore.svelte.js +41 -13
- package/dist/styles/base.css +6 -0
- package/dist/svelte-app.d.ts +31 -0
- package/dist/svelte-app.js +110 -26
- package/dist/types/events.d.ts +17 -0
- package/dist/types/impact.d.ts +52 -0
- package/dist/types/lock.d.ts +35 -0
- package/dist/types/lock.js +13 -0
- package/dist/types/navbar.d.ts +6 -0
- package/dist/utils/links.d.ts +29 -0
- package/dist/utils/links.js +63 -0
- package/dist/webmcp/runtime.js +16 -3
- package/dist/webmcp/types.d.ts +11 -1
- package/package.json +1 -1
|
@@ -25,6 +25,7 @@ import { PortCoordinateStore } from './portCoordinateStore.svelte.js';
|
|
|
25
25
|
import { PipelinePanelStore } from './pipelinePanelStore.svelte.js';
|
|
26
26
|
import { InlineEditStore } from './inlineEditStore.svelte.js';
|
|
27
27
|
import { EditorModeStore } from './editorModeStore.svelte.js';
|
|
28
|
+
import { EditorLockStore } from './lockStore.svelte.js';
|
|
28
29
|
import { AttachedRunStore } from './attachedRunStore.svelte.js';
|
|
29
30
|
import { NodeHighlightStore } from './nodeHighlightStore.svelte.js';
|
|
30
31
|
import { ConnectDragStore } from './connectDragStore.svelte.js';
|
|
@@ -106,7 +107,14 @@ export function createFlowDropInstance(options = {}) {
|
|
|
106
107
|
// keep operating on the default editor's history stack.
|
|
107
108
|
const history = isDefault ? historyService : new HistoryService();
|
|
108
109
|
const workflow = new WorkflowStore(history);
|
|
110
|
+
// A lock makes the workflow store refuse every edit, whoever asks.
|
|
111
|
+
const lock = new EditorLockStore();
|
|
112
|
+
// The lock store blurs a field being typed in before it locks, so that edit lands first.
|
|
113
|
+
lock.onChange((locked) => workflow.setLocked(locked));
|
|
109
114
|
const historyBindings = new HistoryStore(history);
|
|
115
|
+
// A locked workflow keeps its history where it is: undo and redo would only
|
|
116
|
+
// move the position, because the store refuses the restore.
|
|
117
|
+
historyBindings.setIsBlockedCheck(() => workflow.locked);
|
|
110
118
|
// Default wiring: undo/redo restores into this instance's workflow store.
|
|
111
119
|
// WorkflowEditor overrides this with a richer callback while mounted.
|
|
112
120
|
historyBindings.setOnRestoreCallback((restored) => workflow.restoreFromHistory(restored));
|
|
@@ -136,6 +144,7 @@ export function createFlowDropInstance(options = {}) {
|
|
|
136
144
|
() => historyBindings.cleanup(),
|
|
137
145
|
() => historyBindings.setOnRestoreCallback(null),
|
|
138
146
|
() => historyBindings.setBeforeNavigateCallback(null),
|
|
147
|
+
() => historyBindings.setIsBlockedCheck(null),
|
|
139
148
|
() => doctor.dispose(),
|
|
140
149
|
() => workflow.setOnDirtyStateChange(null),
|
|
141
150
|
() => workflow.setOnWorkflowChange(null),
|
|
@@ -177,6 +186,7 @@ export function createFlowDropInstance(options = {}) {
|
|
|
177
186
|
pipelinePanel: new PipelinePanelStore(id),
|
|
178
187
|
inlineEdit: new InlineEditStore(),
|
|
179
188
|
editorMode: new EditorModeStore(),
|
|
189
|
+
lock,
|
|
180
190
|
attachedRun: new AttachedRunStore(),
|
|
181
191
|
highlight: new NodeHighlightStore(),
|
|
182
192
|
connectDrag: new ConnectDragStore(),
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor lock: the reasons a workflow cannot be edited right now, and the
|
|
3
|
+
* actions a person is offered.
|
|
4
|
+
*
|
|
5
|
+
* One store per instance. While a lock is set the workflow store refuses every
|
|
6
|
+
* edit (see `WorkflowStore.setLocked`) and the canvas shows the banner. A host
|
|
7
|
+
* sets it through the `lock` option or `app.setLock(...)`, and removes it with
|
|
8
|
+
* `null`. Pressing an action reports its id to the host (`onLockAction`).
|
|
9
|
+
*
|
|
10
|
+
* @module stores/lockStore
|
|
11
|
+
*/
|
|
12
|
+
import type { EditorLock } from '../types/lock.js';
|
|
13
|
+
export declare class EditorLockStore {
|
|
14
|
+
#private;
|
|
15
|
+
/** The lock in force, or null when the editor is not locked. */
|
|
16
|
+
get current(): EditorLock | null;
|
|
17
|
+
/** Whether the editor is locked. */
|
|
18
|
+
get isLocked(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Lock the editor, replace the lock, or (with `null`) unlock it. A value that
|
|
21
|
+
* is not a lock unlocks.
|
|
22
|
+
*/
|
|
23
|
+
set(lock: EditorLock | null | undefined): void;
|
|
24
|
+
/** Remove the lock. */
|
|
25
|
+
clear(): void;
|
|
26
|
+
/** Be told when the editor becomes locked or unlocked. Returns a function that stops listening. */
|
|
27
|
+
onChange(listener: (locked: boolean) => void): () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Be told just before the editor becomes locked, while it still reads as
|
|
30
|
+
* unlocked, so an edit in progress can be saved. Returns a function that stops listening.
|
|
31
|
+
*
|
|
32
|
+
* @internal Used by the editor to save a half-typed name; not a supported host API.
|
|
33
|
+
*/
|
|
34
|
+
onBeforeLock(listener: () => void): () => void;
|
|
35
|
+
/** Be told when a person presses a lock action. Returns a function that stops listening. */
|
|
36
|
+
onAction(listener: (id: string) => void): () => void;
|
|
37
|
+
/** A person pressed the action `id`. Reported to the host, which decides what it does. */
|
|
38
|
+
fire(id: string): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor lock: the reasons a workflow cannot be edited right now, and the
|
|
3
|
+
* actions a person is offered.
|
|
4
|
+
*
|
|
5
|
+
* One store per instance. While a lock is set the workflow store refuses every
|
|
6
|
+
* edit (see `WorkflowStore.setLocked`) and the canvas shows the banner. A host
|
|
7
|
+
* sets it through the `lock` option or `app.setLock(...)`, and removes it with
|
|
8
|
+
* `null`. Pressing an action reports its id to the host (`onLockAction`).
|
|
9
|
+
*
|
|
10
|
+
* @module stores/lockStore
|
|
11
|
+
*/
|
|
12
|
+
/** Keep what the banner needs, and drop anything that is not text. */
|
|
13
|
+
function normalise(lock) {
|
|
14
|
+
if (!lock || typeof lock !== 'object')
|
|
15
|
+
return null;
|
|
16
|
+
const reasons = (Array.isArray(lock.reasons) ? lock.reasons : []).filter((r) => r && typeof r.message === 'string' && r.message !== '');
|
|
17
|
+
const actions = (Array.isArray(lock.actions) ? lock.actions : []).filter((a) => a && typeof a.id === 'string' && a.id !== '' && typeof a.label === 'string');
|
|
18
|
+
return {
|
|
19
|
+
reasons: reasons.map((r) => ({
|
|
20
|
+
kind: String(r.kind ?? ''),
|
|
21
|
+
message: r.message,
|
|
22
|
+
url: r.url ?? null
|
|
23
|
+
})),
|
|
24
|
+
actions: actions.map((a) => ({ id: a.id, label: a.label, primary: a.primary === true }))
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Blur the focused element when it sits inside a lock fence (a config form or
|
|
29
|
+
* panel body) or is an in-place editor that commits on blur (`data-lock-commit`).
|
|
30
|
+
*/
|
|
31
|
+
function blurFieldInsideLockFence() {
|
|
32
|
+
if (typeof document === 'undefined')
|
|
33
|
+
return;
|
|
34
|
+
const active = document.activeElement;
|
|
35
|
+
if (active instanceof HTMLElement && active.closest('.flowdrop-lock-fence, [data-lock-commit]'))
|
|
36
|
+
active.blur();
|
|
37
|
+
}
|
|
38
|
+
export class EditorLockStore {
|
|
39
|
+
#current = $state(null);
|
|
40
|
+
#changeListeners = new Set();
|
|
41
|
+
#beforeLockListeners = new Set();
|
|
42
|
+
#actionListeners = new Set();
|
|
43
|
+
/** The lock in force, or null when the editor is not locked. */
|
|
44
|
+
get current() {
|
|
45
|
+
return this.#current;
|
|
46
|
+
}
|
|
47
|
+
/** Whether the editor is locked. */
|
|
48
|
+
get isLocked() {
|
|
49
|
+
return this.#current !== null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Lock the editor, replace the lock, or (with `null`) unlock it. A value that
|
|
53
|
+
* is not a lock unlocks.
|
|
54
|
+
*/
|
|
55
|
+
set(lock) {
|
|
56
|
+
const next = normalise(lock);
|
|
57
|
+
const was = this.#current !== null;
|
|
58
|
+
// A field being typed in commits on blur. Blur it while the editor still
|
|
59
|
+
// reads as unlocked, so the edit lands before anything refuses it.
|
|
60
|
+
if (!was && next !== null) {
|
|
61
|
+
// Let an editor save what is half typed (a name beside a port) first.
|
|
62
|
+
for (const listener of [...this.#beforeLockListeners])
|
|
63
|
+
listener();
|
|
64
|
+
blurFieldInsideLockFence();
|
|
65
|
+
}
|
|
66
|
+
this.#current = next;
|
|
67
|
+
const is = next !== null;
|
|
68
|
+
if (was !== is)
|
|
69
|
+
for (const listener of [...this.#changeListeners])
|
|
70
|
+
listener(is);
|
|
71
|
+
}
|
|
72
|
+
/** Remove the lock. */
|
|
73
|
+
clear() {
|
|
74
|
+
this.set(null);
|
|
75
|
+
}
|
|
76
|
+
/** Be told when the editor becomes locked or unlocked. Returns a function that stops listening. */
|
|
77
|
+
onChange(listener) {
|
|
78
|
+
this.#changeListeners.add(listener);
|
|
79
|
+
return () => {
|
|
80
|
+
this.#changeListeners.delete(listener);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Be told just before the editor becomes locked, while it still reads as
|
|
85
|
+
* unlocked, so an edit in progress can be saved. Returns a function that stops listening.
|
|
86
|
+
*
|
|
87
|
+
* @internal Used by the editor to save a half-typed name; not a supported host API.
|
|
88
|
+
*/
|
|
89
|
+
onBeforeLock(listener) {
|
|
90
|
+
this.#beforeLockListeners.add(listener);
|
|
91
|
+
return () => {
|
|
92
|
+
this.#beforeLockListeners.delete(listener);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** Be told when a person presses a lock action. Returns a function that stops listening. */
|
|
96
|
+
onAction(listener) {
|
|
97
|
+
this.#actionListeners.add(listener);
|
|
98
|
+
return () => {
|
|
99
|
+
this.#actionListeners.delete(listener);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** A person pressed the action `id`. Reported to the host, which decides what it does. */
|
|
103
|
+
fire(id) {
|
|
104
|
+
if (!this.#current?.actions.some((a) => a.id === id))
|
|
105
|
+
return;
|
|
106
|
+
for (const listener of [...this.#actionListeners])
|
|
107
|
+
listener(id);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -48,6 +48,8 @@ export interface ActiveRun {
|
|
|
48
48
|
startedAt: number;
|
|
49
49
|
/** When the run reached a terminal status (ms epoch), `null` while it is live. */
|
|
50
50
|
endedAt: number | null;
|
|
51
|
+
/** The run is queued and no worker has picked it up yet (the site says `waiting_for_worker`). */
|
|
52
|
+
waitingForWorker: boolean;
|
|
51
53
|
}
|
|
52
54
|
/** What a {@link RunController} is built from: the instance's own pieces. */
|
|
53
55
|
export interface RunControllerDeps {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { SvelteSet } from 'svelte/reactivity';
|
|
19
19
|
import { nodeExecutionService } from '../services/nodeExecutionService.js';
|
|
20
|
-
import {
|
|
20
|
+
import { readRunState } from '../services/runsService.js';
|
|
21
21
|
import { pipelineSignalService } from '../services/pipelineSignalService.js';
|
|
22
22
|
import { workflowLaunchService } from '../services/workflowLaunchService.js';
|
|
23
23
|
import { describeLaunchResult } from '../playground/commands/index.js';
|
|
@@ -989,7 +989,10 @@ export class RunController {
|
|
|
989
989
|
runId,
|
|
990
990
|
status,
|
|
991
991
|
startedAt: tracked.startedAt,
|
|
992
|
-
endedAt: TERMINAL_RUN_STATUSES.includes(status) ? (this.#endedAt ?? tracked.startedAt) : null
|
|
992
|
+
endedAt: TERMINAL_RUN_STATUSES.includes(status) ? (this.#endedAt ?? tracked.startedAt) : null,
|
|
993
|
+
waitingForWorker: tracked.origin === 'host' &&
|
|
994
|
+
status === 'running' &&
|
|
995
|
+
tracked.activityKind === 'waiting_for_worker'
|
|
993
996
|
};
|
|
994
997
|
});
|
|
995
998
|
/**
|
|
@@ -1036,7 +1039,7 @@ export class RunController {
|
|
|
1036
1039
|
this.#hostStatusHook = onRunStatus;
|
|
1037
1040
|
out.onRunStatus = async (runId) => {
|
|
1038
1041
|
const envelope = await onRunStatus(runId);
|
|
1039
|
-
this.#applyHostStatus(runId, envelope.ok ? envelope.data?.status : undefined);
|
|
1042
|
+
this.#applyHostStatus(runId, envelope.ok ? envelope.data?.status : undefined, envelope.ok ? (envelope.data?.activity?.kind ?? null) : null);
|
|
1040
1043
|
return envelope;
|
|
1041
1044
|
};
|
|
1042
1045
|
}
|
|
@@ -1071,8 +1074,9 @@ export class RunController {
|
|
|
1071
1074
|
};
|
|
1072
1075
|
const terminal = TERMINAL_RUN_STATUSES.includes(hostStatus);
|
|
1073
1076
|
this.#endedAt = terminal ? Date.now() : null;
|
|
1077
|
+
// Read the status now, so "waiting for a worker" shows at once; then keep the interval.
|
|
1074
1078
|
if (!terminal)
|
|
1075
|
-
this.#scheduleHostPoll(runId,
|
|
1079
|
+
this.#scheduleHostPoll(runId, 0);
|
|
1076
1080
|
}
|
|
1077
1081
|
/**
|
|
1078
1082
|
* The run opened from the Runs list and still shown, or `null` (nothing
|
|
@@ -1137,17 +1141,21 @@ export class RunController {
|
|
|
1137
1141
|
};
|
|
1138
1142
|
this.#endedAt = TERMINAL_RUN_STATUSES.includes(hostStatus) ? Date.now() : null;
|
|
1139
1143
|
if (!TERMINAL_RUN_STATUSES.includes(hostStatus)) {
|
|
1140
|
-
this.#scheduleHostPoll(runId,
|
|
1144
|
+
this.#scheduleHostPoll(runId, 0);
|
|
1141
1145
|
}
|
|
1142
1146
|
}
|
|
1143
|
-
#applyHostStatus(runId, status) {
|
|
1147
|
+
#applyHostStatus(runId, status, activityKind = null) {
|
|
1144
1148
|
const tracked = this.#tracked;
|
|
1145
1149
|
if (tracked?.origin !== 'host' || tracked.runId !== runId || status === undefined)
|
|
1146
1150
|
return;
|
|
1147
1151
|
const next = hostRunStatus(status);
|
|
1148
|
-
if (next === tracked.hostStatus)
|
|
1152
|
+
if (next === tracked.hostStatus) {
|
|
1153
|
+
if ((tracked.activityKind ?? null) !== activityKind) {
|
|
1154
|
+
this.#tracked = { ...tracked, activityKind };
|
|
1155
|
+
}
|
|
1149
1156
|
return;
|
|
1150
|
-
|
|
1157
|
+
}
|
|
1158
|
+
this.#tracked = { ...tracked, hostStatus: next, activityKind };
|
|
1151
1159
|
if (TERMINAL_RUN_STATUSES.includes(next)) {
|
|
1152
1160
|
this.#endedAt = Date.now();
|
|
1153
1161
|
this.#clearHostPoll();
|
|
@@ -1173,7 +1181,7 @@ export class RunController {
|
|
|
1173
1181
|
const envelope = await hook(runId);
|
|
1174
1182
|
if (epoch !== this.#hostPollEpoch)
|
|
1175
1183
|
return;
|
|
1176
|
-
this.#applyHostStatus(runId, envelope.ok ? envelope.data?.status : undefined);
|
|
1184
|
+
this.#applyHostStatus(runId, envelope.ok ? envelope.data?.status : undefined, envelope.ok ? (envelope.data?.activity?.kind ?? null) : null);
|
|
1177
1185
|
}
|
|
1178
1186
|
catch (err) {
|
|
1179
1187
|
logger.error('Failed to read host run status:', err);
|
|
@@ -1192,8 +1200,16 @@ export class RunController {
|
|
|
1192
1200
|
const config = this.#api.config;
|
|
1193
1201
|
if (!config)
|
|
1194
1202
|
return { ok: false };
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1203
|
+
const state = await readRunState(config, runId, this.#api.authProvider);
|
|
1204
|
+
if (state === undefined || state.status === undefined)
|
|
1205
|
+
return { ok: false };
|
|
1206
|
+
return {
|
|
1207
|
+
ok: true,
|
|
1208
|
+
data: {
|
|
1209
|
+
status: state.status,
|
|
1210
|
+
activity: state.activityKind === null ? null : { kind: state.activityKind }
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1197
1213
|
};
|
|
1198
1214
|
#clearHostPoll() {
|
|
1199
1215
|
if (this.#hostPoll !== null)
|
|
@@ -102,6 +102,10 @@ export declare class WorkflowStore {
|
|
|
102
102
|
/** Bound mutation facade — see {@link WorkflowStoreActions}. */
|
|
103
103
|
readonly actions: WorkflowStoreActions;
|
|
104
104
|
constructor(history: HistoryService);
|
|
105
|
+
/** Whether edits are refused (the editor is locked). */
|
|
106
|
+
get locked(): boolean;
|
|
107
|
+
/** Refuse (or allow again) every edit. Ends an open config-edit session first. */
|
|
108
|
+
setLocked(locked: boolean): void;
|
|
105
109
|
/** The current workflow, or null when none is loaded. */
|
|
106
110
|
get current(): Workflow | null;
|
|
107
111
|
/**
|
|
@@ -276,10 +280,12 @@ export declare class WorkflowStore {
|
|
|
276
280
|
* @param updates - Partial node updates (typically `{ data }`)
|
|
277
281
|
* @param opts.fieldKey - The config field being edited; drives per-field
|
|
278
282
|
* session boundaries. Omit to treat the whole node as one session.
|
|
283
|
+
* @returns `false` when the edit was refused (no workflow, or the editor is
|
|
284
|
+
* locked): whatever mirrors the store must not show it either.
|
|
279
285
|
*/
|
|
280
286
|
updateNodeConfig(nodeId: string, updates: Partial<WorkflowNode>, opts?: {
|
|
281
287
|
fieldKey?: string;
|
|
282
|
-
}):
|
|
288
|
+
}): boolean;
|
|
283
289
|
/**
|
|
284
290
|
* Finalize the in-progress config-edit session, if any.
|
|
285
291
|
*
|
|
@@ -136,6 +136,12 @@ export class WorkflowStore {
|
|
|
136
136
|
* When true, prevents pushing to history to avoid recursive loops.
|
|
137
137
|
*/
|
|
138
138
|
#restoringFromHistory = false;
|
|
139
|
+
/**
|
|
140
|
+
* Whether the editor is locked: every edit is refused, so a locked canvas
|
|
141
|
+
* cannot change by any route (canvas, config panel, console, shortcuts,
|
|
142
|
+
* undo). Loading a workflow (`initialize`) still works.
|
|
143
|
+
*/
|
|
144
|
+
#locked = $state(false);
|
|
139
145
|
/** Whether history recording is enabled (disable for bulk operations). */
|
|
140
146
|
#historyEnabled = true;
|
|
141
147
|
/**
|
|
@@ -182,6 +188,18 @@ export class WorkflowStore {
|
|
|
182
188
|
// -----------------------------------------------------------------------
|
|
183
189
|
// Reactive getters
|
|
184
190
|
// -----------------------------------------------------------------------
|
|
191
|
+
/** Whether edits are refused (the editor is locked). */
|
|
192
|
+
get locked() {
|
|
193
|
+
return this.#locked;
|
|
194
|
+
}
|
|
195
|
+
/** Refuse (or allow again) every edit. Ends an open config-edit session first. */
|
|
196
|
+
setLocked(locked) {
|
|
197
|
+
if (locked === this.#locked)
|
|
198
|
+
return;
|
|
199
|
+
if (locked)
|
|
200
|
+
this.finalizeNodeConfig();
|
|
201
|
+
this.#locked = locked;
|
|
202
|
+
}
|
|
185
203
|
/** The current workflow, or null when none is loaded. */
|
|
186
204
|
get current() {
|
|
187
205
|
return this.#workflow;
|
|
@@ -477,6 +495,8 @@ export class WorkflowStore {
|
|
|
477
495
|
* for every small change. History is pushed by specific actions or drag handlers.
|
|
478
496
|
*/
|
|
479
497
|
updateWorkflow(workflow) {
|
|
498
|
+
if (this.#locked)
|
|
499
|
+
return;
|
|
480
500
|
this.#workflow = this.#withoutRepliesOnRemovedNodes(workflow);
|
|
481
501
|
this.#bumpVersion();
|
|
482
502
|
this.#notifyWorkflowChange('metadata');
|
|
@@ -487,6 +507,8 @@ export class WorkflowStore {
|
|
|
487
507
|
* This bypasses history recording to prevent recursive loops.
|
|
488
508
|
*/
|
|
489
509
|
restoreFromHistory(workflow) {
|
|
510
|
+
if (this.#locked)
|
|
511
|
+
return;
|
|
490
512
|
// Undo/redo supersedes any in-progress config edit; drop the session marker
|
|
491
513
|
// (the history service already closed the transaction).
|
|
492
514
|
this.#configEditKey = null;
|
|
@@ -499,7 +521,7 @@ export class WorkflowStore {
|
|
|
499
521
|
}
|
|
500
522
|
/** Update nodes. */
|
|
501
523
|
updateNodes(nodes) {
|
|
502
|
-
if (!this.#workflow)
|
|
524
|
+
if (!this.#workflow || this.#locked)
|
|
503
525
|
return;
|
|
504
526
|
// Check if nodes have actually changed to prevent infinite loops
|
|
505
527
|
if (!hasWorkflowDataChanged(this.#workflow, nodes, this.#workflow.edges)) {
|
|
@@ -520,7 +542,7 @@ export class WorkflowStore {
|
|
|
520
542
|
}
|
|
521
543
|
/** Update edges. */
|
|
522
544
|
updateEdges(edges) {
|
|
523
|
-
if (!this.#workflow)
|
|
545
|
+
if (!this.#workflow || this.#locked)
|
|
524
546
|
return;
|
|
525
547
|
// Check if edges have actually changed to prevent infinite loops
|
|
526
548
|
if (!hasWorkflowDataChanged(this.#workflow, this.#workflow.nodes, edges)) {
|
|
@@ -541,7 +563,7 @@ export class WorkflowStore {
|
|
|
541
563
|
}
|
|
542
564
|
/** Update workflow name. */
|
|
543
565
|
updateName(name) {
|
|
544
|
-
if (!this.#workflow)
|
|
566
|
+
if (!this.#workflow || this.#locked)
|
|
545
567
|
return;
|
|
546
568
|
this.#workflow = {
|
|
547
569
|
...this.#workflow,
|
|
@@ -553,7 +575,7 @@ export class WorkflowStore {
|
|
|
553
575
|
}
|
|
554
576
|
/** Add a node. */
|
|
555
577
|
addNode(node) {
|
|
556
|
-
if (!this.#workflow)
|
|
578
|
+
if (!this.#workflow || this.#locked)
|
|
557
579
|
return;
|
|
558
580
|
this.#workflow = {
|
|
559
581
|
...this.#workflow,
|
|
@@ -571,7 +593,7 @@ export class WorkflowStore {
|
|
|
571
593
|
* A single undo will restore both the node and its edges.
|
|
572
594
|
*/
|
|
573
595
|
removeNode(nodeId) {
|
|
574
|
-
if (!this.#workflow)
|
|
596
|
+
if (!this.#workflow || this.#locked)
|
|
575
597
|
return;
|
|
576
598
|
this.#workflow = this.#withoutRepliesOnRemovedNodes({
|
|
577
599
|
...this.#workflow,
|
|
@@ -585,7 +607,7 @@ export class WorkflowStore {
|
|
|
585
607
|
}
|
|
586
608
|
/** Add an edge. */
|
|
587
609
|
addEdge(edge) {
|
|
588
|
-
if (!this.#workflow)
|
|
610
|
+
if (!this.#workflow || this.#locked)
|
|
589
611
|
return;
|
|
590
612
|
// Never append an edge whose id already exists — SvelteFlow keys edges by id
|
|
591
613
|
// and a duplicate throws `each_key_duplicate`, taking down the canvas. Guard
|
|
@@ -603,7 +625,7 @@ export class WorkflowStore {
|
|
|
603
625
|
}
|
|
604
626
|
/** Remove an edge. */
|
|
605
627
|
removeEdge(edgeId) {
|
|
606
|
-
if (!this.#workflow)
|
|
628
|
+
if (!this.#workflow || this.#locked)
|
|
607
629
|
return;
|
|
608
630
|
this.#workflow = {
|
|
609
631
|
...this.#workflow,
|
|
@@ -620,7 +642,7 @@ export class WorkflowStore {
|
|
|
620
642
|
* Used for config changes. Pushes to history for undo support.
|
|
621
643
|
*/
|
|
622
644
|
updateNode(nodeId, updates) {
|
|
623
|
-
if (!this.#workflow)
|
|
645
|
+
if (!this.#workflow || this.#locked)
|
|
624
646
|
return;
|
|
625
647
|
this.#workflow = {
|
|
626
648
|
...this.#workflow,
|
|
@@ -649,10 +671,12 @@ export class WorkflowStore {
|
|
|
649
671
|
* @param updates - Partial node updates (typically `{ data }`)
|
|
650
672
|
* @param opts.fieldKey - The config field being edited; drives per-field
|
|
651
673
|
* session boundaries. Omit to treat the whole node as one session.
|
|
674
|
+
* @returns `false` when the edit was refused (no workflow, or the editor is
|
|
675
|
+
* locked): whatever mirrors the store must not show it either.
|
|
652
676
|
*/
|
|
653
677
|
updateNodeConfig(nodeId, updates, opts) {
|
|
654
|
-
if (!this.#workflow)
|
|
655
|
-
return;
|
|
678
|
+
if (!this.#workflow || this.#locked)
|
|
679
|
+
return false;
|
|
656
680
|
const sessionKey = `${nodeId}::${opts?.fieldKey ?? ''}`;
|
|
657
681
|
// Moving to a different field/node closes the previous field's session.
|
|
658
682
|
if (this.#configEditKey !== null && this.#configEditKey !== sessionKey) {
|
|
@@ -674,6 +698,7 @@ export class WorkflowStore {
|
|
|
674
698
|
this.#bumpVersion();
|
|
675
699
|
// Deliberately no #pushToHistory (coalesced into the transaction) and no
|
|
676
700
|
// #notifyWorkflowChange (deferred to finalize) — that is the whole point.
|
|
701
|
+
return true;
|
|
677
702
|
}
|
|
678
703
|
/**
|
|
679
704
|
* Finalize the in-progress config-edit session, if any.
|
|
@@ -710,7 +735,7 @@ export class WorkflowStore {
|
|
|
710
735
|
}
|
|
711
736
|
/** Update workflow metadata. */
|
|
712
737
|
updateMetadata(metadata) {
|
|
713
|
-
if (!this.#workflow)
|
|
738
|
+
if (!this.#workflow || this.#locked)
|
|
714
739
|
return;
|
|
715
740
|
this.#workflow = {
|
|
716
741
|
...this.#workflow,
|
|
@@ -726,7 +751,7 @@ export class WorkflowStore {
|
|
|
726
751
|
* Creates a single history entry for the entire batch.
|
|
727
752
|
*/
|
|
728
753
|
batchUpdate(updates) {
|
|
729
|
-
if (!this.#workflow)
|
|
754
|
+
if (!this.#workflow || this.#locked)
|
|
730
755
|
return;
|
|
731
756
|
const next = {
|
|
732
757
|
...this.#workflow,
|
|
@@ -777,7 +802,7 @@ export class WorkflowStore {
|
|
|
777
802
|
* records a meaningful description for the undo history.
|
|
778
803
|
*/
|
|
779
804
|
swapNode(updates) {
|
|
780
|
-
if (!this.#workflow)
|
|
805
|
+
if (!this.#workflow || this.#locked)
|
|
781
806
|
return;
|
|
782
807
|
// Node swap is the one mutation that actively moves interface bindings —
|
|
783
808
|
// every other mutation (including delete) leaves them untouched. The chat
|
|
@@ -811,6 +836,9 @@ export class WorkflowStore {
|
|
|
811
836
|
* @param workflow - Optional workflow to push (uses store state if not provided)
|
|
812
837
|
*/
|
|
813
838
|
pushHistory(description, workflow) {
|
|
839
|
+
// A locked store refuses every edit, so there is nothing to undo.
|
|
840
|
+
if (this.#locked)
|
|
841
|
+
return;
|
|
814
842
|
this.#pushToHistory(description, workflow);
|
|
815
843
|
}
|
|
816
844
|
}
|
package/dist/styles/base.css
CHANGED
|
@@ -467,6 +467,12 @@
|
|
|
467
467
|
cursor: not-allowed;
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
+
/* Read-only (a locked editor): the value can be focused, selected and copied, not changed. */
|
|
471
|
+
.flowdrop-input[readonly] {
|
|
472
|
+
background-color: var(--fd-muted);
|
|
473
|
+
border-color: var(--fd-border-muted);
|
|
474
|
+
}
|
|
475
|
+
|
|
470
476
|
/* Invalid keeps its error border even on hover. */
|
|
471
477
|
.flowdrop-input--invalid,
|
|
472
478
|
.flowdrop-input--invalid:hover:not(:disabled) {
|
package/dist/svelte-app.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { Workflow, NodeMetadata, PortConfig, CategoryDefinition, ConfigSche
|
|
|
10
10
|
import type { EndpointConfig } from './config/endpoints.js';
|
|
11
11
|
import type { AuthProvider } from './types/auth.js';
|
|
12
12
|
import type { EditorPlaygroundConfig } from './types/playground.js';
|
|
13
|
+
import type { EditorLock } from './types/lock.js';
|
|
13
14
|
import type { FlowDropEventHandlers, FlowDropFeatures } from './types/events.js';
|
|
14
15
|
import type { FlowDropTheme, FlowDropThemeName } from './types/theme.js';
|
|
15
16
|
import type { WorkflowFormatAdapter } from './registry/workflowFormatRegistry.js';
|
|
@@ -67,6 +68,20 @@ export interface FlowDropMountOptions {
|
|
|
67
68
|
* @default 'edit'
|
|
68
69
|
*/
|
|
69
70
|
mode?: 'edit' | 'readonly' | 'locked';
|
|
71
|
+
/**
|
|
72
|
+
* Open the editor locked: the workflow is read-only, nothing can change it
|
|
73
|
+
* (canvas, config panels, console, shortcuts, undo), Save is disabled (a
|
|
74
|
+
* Save in `navbarActions` stays enabled; it saves nothing and says the editor
|
|
75
|
+
* is locked), and a
|
|
76
|
+
* banner above the canvas lists `reasons` (plain text, optional link) and
|
|
77
|
+
* offers `actions` (buttons). A button press calls `onLockAction(id)`; the
|
|
78
|
+
* host answers it, for example by removing the lock with `app.setLock(null)`.
|
|
79
|
+
* Selecting, panning, zooming and inspecting stay available. Unset, the
|
|
80
|
+
* editor is not locked and nothing changes.
|
|
81
|
+
*/
|
|
82
|
+
lock?: EditorLock | null;
|
|
83
|
+
/** Called with the action's `id` when a person presses a button on the lock banner. */
|
|
84
|
+
onLockAction?: (id: string) => void;
|
|
70
85
|
/**
|
|
71
86
|
* Start in Test mode (`'test'`): the Playground docked beside the canvas,
|
|
72
87
|
* the inspector always open. Edit | Test is a second axis beside `mode`: it
|
|
@@ -260,6 +275,11 @@ export interface MountedFlowDropApp {
|
|
|
260
275
|
* `app.instance.history.undo()` on the mount that owns the editor.
|
|
261
276
|
*/
|
|
262
277
|
instance: FlowDropInstance;
|
|
278
|
+
/**
|
|
279
|
+
* Lock the editor (see the `lock` mount option) or, with `null`, unlock it.
|
|
280
|
+
* The same as `app.instance.lock.set(...)`.
|
|
281
|
+
*/
|
|
282
|
+
setLock: (lock: EditorLock | null) => void;
|
|
263
283
|
/**
|
|
264
284
|
* Destroy the app and clean up resources
|
|
265
285
|
*/
|
|
@@ -401,6 +421,17 @@ export declare function mountWorkflowEditor(container: HTMLElement, options?: {
|
|
|
401
421
|
builtinEditors?: boolean;
|
|
402
422
|
/** Customise the canvas context menu — see {@link FlowDropMountOptions.contextMenu}. */
|
|
403
423
|
contextMenu?: ContextMenuOptions;
|
|
424
|
+
/**
|
|
425
|
+
* Open the editor locked: the workflow is read-only, nothing can change it
|
|
426
|
+
* (canvas, undo), and a banner above the canvas lists `reasons` (plain text,
|
|
427
|
+
* optional link) and offers `actions` (buttons). A button press calls
|
|
428
|
+
* `onLockAction(id)`; the host answers it, for example by removing the lock
|
|
429
|
+
* with `app.setLock(null)`. Selecting, panning, zooming and inspecting stay
|
|
430
|
+
* available. Unset, the editor is not locked and nothing changes.
|
|
431
|
+
*/
|
|
432
|
+
lock?: EditorLock | null;
|
|
433
|
+
/** Called with the action's `id` when a person presses a button on the lock banner. */
|
|
434
|
+
onLockAction?: (id: string) => void;
|
|
404
435
|
}): Promise<MountedFlowDropApp>;
|
|
405
436
|
/**
|
|
406
437
|
* Unmount a FlowDrop app
|