@jnrs/lingshu-smart 3.1.4 → 3.1.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/AGENTS.md CHANGED
@@ -652,19 +652,18 @@ type ILayerOperating =
652
652
 
653
653
  ### 架构
654
654
 
655
- | 模块 | 职责 |
656
- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --- |
657
- | `utils/logger.ts` | 统一日志工具,支持 tag 着色、LogLevel 过滤、`operating` 追踪级别 |
658
- | `utils/debug-flags.ts` | 模块级动画标志位,供 UI 组件直接导入控制循环动画 |
659
- | `utils/performance-stats.ts` | 性能统计工具,记录运行时长和 WebSocket 数据接收量 |
660
- | `stores/useDebugStore.ts` | 全局设置 Pinia store(facade):响应式读写 `useDataStore.globalSetting` / `scriptsConfig`(脚本按方案分组;其 `scriptSteps` / `scriptLooping` 基于「激活方案」,组件持有明确方案上下文时建议直接用 `useDataStore` 按 caseId 读写),持久化统一在 `@jnrs/lingshu-smart` | |
661
- | `composables/useDebugEasterEgg.ts` | 调试触发检测:500ms 内 10 次点击打开面板 |
662
- | `components/debug/GlobalSetting.vue` | 全局设置对话框 UI(原 DebugPanel,含语言/日志等级/FPS/阴影/动画等开关) |
663
- | `components/debug/ScriptRunner/` | Socket 脚本模拟器:脚本步骤编排、断点调试,生成标准信封协议消息(`envelope + payload`,含 device_init / device_command / resource_command / alarm_push / scene_reset 等模板);设备下拉支持自定义/全部复位(resetAll)/资源操作,产物经 `feedSocketMessage` 直接驱动画布;脚本**按方案分组**存储(`ScriptCaseData[]`:caseId / caseName / steps / looping,与 `wsProxyConfig` 对称,经 `currentCase` prop 确定归属);支持**一键烧录**(二次确认后写入 `public/lingshu-smart/mockSocket.json`,开发服务器接口 `POST /lingshu-smart/__burn-mock-socket`,宿主无需改动)与**导入/导出** JSON 文件;弹窗打开时按「文件优先 + 未烧录改动确认」懒加载当前方案(见 `scriptFile.ts`) |
664
- | `components/debug/WsProxy/` | WebSocket 代理器:声明式字段映射将后端 socket 结构桥接为标准信封协议消息(`envelope + payload`,snake_case)并经 `feedSocketMessage` 驱动画布,标准信封消息直接透传;支持连接/断开/重连(指数退避)、心跳 ping/pong、日志、配置导出/导入、场景像素换算(percentToPixel 百分比/ runtimeToPixel 运行时坐标)、standalone 独立标签页模式 / remote 远程接收模式(BroadcastChannel 跨标签页流转数据);操作规则含 single/resource/global/resetAll(ResetAll 接收源类型值 `resetAll` 后生成全部复位) |
665
- | `components/debug/WsProxy/WsProxyPage.vue` | `WsProxy` 独立路由页面组件:以独立 URL/标签页运行代理器配置,将标准协议消息/状态广播给预览页驱动图形运转 |
666
- | `controller/SocketDispatcher.ts` | Socket 协议分发器:解析 `envelope + payload`,识别心跳、按 `envelope.id` 去重、按类型分发(device_init / device_command / resource_command / alarm_push / runtime_status_push / scene_reset),对象资源池管理资源生命周期,处理完毕回执 `command_ack`(0/400/404/409/500) |
667
- | `controller/AppController.ts` | 画布控制器:提供 `toggleShadows` / `toggleAnimations` / `setFps` / `resetAllModels` / `setAlarmHighlight` 等方法 |
655
+ | 模块 | 职责 |
656
+ | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --- |
657
+ | `utils/logger.ts` | 统一日志工具,支持 tag 着色、LogLevel 过滤、`operating` 追踪级别 |
658
+ | `utils/debug-flags.ts` | 模块级动画标志位,供 UI 组件直接导入控制循环动画 |
659
+ | `utils/performance-stats.ts` | 性能统计工具,记录运行时长和 WebSocket 数据接收量 |
660
+ | `stores/useDebugStore.ts` | 全局设置 Pinia store(facade):响应式读写 `useDataStore.globalSetting` / `scriptsConfig`(脚本按方案分组;其 `scriptSteps` / `scriptLooping` 基于「激活方案」,组件持有明确方案上下文时建议直接用 `useDataStore` 按 caseId 读写),持久化统一在 `@jnrs/lingshu-smart` | |
661
+ | `composables/useDebugEasterEgg.ts` | 调试触发检测:500ms 内 10 次点击打开面板 |
662
+ | `components/debug/GlobalSetting.vue` | 全局设置对话框 UI(原 DebugPanel,含语言/日志等级/FPS/阴影/动画等开关) |
663
+ | `components/debug/ScriptRunner/` | Socket 脚本模拟器:脚本步骤编排、断点调试,生成标准信封协议消息(`envelope + payload`,含 device_init / device_command / resource_command / alarm_push / scene_reset 等模板);设备下拉支持自定义/全部复位(resetAll)/资源操作,「添加」支持单点 / 持续运行 / **自定义脚本**(`__raw__`:编辑「消息数据(JSON)」,运行时原样透出、不包装 envelope 不做加工)三种步骤,产物经 `feedSocketMessage`/`feedMessage` 驱动画布;脚本**按方案分组**存储(`ScriptCaseData[]`:caseId / caseName / steps / looping,与 `wsProxyConfig` 对称,经 `currentCase` prop 确定归属);支持**一键烧录**(二次确认后写入 `public/lingshu-smart/mockSocket.json`,开发服务器接口 `POST /lingshu-smart/__burn-mock-socket`,宿主无需改动)与**导入/导出** JSON 文件;弹窗打开时按「文件优先 + 未烧录改动确认」懒加载当前方案(见 `scriptFile.ts`) |
664
+ | `components/debug/WsProxy/` | WebSocket 代理器:声明式字段映射将后端 socket 结构桥接为标准信封协议消息(`envelope + payload`,snake_case)并经 `feedSocketMessage` 驱动画布,标准信封消息直接透传;顶部单选「信封模式 / 注册表模式」+ 连接面板「Websocket 数据来源」下拉(内置 / 外接,组合出 builtin / external / registry / registry-external 四种数据源);注册表模式**仅按「消息类型值」分发**——「设备状态配置」为每台画布设备独立配置消息类型值(`RegistryDeviceBinding.typeValue`,消息类型字段值相等即归属该设备)与设备主键字段名(`idField`,缺省回退全局 `registryIdField`),提取主键查注册表匹配具体设备后驱动;「设备类型标识」(枚举值+number 绑定,`registryDevices`)仅作标识信息展示,`device_type`/`device_id` 由代理器自动注入;资源消息按各资源组「消息类型值」(`resourceFields.typeValues`)分发,`to/from.device_id`(注册表主键)经注册表+绑定自动翻译为画布业务标识并注入 `device_type`;「消息配置」(payloadKey / sourceTypeField)两种流水线均生效;支持连接/断开/重连(指数退避)、心跳 ping/pong、日志、配置导出/导入、场景像素换算(percentToPixel 百分比/ runtimeToPixel 运行时坐标)、standalone 独立标签页模式 / remote 远程接收模式(BroadcastChannel 跨标签页流转数据);操作规则含 single/resource/resetAll(ResetAll 接收源类型值 `scene_reset` 后生成全部复位) |
665
+ | `controller/SocketDispatcher.ts` | Socket 协议分发器:解析 `envelope + payload`,识别心跳、按 `envelope.id` 去重、按类型分发(device_init / device_command / resource_command / alarm_push / runtime_status_push / scene_reset),对象资源池管理资源生命周期,处理完毕回执 `command_ack`(0/400/404/409/500) |
666
+ | `controller/AppController.ts` | 画布控制器:提供 `toggleShadows` / `toggleAnimations` / `setFps` / `resetAllModels` / `setAlarmHighlight` 等方法 |
668
667
 
