@nywqs/scada-engine 1.1.28 → 1.1.29
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/assets/dataProcessor.worker-DerLDc7p.js +1 -0
- package/dist/scada-engine.css +1 -1
- package/dist/scada-engine.es.js +10235 -9719
- package/dist/scada-engine.umd.js +26 -26
- package/dist/src/scada-components/registry.d.ts +61 -4
- package/dist/src/utils/animationScheduler.d.ts +85 -0
- package/dist/src/utils/canvasLayerManager.d.ts +88 -0
- package/dist/src/utils/dataBindingService.d.ts +15 -0
- package/dist/src/utils/index.d.ts +4 -0
- package/dist/src/utils/nodeOperations.d.ts +1 -1
- package/dist/src/utils/viewportCulling.d.ts +63 -0
- package/dist/src/utils/workerManager.d.ts +57 -0
- package/dist/src/views/workflow/components/ElementSelector.d.ts +2 -10
- package/dist/src/views/workflow/services/canvasElementService.d.ts +4 -4
- package/dist/src/views/workflow/types/element.d.ts +16 -0
- package/dist/src/workers/dataProcessor.worker.d.ts +21 -0
- package/package.json +1 -1
|
@@ -1,35 +1,79 @@
|
|
|
1
1
|
import { ComponentRegistry, ComponentConfig, ComponentCategory } from './types';
|
|
2
2
|
|
|
3
|
+
type ComponentLoader = () => Promise<{
|
|
4
|
+
default: ComponentConfig;
|
|
5
|
+
}>;
|
|
3
6
|
/**
|
|
4
7
|
* 组件注册表
|
|
5
8
|
*/
|
|
6
9
|
declare class ComponentRegistryManager {
|
|
7
10
|
private registry;
|
|
11
|
+
private lazyRegistry;
|
|
12
|
+
private loadingPromises;
|
|
8
13
|
constructor();
|
|
9
14
|
/**
|
|
10
|
-
* 注册默认组件
|
|
15
|
+
* 注册默认组件(立即加载)
|
|
11
16
|
*/
|
|
12
17
|
private registerDefaultComponents;
|
|
18
|
+
/**
|
|
19
|
+
* 注册懒加载组件(零配置 - 基于约定自动发现)
|
|
20
|
+
* 约定:所有 ./iot/industrial-*.ts 文件自动注册为懒加载组件
|
|
21
|
+
* 策略:延迟加载 - 首次请求组件时才加载整个模块,并注册模块内的所有组件
|
|
22
|
+
*/
|
|
23
|
+
private registerLazyComponents;
|
|
24
|
+
/**
|
|
25
|
+
* 注册 Vue Shape 到 X6
|
|
26
|
+
*/
|
|
27
|
+
private registerVueShape;
|
|
13
28
|
/**
|
|
14
29
|
* 注册组件
|
|
15
30
|
*/
|
|
16
31
|
register(config: ComponentConfig): void;
|
|
32
|
+
/**
|
|
33
|
+
* 注册懒加载组件
|
|
34
|
+
*/
|
|
35
|
+
registerLazy(id: string, loader: ComponentLoader): void;
|
|
17
36
|
/**
|
|
18
37
|
* 批量注册组件
|
|
19
38
|
*/
|
|
20
39
|
registerBatch(configs: ComponentConfig[]): void;
|
|
21
40
|
/**
|
|
22
|
-
* 获取组件配置
|
|
41
|
+
* 获取组件配置(支持懒加载)
|
|
42
|
+
*/
|
|
43
|
+
getComponent(id: string): Promise<ComponentConfig | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* 同步获取组件(仅已加载的)
|
|
46
|
+
*/
|
|
47
|
+
getComponentSync(id: string): ComponentConfig | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* 加载懒加载组件
|
|
50
|
+
*/
|
|
51
|
+
private loadComponent;
|
|
52
|
+
/**
|
|
53
|
+
* 预加载组件
|
|
54
|
+
*/
|
|
55
|
+
preloadComponent(id: string): Promise<boolean>;
|
|
56
|
+
/**
|
|
57
|
+
* 批量预加载组件
|
|
23
58
|
*/
|
|
24
|
-
|
|
59
|
+
preloadComponents(ids: string[]): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* 预加载所有组件
|
|
62
|
+
* 包括模块级别的懒加载(以 __module__ 开头)
|
|
63
|
+
*/
|
|
64
|
+
preloadAllComponents(): Promise<void>;
|
|
25
65
|
/**
|
|
26
66
|
* 通过shape获取组件配置
|
|
27
67
|
*/
|
|
28
68
|
getComponentByShape(shape: string): ComponentConfig | undefined;
|
|
29
69
|
/**
|
|
30
|
-
* 获取所有组件
|
|
70
|
+
* 获取所有组件(仅已加载)
|
|
31
71
|
*/
|
|
32
72
|
getAllComponents(): ComponentRegistry;
|
|
73
|
+
/**
|
|
74
|
+
* 获取所有组件ID(包括未加载)
|
|
75
|
+
*/
|
|
76
|
+
getAllComponentIds(): string[];
|
|
33
77
|
/**
|
|
34
78
|
* 按分类获取组件
|
|
35
79
|
*/
|
|
@@ -50,6 +94,19 @@ declare class ComponentRegistryManager {
|
|
|
50
94
|
* 获取组件数量
|
|
51
95
|
*/
|
|
52
96
|
getCount(): number;
|
|
97
|
+
/**
|
|
98
|
+
* 获取已加载组件数量
|
|
99
|
+
*/
|
|
100
|
+
getLoadedCount(): number;
|
|
101
|
+
/**
|
|
102
|
+
* 获取懒加载统计
|
|
103
|
+
*/
|
|
104
|
+
getLazyLoadStats(): {
|
|
105
|
+
total: number;
|
|
106
|
+
loaded: number;
|
|
107
|
+
pending: number;
|
|
108
|
+
loadRate: string;
|
|
109
|
+
};
|
|
53
110
|
/**
|
|
54
111
|
* 清空注册表
|
|
55
112
|
*/
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 统一动画调度器
|
|
3
|
+
* 解决多个组件独立使用 requestAnimationFrame 导致的性能问题
|
|
4
|
+
*
|
|
5
|
+
* 优势:
|
|
6
|
+
* 1. 统一时间步进,避免动画不同步
|
|
7
|
+
* 2. 减少 RAF 调用次数,降低浏览器开销
|
|
8
|
+
* 3. 集中管理所有动画,便于调试和性能监控
|
|
9
|
+
* 4. 支持动画暂停/恢复/销毁
|
|
10
|
+
*/
|
|
11
|
+
export interface AnimationTask {
|
|
12
|
+
id: string;
|
|
13
|
+
callback: (deltaTime: number, currentTime: number) => void;
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
lastTime: number;
|
|
16
|
+
}
|
|
17
|
+
declare class AnimationScheduler {
|
|
18
|
+
private tasks;
|
|
19
|
+
private rafId;
|
|
20
|
+
private isRunning;
|
|
21
|
+
private lastFrameTime;
|
|
22
|
+
private frameCount;
|
|
23
|
+
private fpsUpdateTime;
|
|
24
|
+
private currentFps;
|
|
25
|
+
/**
|
|
26
|
+
* 注册动画任务
|
|
27
|
+
* @param id 唯一标识符(通常使用组件 nodeId)
|
|
28
|
+
* @param callback 动画回调函数 (deltaTime: 距上次调用的毫秒数, currentTime: 当前时间戳)
|
|
29
|
+
*/
|
|
30
|
+
register(id: string, callback: (deltaTime: number, currentTime: number) => void): void;
|
|
31
|
+
/**
|
|
32
|
+
* 注销动画任务
|
|
33
|
+
* @param id 任务标识符
|
|
34
|
+
*/
|
|
35
|
+
unregister(id: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* 启用/禁用特定任务
|
|
38
|
+
* @param id 任务标识符
|
|
39
|
+
* @param enabled 是否启用
|
|
40
|
+
*/
|
|
41
|
+
setEnabled(id: string, enabled: boolean): void;
|
|
42
|
+
/**
|
|
43
|
+
* 启动调度器
|
|
44
|
+
*/
|
|
45
|
+
private start;
|
|
46
|
+
/**
|
|
47
|
+
* 停止调度器
|
|
48
|
+
*/
|
|
49
|
+
private stop;
|
|
50
|
+
/**
|
|
51
|
+
* 动画帧循环
|
|
52
|
+
*/
|
|
53
|
+
private tick;
|
|
54
|
+
/**
|
|
55
|
+
* 获取当前 FPS
|
|
56
|
+
*/
|
|
57
|
+
getFps(): number;
|
|
58
|
+
/**
|
|
59
|
+
* 获取活跃任务数量
|
|
60
|
+
*/
|
|
61
|
+
getActiveTaskCount(): number;
|
|
62
|
+
/**
|
|
63
|
+
* 暂停所有动画
|
|
64
|
+
*/
|
|
65
|
+
pauseAll(): void;
|
|
66
|
+
/**
|
|
67
|
+
* 恢复所有动画
|
|
68
|
+
*/
|
|
69
|
+
resumeAll(): void;
|
|
70
|
+
/**
|
|
71
|
+
* 清除所有任务并停止调度器
|
|
72
|
+
*/
|
|
73
|
+
destroy(): void;
|
|
74
|
+
/**
|
|
75
|
+
* 获取调度器状态(用于调试)
|
|
76
|
+
*/
|
|
77
|
+
getStatus(): {
|
|
78
|
+
isRunning: boolean;
|
|
79
|
+
taskCount: number;
|
|
80
|
+
activeTaskCount: number;
|
|
81
|
+
fps: number;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export declare const animationScheduler: AnimationScheduler;
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Graph } from '@antv/x6';
|
|
2
|
+
|
|
3
|
+
export declare enum CanvasLayer {
|
|
4
|
+
BACKGROUND = "background",
|
|
5
|
+
STATIC = "static",
|
|
6
|
+
ANIMATION = "animation",
|
|
7
|
+
INTERACTION = "interaction",
|
|
8
|
+
HIGHLIGHT = "highlight"
|
|
9
|
+
}
|
|
10
|
+
export declare class CanvasLayerManager {
|
|
11
|
+
private graph;
|
|
12
|
+
private layers;
|
|
13
|
+
private layerConfig;
|
|
14
|
+
private containerElement;
|
|
15
|
+
private dirtyLayers;
|
|
16
|
+
private renderScheduled;
|
|
17
|
+
private staticNodes;
|
|
18
|
+
private animationNodes;
|
|
19
|
+
/**
|
|
20
|
+
* 初始化分层系统
|
|
21
|
+
*/
|
|
22
|
+
init(graph: Graph, container: HTMLElement): void;
|
|
23
|
+
/**
|
|
24
|
+
* 创建图层 Canvas
|
|
25
|
+
*/
|
|
26
|
+
private createLayer;
|
|
27
|
+
/**
|
|
28
|
+
* 附加事件监听器
|
|
29
|
+
*/
|
|
30
|
+
private attachEventListeners;
|
|
31
|
+
/**
|
|
32
|
+
* 标记图层为脏(需要重绘)
|
|
33
|
+
*/
|
|
34
|
+
markDirty(layer: CanvasLayer): void;
|
|
35
|
+
/**
|
|
36
|
+
* 调度渲染
|
|
37
|
+
*/
|
|
38
|
+
private scheduleRender;
|
|
39
|
+
/**
|
|
40
|
+
* 渲染所有脏图层
|
|
41
|
+
*/
|
|
42
|
+
private render;
|
|
43
|
+
/**
|
|
44
|
+
* 渲染单个图层
|
|
45
|
+
*/
|
|
46
|
+
private renderLayer;
|
|
47
|
+
/**
|
|
48
|
+
* 渲染背景层
|
|
49
|
+
*/
|
|
50
|
+
private renderBackground;
|
|
51
|
+
/**
|
|
52
|
+
* 渲染静态层
|
|
53
|
+
*/
|
|
54
|
+
private renderStatic;
|
|
55
|
+
/**
|
|
56
|
+
* 渲染动画层
|
|
57
|
+
*/
|
|
58
|
+
private renderAnimation;
|
|
59
|
+
/**
|
|
60
|
+
* 渲染交互层
|
|
61
|
+
*/
|
|
62
|
+
private renderInteraction;
|
|
63
|
+
/**
|
|
64
|
+
* 渲染高亮层
|
|
65
|
+
*/
|
|
66
|
+
private renderHighlight;
|
|
67
|
+
/**
|
|
68
|
+
* 标记节点为动画节点
|
|
69
|
+
*/
|
|
70
|
+
markAsAnimation(nodeId: string): void;
|
|
71
|
+
/**
|
|
72
|
+
* 标记节点为静态节点
|
|
73
|
+
*/
|
|
74
|
+
markAsStatic(nodeId: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* 获取性能统计
|
|
77
|
+
*/
|
|
78
|
+
getStats(): {
|
|
79
|
+
staticNodes: number;
|
|
80
|
+
animationNodes: number;
|
|
81
|
+
dirtyLayers: number;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* 销毁分层系统
|
|
85
|
+
*/
|
|
86
|
+
destroy(): void;
|
|
87
|
+
}
|
|
88
|
+
export declare const canvasLayerManager: CanvasLayerManager;
|
|
@@ -7,6 +7,9 @@ import { BindingConfig } from '../types/binding';
|
|
|
7
7
|
export declare class DataBindingService {
|
|
8
8
|
private graph;
|
|
9
9
|
private dataCallbackRegistered;
|
|
10
|
+
private updateQueue;
|
|
11
|
+
private flushTimer;
|
|
12
|
+
private readonly FLUSH_DELAY;
|
|
10
13
|
/**
|
|
11
14
|
* 设置 Graph 实例
|
|
12
15
|
*/
|
|
@@ -23,6 +26,18 @@ export declare class DataBindingService {
|
|
|
23
26
|
* 更新单个节点的数据
|
|
24
27
|
*/
|
|
25
28
|
private updateNodeData;
|
|
29
|
+
/**
|
|
30
|
+
* 将更新添加到队列
|
|
31
|
+
*/
|
|
32
|
+
private queueUpdates;
|
|
33
|
+
/**
|
|
34
|
+
* 调度批量刷新
|
|
35
|
+
*/
|
|
36
|
+
private scheduleFlush;
|
|
37
|
+
/**
|
|
38
|
+
* 执行批量更新
|
|
39
|
+
*/
|
|
40
|
+
private flush;
|
|
26
41
|
/**
|
|
27
42
|
* 从原始数据中提取点位值
|
|
28
43
|
*
|
|
@@ -16,3 +16,7 @@ export * from './dataBindingService';
|
|
|
16
16
|
export * from './eventManager';
|
|
17
17
|
export * from './contextMenuManager';
|
|
18
18
|
export * from './canvasConfigWatcher';
|
|
19
|
+
export * from './animationScheduler';
|
|
20
|
+
export * from './viewportCulling';
|
|
21
|
+
export * from './workerManager';
|
|
22
|
+
export * from './canvasLayerManager';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Graph } from '@antv/x6';
|
|
2
|
+
|
|
3
|
+
interface ViewportConfig {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
padding: number;
|
|
6
|
+
updateThrottle: number;
|
|
7
|
+
}
|
|
8
|
+
declare class ViewportCullingService {
|
|
9
|
+
private graph;
|
|
10
|
+
private config;
|
|
11
|
+
private updateTimer;
|
|
12
|
+
private isUpdating;
|
|
13
|
+
private nodeVisibilityCache;
|
|
14
|
+
private stats;
|
|
15
|
+
/**
|
|
16
|
+
* 初始化服务
|
|
17
|
+
*/
|
|
18
|
+
init(graph: Graph, config?: Partial<ViewportConfig>): void;
|
|
19
|
+
/**
|
|
20
|
+
* 调度更新(节流)
|
|
21
|
+
*/
|
|
22
|
+
private scheduleUpdate;
|
|
23
|
+
/**
|
|
24
|
+
* 更新节点可见性
|
|
25
|
+
*/
|
|
26
|
+
private updateVisibility;
|
|
27
|
+
/**
|
|
28
|
+
* 获取视口矩形区域
|
|
29
|
+
*/
|
|
30
|
+
private getViewportRect;
|
|
31
|
+
/**
|
|
32
|
+
* 判断节点是否在视口内
|
|
33
|
+
*/
|
|
34
|
+
private isNodeInViewport;
|
|
35
|
+
/**
|
|
36
|
+
* 强制更新所有节点可见性
|
|
37
|
+
*/
|
|
38
|
+
forceUpdate(): void;
|
|
39
|
+
/**
|
|
40
|
+
* 启用/禁用视口裁剪
|
|
41
|
+
*/
|
|
42
|
+
setEnabled(enabled: boolean): void;
|
|
43
|
+
/**
|
|
44
|
+
* 显示所有节点
|
|
45
|
+
*/
|
|
46
|
+
private showAllNodes;
|
|
47
|
+
/**
|
|
48
|
+
* 获取性能统计
|
|
49
|
+
*/
|
|
50
|
+
getStats(): {
|
|
51
|
+
totalNodes: number;
|
|
52
|
+
visibleNodes: number;
|
|
53
|
+
culledNodes: number;
|
|
54
|
+
cullRate: string;
|
|
55
|
+
lastUpdateTime: number;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* 销毁服务
|
|
59
|
+
*/
|
|
60
|
+
destroy(): void;
|
|
61
|
+
}
|
|
62
|
+
export declare const viewportCulling: ViewportCullingService;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker 管理器
|
|
3
|
+
* 管理 WebWorker 生命周期和消息通信
|
|
4
|
+
*/
|
|
5
|
+
export declare class WorkerManager {
|
|
6
|
+
private worker;
|
|
7
|
+
private pendingTasks;
|
|
8
|
+
private messageIdCounter;
|
|
9
|
+
private readonly TASK_TIMEOUT;
|
|
10
|
+
/**
|
|
11
|
+
* 初始化 Worker
|
|
12
|
+
*/
|
|
13
|
+
init(): void;
|
|
14
|
+
/**
|
|
15
|
+
* 处理 Worker 消息
|
|
16
|
+
*/
|
|
17
|
+
private handleMessage;
|
|
18
|
+
/**
|
|
19
|
+
* 处理 Worker 错误
|
|
20
|
+
*/
|
|
21
|
+
private handleError;
|
|
22
|
+
/**
|
|
23
|
+
* 发送消息到 Worker
|
|
24
|
+
*/
|
|
25
|
+
private sendMessage;
|
|
26
|
+
/**
|
|
27
|
+
* 主线程回退处理
|
|
28
|
+
*/
|
|
29
|
+
private fallbackProcess;
|
|
30
|
+
/**
|
|
31
|
+
* 解析设备数据
|
|
32
|
+
*/
|
|
33
|
+
parseDeviceData(rawData: any): Promise<any>;
|
|
34
|
+
/**
|
|
35
|
+
* 转换绑定数据
|
|
36
|
+
*/
|
|
37
|
+
transformBindingData(bindings: any[], deviceData: any): Promise<any[]>;
|
|
38
|
+
/**
|
|
39
|
+
* 批量计算
|
|
40
|
+
*/
|
|
41
|
+
batchCalculate(calculations: Array<{
|
|
42
|
+
type: string;
|
|
43
|
+
params: any;
|
|
44
|
+
}>): Promise<any[]>;
|
|
45
|
+
/**
|
|
46
|
+
* 获取 Worker 状态
|
|
47
|
+
*/
|
|
48
|
+
getStatus(): {
|
|
49
|
+
isActive: boolean;
|
|
50
|
+
pendingTasks: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* 终止 Worker
|
|
54
|
+
*/
|
|
55
|
+
terminate(): void;
|
|
56
|
+
}
|
|
57
|
+
export declare const workerManager: WorkerManager;
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
name: string;
|
|
4
|
-
type: string;
|
|
5
|
-
icon: string;
|
|
6
|
-
properties: Array<{
|
|
7
|
-
key: string;
|
|
8
|
-
label: string;
|
|
9
|
-
}>;
|
|
10
|
-
}
|
|
1
|
+
import { ElementInfo } from '../types/element';
|
|
2
|
+
|
|
11
3
|
interface Props {
|
|
12
4
|
visible: boolean;
|
|
13
5
|
elements?: ElementInfo[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Graph } from '@antv/x6';
|
|
2
|
-
import { ElementInfo } from '../
|
|
2
|
+
import { ElementInfo } from '../types/element';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 画布图元服务类
|
|
@@ -13,7 +13,7 @@ declare class CanvasElementService {
|
|
|
13
13
|
/**
|
|
14
14
|
* 获取画布所有图元
|
|
15
15
|
*/
|
|
16
|
-
getElements(): ElementInfo[]
|
|
16
|
+
getElements(): Promise<ElementInfo[]>;
|
|
17
17
|
/**
|
|
18
18
|
* 获取图元的可配置属性列表(仅返回组件 props 中定义的属性)
|
|
19
19
|
*/
|
|
@@ -21,11 +21,11 @@ declare class CanvasElementService {
|
|
|
21
21
|
/**
|
|
22
22
|
* 根据ID获取图元
|
|
23
23
|
*/
|
|
24
|
-
getElementById(id: string): ElementInfo | null
|
|
24
|
+
getElementById(id: string): Promise<ElementInfo | null>;
|
|
25
25
|
/**
|
|
26
26
|
* 搜索图元
|
|
27
27
|
*/
|
|
28
|
-
searchElements(keyword: string): ElementInfo[]
|
|
28
|
+
searchElements(keyword: string): Promise<ElementInfo[]>;
|
|
29
29
|
}
|
|
30
30
|
export declare const canvasElementService: CanvasElementService;
|
|
31
31
|
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 数据处理 Worker
|
|
3
|
+
* 在后台线程处理复杂数据转换,避免阻塞主线程
|
|
4
|
+
*/
|
|
5
|
+
export declare enum WorkerMessageType {
|
|
6
|
+
PARSE_DEVICE_DATA = "PARSE_DEVICE_DATA",
|
|
7
|
+
TRANSFORM_BINDING_DATA = "TRANSFORM_BINDING_DATA",
|
|
8
|
+
BATCH_CALCULATE = "BATCH_CALCULATE",
|
|
9
|
+
ERROR = "ERROR"
|
|
10
|
+
}
|
|
11
|
+
export interface WorkerMessage {
|
|
12
|
+
id: string;
|
|
13
|
+
type: WorkerMessageType;
|
|
14
|
+
payload: any;
|
|
15
|
+
}
|
|
16
|
+
export interface WorkerResponse {
|
|
17
|
+
id: string;
|
|
18
|
+
type: WorkerMessageType;
|
|
19
|
+
result?: any;
|
|
20
|
+
error?: string;
|
|
21
|
+
}
|