@digitalsee-ai/rcs 2.0.4-beta9 → 2.0.5-beta1

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.
@@ -26,7 +26,6 @@ export declare function parseDescriptorTypeKey(type: string): {
26
26
  * 取代 13 个仅做 SuperBaseNode 包装的细瘦组件(Action/Trigger/Condition/Loop/...)。
27
27
  * 节点之间的差异由 CLASSIC_DESCRIPTORS 描述:
28
28
  * - className:驱动 *.less 中的节点变体样式
29
- * - fallbackIcon:data.icon 为空时的回退图标
30
29
  * - inputs / outputs / byProtocol:按 (type, protocol) 的静态端口声明
31
30
  * (经 resolveNodeHandleConfigs 转为端口元数据:id + 位置 + 方向 + 约束)
32
31
  * - useNodePackagePorts:是否走 useNodePackagePorts 加载 schema 端口
@@ -23,8 +23,8 @@ export interface BaseNodeProps {
23
23
  id: string;
24
24
  data: NodeData;
25
25
  type?: NodeType;
26
+ saveType?: string;
26
27
  selected?: boolean;
27
- fallbackIcon?: React.ReactNode;
28
28
  iconUri?: string;
29
29
  color?: string;
30
30
  inputs?: HandleConfig[];
@@ -0,0 +1,28 @@
1
+ import { IconImageProps } from '../../design-system/IconImage';
2
+ import { NodeType } from '../../types/Node';
3
+ import { default as React } from 'react';
4
+ interface NodeIconProps {
5
+ /** 容器基础类名(如 workflow-node-icon / node-config-icon),无 icon 时追加 no-icon */
6
+ className: string;
7
+ /** 图标地址;缺省或加载失败时按 nodeType 回退默认图标,无匹配类型时回退 name 首字符 */
8
+ icon?: string;
9
+ /** 无 icon 时的回退文案来源 */
10
+ name?: string;
11
+ /** 节点类型,用于在 icon 加载失败时展示对应类型的默认图标 */
12
+ nodeType?: NodeType | string;
13
+ /** 容器透传属性(如 data-category) */
14
+ containerProps?: IconImageProps['containerProps'];
15
+ }
16
+ /**
17
+ * @description 节点类型 → 加载失败 / 未配置图标时的默认图标映射。
18
+ *
19
+ * 远程图标通常指向公网 CDN,在专网或离线环境下不可达;此时按节点类型展示
20
+ * 对应的内置图标,避免统一退化成首字母占位,保留节点的类型辨识度。
21
+ */
22
+ export declare const NODE_TYPE_FALLBACK_ICONS: Record<string, React.ReactNode>;
23
+ /**
24
+ * @description 节点图标:有 icon 且可达时以图片渲染;缺省或加载失败时按 nodeType 回退默认图标,
25
+ * 无匹配类型时回退渲染 name 首字符。
26
+ */
27
+ declare const NodeIcon: React.FC<NodeIconProps>;
28
+ export default NodeIcon;
@@ -3,13 +3,11 @@ import { HandleConfig } from './SuperBaseNode';
3
3
  import { NodeType } from '../types/Node';
4
4
  import { resolveSwitchNodePackagePortSchema, SwitchNodePackageBranch } from '../utils/switchNodePackage';
5
5
  import { Node } from '@xyflow/react';
6
- import { default as React } from 'react';
7
6
  import { DipPortSchema } from '../api/dip';
8
7
  export type NodeLegacyData = Record<string, unknown> | undefined | null;
9
8
  export interface NodeTypeDescriptor {
10
9
  type: NodeType | string;
11
10
  className: string;
12
- fallbackIcon: React.ReactNode;
13
11
  /** type 级默认输入端口声明(node.data.protocol 缺失或未命中 byProtocol 时使用) */
14
12
  inputs: NodePortSchema[];
15
13
  /** type 级默认输出端口声明 */
@@ -67,7 +65,7 @@ export interface RegisterNodeTypeDescriptorOptions {
67
65
  *
68
66
  * - 缺 nodeKey:console.warn 后返回 null,由调用方回退到 NodeType 经典描述符
69
67
  * - 同 id 重复注册视为幂等,不会重复触发 listeners
70
- * - dynamic 描述符继承 base 描述符的全部字段(className / fallbackIcon /
68
+ * - dynamic 描述符继承 base 描述符的全部字段(className /
71
69
  * useNodePackagePorts / inputs / outputs / byProtocol),仅 metadata 不同
72
70
  */
73
71
  export declare function registerNodeTypeDescriptor(options: RegisterNodeTypeDescriptorOptions): string | null;
@@ -15,6 +15,7 @@ interface TextFieldProps extends IFieldSuperProps {
15
15
  lang?: CodeEditorLanguage;
16
16
  onFocus?: () => void;
17
17
  onBlur?: () => void;
18
+ required?: boolean;
18
19
  }
19
20
  export declare const TextField: (props: TextFieldProps) => import("react/jsx-runtime").JSX.Element;
20
21
  export {};
@@ -0,0 +1,30 @@
1
+ import { default as React } from 'react';
2
+ export interface IconImageProps {
3
+ /** 远程图标地址;为空或加载失败时展示降级占位。 */
4
+ src?: string | null;
5
+ /** 降级占位文案来源(取首字符大写)。 */
6
+ name?: string;
7
+ /** 自定义降级内容,优先于首字符占位。 */
8
+ fallback?: React.ReactNode;
9
+ /** 图片替代文本。 */
10
+ alt?: string;
11
+ /** 容器类名(如 workflow-node-icon / item-icon)。 */
12
+ className?: string;
13
+ /** 图片类名。 */
14
+ imgClassName?: string;
15
+ /** 容器透传属性(如 data-category)。 */
16
+ containerProps?: React.HTMLAttributes<HTMLDivElement> & Record<string, unknown>;
17
+ /** 容器行内样式。 */
18
+ style?: React.CSSProperties;
19
+ }
20
+ /**
21
+ * @description 统一图标渲染组件:远程图标可达时展示图片,不可达时降级为首字母占位。
22
+ *
23
+ * 相比直接使用 background-image,本组件基于 <img> 的 onError 事件判定失败,
24
+ * 可在专网 / 离线(无法访问公网 CDN)环境下稳定降级,不会出现空白图标位。
25
+ *
26
+ * @param {IconImageProps} props 图标地址、降级文案与容器样式。
27
+ * @returns {JSX.Element} 图标容器 JSX。
28
+ */
29
+ declare const IconImage: React.FC<IconImageProps>;
30
+ export default IconImage;
@@ -1,3 +1,4 @@
1
1
  export { type AiFlowNodeTestPanelProps, type AiFlowNodeTestStatus, default as AiFlowNodeTestPanel, } from './AiFlowNodeTestPanel';
2
2
  export { type AiFlowVariableNode, type AiFlowVariableSection, type AiFlowVariableTreeProps, type AiFlowVariableType, default as AiFlowVariableTree, } from './AiFlowVariableTree';
3
+ export { default as IconImage, type IconImageProps, } from './IconImage';
3
4
  export { AI_FLOW_DESIGN_SYSTEM_VERSION, type AiFlowTokens, aiFlowCssVariables, aiFlowTokens, } from './tokens';
@@ -0,0 +1,25 @@
1
+ export interface UseImageFallbackResult {
2
+ /** true:应展示降级占位(无地址 / 已失败 / 超时 / 浏览器离线)。 */
3
+ failed: boolean;
4
+ /** true:远程图片仍在加载中。 */
5
+ loading: boolean;
6
+ /** 供 <img> 的 key 使用:网络恢复后自增,强制浏览器重新发起请求。 */
7
+ imageKey: string;
8
+ /** <img> 的 onLoad 回调。 */
9
+ onLoad: () => void;
10
+ /** <img> 的 onError 回调。 */
11
+ onError: () => void;
12
+ }
13
+ /**
14
+ * @description 远程图片降级 Hook。
15
+ *
16
+ * 处理专网 / 离线环境下远程图标不可用的场景:
17
+ * - 浏览器离线时直接跳过请求,立即降级,避免请求悬挂;
18
+ * - 加载失败(DNS 失败 / 404 / 防火墙拦截)时降级,并缓存失败地址避免重复请求;
19
+ * - 加载超时(请求悬挂)时降级,仅影响当前实例,不污染全局缓存;
20
+ * - 网络恢复(online 事件)后自动重试,恢复真实图标。
21
+ *
22
+ * @param {string | null | undefined} src 远程图片地址。
23
+ * @returns {UseImageFallbackResult} 降级状态与事件回调。
24
+ */
25
+ export declare function useImageFallback(src?: string | null): UseImageFallbackResult;
@@ -107,6 +107,7 @@ export { NodeStatus, NodeType } from './enums/node';
107
107
  export { WorkflowOpStatus } from './enums/workflow';
108
108
  export { default as HandleFactory } from './Handles/HandleFactory';
109
109
  export { useCanvasLayout } from './hooks/useCanvasLayout';
110
+ export { useImageFallback } from './hooks/useImageFallback';
110
111
  export { useUndo } from './hooks/useUndo';
111
112
  export { useWorkflow } from './hooks/useWorkflow';
112
113
  export { default as AiFlowNodeStatusBadge, type NodeStatusBadgeProps as AiFlowNodeStatusBadgeProps, } from './Nodes/components/NodeStatusBadge';
@@ -116,6 +117,7 @@ export type { CanvasAPI, CanvasEngineConfig, CanvasNavigate, DeepPartial, Histor
116
117
  export * from './types/flowVersion';
117
118
  export * from './types/Node';
118
119
  export * from './types/Workflow';
120
+ export { clearFailedImages, configureImageFallback, type ImageFallbackConfig, isImageFailed, } from './utils/imageFallback';
119
121
  export type { LocaleType as WorkflowLocale, TranslateFn as WorkflowTranslateFn, } from '../../../locales';
120
122
  export { createTranslator } from '../../../locales';
121
123
  export { DigitalseeWorkFlow, defaultCanvasEngineConfig, mergeConfig };
@@ -0,0 +1,75 @@
1
+ /**
2
+ * 远程图标降级能力(内网 / 离线 / 无法访问公网场景)。
3
+ *
4
+ * 背景:节点、动作、分类的图标均由后端配置下发,URL 通常指向公网 CDN。
5
+ * 在专网、离线或防火墙拦截的环境下这些图片无法加载,若不做处理会出现:
6
+ * - CSS background-image 静默失败:图标位置变成空白方块,没有任何提示;
7
+ * - <img> 加载失败:显示浏览器的破图占位,视觉上明显异常。
8
+ *
9
+ * 这里维护一份「已失败 URL」的全局缓存,配合 useImageFallback 使用:
10
+ * 1. 同一 URL 失败后不再重复发起请求,避免大量节点反复请求不可达地址;
11
+ * 2. 监听 online 事件,网络恢复后清空缓存并触发重试,图标可自动恢复;
12
+ * 3. 支持配置全局降级图标(内网可达的本地资源),优先于首字母占位。
13
+ */
14
+ /** 远程图标加载超时默认值(毫秒):超过该时长仍未完成即视为失败并降级。 */
15
+ export declare const DEFAULT_IMAGE_LOAD_TIMEOUT = 8000;
16
+ export interface ImageFallbackConfig {
17
+ /**
18
+ * 全局降级图标地址。
19
+ * 建议填写内网可达的本地资源或 data URI,命中后优先于首字母占位展示。
20
+ */
21
+ fallbackIconUrl?: string;
22
+ /** 远程图标加载超时(毫秒),0 表示不启用超时降级。 */
23
+ timeout?: number;
24
+ /** 浏览器判定离线时是否直接跳过请求(默认 true,避免请求悬挂)。 */
25
+ skipWhenOffline?: boolean;
26
+ }
27
+ type ResolvedImageFallbackConfig = Required<ImageFallbackConfig>;
28
+ /**
29
+ * @description 更新全局降级配置,建议在应用初始化时调用一次。
30
+ * @param {Partial<ImageFallbackConfig>} next 需要覆盖的配置项。
31
+ */
32
+ export declare function configureImageFallback(next: Partial<ImageFallbackConfig>): void;
33
+ /**
34
+ * @description 读取当前生效的降级配置。
35
+ * @returns {ResolvedImageFallbackConfig} 当前配置快照。
36
+ */
37
+ export declare function getImageFallbackConfig(): ResolvedImageFallbackConfig;
38
+ /**
39
+ * @description 订阅配置变更,返回取消订阅函数。
40
+ * @param {() => void} listener 配置变更回调。
41
+ * @returns {() => void} 取消订阅函数。
42
+ */
43
+ export declare function subscribeImageFallbackConfig(listener: () => void): () => void;
44
+ /**
45
+ * @description 订阅网络恢复事件(浏览器重新联网),返回取消订阅函数。
46
+ * @param {() => void} listener 网络恢复回调。
47
+ * @returns {() => void} 取消订阅函数。
48
+ */
49
+ export declare function subscribeImageRecovery(listener: () => void): () => void;
50
+ /**
51
+ * @description 浏览器是否处于在线状态;SSR / 不支持 navigator.onLine 时按在线处理。
52
+ * @returns {boolean} 是否在线。
53
+ */
54
+ export declare function isBrowserOnline(): boolean;
55
+ /**
56
+ * @description 判断某个远程图片是否已被判定为加载失败。
57
+ * @param {string | null | undefined} src 图片地址。
58
+ * @returns {boolean} 是否已失败(无地址视为不可用)。
59
+ */
60
+ export declare function isImageFailed(src?: string | null): boolean;
61
+ /**
62
+ * @description 标记某个远程图片加载失败,后续同地址的实例不再重复请求。
63
+ * @param {string | null | undefined} src 图片地址。
64
+ */
65
+ export declare function markImageFailed(src?: string | null): void;
66
+ /**
67
+ * @description 清空失败缓存(网络恢复或宿主主动重试时调用)。
68
+ */
69
+ export declare function clearFailedImages(): void;
70
+ /**
71
+ * @description 读取当前失败缓存内容,便于排查与测试。
72
+ * @returns {string[]} 已失败的 URL 列表。
73
+ */
74
+ export declare function getFailedImageUrls(): string[];
75
+ export {};
@@ -84,6 +84,8 @@ export interface ValueModeWrapperProps {
84
84
  * 代码编辑器语言(json / javascript)
85
85
  */
86
86
  lang?: CodeEditorLanguage;
87
+ /** 是否必填 */
88
+ required?: boolean;
87
89
  }
88
90
  export declare const ValueModeWrapper: React.FC<ValueModeWrapperProps>;
89
91
  export default ValueModeWrapper;
@@ -66,6 +66,8 @@ export interface FieldComponentProps<T extends FieldDef = FieldDef, K = unknown>
66
66
  onChange?: (value: unknown) => void;
67
67
  /** 字段 ID(由 Form.Item 注入) */
68
68
  id?: string;
69
+ /** 是否必填 */
70
+ required?: boolean;
69
71
  }
70
72
  /**
71
73
  * 字段组件元数据
@@ -1,5 +1,5 @@
1
1
  import { jsx as t, jsxs as _ } from "react/jsx-runtime";
2
- import { D as L, V as T, e as E, i as P, t as l, f as R, d as O } from "./index-e5FvUBY-.mjs";
2
+ import { D as L, V as T, e as E, i as P, t as l, f as R, d as O } from "./index-DpaoO6Cc.mjs";
3
3
  import { useEventEmitter as B, useReactive as A, useSize as W } from "ahooks";
4
4
  import { FormattedMessage as b } from "react-intl";
5
5
  import { CloseCircleFilled as H, CheckCircleFilled as G } from "@ant-design/icons";
@@ -285,4 +285,4 @@ function $e(e) {
285
285
  export {
286
286
  $e as default
287
287
  };
288
- //# sourceMappingURL=index-BCflRiZo.mjs.map
288
+ //# sourceMappingURL=index-CNiN54LX.mjs.map