@agentscope-ai/flow 0.0.10 → 0.0.12
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/dist/components/base-node/index.d.ts +3 -0
- package/dist/components/base-node/index.js +11 -2
- package/dist/hooks/use-nodes-interaction.js +20 -2
- package/dist/i18n/locales/en-us.json +2 -0
- package/dist/i18n/locales/ja-jp.json +2 -0
- package/dist/i18n/locales/zh-cn.json +2 -0
- package/package.json +1 -1
|
@@ -10,6 +10,9 @@ interface IProps extends NodeProps<IWorkFlowNode> {
|
|
|
10
10
|
disableAction?: boolean;
|
|
11
11
|
className?: string;
|
|
12
12
|
hasFailBranch?: boolean;
|
|
13
|
+
slots?: {
|
|
14
|
+
afterLabel?: React.ReactNode;
|
|
15
|
+
};
|
|
13
16
|
}
|
|
14
17
|
export declare const NodeStatusIcon: React.MemoExoticComponent<({ status }: {
|
|
15
18
|
status: IWorkFlowStatus;
|
|
@@ -64,6 +64,7 @@ export var NodeStatusIcon = /*#__PURE__*/memo(function (_ref) {
|
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
66
|
function BaseNode(props) {
|
|
67
|
+
var _props$slots;
|
|
67
68
|
var containerRef = useRef(null);
|
|
68
69
|
var taskStore = useStore(function (store) {
|
|
69
70
|
return store.taskStore;
|
|
@@ -179,7 +180,7 @@ function BaseNode(props) {
|
|
|
179
180
|
tooltip: true
|
|
180
181
|
},
|
|
181
182
|
className: "spark-flow-node-label flex-1 w-1"
|
|
182
|
-
}, props.data.label)), !!nodeResult && showResults ? /*#__PURE__*/React.createElement(NodeStatusIcon, {
|
|
183
|
+
}, props.data.label), !!((_props$slots = props.slots) !== null && _props$slots !== void 0 && _props$slots.afterLabel) && props.slots.afterLabel), !!nodeResult && showResults ? /*#__PURE__*/React.createElement(NodeStatusIcon, {
|
|
183
184
|
status: nodeResult.nodeStatus
|
|
184
185
|
}) : props.disableAction ? null : /*#__PURE__*/React.createElement("div", {
|
|
185
186
|
onClick: function onClick(e) {
|
|
@@ -278,11 +279,19 @@ export var GroupNode = /*#__PURE__*/memo(function (props) {
|
|
|
278
279
|
var _useNodesInteraction2 = useNodesInteraction(),
|
|
279
280
|
onAddNewNode = _useNodesInteraction2.onAddNewNode;
|
|
280
281
|
var onDrop = function onDrop(event) {
|
|
282
|
+
var _event$dataTransfer;
|
|
281
283
|
setHovered(false);
|
|
282
284
|
setIsDragging(false);
|
|
283
285
|
event.preventDefault();
|
|
284
286
|
event.stopPropagation();
|
|
285
|
-
|
|
287
|
+
// 兼容某些 Windows Chrome 版本 dataTransfer 可能为 undefined 的情况
|
|
288
|
+
if (!event.dataTransfer) {
|
|
289
|
+
message.warning($i18n.get({
|
|
290
|
+
id: 'spark-flow.components.BaseNode.index.browserDragNotSupported',
|
|
291
|
+
dm: '当前浏览器不支持完整的拖拽功能,请尝试:1. 升级到最新的chrome浏览器;2. 使用浏览器的匿名模式 3. 使用其他浏览器,如:edge;'
|
|
292
|
+
}));
|
|
293
|
+
}
|
|
294
|
+
var type = (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.getData('application/reactflow');
|
|
286
295
|
if (typeof type === 'undefined' || !type) {
|
|
287
296
|
return;
|
|
288
297
|
}
|
|
@@ -12,8 +12,12 @@ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread n
|
|
|
12
12
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
13
13
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
14
14
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
15
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
16
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
17
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
18
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
20
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
21
|
import { ITERATION_PADDING, NEW_NODE_PADDING } from "../constant";
|
|
18
22
|
import { useStore } from "../flow/context";
|
|
19
23
|
import $i18n from "../i18n";
|
|
@@ -25,6 +29,9 @@ import { useCallback } from 'react';
|
|
|
25
29
|
import { useFlowInteraction } from "./use-flow-interaction";
|
|
26
30
|
import { useFlowSave } from "./use-flow-save";
|
|
27
31
|
export var useNodesInteraction = function useNodesInteraction() {
|
|
32
|
+
var _message$useMessage = message.useMessage(),
|
|
33
|
+
_message$useMessage2 = _slicedToArray(_message$useMessage, 1),
|
|
34
|
+
messageApi = _message$useMessage2[0];
|
|
28
35
|
var _useFlowSave = useFlowSave(),
|
|
29
36
|
handleSaveFlowDraft = _useFlowSave.handleSaveFlowDraft;
|
|
30
37
|
var store = useStoreApi();
|
|
@@ -318,9 +325,17 @@ export var useNodesInteraction = function useNodesInteraction() {
|
|
|
318
325
|
};
|
|
319
326
|
}(), [store, handleSaveFlowDraft, nodeSchemaMap, onAddCustomNode, addNewNodeCallback]);
|
|
320
327
|
var onDrop = useCallback(function (event, parentId) {
|
|
328
|
+
var _event$dataTransfer;
|
|
321
329
|
setIsDragging(false);
|
|
322
330
|
event.preventDefault();
|
|
323
|
-
|
|
331
|
+
// 兼容某些 Windows Chrome 版本 dataTransfer 可能为 undefined 的情况
|
|
332
|
+
if (!event.dataTransfer) {
|
|
333
|
+
messageApi.warning($i18n.get({
|
|
334
|
+
id: 'spark-flow.hooks.useNodesInteraction.browserDragNotSupported',
|
|
335
|
+
dm: '当前浏览器不支持完整的拖拽功能,请尝试:1. 升级到最新的chrome浏览器;2. 使用浏览器的匿名模式 3. 使用其他浏览器,如:edge;'
|
|
336
|
+
}));
|
|
337
|
+
}
|
|
338
|
+
var type = (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.getData('application/reactflow');
|
|
324
339
|
if (typeof type === 'undefined' || !type) {
|
|
325
340
|
return;
|
|
326
341
|
}
|
|
@@ -334,7 +349,10 @@ export var useNodesInteraction = function useNodesInteraction() {
|
|
|
334
349
|
}, [onAddNewNode]);
|
|
335
350
|
var onDragOver = useCallback(function (event) {
|
|
336
351
|
event.preventDefault();
|
|
337
|
-
|
|
352
|
+
// 兼容某些 Windows Chrome 版本 dataTransfer 可能为 undefined 的情况
|
|
353
|
+
if (event.dataTransfer) {
|
|
354
|
+
event.dataTransfer.dropEffect = 'move';
|
|
355
|
+
}
|
|
338
356
|
}, []);
|
|
339
357
|
var handleSelectNode = useCallback(function (nodeId) {
|
|
340
358
|
var _store$getState4 = store.getState(),
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"spark-flow.components.BaseNode.index.debug": "Debug",
|
|
6
6
|
"spark-flow.components.BaseNode.index.whenError": "when errors occurred",
|
|
7
7
|
"spark-flow.components.BaseNode.index.errorBranch": "Error branch",
|
|
8
|
+
"spark-flow.components.BaseNode.index.browserDragNotSupported": "Your browser does not fully support drag and drop. Please try: 1. Upgrade to the latest Chrome browser; 2. Use the browser's incognito mode; 3. Use another browser, such as Edge.",
|
|
8
9
|
"spark-flow.components.CheckListBtn.index.checklistVar1": "Checklist · {var1}",
|
|
9
10
|
"spark-flow.components.CheckListBtn.index.allResolved": "All items in the checklist have been resolved",
|
|
10
11
|
"spark-flow.components.CodeInput.index.arrayEmpty": "Array(Empty)",
|
|
@@ -294,6 +295,7 @@
|
|
|
294
295
|
"spark-flow.hooks.useNodesInteraction.nodeCannotBeAddedToGroup": "This node cannot be added to the sub canvas",
|
|
295
296
|
"spark-flow.hooks.useNodesInteraction.nodeCannotBeAddedToGroupWithNodeType": "This node cannot be added to the sub canvas with this node type",
|
|
296
297
|
"spark-flow.hooks.useNodesInteraction.copySuccess": "Successful",
|
|
298
|
+
"spark-flow.hooks.useNodesInteraction.browserDragNotSupported": "Your browser does not fully support drag and drop. Please try: 1. Upgrade to the latest Chrome browser; 2. Use the browser's incognito mode; 3. Use another browser, such as Edge.",
|
|
297
299
|
"spark-flow.hooks.useNodesOutputParams.builtinVariable": "Built-in Variable",
|
|
298
300
|
"spark-flow.components.CodeInput.index.jsonEdit": "Json edit",
|
|
299
301
|
"spark-flow.demos.spark-flow-1.components.WorkFlowHeader.index.clear": "Clear",
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"spark-flow.components.BaseNode.index.debug": "デバッグ",
|
|
6
6
|
"spark-flow.components.BaseNode.index.whenError": "エラー発生時",
|
|
7
7
|
"spark-flow.components.BaseNode.index.errorBranch": "エラーブランチ",
|
|
8
|
+
"spark-flow.components.BaseNode.index.browserDragNotSupported": "現在のブラウザはドラッグ&ドロップを完全にサポートしていません。次の方法をお試しください:1. 最新のChromeブラウザにアップグレードする;2. ブラウザのシークレットモードを使用する;3. Edgeなど他のブラウザを使用する。",
|
|
8
9
|
"spark-flow.components.CheckListBtn.index.checklistVar1": "チェックリスト · {var1}",
|
|
9
10
|
"spark-flow.components.CheckListBtn.index.allResolved": "すべてのチェックリスト項目が解決されました",
|
|
10
11
|
"spark-flow.components.CodeInput.index.arrayEmpty": "Array(空の配列)",
|
|
@@ -294,6 +295,7 @@
|
|
|
294
295
|
"spark-flow.hooks.useNodesInteraction.nodeCannotBeAddedToGroup": "このノードはサブキャンバスに追加できません",
|
|
295
296
|
"spark-flow.hooks.useNodesInteraction.nodeCannotBeAddedToGroupWithNodeType": "このノードはこのサブキャンバスに追加できません",
|
|
296
297
|
"spark-flow.hooks.useNodesInteraction.copySuccess": "コピー成功",
|
|
298
|
+
"spark-flow.hooks.useNodesInteraction.browserDragNotSupported": "現在のブラウザはドラッグ&ドロップを完全にサポートしていません。次の方法をお試しください:1. 最新のChromeブラウザにアップグレードする;2. ブラウザのシークレットモードを使用する;3. Edgeなど他のブラウザを使用する。",
|
|
297
299
|
"spark-flow.hooks.useNodesOutputParams.builtinVariable": "組み込み変数",
|
|
298
300
|
"spark-flow.components.CodeInput.index.jsonEdit": "JSON編集",
|
|
299
301
|
"spark-flow.demos.spark-flow-1.components.WorkFlowHeader.index.clear": "クリア"
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"spark-flow.components.BaseNode.index.debug": "调试",
|
|
6
6
|
"spark-flow.components.BaseNode.index.whenError": "当异常时",
|
|
7
7
|
"spark-flow.components.BaseNode.index.errorBranch": "异常分支",
|
|
8
|
+
"spark-flow.components.BaseNode.index.browserDragNotSupported": "当前浏览器不支持完整的拖拽功能,请尝试:1. 升级到最新的chrome浏览器;2. 使用浏览器的匿名模式 3. 使用其他浏览器,如:edge;",
|
|
8
9
|
"spark-flow.components.CheckListBtn.index.checklistVar1": "检查清单 · {var1}",
|
|
9
10
|
"spark-flow.components.CheckListBtn.index.allResolved": "所有清单项已解决",
|
|
10
11
|
"spark-flow.components.CodeInput.index.arrayEmpty": "Array(空数组)",
|
|
@@ -294,6 +295,7 @@
|
|
|
294
295
|
"spark-flow.hooks.useNodesInteraction.nodeCannotBeAddedToGroup": "该节点不能添加到子画布中",
|
|
295
296
|
"spark-flow.hooks.useNodesInteraction.nodeCannotBeAddedToGroupWithNodeType": "该节点不能添加到该类型的子画布中",
|
|
296
297
|
"spark-flow.hooks.useNodesInteraction.copySuccess": "复制成功",
|
|
298
|
+
"spark-flow.hooks.useNodesInteraction.browserDragNotSupported": "当前浏览器不支持完整的拖拽功能,请尝试:1. 升级到最新的chrome浏览器;2. 使用浏览器的匿名模式 3. 使用其他浏览器,如:edge;",
|
|
297
299
|
"spark-flow.hooks.useNodesOutputParams.builtinVariable": "内置变量",
|
|
298
300
|
"spark-flow.components.CodeInput.index.jsonEdit": "JSON编辑",
|
|
299
301
|
"spark-flow.demos.spark-flow-1.components.WorkFlowHeader.index.clear": "清除",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentscope-ai/flow",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "A powerful and flexible flow canvas rendering engine designed for AI applications. Provides comprehensive workflow visualization and interaction capabilities for platforms like Bailian and AgentScope, enabling seamless creation and management of complex AI agent workflows with an intuitive drag-and-drop interface.",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|