@bian-womp/spark-workbench 0.2.17 → 0.2.19
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/lib/cjs/index.cjs +155 -84
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/core/contracts.d.ts +2 -4
- package/lib/cjs/src/core/contracts.d.ts.map +1 -1
- package/lib/cjs/src/misc/Inspector.d.ts.map +1 -1
- package/lib/cjs/src/misc/context/WorkbenchContext.d.ts +5 -5
- package/lib/cjs/src/misc/context/WorkbenchContext.d.ts.map +1 -1
- package/lib/cjs/src/misc/context/WorkbenchContext.provider.d.ts.map +1 -1
- package/lib/cjs/src/misc/layout.d.ts +53 -0
- package/lib/cjs/src/misc/layout.d.ts.map +1 -0
- package/lib/cjs/src/misc/mapping.d.ts +6 -6
- package/lib/cjs/src/misc/mapping.d.ts.map +1 -1
- package/lib/esm/index.js +155 -84
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/core/contracts.d.ts +2 -4
- package/lib/esm/src/core/contracts.d.ts.map +1 -1
- package/lib/esm/src/misc/Inspector.d.ts.map +1 -1
- package/lib/esm/src/misc/context/WorkbenchContext.d.ts +5 -5
- package/lib/esm/src/misc/context/WorkbenchContext.d.ts.map +1 -1
- package/lib/esm/src/misc/context/WorkbenchContext.provider.d.ts.map +1 -1
- package/lib/esm/src/misc/layout.d.ts +53 -0
- package/lib/esm/src/misc/layout.d.ts.map +1 -0
- package/lib/esm/src/misc/mapping.d.ts +6 -6
- package/lib/esm/src/misc/mapping.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { GraphDefinition, ValidationIssue
|
|
2
|
-
export type ValidationIssue = BuilderValidationIssue;
|
|
1
|
+
import type { GraphDefinition, ValidationIssue, ValidationReport } from "@bian-womp/spark-graph";
|
|
3
2
|
export type ValidationResult = ValidationReport;
|
|
4
|
-
export type
|
|
5
|
-
export type HandleIssue = SimpleIssue & {
|
|
3
|
+
export type HandleIssue = ValidationIssue & {
|
|
6
4
|
handle: string;
|
|
7
5
|
};
|
|
8
6
|
export interface GraphActions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../../src/core/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../../src/core/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAGhD,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/D,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,IAAI,eAAe,CAAC;IAC1B,QAAQ,IAAI,gBAAgB,CAAC;IAC7B,OAAO,CACL,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG;QACvD,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KACrC,GACA,MAAM,CAAC;IACV,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,OAAO,CACL,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GACnE,MAAM,CAAC;IACV,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,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E,
|
|
1
|
+
{"version":3,"file":"Inspector.d.ts","sourceRoot":"","sources":["../../../../src/misc/Inspector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAOnD,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1C,qBAAqB,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;IACvD,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,GAAG,CAAC,OAAO,CAAC;IAC7D,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC/B,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CACxE,2CAmbA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { Registry, GraphDefinition } from "@bian-womp/spark-graph";
|
|
2
|
+
import type { Registry, GraphDefinition, ValidationIssue } from "@bian-womp/spark-graph";
|
|
3
3
|
import { InMemoryWorkbench } from "../../core/InMemoryWorkbench";
|
|
4
4
|
import { IGraphRunner, type EngineKind } from "../../runtime/IGraphRunner";
|
|
5
|
-
import type { HandleIssue, NodeRunStatus, EdgeRunStatus,
|
|
5
|
+
import type { HandleIssue, NodeRunStatus, EdgeRunStatus, DebugEvent } from "../../core/contracts";
|
|
6
6
|
export interface WorkbenchContextValue {
|
|
7
7
|
wb: InMemoryWorkbench;
|
|
8
8
|
runner: IGraphRunner;
|
|
@@ -24,13 +24,13 @@ export interface WorkbenchContextValue {
|
|
|
24
24
|
validationByNode: {
|
|
25
25
|
inputs: Record<string, HandleIssue[]>;
|
|
26
26
|
outputs: Record<string, HandleIssue[]>;
|
|
27
|
-
issues: Record<string,
|
|
27
|
+
issues: Record<string, ValidationIssue[]>;
|
|
28
28
|
};
|
|
29
29
|
validationByEdge: {
|
|
30
30
|
errors: Record<string, boolean>;
|
|
31
|
-
issues: Record<string,
|
|
31
|
+
issues: Record<string, ValidationIssue[]>;
|
|
32
32
|
};
|
|
33
|
-
validationGlobal:
|
|
33
|
+
validationGlobal: ValidationIssue[];
|
|
34
34
|
events: Array<DebugEvent>;
|
|
35
35
|
clearEvents: () => void;
|
|
36
36
|
isRunning: () => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkbenchContext.d.ts","sourceRoot":"","sources":["../../../../../src/misc/context/WorkbenchContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"WorkbenchContext.d.ts","sourceRoot":"","sources":["../../../../../src/misc/context/WorkbenchContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,aAAa,EACb,UAAU,EACX,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,q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CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,
|
|
1
|
+
{"version":3,"file":"WorkbenchContext.provider.d.ts","sourceRoot":"","sources":["../../../../../src/misc/context/WorkbenchContext.provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,QAAQ,EAAwB,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAmB,MAAM,4BAA4B,CAAC;AAiB3E,wBAAgB,iBAAiB,CAAC,EAChC,EAAE,EACF,MAAM,EACN,QAAQ,EACR,WAAW,EACX,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,iBAAiB,CAAC;IACtB,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,2CA6jBA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ResolvedHandles } from "@bian-womp/spark-protocol";
|
|
2
|
+
import type { GraphDefinition, Registry } from "@bian-womp/spark-graph";
|
|
3
|
+
import { Position } from "@xyflow/react";
|
|
4
|
+
export declare function computeEffectiveHandles(node: GraphDefinition["nodes"][number], registry: Registry): ResolvedHandles;
|
|
5
|
+
export declare function countVisibleHandles(handles: Omit<ResolvedHandles, "inputDefaults">): {
|
|
6
|
+
inputsCount: number;
|
|
7
|
+
outputsCount: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function estimateNodeSize(args: {
|
|
10
|
+
node: GraphDefinition["nodes"][number];
|
|
11
|
+
registry: Registry;
|
|
12
|
+
showValues?: boolean;
|
|
13
|
+
overrides?: {
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
};
|
|
17
|
+
}): {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
inputsCount: number;
|
|
21
|
+
outputsCount: number;
|
|
22
|
+
rowCount: number;
|
|
23
|
+
};
|
|
24
|
+
export declare function layoutNode(args: {
|
|
25
|
+
node: GraphDefinition["nodes"][number];
|
|
26
|
+
registry: Registry;
|
|
27
|
+
showValues?: boolean;
|
|
28
|
+
overrides?: {
|
|
29
|
+
width?: number;
|
|
30
|
+
height?: number;
|
|
31
|
+
};
|
|
32
|
+
}): {
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
inputOrder: string[];
|
|
36
|
+
outputOrder: string[];
|
|
37
|
+
handles: Array<{
|
|
38
|
+
id: string;
|
|
39
|
+
type: "source" | "target";
|
|
40
|
+
position: Position;
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
width?: number;
|
|
44
|
+
height?: number;
|
|
45
|
+
}>;
|
|
46
|
+
handleLayout: Array<{
|
|
47
|
+
id: string;
|
|
48
|
+
type: "source" | "target";
|
|
49
|
+
position: Position;
|
|
50
|
+
y: number;
|
|
51
|
+
}>;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../../src/misc/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGxE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EACtC,QAAQ,EAAE,QAAQ,GACjB,eAAe,CAOjB;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,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CAAC,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,YAAY,EAAE,KAAK,CAAC;QAClB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;QAC1B,QAAQ,EAAE,QAAQ,CAAC;QACnB,CAAC,EAAE,MAAM,CAAC;KACX,CAAC,CAAC;CACJ,CAkDA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type GraphDefinition, type Registry } from "@bian-womp/spark-graph";
|
|
2
|
-
import type { EdgeRunStatus, NodeRunStatus } from "../core/contracts";
|
|
3
|
-
import type { SimpleIssue, HandleIssue } from "../core/contracts";
|
|
1
|
+
import { type GraphDefinition, type Registry, type ValidationIssue } from "@bian-womp/spark-graph";
|
|
4
2
|
import { Position } from "@xyflow/react";
|
|
3
|
+
import type { EdgeRunStatus, NodeRunStatus } from "../core/contracts";
|
|
4
|
+
import type { HandleIssue } from "../core/contracts";
|
|
5
5
|
export interface RFNode {
|
|
6
6
|
id: string;
|
|
7
7
|
position: {
|
|
@@ -66,7 +66,7 @@ export interface RFNodeData extends Record<string, unknown> {
|
|
|
66
66
|
validation?: {
|
|
67
67
|
inputs: HandleIssue[];
|
|
68
68
|
outputs: HandleIssue[];
|
|
69
|
-
issues:
|
|
69
|
+
issues: ValidationIssue[];
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
export declare function toReactFlow(def: GraphDefinition, positions: Record<string, {
|
|
@@ -84,7 +84,7 @@ export declare function toReactFlow(def: GraphDefinition, positions: Record<stri
|
|
|
84
84
|
nodeValidation?: {
|
|
85
85
|
inputs: Record<string, HandleIssue[]>;
|
|
86
86
|
outputs: Record<string, HandleIssue[]>;
|
|
87
|
-
issues: Record<string,
|
|
87
|
+
issues: Record<string, ValidationIssue[]>;
|
|
88
88
|
};
|
|
89
89
|
edgeValidation?: Record<string, boolean>;
|
|
90
90
|
selectedNodeIds?: Set<string>;
|
|
@@ -101,7 +101,7 @@ export declare function getNodeBorderClassNames(args: {
|
|
|
101
101
|
selected?: boolean;
|
|
102
102
|
status?: NodeRunStatus;
|
|
103
103
|
validation?: {
|
|
104
|
-
issues?:
|
|
104
|
+
issues?: ValidationIssue[];
|
|
105
105
|
};
|
|
106
106
|
}): string;
|
|
107
107
|
//# sourceMappingURL=mapping.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../../../src/misc/mapping.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../../../src/misc/mapping.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,eAAe,EAErB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,UAAU,GAC5C,UAAU,GACV,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,OAAO,CAAC,EAAE,KAAK,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,QAAQ,GAAG,QAAQ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
1182
1182
|
const NODE_ROW_HEIGHT_PX = 22;
|
|
1183
1183
|
|
|
1184
|
+
function computeEffectiveHandles(node, registry) {
|
|
1185
|
+
const desc = registry.nodes.get(node.typeId);
|
|
1186
|
+
const resolved = node.resolvedHandles || {};
|
|
1187
|
+
const inputs = { ...desc?.inputs, ...resolved.inputs };
|
|
1188
|
+
const outputs = { ...desc?.outputs, ...resolved.outputs };
|
|
1189
|
+
const inputDefaults = { ...desc?.inputDefaults, ...resolved.inputDefaults };
|
|
1190
|
+
return { inputs, outputs, inputDefaults };
|
|
1191
|
+
}
|
|
1192
|
+
function countVisibleHandles(handles) {
|
|
1193
|
+
const inputIds = Object.keys(handles.inputs).filter((k) => !isInputPrivate(handles.inputs, k));
|
|
1194
|
+
const outputIds = Object.keys(handles.outputs);
|
|
1195
|
+
return { inputsCount: inputIds.length, outputsCount: outputIds.length };
|
|
1196
|
+
}
|
|
1197
|
+
function estimateNodeSize(args) {
|
|
1198
|
+
const { node, registry, showValues, overrides } = args;
|
|
1199
|
+
const { inputs, outputs } = computeEffectiveHandles(node, registry);
|
|
1200
|
+
// Count only non-private inputs for rows on left
|
|
1201
|
+
const { inputsCount, outputsCount } = countVisibleHandles({
|
|
1202
|
+
inputs,
|
|
1203
|
+
outputs,
|
|
1204
|
+
});
|
|
1205
|
+
const rows = Math.max(inputsCount, outputsCount);
|
|
1206
|
+
const baseWidth = showValues ? 320 : 240;
|
|
1207
|
+
const width = overrides?.width ?? baseWidth;
|
|
1208
|
+
const height = overrides?.height ?? NODE_HEADER_HEIGHT_PX + rows * NODE_ROW_HEIGHT_PX;
|
|
1209
|
+
return { width, height, inputsCount, outputsCount, rowCount: rows };
|
|
1210
|
+
}
|
|
1211
|
+
function layoutNode(args) {
|
|
1212
|
+
const { node, registry, showValues, overrides } = args;
|
|
1213
|
+
const { inputs, outputs } = computeEffectiveHandles(node, registry);
|
|
1214
|
+
const inputOrder = Object.keys(inputs).filter((k) => !isInputPrivate(inputs, k));
|
|
1215
|
+
const outputOrder = Object.keys(outputs);
|
|
1216
|
+
const { width, height } = estimateNodeSize({
|
|
1217
|
+
node,
|
|
1218
|
+
registry,
|
|
1219
|
+
showValues,
|
|
1220
|
+
overrides,
|
|
1221
|
+
});
|
|
1222
|
+
const HEADER = NODE_HEADER_HEIGHT_PX;
|
|
1223
|
+
const ROW = NODE_ROW_HEIGHT_PX;
|
|
1224
|
+
const handles = [
|
|
1225
|
+
...inputOrder.map((id, i) => ({
|
|
1226
|
+
id,
|
|
1227
|
+
type: "target",
|
|
1228
|
+
position: Position.Left,
|
|
1229
|
+
x: 0,
|
|
1230
|
+
y: HEADER + i * ROW,
|
|
1231
|
+
width: 1,
|
|
1232
|
+
height: ROW + 2,
|
|
1233
|
+
})),
|
|
1234
|
+
...outputOrder.map((id, i) => ({
|
|
1235
|
+
id,
|
|
1236
|
+
type: "source",
|
|
1237
|
+
position: Position.Right,
|
|
1238
|
+
x: width - 1,
|
|
1239
|
+
y: HEADER + i * ROW,
|
|
1240
|
+
width: 1,
|
|
1241
|
+
height: ROW + 2,
|
|
1242
|
+
})),
|
|
1243
|
+
];
|
|
1244
|
+
const handleLayout = [
|
|
1245
|
+
...inputOrder.map((id, i) => ({
|
|
1246
|
+
id,
|
|
1247
|
+
type: "target",
|
|
1248
|
+
position: Position.Left,
|
|
1249
|
+
y: HEADER + i * ROW + ROW / 2,
|
|
1250
|
+
})),
|
|
1251
|
+
...outputOrder.map((id, i) => ({
|
|
1252
|
+
id,
|
|
1253
|
+
type: "source",
|
|
1254
|
+
position: Position.Right,
|
|
1255
|
+
y: HEADER + i * ROW + ROW / 2,
|
|
1256
|
+
})),
|
|
1257
|
+
];
|
|
1258
|
+
return { width, height, inputOrder, outputOrder, handles, handleLayout };
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1184
1261
|
function toReactFlow(def, positions, registry, opts) {
|
|
1185
1262
|
const EDGE_STYLE_ERROR = { stroke: "#ef4444", strokeWidth: 2 };
|
|
1186
1263
|
const EDGE_STYLE_RUNNING = { stroke: "#3b82f6" };
|
|
@@ -1195,54 +1272,31 @@ function toReactFlow(def, positions, registry, opts) {
|
|
|
1195
1272
|
connectedInputs[nid].add(hid);
|
|
1196
1273
|
}
|
|
1197
1274
|
const nodes = def.nodes.map((n) => {
|
|
1198
|
-
const
|
|
1199
|
-
|
|
1200
|
-
const
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1275
|
+
const { inputs: inputSource, outputs: outputSource } = computeEffectiveHandles(n, registry);
|
|
1276
|
+
const overrideSize = opts.getDefaultNodeSize?.(n.typeId);
|
|
1277
|
+
const geom = layoutNode({
|
|
1278
|
+
node: n,
|
|
1279
|
+
registry,
|
|
1280
|
+
showValues: opts.showValues,
|
|
1281
|
+
overrides: overrideSize,
|
|
1282
|
+
});
|
|
1283
|
+
const inputHandles = geom.inputOrder.map((id) => ({
|
|
1284
|
+
id,
|
|
1285
|
+
typeId: getInputTypeId(inputSource, id),
|
|
1286
|
+
}));
|
|
1287
|
+
const outputHandles = geom.outputOrder.map((id) => ({
|
|
1208
1288
|
id,
|
|
1209
|
-
typeId: formatDeclaredTypeSignature(
|
|
1289
|
+
typeId: formatDeclaredTypeSignature(outputSource[id]),
|
|
1210
1290
|
}));
|
|
1211
1291
|
nodeHandleMap[n.nodeId] = {
|
|
1212
1292
|
inputs: new Set(inputHandles.map((h) => h.id)),
|
|
1213
1293
|
outputs: new Set(outputHandles.map((h) => h.id)),
|
|
1214
1294
|
};
|
|
1215
|
-
//
|
|
1216
|
-
const
|
|
1217
|
-
const
|
|
1218
|
-
const maxRows = Math.max(inputHandles.length, outputHandles.length);
|
|
1219
|
-
// Allow external override to dictate initial size
|
|
1220
|
-
const overrideSize = opts.getDefaultNodeSize?.(n.typeId);
|
|
1221
|
-
const initialWidth = overrideSize?.width ?? (opts.showValues ? 320 : 240);
|
|
1222
|
-
const initialHeight = overrideSize?.height ?? HEADER_SIZE + maxRows * ROW_SIZE;
|
|
1295
|
+
// Shared sizing
|
|
1296
|
+
const initialWidth = geom.width;
|
|
1297
|
+
const initialHeight = geom.height;
|
|
1223
1298
|
// Precompute handle bounds so edges can render immediately without waiting for measurement
|
|
1224
|
-
const handles =
|
|
1225
|
-
// Inputs on the left as targets
|
|
1226
|
-
...inputHandles.map((h, i) => ({
|
|
1227
|
-
id: h.id,
|
|
1228
|
-
type: "target",
|
|
1229
|
-
position: Position.Left,
|
|
1230
|
-
x: 0,
|
|
1231
|
-
y: HEADER_SIZE + i * ROW_SIZE,
|
|
1232
|
-
width: 1,
|
|
1233
|
-
height: ROW_SIZE + 2,
|
|
1234
|
-
})),
|
|
1235
|
-
// Outputs on the right as sources
|
|
1236
|
-
...outputHandles.map((h, i) => ({
|
|
1237
|
-
id: h.id,
|
|
1238
|
-
type: "source",
|
|
1239
|
-
position: Position.Right,
|
|
1240
|
-
x: initialWidth - 1,
|
|
1241
|
-
y: HEADER_SIZE + i * ROW_SIZE,
|
|
1242
|
-
width: 1,
|
|
1243
|
-
height: ROW_SIZE + 2,
|
|
1244
|
-
})),
|
|
1245
|
-
];
|
|
1299
|
+
const handles = geom.handles;
|
|
1246
1300
|
return {
|
|
1247
1301
|
id: n.nodeId,
|
|
1248
1302
|
data: {
|
|
@@ -1254,20 +1308,7 @@ function toReactFlow(def, positions, registry, opts) {
|
|
|
1254
1308
|
h.id,
|
|
1255
1309
|
!!connectedInputs[n.nodeId]?.has(h.id),
|
|
1256
1310
|
])),
|
|
1257
|
-
handleLayout:
|
|
1258
|
-
...inputHandles.map((h, i) => ({
|
|
1259
|
-
id: h.id,
|
|
1260
|
-
type: "target",
|
|
1261
|
-
position: Position.Left,
|
|
1262
|
-
y: HEADER_SIZE + i * ROW_SIZE + ROW_SIZE / 2,
|
|
1263
|
-
})),
|
|
1264
|
-
...outputHandles.map((h, i) => ({
|
|
1265
|
-
id: h.id,
|
|
1266
|
-
type: "source",
|
|
1267
|
-
position: Position.Right,
|
|
1268
|
-
y: HEADER_SIZE + i * ROW_SIZE + ROW_SIZE / 2,
|
|
1269
|
-
})),
|
|
1270
|
-
],
|
|
1311
|
+
handleLayout: geom.handleLayout,
|
|
1271
1312
|
showValues: opts.showValues,
|
|
1272
1313
|
renderWidth: initialWidth,
|
|
1273
1314
|
renderHeight: initialHeight,
|
|
@@ -1466,6 +1507,7 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
|
|
|
1466
1507
|
// Auto layout (simple layered layout)
|
|
1467
1508
|
const runAutoLayout = useCallback(() => {
|
|
1468
1509
|
const cur = wb.export();
|
|
1510
|
+
// Build DAG layers by indegree
|
|
1469
1511
|
const indegree = {};
|
|
1470
1512
|
const adj = {};
|
|
1471
1513
|
for (const n of cur.nodes) {
|
|
@@ -1492,14 +1534,36 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
|
|
|
1492
1534
|
layers.push(layer);
|
|
1493
1535
|
q.splice(0, q.length, ...next);
|
|
1494
1536
|
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1537
|
+
// Size-aware placement: columns by layer, stacking nodes vertically in each column
|
|
1538
|
+
// Use the same sizing heuristic as mapping via estimateNodeSize
|
|
1539
|
+
const H_GAP = 160;
|
|
1540
|
+
const V_GAP = 24;
|
|
1497
1541
|
const pos = {};
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1542
|
+
let curX = 0;
|
|
1543
|
+
for (const layer of layers) {
|
|
1544
|
+
// Compute max width in this layer and individual heights
|
|
1545
|
+
let maxWidth = 0;
|
|
1546
|
+
const heights = {};
|
|
1547
|
+
for (const id of layer) {
|
|
1548
|
+
const node = cur.nodes.find((n) => n.nodeId === id);
|
|
1549
|
+
if (!node)
|
|
1550
|
+
continue;
|
|
1551
|
+
// Prefer showValues sizing similar to node rendering
|
|
1552
|
+
// Lazy import to avoid circular deps at module top
|
|
1553
|
+
const size = estimateNodeSize({ node, registry, showValues: true });
|
|
1554
|
+
heights[id] = size.height;
|
|
1555
|
+
if (size.width > maxWidth)
|
|
1556
|
+
maxWidth = size.width;
|
|
1557
|
+
}
|
|
1558
|
+
// Place nodes in this column
|
|
1559
|
+
let curY = 0;
|
|
1560
|
+
for (const id of layer) {
|
|
1561
|
+
const h = heights[id] ?? 0;
|
|
1562
|
+
pos[id] = { x: curX, y: curY };
|
|
1563
|
+
curY += h + V_GAP;
|
|
1564
|
+
}
|
|
1565
|
+
curX += maxWidth + H_GAP;
|
|
1566
|
+
}
|
|
1503
1567
|
wb.setPositions(pos);
|
|
1504
1568
|
}, [wb]);
|
|
1505
1569
|
const updateEdgeType = useCallback((edgeId, typeId) => wb.updateEdgeType(edgeId, typeId), [wb]);
|
|
@@ -1595,15 +1659,6 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
|
|
|
1595
1659
|
return add("runner", "error")(e);
|
|
1596
1660
|
});
|
|
1597
1661
|
const off3 = runner.on("invalidate", (e) => {
|
|
1598
|
-
if (e?.reason === "graph-updated") {
|
|
1599
|
-
setNodeStatus((s) => {
|
|
1600
|
-
const next = {};
|
|
1601
|
-
for (const n of wb.export().nodes) {
|
|
1602
|
-
next[n.nodeId] = { ...s[n.nodeId], invalidated: true };
|
|
1603
|
-
}
|
|
1604
|
-
return next;
|
|
1605
|
-
});
|
|
1606
|
-
}
|
|
1607
1662
|
// After build/update, pull resolved handles and merge in-place (no graphChanged)
|
|
1608
1663
|
if (e?.reason === "graph-updated" || e?.reason === "graph-built") {
|
|
1609
1664
|
refreshResolvedHandles();
|
|
@@ -1772,17 +1827,17 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
|
|
|
1772
1827
|
const arr = inputs[d.nodeId] ?? (inputs[d.nodeId] = []);
|
|
1773
1828
|
arr.push({ handle: String(d.input), level, message, code });
|
|
1774
1829
|
const nodeArr = issues[d.nodeId] ?? (issues[d.nodeId] = []);
|
|
1775
|
-
nodeArr.push(
|
|
1830
|
+
nodeArr.push(is);
|
|
1776
1831
|
}
|
|
1777
1832
|
if (d.output) {
|
|
1778
1833
|
const arr = outputs[d.nodeId] ?? (outputs[d.nodeId] = []);
|
|
1779
1834
|
arr.push({ handle: String(d.output), level, message, code });
|
|
1780
1835
|
const nodeArr = issues[d.nodeId] ?? (issues[d.nodeId] = []);
|
|
1781
|
-
nodeArr.push(
|
|
1836
|
+
nodeArr.push(is);
|
|
1782
1837
|
}
|
|
1783
1838
|
if (!d.input && !d.output) {
|
|
1784
1839
|
const arr = issues[d.nodeId] ?? (issues[d.nodeId] = []);
|
|
1785
|
-
arr.push(
|
|
1840
|
+
arr.push(is);
|
|
1786
1841
|
}
|
|
1787
1842
|
}
|
|
1788
1843
|
}
|
|
@@ -1794,11 +1849,8 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
|
|
|
1794
1849
|
return list;
|
|
1795
1850
|
for (const is of validation.issues ?? []) {
|
|
1796
1851
|
const d = is.data;
|
|
1797
|
-
const level = is.level;
|
|
1798
|
-
const code = String(is.code ?? "");
|
|
1799
|
-
const message = String(is.message ?? code);
|
|
1800
1852
|
if (!d || (!d.nodeId && !d.edgeId)) {
|
|
1801
|
-
list.push(
|
|
1853
|
+
list.push(is);
|
|
1802
1854
|
}
|
|
1803
1855
|
}
|
|
1804
1856
|
return list;
|
|
@@ -1811,13 +1863,11 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
|
|
|
1811
1863
|
for (const is of validation.issues ?? []) {
|
|
1812
1864
|
const d = is.data;
|
|
1813
1865
|
const level = is.level;
|
|
1814
|
-
const code = String(is.code ?? "");
|
|
1815
|
-
const message = String(is.message ?? code);
|
|
1816
1866
|
if (d?.edgeId) {
|
|
1817
1867
|
if (level === "error")
|
|
1818
1868
|
errors[d.edgeId] = true;
|
|
1819
1869
|
const arr = issues[d.edgeId] ?? (issues[d.edgeId] = []);
|
|
1820
|
-
arr.push(
|
|
1870
|
+
arr.push(is);
|
|
1821
1871
|
}
|
|
1822
1872
|
}
|
|
1823
1873
|
return { errors, issues };
|
|
@@ -2017,11 +2067,29 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
|
|
|
2017
2067
|
setOriginals(nextOriginals);
|
|
2018
2068
|
}, [selectedNodeId, selectedDesc, valuesTick]);
|
|
2019
2069
|
const widthClass = debug ? "w-[480px]" : "w-[320px]";
|
|
2020
|
-
|
|
2070
|
+
const { wb } = useWorkbenchContext();
|
|
2071
|
+
const deleteEdgeById = (edgeId) => {
|
|
2072
|
+
if (!edgeId)
|
|
2073
|
+
return;
|
|
2074
|
+
try {
|
|
2075
|
+
wb.disconnect(edgeId);
|
|
2076
|
+
}
|
|
2077
|
+
catch { }
|
|
2078
|
+
};
|
|
2079
|
+
return (jsxs("div", { className: `${widthClass} border-l border-gray-300 p-3 flex flex-col h-full min-h-0 overflow-hidden`, children: [contextPanel && jsx("div", { className: "mb-2", children: contextPanel }), jsx("div", { className: "font-semibold mb-2", children: "Inspector" }), jsxs("div", { className: "text-xs text-gray-500 mb-2", children: ["valuesTick: ", valuesTick] }), jsx("div", { className: "flex-1 overflow-auto", children: !selectedNode && !selectedEdge ? (jsxs("div", { children: [jsx("div", { className: "text-gray-500", children: "Select a node or edge." }), globalValidationIssues && globalValidationIssues.length > 0 && (jsxs("div", { className: "mt-2 text-xs bg-red-50 border border-red-200 rounded px-2 py-1", children: [jsx("div", { className: "font-semibold mb-1", children: "Validation" }), jsx("ul", { className: "list-disc ml-4", children: globalValidationIssues.map((m, i) => (jsxs("li", { className: "flex items-center gap-1", children: [jsx(IssueBadge, { level: m.level, size: 24, className: "w-6 h-6" }), jsx("span", { children: `${m.code}: ${m.message}` }), !!m.data?.edgeId && (jsx("button", { className: "ml-2 text-[10px] px-1 py-[2px] border border-red-300 rounded text-red-700 hover:bg-red-50", onClick: (e) => {
|
|
2080
|
+
e.stopPropagation();
|
|
2081
|
+
deleteEdgeById(m.data?.edgeId);
|
|
2082
|
+
}, title: "Delete referenced edge", children: "Delete edge" }))] }, i))) })] }))] })) : selectedEdge ? (jsxs("div", { children: [jsxs("div", { className: "mb-2", children: [jsxs("div", { children: ["Edge: ", selectedEdge.id] }), jsxs("div", { children: [selectedEdge.source.nodeId, ".", selectedEdge.source.handle, " \u2192", " ", selectedEdge.target.nodeId, ".", selectedEdge.target.handle] }), jsx("div", { className: "mt-1", children: jsx("button", { className: "text-xs px-2 py-1 border border-red-300 rounded text-red-700 hover:bg-red-50", onClick: (e) => {
|
|
2083
|
+
e.stopPropagation();
|
|
2084
|
+
deleteEdgeById(selectedEdge.id);
|
|
2085
|
+
}, title: "Delete this edge", children: "Delete edge" }) }), jsxs("div", { className: "flex items-center gap-2 mt-1", children: [jsxs("label", { className: "w-20 flex flex-col", children: [jsx("span", { children: "Type" }), jsx("span", { className: "text-gray-500 text-[11px]", children: "DataTypeId" })] }), jsxs("select", { className: "border border-gray-300 rounded px-2 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500 w-full", value: selectedEdge.typeId ?? "", onChange: (e) => {
|
|
2021
2086
|
const v = e.target.value;
|
|
2022
2087
|
const next = v === "" ? undefined : v;
|
|
2023
2088
|
updateEdgeType(selectedEdge.id, next);
|
|
2024
|
-
}, children: [jsx("option", { value: "", children: "(infer from source)" }), Array.from(registry.types.keys()).map((tid) => (jsx("option", { value: tid, children: tid }, tid)))] })] })] }), selectedEdgeValidation.length > 0 && (jsxs("div", { className: "mt-2 text-xs bg-red-50 border border-red-200 rounded px-2 py-1", children: [jsx("div", { className: "font-semibold mb-1", children: "Validation" }), jsx("ul", { className: "list-disc ml-4", children: selectedEdgeValidation.map((m, i) => (jsxs("li", { className: "flex items-center gap-1", children: [jsx(IssueBadge, { level: m.level, size: 24, className: "w-6 h-6" }), jsx("span", { children: `${m.code}: ${m.message}` })
|
|
2089
|
+
}, children: [jsx("option", { value: "", children: "(infer from source)" }), Array.from(registry.types.keys()).map((tid) => (jsx("option", { value: tid, children: tid }, tid)))] })] })] }), selectedEdgeValidation.length > 0 && (jsxs("div", { className: "mt-2 text-xs bg-red-50 border border-red-200 rounded px-2 py-1", children: [jsx("div", { className: "font-semibold mb-1", children: "Validation" }), jsx("ul", { className: "list-disc ml-4", children: selectedEdgeValidation.map((m, i) => (jsxs("li", { className: "flex items-center gap-1", children: [jsx(IssueBadge, { level: m.level, size: 24, className: "w-6 h-6" }), jsx("span", { children: `${m.code}: ${m.message}` }), jsx("button", { className: "ml-2 text-[10px] px-1 py-[2px] border border-red-300 rounded text-red-700 hover:bg-red-50", onClick: (e) => {
|
|
2090
|
+
e.stopPropagation();
|
|
2091
|
+
deleteEdgeById(selectedEdge.id);
|
|
2092
|
+
}, title: "Delete this edge", children: "Delete edge" })] }, i))) })] }))] })) : (jsxs("div", { children: [selectedNode && (jsxs("div", { className: "mb-2", children: [jsxs("div", { children: ["Node: ", selectedNode.nodeId] }), jsxs("div", { children: ["Type: ", selectedNode.typeId] }), !!selectedNodeStatus?.lastError && (jsx("div", { className: "mt-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1 break-words", children: String(selectedNodeStatus.lastError?.message ??
|
|
2025
2093
|
selectedNodeStatus.lastError) }))] })), jsxs("div", { className: "mb-2", children: [jsx("div", { className: "font-semibold mb-1", children: "Inputs" }), inputHandles.length === 0 ? (jsx("div", { className: "text-gray-500", children: "No inputs" })) : (inputHandles.map((h) => {
|
|
2026
2094
|
const typeId = getInputTypeId(selectedDesc?.inputs, h);
|
|
2027
2095
|
const isLinked = def.edges.some((e) => e.target.nodeId === selectedNodeId &&
|
|
@@ -2079,7 +2147,10 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
|
|
|
2079
2147
|
.map((v) => `${v.code}: ${v.message}`)
|
|
2080
2148
|
.join("; ");
|
|
2081
2149
|
return (jsx(IssueBadge, { level: outErr ? "error" : "warning", size: 24, className: "ml-1 w-6 h-6", title: outTitle }));
|
|
2082
|
-
})()] }, h))))] }), selectedNodeValidation.length > 0 && (jsxs("div", { className: "mt-2 text-xs bg-red-50 border border-red-200 rounded px-2 py-1", children: [jsx("div", { className: "font-semibold mb-1", children: "Validation" }), jsx("ul", { className: "list-disc ml-4", children: selectedNodeValidation.map((m, i) => (jsxs("li", { className: "flex items-center gap-1", children: [jsx(IssueBadge, { level: m.level, size: 24, className: "w-6 h-6" }), jsx("span", { children: `${m.code}: ${m.message}` })
|
|
2150
|
+
})()] }, h))))] }), selectedNodeValidation.length > 0 && (jsxs("div", { className: "mt-2 text-xs bg-red-50 border border-red-200 rounded px-2 py-1", children: [jsx("div", { className: "font-semibold mb-1", children: "Validation" }), jsx("ul", { className: "list-disc ml-4", children: selectedNodeValidation.map((m, i) => (jsxs("li", { className: "flex items-center gap-1", children: [jsx(IssueBadge, { level: m.level, size: 24, className: "w-6 h-6" }), jsx("span", { children: `${m.code}: ${m.message}` }), !!m.data?.edgeId && (jsx("button", { className: "ml-2 text-[10px] px-1 py-[2px] border border-red-300 rounded text-red-700 hover:bg-red-50", onClick: (e) => {
|
|
2151
|
+
e.stopPropagation();
|
|
2152
|
+
deleteEdgeById(m.data?.edgeId);
|
|
2153
|
+
}, title: "Delete referenced edge", children: "Delete edge" }))] }, i))) })] }))] })) }), debug && (jsx("div", { className: "mt-3 flex-none min-h-0 h-[50%]", children: jsx(DebugEvents, { autoScroll: !!autoScroll, hideWorkbench: !!hideWorkbench, onAutoScrollChange: onAutoScrollChange, onHideWorkbenchChange: onHideWorkbenchChange }) }))] }));
|
|
2083
2154
|
}
|
|
2084
2155
|
|
|
2085
2156
|
function NodeHandles({ data, isConnectable, inputClassName = "!w-2 !h-2 !bg-gray-600", outputClassName = "!w-2 !h-2 !bg-gray-600", getClassName, renderLabel, labelClassName = "absolute text-[11px] text-gray-700 dark:text-gray-300 pointer-events-none", }) {
|