@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/src/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./misc/mapping";
|
|
|
11
11
|
export * from "./misc/context/WorkbenchContext";
|
|
12
12
|
export * from "./misc/context/WorkbenchContext.provider";
|
|
13
13
|
export * from "./misc/Inspector";
|
|
14
|
+
export * from "./misc/DefaultNode";
|
|
14
15
|
export * from "./misc/WorkbenchCanvas";
|
|
15
16
|
export * from "./misc/WorkbenchStudio";
|
|
16
17
|
export * from "./misc/value";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,iCAAiC,CAAC;AAChD,cAAc,0CAA0C,CAAC;AAEzD,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,iCAAiC,CAAC;AAChD,cAAc,0CAA0C,CAAC;AAEzD,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
@@ -2,4 +2,5 @@ import React from "react";
|
|
|
2
2
|
import { type NodeProps, type Node } from "@xyflow/react";
|
|
3
3
|
import { type RFNodeData } from "./mapping";
|
|
4
4
|
export declare const DefaultNode: React.NamedExoticComponent<NodeProps<Node<RFNodeData>>>;
|
|
5
|
+
export declare function DefaultNodeContent({ data, isConnectable, }: Pick<NodeProps<Node<RFNodeData>>, "data" | "isConnectable">): import("react/jsx-runtime").JSX.Element;
|
|
5
6
|
//# sourceMappingURL=DefaultNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultNode.d.ts","sourceRoot":"","sources":["../../../../src/misc/DefaultNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,IAAI,EACV,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"DefaultNode.d.ts","sourceRoot":"","sources":["../../../../src/misc/DefaultNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,IAAI,EACV,MAAM,eAAe,CAAC;AAMvB,OAAO,EAA2B,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAErE,eAAO,MAAM,WAAW,yDAgFtB,CAAC;AAGH,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,aAAa,GACd,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC,2CA2H7D"}
|
package/lib/esm/index.js
CHANGED
|
@@ -4,8 +4,8 @@ import React, { useCallback, useState, useRef, useEffect, useMemo, createContext
|
|
|
4
4
|
import { Position, Handle, useUpdateNodeInternals, useReactFlow, ReactFlowProvider, ReactFlow, Background, BackgroundVariant, MiniMap, Controls } from '@xyflow/react';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
6
|
import { XCircleIcon, WarningCircleIcon, PlugsConnectedIcon, ClockClockwiseIcon, WifiHighIcon, WifiSlashIcon } from '@phosphor-icons/react';
|
|
7
|
-
import isEqual from 'lodash/isEqual';
|
|
8
7
|
import cx from 'classnames';
|
|
8
|
+
import isEqual from 'lodash/isEqual';
|
|
9
9
|
|
|
10
10
|
class DefaultUIExtensionRegistry {
|
|
11
11
|
constructor() {
|
|
@@ -1987,7 +1987,7 @@ function NodeHandles({ data, isConnectable, inputClassName = "!w-2 !h-2 !bg-gray
|
|
|
1987
1987
|
const y = placed?.y;
|
|
1988
1988
|
const cls = getClassName?.({ kind: "output", id: h.id, type: "source" }) ??
|
|
1989
1989
|
outputClassName;
|
|
1990
|
-
return (jsxs(React.Fragment, { children: [jsx(Handle, { id: h.id, type: "source", position: position, isConnectable: isConnectable, className: cls
|
|
1990
|
+
return (jsxs(React.Fragment, { children: [jsx(Handle, { id: h.id, type: "source", position: position, isConnectable: isConnectable, className: `${cls} wb-nodrag wb-nowheel`, style: y !== undefined ? { top: y } : undefined }), renderLabel && (jsx("div", { className: labelClassName + " right-2", style: {
|
|
1991
1991
|
top: (y ?? 0) - 8,
|
|
1992
1992
|
left: "50%",
|
|
1993
1993
|
textAlign: "right",
|
|
@@ -2000,7 +2000,7 @@ function NodeHandles({ data, isConnectable, inputClassName = "!w-2 !h-2 !bg-gray
|
|
|
2000
2000
|
|
|
2001
2001
|
const DefaultNode = React.memo(function DefaultNode({ id, data, selected, isConnectable, }) {
|
|
2002
2002
|
const updateNodeInternals = useUpdateNodeInternals();
|
|
2003
|
-
const { typeId, showValues
|
|
2003
|
+
const { typeId, showValues } = data;
|
|
2004
2004
|
const inputEntries = data.inputHandles ?? [];
|
|
2005
2005
|
const outputEntries = data.outputHandles ?? [];
|
|
2006
2006
|
React.useEffect(() => {
|
|
@@ -2018,14 +2018,11 @@ const DefaultNode = React.memo(function DefaultNode({ id, data, selected, isConn
|
|
|
2018
2018
|
outputs: [],
|
|
2019
2019
|
issues: [],
|
|
2020
2020
|
};
|
|
2021
|
-
const hasError = !!status.lastError;
|
|
2022
|
-
const isRunning = !!status.activeRuns;
|
|
2023
2021
|
const containerBorder = getNodeBorderClassNames({
|
|
2024
2022
|
selected,
|
|
2025
2023
|
status,
|
|
2026
2024
|
validation,
|
|
2027
2025
|
});
|
|
2028
|
-
const pct = Math.round(Math.max(0, Math.min(1, Number(status.progress) || 0)) * 100);
|
|
2029
2026
|
return (jsxs("div", { className: cx("rounded-lg bg-white/70 !dark:bg-stone-900", containerBorder), style: {
|
|
2030
2027
|
position: "relative",
|
|
2031
2028
|
minWidth: typeof data.renderWidth === "number" ? data.renderWidth : undefined,
|
|
@@ -2033,11 +2030,24 @@ const DefaultNode = React.memo(function DefaultNode({ id, data, selected, isConn
|
|
|
2033
2030
|
}, children: [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: {
|
|
2034
2031
|
maxHeight: NODE_HEADER_HEIGHT_PX,
|
|
2035
2032
|
minHeight: NODE_HEADER_HEIGHT_PX,
|
|
2036
|
-
}, children: [jsx("strong", { className: "flex-1 h-full text-sm", style: { lineHeight: `${NODE_HEADER_HEIGHT_PX}px` }, children: typeId }), jsxs("div", { className: "flex items-center gap-1", children: [
|
|
2033
|
+
}, children: [jsx("strong", { className: "flex-1 h-full text-sm", style: { lineHeight: `${NODE_HEADER_HEIGHT_PX}px` }, children: typeId }), jsxs("div", { className: "flex items-center gap-1", children: [validation.issues && validation.issues.length > 0 && (jsx(IssueBadge, { level: validation.issues.some((i) => i.level === "error")
|
|
2037
2034
|
? "error"
|
|
2038
2035
|
: "warning", size: 12, className: "w-3 h-3", title: validation.issues
|
|
2039
2036
|
.map((v) => `${v.code}: ${v.message}`)
|
|
2040
|
-
.join("; ") })), jsxs("span", { className: "text-[10px] opacity-70", children: ["(", id, ")"] })] })] }), jsx(
|
|
2037
|
+
.join("; ") })), jsxs("span", { className: "text-[10px] opacity-70", children: ["(", id, ")"] })] })] }), jsx(DefaultNodeContent, { data: data, isConnectable: isConnectable })] }));
|
|
2038
|
+
});
|
|
2039
|
+
DefaultNode.displayName = "DefaultNode";
|
|
2040
|
+
function DefaultNodeContent({ data, isConnectable, }) {
|
|
2041
|
+
const { showValues, inputValues, outputValues, toString } = data;
|
|
2042
|
+
const inputEntries = data.inputHandles ?? [];
|
|
2043
|
+
const outputEntries = data.outputHandles ?? [];
|
|
2044
|
+
const status = data.status ?? { activeRuns: 0 };
|
|
2045
|
+
const validation = data.validation ?? {
|
|
2046
|
+
inputs: [],
|
|
2047
|
+
outputs: []};
|
|
2048
|
+
const isRunning = !!status.activeRuns;
|
|
2049
|
+
const pct = Math.round(Math.max(0, Math.min(1, Number(status.progress) || 0)) * 100);
|
|
2050
|
+
return (jsxs(Fragment, { children: [jsx("div", { className: cx("h-px", (isRunning || pct > 0) && "bg-blue-200 dark:bg-blue-900"), children: jsx("div", { className: cx("h-px transition-all", (isRunning || pct > 0) && "bg-blue-500"), style: { width: isRunning || pct > 0 ? `${pct}%` : 0 } }) }), jsx(NodeHandles, { data: data, isConnectable: isConnectable, getClassName: ({ kind, id }) => {
|
|
2041
2051
|
const vIssues = (kind === "input" ? validation.inputs : validation.outputs).filter((v) => v.handle === id);
|
|
2042
2052
|
const hasAny = vIssues.length > 0;
|
|
2043
2053
|
const hasErr = vIssues.some((v) => v.level === "error");
|
|
@@ -2053,7 +2063,6 @@ const DefaultNode = React.memo(function DefaultNode({ id, data, selected, isConn
|
|
|
2053
2063
|
const title = vIssues
|
|
2054
2064
|
.map((v) => `${v.code}: ${v.message}`)
|
|
2055
2065
|
.join("; ");
|
|
2056
|
-
// Compose label with truncated value to prevent layout growth
|
|
2057
2066
|
const valueText = (() => {
|
|
2058
2067
|
if (!showValues)
|
|
2059
2068
|
return undefined;
|
|
@@ -2067,8 +2076,7 @@ const DefaultNode = React.memo(function DefaultNode({ id, data, selected, isConn
|
|
|
2067
2076
|
})();
|
|
2068
2077
|
return (jsxs("span", { className: "flex items-center gap-1 w-full", children: [kind === "output" ? (jsxs(Fragment, { children: [valueText !== undefined && (jsx("span", { className: "opacity-60 truncate pl-1", style: { flex: 1, minWidth: 0, maxWidth: "100%" }, children: valueText })), jsx("span", { className: "truncate shrink-0", style: { maxWidth: "40%" }, children: id })] })) : (jsxs(Fragment, { children: [jsx("span", { className: "truncate shrink-0", style: { maxWidth: "40%" }, children: id }), valueText !== undefined && (jsx("span", { className: "opacity-60 truncate pr-1", style: { flex: 1, minWidth: 0, maxWidth: "100%" }, children: valueText }))] })), hasAny && (jsx(IssueBadge, { level: hasErr ? "error" : "warning", size: 12, className: "shrink-0", title: title }))] }));
|
|
2069
2078
|
} })] }));
|
|
2070
|
-
}
|
|
2071
|
-
DefaultNode.displayName = "DefaultNode";
|
|
2079
|
+
}
|
|
2072
2080
|
|
|
2073
2081
|
function DefaultContextMenu({ open, clientPos, onAdd, onClose, }) {
|
|
2074
2082
|
const { registry } = useWorkbenchContext();
|
|
@@ -2941,5 +2949,5 @@ function WorkbenchStudio({ engine, onEngineChange, example, onExampleChange, bac
|
|
|
2941
2949
|
}, httpBaseUrl: httpBaseUrl, onHttpBaseUrlChange: onHttpBaseUrlChange, wsUrl: wsUrl, onWsUrlChange: onWsUrlChange, debug: debug, onDebugChange: onDebugChange, showValues: showValues, onShowValuesChange: onShowValuesChange, hideWorkbench: hideWorkbench, onHideWorkbenchChange: onHideWorkbenchChange, overrides: overrides, onInit: onInit, onChange: onChange }) }));
|
|
2942
2950
|
}
|
|
2943
2951
|
|
|
2944
|
-
export { AbstractWorkbench, CLIWorkbench, DefaultUIExtensionRegistry, InMemoryWorkbench, Inspector, LocalGraphRunner, NodeHandles, RemoteGraphRunner, WorkbenchCanvas, WorkbenchContext, WorkbenchProvider, WorkbenchStudio, formatDataUrlAsLabel, formatDeclaredTypeSignature, getNodeBorderClassNames, preformatValueForDisplay, resolveOutputDisplay, summarizeDeep, toReactFlow, useQueryParamBoolean, useQueryParamString, useThrottledValue, useWorkbenchBridge, useWorkbenchContext, useWorkbenchGraphTick, useWorkbenchGraphUiTick, useWorkbenchVersionTick };
|
|
2952
|
+
export { AbstractWorkbench, CLIWorkbench, DefaultNode, DefaultNodeContent, DefaultUIExtensionRegistry, InMemoryWorkbench, Inspector, LocalGraphRunner, NodeHandles, RemoteGraphRunner, WorkbenchCanvas, WorkbenchContext, WorkbenchProvider, WorkbenchStudio, formatDataUrlAsLabel, formatDeclaredTypeSignature, getNodeBorderClassNames, preformatValueForDisplay, resolveOutputDisplay, summarizeDeep, toReactFlow, useQueryParamBoolean, useQueryParamString, useThrottledValue, useWorkbenchBridge, useWorkbenchContext, useWorkbenchGraphTick, useWorkbenchGraphUiTick, useWorkbenchVersionTick };
|
|
2945
2953
|
//# sourceMappingURL=index.js.map
|