@bian-womp/spark-workbench 0.2.5 → 0.2.6
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 +21 -11
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/index.d.ts +1 -0
- package/lib/cjs/src/index.d.ts.map +1 -1
- package/lib/cjs/src/misc/DefaultNode.d.ts +1 -0
- package/lib/cjs/src/misc/DefaultNode.d.ts.map +1 -1
- package/lib/esm/index.js +20 -12
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/index.d.ts +1 -0
- package/lib/esm/src/index.d.ts.map +1 -1
- package/lib/esm/src/misc/DefaultNode.d.ts +1 -0
- package/lib/esm/src/misc/DefaultNode.d.ts.map +1 -1
- package/package.json +4 -4
package/lib/cjs/index.cjs
CHANGED
|
@@ -6,8 +6,8 @@ var React = require('react');
|
|
|
6
6
|
var react = require('@xyflow/react');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var react$1 = require('@phosphor-icons/react');
|
|
9
|
-
var isEqual = require('lodash/isEqual');
|
|
10
9
|
var cx = require('classnames');
|
|
10
|
+
var isEqual = require('lodash/isEqual');
|
|
11
11
|
|
|
12
12
|
class DefaultUIExtensionRegistry {
|
|
13
13
|
constructor() {
|
|
@@ -1989,7 +1989,7 @@ function NodeHandles({ data, isConnectable, inputClassName = "!w-2 !h-2 !bg-gray
|
|
|
1989
1989
|
const y = placed?.y;
|
|
1990
1990
|
const cls = getClassName?.({ kind: "output", id: h.id, type: "source" }) ??
|
|
1991
1991
|
outputClassName;
|
|
1992
|
-
return (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx(react.Handle, { id: h.id, type: "source", position: position, isConnectable: isConnectable, className: cls
|
|
1992
|
+
return (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx(react.Handle, { id: h.id, type: "source", position: position, isConnectable: isConnectable, className: `${cls} wb-nodrag wb-nowheel`, style: y !== undefined ? { top: y } : undefined }), renderLabel && (jsxRuntime.jsx("div", { className: labelClassName + " right-2", style: {
|
|
1993
1993
|
top: (y ?? 0) - 8,
|
|
1994
1994
|
left: "50%",
|
|
1995
1995
|
textAlign: "right",
|
|
@@ -2002,7 +2002,7 @@ function NodeHandles({ data, isConnectable, inputClassName = "!w-2 !h-2 !bg-gray
|
|
|
2002
2002
|
|
|
2003
2003
|
const DefaultNode = React.memo(function DefaultNode({ id, data, selected, isConnectable, }) {
|
|
2004
2004
|
const updateNodeInternals = react.useUpdateNodeInternals();
|
|
2005
|
-
const { typeId, showValues
|
|
2005
|
+
const { typeId, showValues } = data;
|
|
2006
2006
|
const inputEntries = data.inputHandles ?? [];
|
|
2007
2007
|
const outputEntries = data.outputHandles ?? [];
|
|
2008
2008
|
React.useEffect(() => {
|
|
@@ -2020,14 +2020,11 @@ const DefaultNode = React.memo(function DefaultNode({ id, data, selected, isConn
|
|
|
2020
2020
|
outputs: [],
|
|
2021
2021
|
issues: [],
|
|
2022
2022
|
};
|
|
2023
|
-
const hasError = !!status.lastError;
|
|
2024
|
-
const isRunning = !!status.activeRuns;
|
|
2025
2023
|
const containerBorder = getNodeBorderClassNames({
|
|
2026
2024
|
selected,
|
|
2027
2025
|
status,
|
|
2028
2026
|
validation,
|
|
2029
2027
|
});
|
|
2030
|
-
const pct = Math.round(Math.max(0, Math.min(1, Number(status.progress) || 0)) * 100);
|
|
2031
2028
|
return (jsxRuntime.jsxs("div", { className: cx("rounded-lg bg-white/70 !dark:bg-stone-900", containerBorder), style: {
|
|
2032
2029
|
position: "relative",
|
|
2033
2030
|
minWidth: typeof data.renderWidth === "number" ? data.renderWidth : undefined,
|
|
@@ -2035,11 +2032,24 @@ const DefaultNode = React.memo(function DefaultNode({ id, data, selected, isConn
|
|
|
2035
2032
|
}, children: [jsxRuntime.jsxs("div", { className: "flex items-center justify-center px-2 border-b border-solid border-gray-500 dark:border-gray-400 text-gray-600 dark:text-gray-300", style: {
|
|
2036
2033
|
maxHeight: NODE_HEADER_HEIGHT_PX,
|
|
2037
2034
|
minHeight: NODE_HEADER_HEIGHT_PX,
|
|
2038
|
-
}, children: [jsxRuntime.jsx("strong", { className: "flex-1 h-full text-sm", style: { lineHeight: `${NODE_HEADER_HEIGHT_PX}px` }, children: typeId }), jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
2035
|
+
}, children: [jsxRuntime.jsx("strong", { className: "flex-1 h-full text-sm", style: { lineHeight: `${NODE_HEADER_HEIGHT_PX}px` }, children: typeId }), jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [validation.issues && validation.issues.length > 0 && (jsxRuntime.jsx(IssueBadge, { level: validation.issues.some((i) => i.level === "error")
|
|
2039
2036
|
? "error"
|
|
2040
2037
|
: "warning", size: 12, className: "w-3 h-3", title: validation.issues
|
|
2041
2038
|
.map((v) => `${v.code}: ${v.message}`)
|
|
2042
|
-
.join("; ") })), jsxRuntime.jsxs("span", { className: "text-[10px] opacity-70", children: ["(", id, ")"] })] })] }), jsxRuntime.jsx(
|
|
2039
|
+
.join("; ") })), jsxRuntime.jsxs("span", { className: "text-[10px] opacity-70", children: ["(", id, ")"] })] })] }), jsxRuntime.jsx(DefaultNodeContent, { data: data, isConnectable: isConnectable })] }));
|
|
2040
|
+
});
|
|
2041
|
+
DefaultNode.displayName = "DefaultNode";
|
|
2042
|
+
function DefaultNodeContent({ data, isConnectable, }) {
|
|
2043
|
+
const { showValues, inputValues, outputValues, toString } = data;
|
|
2044
|
+
const inputEntries = data.inputHandles ?? [];
|
|
2045
|
+
const outputEntries = data.outputHandles ?? [];
|
|
2046
|
+
const status = data.status ?? { activeRuns: 0 };
|
|
2047
|
+
const validation = data.validation ?? {
|
|
2048
|
+
inputs: [],
|
|
2049
|
+
outputs: []};
|
|
2050
|
+
const isRunning = !!status.activeRuns;
|
|
2051
|
+
const pct = Math.round(Math.max(0, Math.min(1, Number(status.progress) || 0)) * 100);
|
|
2052
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: cx("h-px", (isRunning || pct > 0) && "bg-blue-200 dark:bg-blue-900"), children: jsxRuntime.jsx("div", { className: cx("h-px transition-all", (isRunning || pct > 0) && "bg-blue-500"), style: { width: isRunning || pct > 0 ? `${pct}%` : 0 } }) }), jsxRuntime.jsx(NodeHandles, { data: data, isConnectable: isConnectable, getClassName: ({ kind, id }) => {
|
|
2043
2053
|
const vIssues = (kind === "input" ? validation.inputs : validation.outputs).filter((v) => v.handle === id);
|
|
2044
2054
|
const hasAny = vIssues.length > 0;
|
|
2045
2055
|
const hasErr = vIssues.some((v) => v.level === "error");
|
|
@@ -2055,7 +2065,6 @@ const DefaultNode = React.memo(function DefaultNode({ id, data, selected, isConn
|
|
|
2055
2065
|
const title = vIssues
|
|
2056
2066
|
.map((v) => `${v.code}: ${v.message}`)
|
|
2057
2067
|
.join("; ");
|
|
2058
|
-
// Compose label with truncated value to prevent layout growth
|
|
2059
2068
|
const valueText = (() => {
|
|
2060
2069
|
if (!showValues)
|
|
2061
2070
|
return undefined;
|
|
@@ -2069,8 +2078,7 @@ const DefaultNode = React.memo(function DefaultNode({ id, data, selected, isConn
|
|
|
2069
2078
|
})();
|
|
2070
2079
|
return (jsxRuntime.jsxs("span", { className: "flex items-center gap-1 w-full", children: [kind === "output" ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [valueText !== undefined && (jsxRuntime.jsx("span", { className: "opacity-60 truncate pl-1", style: { flex: 1, minWidth: 0, maxWidth: "100%" }, children: valueText })), jsxRuntime.jsx("span", { className: "truncate shrink-0", style: { maxWidth: "40%" }, children: id })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { className: "truncate shrink-0", style: { maxWidth: "40%" }, children: id }), valueText !== undefined && (jsxRuntime.jsx("span", { className: "opacity-60 truncate pr-1", style: { flex: 1, minWidth: 0, maxWidth: "100%" }, children: valueText }))] })), hasAny && (jsxRuntime.jsx(IssueBadge, { level: hasErr ? "error" : "warning", size: 12, className: "shrink-0", title: title }))] }));
|
|
2071
2080
|
} })] }));
|
|
2072
|
-
}
|
|
2073
|
-
DefaultNode.displayName = "DefaultNode";
|
|
2081
|
+
}
|
|
2074
2082
|
|
|
2075
2083
|
function DefaultContextMenu({ open, clientPos, onAdd, onClose, }) {
|
|
2076
2084
|
const { registry } = useWorkbenchContext();
|
|
@@ -2945,6 +2953,8 @@ function WorkbenchStudio({ engine, onEngineChange, example, onExampleChange, bac
|
|
|
2945
2953
|
|
|
2946
2954
|
exports.AbstractWorkbench = AbstractWorkbench;
|
|
2947
2955
|
exports.CLIWorkbench = CLIWorkbench;
|
|
2956
|
+
exports.DefaultNode = DefaultNode;
|
|
2957
|
+
exports.DefaultNodeContent = DefaultNodeContent;
|
|
2948
2958
|
exports.DefaultUIExtensionRegistry = DefaultUIExtensionRegistry;
|
|
2949
2959
|
exports.InMemoryWorkbench = InMemoryWorkbench;
|
|
2950
2960
|
exports.Inspector = Inspector;
|