669
668
  ### 日志系统
670
669
 
@@ -25,7 +25,7 @@ type __VLS_Props = {
25
25
  stepErrors: Record<string, string[]>;
26
26
  };
27
27
  declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
28
- add: (kind: "single" | "continuous") => any;
28
+ add: (kind: "single" | "custom" | "continuous") => any;
29
29
  select: (uid: string) => any;
30
30
  stop: () => any;
31
31
  "update:allChecked": (value: boolean) => any;
@@ -37,7 +37,7 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {
37
37
  "step-next": () => any;
38
38
  "load-template": (name: string) => any;
39
39
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
40
- onAdd?: ((kind: "single" | "continuous") => any) | undefined;
40
+ onAdd?: ((kind: "single" | "custom" | "continuous") => any) | undefined;
41
41
  onSelect?: ((uid: string) => any) | undefined;
42
42
  onStop?: (() => any) | undefined;
43
43
  "onUpdate:allChecked"?: ((value: boolean) => any) | undefined;
@@ -86,6 +86,8 @@ export declare const RESET_ALL_TYPE = "__resetAll__";
86
86
  export declare const RESET_ALL_MSG_TYPE = "scene_reset";
87
87
  /** 设备/资源下拉「持续运行」选项的标识值(选中后按设定频率持续发送设备高频消息,模拟生产环境持续运行) */
88
88
  export declare const CONTINUOUS_TYPE = "__continuous__";
89
+ /** 「自定义脚本」步骤标识(右侧配置为「消息数据(JSON)」文本框,运行时原样透出,不包装 envelope、不注入字段、不做任何加工) */
90
+ export declare const RAW_TYPE = "__raw__";
89
91
  /** 资源类型选项(resource_type:workpiece / tool / auxiliary) */
90
92
  export declare const resourceTypeOptions: {
91
93
  label: string;
@@ -141,11 +143,12 @@ export declare const resolveEnvelopeType: (step: {
141
143
  * - device → 目标设备选择 + 设备业务参数(device_command)
142
144
  * - resource → 资源操作参数(to/from 设备,无目标设备)(resource_command)
143
145
  * - custom → 无结构化表单,编辑自定义 JSON【alarm_push / runtime_status_push / device_init / 自定义步骤】
146
+ * - raw → 完全自定义:编辑「消息数据(JSON)」,运行时原样透出【自定义脚本步骤】
144
147
  * - none → 无业务参数,仅提示【scene_reset / 全部复位】
145
148
  * - continuous → 持续运行驱动参数(模拟器步骤物种,与协议信封类型正交)
146
149
  */
147
- export type PayloadMode = 'device' | 'resource' | 'custom' | 'none' | 'continuous';
148
- /** 由信封类型(envelope.type)推导业务区形态;模拟器特殊步骤物种(自定义/持续/复位)优先按 deviceType 判断 */
150
+ export type PayloadMode = 'device' | 'resource' | 'custom' | 'raw' | 'none' | 'continuous';
151
+ /** 由信封类型(envelope.type)推导业务区形态;模拟器特殊步骤物种(自定义/原始/持续/复位)优先按 deviceType 判断 */
149
152
  export declare function payloadModeOf(step: {
150
153
  deviceType: string;
151
154
  msgType: string;
@@ -172,18 +175,17 @@ export declare const deviceFieldConfigs: Record<string, ScriptFieldConfig[]>;
172
175
  */
173
176
  export declare function buildDevicePayload(deviceType: string, params: Record<string, any>, configuredKeys?: string[]): Record<string, any>;
174
177
  /**
175
- * 由脚本步骤生成完整协议消息(envelope + payload),严格对齐 socket-operating-api.md。
178
+ * 由脚本步骤生成完整消息,严格对齐 socket-operating-api.md。
179
+ * 返回值即发送到画布的完整消息对象:常规步骤为 envelope + payload 结构;自定义脚本步骤为原样 JSON。
176
180
  * payload 形态与 envelope.type 联动(与面板 payloadModeOf 一致):
177
181
  * - device_command → 设备嵌套 payload(点路径 params 经 buildDevicePayload 展开)
178
182
  * - resource_command → 资源操作 payload(add / transfer / remove)
179
183
  * - device_init / alarm_push / runtime_status_push → 无结构化表单,取自定义 JSON 作为 payload/完整消息
180
184
  * - scene_reset(含全部复位)→ 空 payload
181
185
  * - 自定义步骤 → 完整消息体原样透出(含 envelope 时保留其 type,重生成 id/timestamp 避免被分发器按 id 去重丢弃)
186
+ * - 自定义脚本步骤(__raw__)→ 消息数据(JSON) 原样透出,不包装 envelope、不注入字段、不做任何加工
182
187
  */
183
- export declare function buildMessage(step: ScriptStep): {
184
- envelope: Record<string, any>;
185
- payload: any;
186
- };
188
+ export declare function buildMessage(step: ScriptStep): Record<string, any>;
187
189
  /**
188
190
  * 模板说明:
189
191
  * - 每个步骤的 deviceId 留空,由 loadTemplate 根据当前方案自动回填
@@ -0,0 +1,45 @@
1
+ import { WsProxyConfig, FieldMapper } from './proxy';
2
+ type __VLS_Props = {
3
+ config: WsProxyConfig;
4
+ /** 是否已配置 dictFn(用于「字典 Label / 字典 Color」选项右侧 tag 显示) */
5
+ hasDictFn?: boolean;
6
+ };
7
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
8
+ "update:config": (value: WsProxyConfig) => any;
9
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
10
+ "onUpdate:config"?: ((value: WsProxyConfig) => any) | undefined;
11
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
12
+ mapperDialogsRef: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
13
+ conditionSources: {
14
+ value: string;
15
+ label: string;
16
+ }[];
17
+ }> & Readonly<{
18
+ onUpdate?: (() => any) | undefined;
19
+ }>, {
20
+ openCondition: (mapper: FieldMapper) => void;
21
+ openValueMap: (mapper: FieldMapper) => void;
22
+ openOperation: (mapper: FieldMapper) => void;
23
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
24
+ update: () => any;
25
+ }, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
26
+ P: {};
27
+ B: {};
28
+ D: {};
29
+ C: {};
30
+ M: {};
31
+ Defaults: {};
32
+ }, Readonly<{
33
+ conditionSources: {
34
+ value: string;
35
+ label: string;
36
+ }[];
37
+ }> & Readonly<{
38
+ onUpdate?: (() => any) | undefined;
39
+ }>, {
40
+ openCondition: (mapper: FieldMapper) => void;
41
+ openValueMap: (mapper: FieldMapper) => void;
42
+ openOperation: (mapper: FieldMapper) => void;
43
+ }, {}, {}, {}, {}> | null;
44
+ }, any>;
45
+ export default _default;
@@ -1,4 +1,4 @@
1
- import { WsProxyConfig, WsProxyCaseConfig } from './proxy';
1
+ import { WsProxyConfig, WsProxyCaseConfig, RegistryCanvasDevice } from './proxy';
2
2
  type __VLS_Props = {
3
3
  config: WsProxyConfig;
4
4
  /** 配置来源:localFile 本地文件 / store 持久化配置(含用户手动修改场景) */
@@ -7,6 +7,8 @@ type __VLS_Props = {
7
7
  manualModified?: boolean;
8
8
  /** 是否已配置 dictFn(用于「字典 Label / 字典 Color」选项右侧 tag 显示) */
9
9
  hasDictFn?: boolean;
10
+ /** 设备类型标识列表数据源:画布全部设备(注册表模式专用,透传给 RegistryConfigBody) */
11
+ deviceList?: RegistryCanvasDevice[];
10
12
  };
11
13
  declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
12
14
  reset: (value: WsProxyCaseConfig[]) => any;
@@ -1,5 +1,7 @@
1
- import { WsProxyRequestMode } from './proxy';
1
+ import { WsProxyDataSource, WsProxyRequestMode } from './proxy';
2
2
  type __VLS_Props = {
3
+ /** 数据源模式:builtin 内置 / external 外接 / registry 注册表(连接面板增加注册表接口配置) */
4
+ dataSource: WsProxyDataSource;
3
5
  url: string;
4
6
  /** 请求模式:direct 直接请求 / proxy 代理请求 */
5
7
  requestMode: WsProxyRequestMode;
@@ -16,27 +18,33 @@ type __VLS_Props = {
16
18
  token: string;
17
19
  /** 父组件是否传入了 token(未传入时输入框下方显示红色提示) */
18
20
  tokenProvided: boolean;
21
+ /** 注册表模式:设备注册表接口地址(请求随「连接/重连」动作统一触发,与 WebSocket 一致) */
22
+ registryUrl?: string;
19
23
  };
20
24
  declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
21
25
  disconnect: () => any;
22
26
  send: (data: string) => any;
27
+ "update:dataSource": (value: WsProxyDataSource) => any;
23
28
  "update:url": (value: string) => any;
24
29
  "update:requestMode": (value: WsProxyRequestMode) => any;
25
30
  "update:autoConnect": (value: boolean) => any;
26
31
  "update:heartbeatInterval": (value: number) => any;
27
32
  "update:carryToken": (value: boolean) => any;
28
33
  "update:token": (value: string) => any;
34
+ "update:registryUrl": (value: string) => any;
29
35
  connect: () => any;
30
36
  reconnect: () => any;
31
37
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
32
38
  onDisconnect?: (() => any) | undefined;
33
39
  onSend?: ((data: string) => any) | undefined;
40
+ "onUpdate:dataSource"?: ((value: WsProxyDataSource) => any) | undefined;
34
41
  "onUpdate:url"?: ((value: string) => any) | undefined;
35
42
  "onUpdate:requestMode"?: ((value: WsProxyRequestMode) => any) | undefined;
36
43
  "onUpdate:autoConnect"?: ((value: boolean) => any) | undefined;
37
44
  "onUpdate:heartbeatInterval"?: ((value: number) => any) | undefined;
38
45
  "onUpdate:carryToken"?: ((value: boolean) => any) | undefined;
39
46
  "onUpdate:token"?: ((value: string) => any) | undefined;
47
+ "onUpdate:registryUrl"?: ((value: string) => any) | undefined;
40
48
  onConnect?: (() => any) | undefined;
41
49
  onReconnect?: (() => any) | undefined;
42
50
  }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
@@ -0,0 +1,18 @@
1
+ import { FieldMapper } from './proxy';
2
+ type __VLS_Props = {
3
+ /** 条件「源业务数据」下拉可选项(由宿主从当前规则的字段映射中收集 source 路径) */
4
+ conditionSources: {
5
+ value: string;
6
+ label: string;
7
+ }[];
8
+ };
9
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {
10
+ openCondition: (mapper: FieldMapper) => void;
11
+ openValueMap: (mapper: FieldMapper) => void;
12
+ openOperation: (mapper: FieldMapper) => void;
13
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
14
+ update: () => any;
15
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
16
+ onUpdate?: (() => any) | undefined;
17
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
18
+ export default _default;
@@ -10,6 +10,8 @@ type __VLS_Props = {
10
10
  showFooter?: boolean;
11
11
  /** 底部栏是否包含「画布字段修改」开关(默认 true;Resource 区域在组外统一控制时传 false) */
12
12
  showToggle?: boolean;
13
+ /** 是否显示「操作」列(默认 true;false 时隐藏表头与行内的删除按钮列) */
14
+ showAction?: boolean;
13
15
  };
14
16
  declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
15
17
  add: () => any;
@@ -32,5 +34,6 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {
32
34
  hasDictFn: boolean;
33
35
  showFooter: boolean;
34
36
  showToggle: boolean;
37
+ showAction: boolean;
35
38
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
36
39
  export default _default;
@@ -0,0 +1,47 @@
1
+ import { WsProxyConfig, FieldMapper, RegistryCanvasDevice } from './proxy';
2
+ type __VLS_Props = {
3
+ config: WsProxyConfig;
4
+ /** 是否已配置 dictFn(用于「字典 Label / 字典 Color」选项右侧 tag 显示) */
5
+ hasDictFn?: boolean;
6
+ /** 设备类型标识列表数据源:画布全部设备(设备名称 + 铭牌) */
7
+ deviceList?: RegistryCanvasDevice[];
8
+ };
9
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
10
+ "update:config": (value: WsProxyConfig) => any;
11
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
12
+ "onUpdate:config"?: ((value: WsProxyConfig) => any) | undefined;
13
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
14
+ mapperDialogsRef: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
15
+ conditionSources: {
16
+ value: string;
17
+ label: string;
18
+ }[];
19
+ }> & Readonly<{
20
+ onUpdate?: (() => any) | undefined;
21
+ }>, {
22
+ openCondition: (mapper: FieldMapper) => void;
23
+ openValueMap: (mapper: FieldMapper) => void;
24
+ openOperation: (mapper: FieldMapper) => void;
25
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
26
+ update: () => any;
27
+ }, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
28
+ P: {};
29
+ B: {};
30
+ D: {};
31
+ C: {};
32
+ M: {};
33
+ Defaults: {};
34
+ }, Readonly<{
35
+ conditionSources: {
36
+ value: string;
37
+ label: string;
38
+ }[];
39
+ }> & Readonly<{
40
+ onUpdate?: (() => any) | undefined;
41
+ }>, {
42
+ openCondition: (mapper: FieldMapper) => void;
43
+ openValueMap: (mapper: FieldMapper) => void;
44
+ openOperation: (mapper: FieldMapper) => void;
45
+ }, {}, {}, {}, {}> | null;
46
+ }, any>;
47
+ export default _default;
@@ -39,12 +39,10 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
39
39
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
40
40
  raw: (data: unknown) => any;
41
41
  "socket-message": (message: SocketMessage<Record<string, unknown>>) => any;
42
- "runtime-status": (data: Record<string, unknown>) => any;
43
42
  "status-change": (connected: boolean) => any;
44
43
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
45
44
  onRaw?: ((data: unknown) => any) | undefined;
46
45
  "onSocket-message"?: ((message: SocketMessage<Record<string, unknown>>) => any) | undefined;
47
- "onRuntime-status"?: ((data: Record<string, unknown>) => any) | undefined;
48
46
  "onStatus-change"?: ((connected: boolean) => any) | undefined;
49
47
  }>, {
50
48
  config: WsProxyConfig;
@@ -70,13 +70,19 @@ export interface ResourceFieldMap {
70
70
  /** 批量离场字段映射列表(batch_remove:resource_ids / resource_type,见 socket-operating-api-backend.md 8.5) */
71
71
  batch_remove?: FieldMapper[];
72
72
  }
73
+ /** Resource 规则资源映射组类型 */
74
+ export type ResourceMappingType = 'add' | 'batch_add' | 'transfer' | 'remove' | 'batch_remove';
75
+ /** 资源映射组类型列表(注册表模式按「消息类型值」分发的遍历顺序) */
76
+ export declare const RESOURCE_MAPPING_TYPES: ResourceMappingType[];
73
77
  /** Resource 规则专属源字段配置(operate: 'resource' 时生效) */
74
78
  export interface ResourceFieldConfig {
75
79
  /** 源 operation 字段路径(相对完整源消息,如 data.operation);配置后按源 operation 值分发到对应映射组,
76
- * 标准信封消息固定按 payload.operation 分发,不受此项影响 */
80
+ * 标准信封消息固定按 payload.operation 分发,不受此项影响(仅信封模式使用;注册表模式按各资源组 typeValues 分发) */
77
81
  operationField?: string;
78
82
  /** batch_add 资源项数组的源字段路径(相对完整源消息,如 data.resources);为空时回退 payloadKey */
79
83
  batchAddItems?: string;
84
+ /** 各资源组的「消息类型值」:消息「消息类型字段名」的值与某组配置的值相等时执行该组映射(注册表模式分发依据) */
85
+ typeValues?: Partial<Record<ResourceMappingType, string>>;
80
86
  }
81
87
  /** 单条类型代理规则 */
82
88
  export interface ProxyRule {
@@ -90,9 +96,9 @@ export interface ProxyRule {
90
96
  equipmentName?: string;
91
97
  /** 是否启用该规则 */
92
98
  enabled: boolean;
93
- /** 操作模式:single 设备驱动(生成 device_command);resource 资源操作(按源 operation 生成 resource_command add/batch_add/transfer/remove/batch_remove);resetAll 全部复位(生成 scene_reset,画布所有模型重建);statusPush 全局运行状态推送(映射产物**不进画布**,经 runtime-status 事件交给页面全局状态信息 bar 消费) */
94
- operate: 'single' | 'resource' | 'resetAll' | 'statusPush';
95
- /** 字段映射列表(operate: 'single' / 'statusPush' 时生效) */
99
+ /** 操作模式:single 设备驱动(生成 device_command);resource 资源操作(按源 operation / 资源组消息类型值生成 resource_command add/batch_add/transfer/remove/batch_remove);resetAll 全部复位(生成 scene_reset,画布所有模型重建) */
100
+ operate: 'single' | 'resource' | 'resetAll';
101
+ /** 字段映射列表(operate: 'single' 时生效) */
96
102
  mappings: FieldMapper[];
97
103
  /** 资源操作字段映射(operate: 'resource' 时生效,未配置的组使用内置默认字段映射) */
98
104
  resourceMappings?: ResourceFieldMap;
@@ -103,16 +109,21 @@ export interface ProxyRule {
103
109
  }
104
110
  /** 请求模式:direct 直接请求(完整 ws/wss 地址);proxy 代理请求(仅 path,通过 vite/nginx 代理转发) */
105
111
  export type WsProxyRequestMode = 'direct' | 'proxy';
106
- /** 数据源:builtin 内置模式(组件内置 WebSocket 请求器);external 外接模式(feedMessage 注入) */
107
- export type WsProxyDataSource = 'builtin' | 'external';
112
+ /** 数据源(流水线 × WS 数据来源 组合):
113
+ * builtin 内置模式(信封流水线 + 组件内置 WebSocket 请求器);external 外接模式(信封流水线 + feedMessage 注入);
114
+ * registry 注册表模式(注册表流水线 + 内置 WebSocket);registry-external 注册表 + 外接(注册表流水线 + feedMessage 注入,
115
+ * 设备注册表仍随「连接/重连」动作拉取,消息由 feedMessage 注入后按注册表解析) */
116
+ export type WsProxyDataSource = 'builtin' | 'external' | 'registry' | 'registry-external';
108
117
  /** WsProxy 代理配置(可导出为 JSON) */
109
118
  export interface WsProxyConfig {
110
119
  /** 配置文件完整路径(public 起始,含 .json),用于定位与加载本地配置文件 */
111
120
  fileUrl?: string;
112
121
  /** 配置版本(字符串,如 '1' / '1.0.0') */
113
122
  version: string;
114
- /** 数据源:builtin 内置模式(组件内置 WebSocket 请求器);external 外接模式(feedMessage 注入);默认 builtin */
123
+ /** 数据源:builtin 内置 / external 外接 / registry 注册表(内置 WS)/ registry-external 注册表(外接注入);默认 builtin */
115
124
  dataSource?: WsProxyDataSource;
125
+ /** 注册表模式设备绑定:画布设备 ↔ 设备类型枚举值 + 设备number(设备类型标识列表,与信封模式 rules 互不影响) */
126
+ registryDevices?: RegistryDeviceBinding[];
116
127
  /** 默认 WebSocket 地址(可选)
117
128
  * direct 模式:完整 ws/wss 地址(如 ws://host:port/path)
118
129
  * proxy 模式:仅路径(如 ws/monitor?page=ctsMonitor),运行时拼接当前页面协议+主机 */
@@ -125,15 +136,20 @@ export interface WsProxyConfig {
125
136
  autoConnect?: boolean;
126
137
  /** 业务数据字段名:源消息下该字段的数据作为协议 payload 来源(默认 data) */
127
138
  payloadKey?: string;
128
- /** 源类型字段名:从源消息中提取消息类型的字段路径(默认 type,可设为 data.device_type 等) */
139
+ /** 消息类型字段名:从源消息中提取消息类型的字段路径(默认 type,可设为 data.device_type 等) */
129
140
  sourceTypeField?: string;
130
141
  /** 心跳检测间隔(秒):0=关闭;>0=开启,定期发送 { type: 'ping' } 检测连接活性(默认 30,见文档基础约定) */
131
142
  heartbeatInterval?: number;
132
143
  /** 断线后是否自动重连(指数退避:初始 1s,每次翻倍,上限 30s,见文档基础约定;默认 true) */
133
144
  autoReconnect?: boolean;
134
145
  /** 模型映射表:源业务数据值 → 设备类型 device_type(如 { '1': 'machine_tool' })
135
- * 供字段映射的「模型映射表」特殊处理引用;映射值为旧 PascalCase 模型名时自动转换为 snake_case device_type */
146
+ * 供字段映射的「模型映射表」特殊处理引用;映射值为旧 PascalCase 模型名时自动转换为 snake_case device_type;
147
+ * 注册表模式下复用本表做「设备类型枚举数值 → 画布设备类型」翻译(见《数字孪生设备与 WebSocket 消息映射规则及实现示例》) */
136
148
  modelMap?: Record<string, string>;
149
+ /** 注册表模式:设备注册表接口地址(如 /device/devices 或 http://host/device/devices),返回设备数组(id / deviceType / number / name) */
150
+ registryUrl?: string;
151
+ /** 注册表模式:源消息中设备数据库主键的字段路径(默认 deviceId,见 PDF 消息示例 { deviceId, status }) */
152
+ registryIdField?: string;
137
153
  /** 各消息类型的代理规则 */
138
154
  rules: ProxyRule[];
139
155
  }
@@ -168,41 +184,115 @@ interface EnvelopeOptions {
168
184
  */
169
185
  export declare function buildSocketMessage(payload: Record<string, unknown>, rule: ProxyRule, envelopeOptions?: EnvelopeOptions, scene?: IScene | null, dictFn?: DictFn, modelMap?: Record<string, string>): SocketMessage<Record<string, unknown>> | null;
170
186
  /**
171
- * 根据 Resource 规则构建 resource_command 协议消息列表(operate: 'resource')
187
+ * 根据 Resource 规则构建 resource_command 协议消息列表(operate: 'resource',信封模式)
172
188
  * 配置了 resourceFields.operationField 时按源 operation 分发(add / batch_add / transfer / remove / batch_remove 各自走对应映射组);
173
189
  * 未配置时保持旧语义:对每条命中消息同时产出 add(operation: 'add',需 resource_id + to.device_id)
174
190
  * 与 remove(operation: 'remove',需 resource_id)两条消息
175
- * to.device_type / from.device_type 支持源字段映射(modelMap 转换)或由映射值直接给出 snake_case device_type
176
191
  */
177
192
  export declare function buildResourceSocketMessages(msg: Record<string, unknown>, payload: Record<string, unknown> | unknown[], rule: ProxyRule, payloadKey: string, envelopeOptions?: EnvelopeOptions, scene?: IScene | null, dictFn?: DictFn, modelMap?: Record<string, string>): SocketMessage<Record<string, unknown>>[];
178
193
  /** 代理解析产物 */
179
194
  export interface ProxyResult {
180
195
  /** 标准信封协议消息(由调用方经 feedSocketMessage 驱动画布) */
181
196
  messages: SocketMessage<Record<string, unknown>>[];
182
- /** 全局运行状态推送(operate:'statusPush')的映射产物:不进入画布,供页面全局状态信息 bar 消费;未命中规则时为 null */
183
- runtimeStatus: Record<string, unknown> | null;
184
197
  }
185
198
  /**
186
199
  * 将原始 WebSocket 消息转换为标准信封协议消息列表(envelope + payload,见 socket-operating-api.md)
187
200
  * 1. 源消息本身就是标准信封消息(envelope + payload)→ 保持 envelope 原样,payload 按匹配规则做全量映射加工:
188
201
  * device_command 按 payload.device_type 匹配规则(enrichPassthroughDevice)、
189
202
  * resource_command 按 payload.operation 分发对应映射组(enrichPassthroughResource,transfer 也会注入 resource_color);
190
- * runtime_status_push 若命中 operate:'statusPush' 规则则**转为 runtimeStatus 产物(不进画布)**;
191
203
  * 未命中规则的类型(device_init / alarm_push 等)原样直通;
192
- * 2. 按 sourceTypeField 提取消息类型匹配规则,经字段映射生成 device_command / resource_command / scene_reset;
193
- * statusPush 规则产出 runtimeStatus(不进画布)。
204
+ * 2. 按 sourceTypeField 提取消息类型匹配规则,经字段映射生成 device_command / resource_command / scene_reset。
194
205
  * 非标准化数据(payload 为数组)返回空 messages,由 @raw 事件透出供父组件处理。
195
206
  * @param rawMessage 原始消息
196
207
  * @param rules 规则列表
197
208
  * @param envelopeOptions 信封选项(caseId)
198
209
  * @param scene 场景信息(用于 percentToPixel / runtimeToPixel 换算特殊处理)
199
210
  * @param payloadKey 业务数据字段名:源消息下该字段的数据作为协议 payload 来源(默认 data,回退到 payload)
200
- * @param sourceTypeField 源类型字段名:从源消息中提取消息类型的字段路径(默认 type)
211
+ * @param sourceTypeField 消息类型字段名:从源消息中提取消息类型的字段路径(默认 type)
201
212
  * @param dictFn 字典转换函数(可选,用于 dictLabel / dictColor 特殊处理)
202
213
  * @param modelMap 模型映射表(可选,用于 modelMap 特殊处理:源业务数据值 → 设备类型 device_type)
203
214
  * @returns 代理解析产物(messages 可能为空数组;非标准数组数据返回空数组由 @raw 处理)
204
215
  */
205
216
  export declare function applyProxy(rawMessage: unknown, rules: ProxyRule[], envelopeOptions?: EnvelopeOptions, scene?: IScene | null, payloadKey?: string, sourceTypeField?: string, dictFn?: DictFn, modelMap?: Record<string, string>): ProxyResult;
217
+ /** 设备注册表条目(GET 注册表接口返回,字段见《数字孪生设备与 WebSocket 消息映射规则及实现示例》:
218
+ * id 设备数据库主键 / deviceType 设备类型枚举数值 / number 同类型设备编号 / name 设备名称) */
219
+ export interface RegistryDeviceInfo {
220
+ id: number | string;
221
+ deviceType: number | string;
222
+ number: number | string;
223
+ name?: string;
224
+ }
225
+ /** 注册表解析后的设备信息(供消息身份解析使用) */
226
+ export interface RegistryResolvedDevice {
227
+ /** 注册表 DB 主键(与源消息 deviceId 对应,字符串化) */
228
+ id: string;
229
+ /** 设备类型枚举数值(字符串化,如 '4' 机床 / '12' 货架) */
230
+ deviceType: string;
231
+ /** 同类型设备编号(字符串化) */
232
+ number: string;
233
+ /** 设备名称 */
234
+ name: string;
235
+ /** 设备业务标识(deviceType_number,见 PDF「deviceType + number 组合唯一确定一台设备」) */
236
+ businessKey: string;
237
+ }
238
+ /** 画布设备行(设备类型标识列表数据源,由画布方案图层构建) */
239
+ export interface RegistryCanvasDevice {
240
+ /** 画布图层 id(定位画布设备) */
241
+ layerId: string;
242
+ /** 画布设备类名 */
243
+ className: string;
244
+ /** 设备名称(equipmentName,回退类名) */
245
+ name: string;
246
+ /** 铭牌文本(未配置为空串) */
247
+ nameplate: string;
248
+ /** 画布设备业务标识(rawData.id,回退图层 id) */
249
+ bizId: string;
250
+ }
251
+ /** 注册表模式设备绑定:画布设备 ↔ 注册表「设备类型枚举值 + 设备number」手动绑定。
252
+ * 与信封模式 rules 互不影响;消息经注册表解析出 deviceType+number 后按绑定关系直接定位画布设备 */
253
+ export interface RegistryDeviceBinding {
254
+ uid: string;
255
+ /** 绑定的画布图层 id */
256
+ layerId: string;
257
+ /** 画布设备类名(创建时的快照,用于 device_type 推导与默认映射模板) */
258
+ className: string;
259
+ /** 设备类型枚举值(与注册表 deviceType 匹配) */
260
+ enumValue: string;
261
+ /** 设备 number(与注册表 number 匹配) */
262
+ number: string;
263
+ /** 消息类型值:消息中「消息类型字段名」的值与该值相等时消息归属该设备(随后按设备主键字段名查注册表匹配具体设备) */
264
+ typeValue?: string;
265
+ /** 设备主键字段名:设备主键在业务载荷中的字段路径(按设备独立配置;缺省回退全局 registryIdField,再回退 deviceId) */
266
+ idField?: string;
267
+ /** 设备状态字段映射(源业务数据 → 协议 payload 路径;不含 device_type / device_id 身份字段,二者由代理器自动注入) */
268
+ mappings: FieldMapper[];
269
+ }
270
+ /** 由画布图层构建「设备类型标识」列表数据(全部设备,设备名称 + 铭牌) */
271
+ export declare function buildRegistryDeviceList(layers: unknown): RegistryCanvasDevice[];
272
+ /** 创建一条设备绑定(状态映射取该设备类默认规则并剔除 device_type / device_id 身份字段) */
273
+ export declare function createRegistryBinding(layerId: string, className: string): RegistryDeviceBinding;
274
+ /** 拉取设备注册表(GET;兼容裸数组与 { data: [...] } 两种返回包装;单项须含 id 与 deviceType;
275
+ * token 非空时以 Authorization: Bearer 请求头携带(与「请求携带Token」开关联动)) */
276
+ export declare function fetchDeviceRegistry(url: string, token?: string): Promise<{
277
+ ok: boolean;
278
+ devices: RegistryDeviceInfo[];
279
+ reason?: string;
280
+ }>;
281
+ /** 生成设备业务标识:deviceType_number(见 PDF:deviceType + number 两个字段组合唯一确定一台设备) */
282
+ export declare function registryBusinessKey(deviceType: number | string, number: number | string): string;
283
+ /** 构建注册表查找表:消息设备主键(字符串化)→ 解析后设备信息(deviceType + number 供「设备类型标识」绑定匹配) */
284
+ export declare function buildRegistryDeviceMap(devices: RegistryDeviceInfo[]): Map<string, RegistryResolvedDevice>;
285
+ /**
286
+ * 注册表模式消息解析(registry 模式专用,替代 applyProxy 的类型匹配):
287
+ * 源消息仅携带设备数据库主键 + 业务字段,支持 { type, data } 信封结构(业务字段在 payloadKey 载荷内)
288
+ * 与平铺结构 { deviceId: 107, status: 1 }(回退到消息根级解析),解析流程:
289
+ * 1. 标准信封消息(如脚本模拟器经 feedMessage 注入)直接透传,与信封流水线一致;
290
+ * 2. 非 single 规则(资源 / 全局操作 / 状态推送)按 sourceTypeField 提取类型值匹配,委托 applyProxy 同源解析;
291
+ * 3. 设备状态类消息:按「消息类型值」分发——消息「消息类型字段名」的值与某设备配置的消息类型值相等时归属该设备,再按该设备的「设备主键字段名」提取主键查注册表匹配具体设备;未命中消息类型值 / 注册表未找到设备 → 日志提示后丢弃;
292
+ * 4. 命中设备后:device_type 由类名自动推导、device_id 取画布设备业务标识(自动注入,无需配置);
293
+ * 5. 应用该设备绑定的状态字段映射(source 路径相对业务载荷,如 status → device_state),生成 device_command 驱动画布。
294
+ */
295
+ export declare function applyProxyRegistry(rawMessage: unknown, rules: ProxyRule[], registryMap: Map<string, RegistryResolvedDevice>, registryIdField: string, envelopeOptions?: EnvelopeOptions, scene?: IScene | null, dictFn?: DictFn, modelMap?: Record<string, string>, payloadKey?: string, sourceTypeField?: string, bindings?: RegistryDeviceBinding[], canvasDevices?: RegistryCanvasDevice[]): ProxyResult;
206
296
  /** 资源新增字段默认映射(target 为 resource_command add 协议 payload 路径,源字段名取自业务 Resource 消息的标准字段)
207
297
  * 颜色:**不做预设**——显式下发 resource_color 时透传使用;如需由 resource_state 映射,请使用方在代理器自行配置
208
298
  * (特殊处理「字典 Color」,或「固定值」直接写死颜色) */
@@ -229,7 +319,7 @@ export declare function getDefaultDeviceRule(className: string): ProxyRule | nul
229
319
  */
230
320
  export declare function createDefaultConfigForCase(caseId: string, deviceClassNames: string[]): WsProxyCaseConfig;
231
321
  /**
232
- * 配置规范化(加载/导入时调用):旧版 target 路径迁移 + BatchRemove 并入 Resource + 补齐 RuntimeStatus 规则。
322
+ * 配置规范化(加载/导入时调用):旧版 target 路径迁移 + BatchRemove 并入 Resource + 移除已废弃 statusPush 规则。
233
323
  * 不做结构合法性校验(校验走 validateConfig)。
234
324
  */
235
325
  export declare function migrateConfig(cfg: WsProxyConfig): WsProxyConfig;