@jnrs/lingshu-smart 2.2.46 → 3.0.0

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.
Files changed (65) hide show
  1. package/AGENTS.md +281 -348
  2. package/dist/components/debug/DataLogPanel.vue.d.ts +29 -3
  3. package/dist/components/debug/PerformanceStats.vue.d.ts +1 -1
  4. package/dist/components/debug/ScriptRunner/ConfigPanel.vue.d.ts +1 -2
  5. package/dist/components/debug/ScriptRunner/StepsPanel.vue.d.ts +4 -2
  6. package/dist/components/debug/ScriptRunner/index.vue.d.ts +11 -0
  7. package/dist/components/debug/ScriptRunner/script.d.ts +140 -41
  8. package/dist/components/debug/ScriptRunner/scriptFile.d.ts +92 -0
  9. package/dist/components/debug/WsProxy/index.vue.d.ts +10 -8
  10. package/dist/components/debug/WsProxy/proxy.d.ts +114 -53
  11. package/dist/components/editor/ControlBar/CaseManger.vue.d.ts +18 -2
  12. package/dist/components/editor/ControlBar/CaseTitleEdit.vue.d.ts +2 -2
  13. package/dist/components/editor/ControlBar/PersistDialog.vue.d.ts +9 -0
  14. package/dist/components/index.js +8419 -6045
  15. package/dist/components/preview/index.vue.d.ts +6852 -4876
  16. package/dist/controller/AppController.d.ts +75 -4
  17. package/dist/controller/SocketDispatcher.d.ts +59 -0
  18. package/dist/fullscreen-BA3oea8O.js +53 -0
  19. package/dist/index-C6Liz-8o.js +1238 -0
  20. package/dist/index.js +36 -27
  21. package/dist/lingshu-smart/cases.json +5890 -14828
  22. package/dist/lingshu-smart/mockSocket.json +263 -0
  23. package/dist/lingshu-smart/wsProxyConfig.json +343 -720
  24. package/dist/playground/ViewPageDemo.vue.d.ts +14412 -10438
  25. package/dist/stores/index.js +1 -1
  26. package/dist/stores/useAppStore.d.ts +20570 -14641
  27. package/dist/stores/useDataStore.d.ts +21139 -14587
  28. package/dist/stores/useDebugStore.d.ts +14 -2
  29. package/dist/stores/useEditorStore.d.ts +3 -3
  30. package/dist/types/app.types.d.ts +1 -1
  31. package/dist/types/components/config.types.d.ts +16 -0
  32. package/dist/types/components/operating.types.d.ts +28 -19
  33. package/dist/types/enums.d.ts +22 -2
  34. package/dist/types/guards.d.ts +4 -1
  35. package/dist/types/index.d.ts +1 -0
  36. package/dist/types/models/config.types.d.ts +41 -9
  37. package/dist/types/models/operating.types.d.ts +64 -74
  38. package/dist/types/socket.types.d.ts +275 -0
  39. package/dist/ui/abstract/ModelAbs.d.ts +42 -2
  40. package/dist/ui/components/Resource.d.ts +0 -1
  41. package/dist/ui/components/StationSlot.d.ts +8 -2
  42. package/dist/ui/components/StationSlotGroup.d.ts +28 -3
  43. package/dist/ui/models/DoubleJointRobot.d.ts +16 -4
  44. package/dist/ui/models/MachineTool.d.ts +6 -2
  45. package/dist/ui/models/MaterialTrack.d.ts +14 -2
  46. package/dist/ui/models/Pallet.d.ts +29 -9
  47. package/dist/ui/models/Rail.d.ts +9 -2
  48. package/dist/ui/models/ResourceOperationWindow.d.ts +2 -1
  49. package/dist/ui/models/ResourceStore.d.ts +7 -5
  50. package/dist/ui/models/Rgv.d.ts +6 -6
  51. package/dist/ui/models/ShuttleStation.d.ts +14 -4
  52. package/dist/ui/models/SingleJointRobot.d.ts +14 -4
  53. package/dist/ui/utils/resolveStationSlotLayers.d.ts +20 -0
  54. package/dist/ui/utils/resolveTypeStyle.d.ts +13 -0
  55. package/dist/useAppStore-DASwAOBy.js +7223 -0
  56. package/dist/utils/fullscreen.d.ts +9 -0
  57. package/dist/utils/index.d.ts +1 -0
  58. package/dist/vite.d.ts +15 -0
  59. package/dist/vite.js +39 -0
  60. package/package.json +6 -2
  61. package/dist/components/editor/OptionCard/Equipment/stationSlot/StationSlotGroupBoth.vue.d.ts +0 -2
  62. package/dist/guards-aLOXCeCF.js +0 -35
  63. package/dist/index-Dsgrnpn0.js +0 -1186
  64. package/dist/useAppStore-CVyLAMtL.js +0 -6125
  65. /package/dist/components/editor/OptionCard/Equipment/{stationSlot/StationSlotGroup.vue.d.ts → models/ResourceStore.vue.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { ILayerOperating } from '../../types';
1
+ import { SocketMessage } from '../../types';
2
2
  export interface LogEntry {
3
3
  datetime: string;
4
4
  type: string;
@@ -11,7 +11,8 @@ export interface WsProxyLogEntry {
11
11
  direction: LogDirection;
12
12
  data: any;
13
13
  }
14
- export type RunLogEntry = ILayerOperating;
14
+ /** 运行日志条目:WsProxy 代理生成的标准信封协议消息(envelope + payload) */
15
+ export type RunLogEntry = SocketMessage<Record<string, unknown>>;
15
16
  type __VLS_Props = {
16
17
  logs: any[];
17
18
  maxLogCount: number;
@@ -24,8 +25,23 @@ type __VLS_Props = {
24
25
  textFn?: (row: any) => string;
25
26
  /** 是否展示方向/类型列(WsProxy 消息日志专用) */
26
27
  showDirectionType?: boolean;
28
+ /** 运行日志专用:envelope.id → command_ack 结果映射。消费端回执关联,
29
+ * 用于展示"跳过 N 项类型不匹配"等消费端语义(代理器本身无资源池状态) */
30
+ ackMap?: Map<string, {
31
+ code: number;
32
+ message: string;
33
+ }>;
27
34
  };
28
- declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
35
+ declare function __VLS_template(): {
36
+ attrs: Partial<{}>;
37
+ slots: {
38
+ 'filter-extra'?(_: {}): any;
39
+ };
40
+ refs: {};
41
+ rootEl: HTMLDivElement;
42
+ };
43
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
44
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
29
45
  copy: () => any;
30
46
  clear: () => any;
31
47
  "update:maxLogCount": (value: number) => any;
@@ -40,5 +56,15 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {
40
56
  dataLabel: string;
41
57
  textFn: (row: any) => string;
42
58
  showDirectionType: boolean;
59
+ ackMap: Map<string, {
60
+ code: number;
61
+ message: string;
62
+ }>;
43
63
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
64
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
44
65
  export default _default;
66
+ type __VLS_WithTemplateSlots<T, S> = T & {
67
+ new (): {
68
+ $slots: S;
69
+ };
70
+ };
@@ -34,9 +34,9 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
34
34
  right: string;
35
35
  top: string;
36
36
  bottom: string;
37
+ position: "static" | "fixed" | "absolute";
37
38
  layout: Layout;
38
39
  collapsible: boolean;
39
40
  showHeader: boolean;
40
- position: "static" | "fixed" | "absolute";
41
41
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
42
42
  export default _default;
@@ -11,7 +11,6 @@ type __VLS_Props = {
11
11
  selectedFieldConfigs: ScriptFieldConfig[];
12
12
  deviceOptions: DeviceOption[];
13
13
  resourceDeviceOptions: DeviceOption[];
14
- statusDisplayColor: string;
15
14
  selectedDeviceValue: DeviceOption | null;
16
15
  addDeviceValue: DeviceOption | null;
17
16
  removeDeviceValue: DeviceOption | null;
@@ -35,5 +34,5 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {
35
34
  "onUpdate:customData"?: ((value: string) => any) | undefined;
36
35
  "onMove-up"?: ((uid: string) => any) | undefined;
37
36
  "onMove-down"?: ((uid: string) => any) | undefined;
38
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
37
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
39
38
  export default _default;
@@ -21,9 +21,11 @@ type __VLS_Props = {
21
21
  isIndeterminate: boolean;
22
22
  scriptTemplates: ScriptTemplate[];
23
23
  deviceOptions: DeviceOption[];
24
+ /** 各步骤缺失的必填字段映射(uid → 字段 key 列表):为有问题的步骤在 info 底部加红色虚线标记 */
25
+ stepErrors: Record<string, string[]>;
24
26
  };
25
27
  declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
26
- add: () => any;
28
+ add: (kind: "single" | "continuous") => any;
27
29
  select: (uid: string) => any;
28
30
  stop: () => any;
29
31
  "update:allChecked": (value: boolean) => any;
@@ -35,7 +37,7 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {
35
37
  "step-next": () => any;
36
38
  "load-template": (name: string) => any;
37
39
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
38
- onAdd?: (() => any) | undefined;
40
+ onAdd?: ((kind: "single" | "continuous") => any) | undefined;
39
41
  onSelect?: ((uid: string) => any) | undefined;
40
42
  onStop?: (() => any) | undefined;
41
43
  "onUpdate:allChecked"?: ((value: boolean) => any) | undefined;
@@ -2,15 +2,26 @@ import { ILayer } from '../../../types';
2
2
  type __VLS_Props = {
3
3
  /** 当前方案的设备图层列表 */
4
4
  layers?: ILayer[];
5
+ /** 当前方案(脚本按方案分组持久化 / 烧录,需据此确定归属;未传时回退 store 中的激活方案) */
6
+ currentCase?: {
7
+ id?: string;
8
+ title?: string;
9
+ } | null;
5
10
  };
6
11
  declare const _default: import('vue').DefineComponent<__VLS_Props, {
7
12
  open: () => void;
8
13
  isRunning: import('vue').Ref<boolean, boolean>;
14
+ /** 快捷执行:运行脚本(供外部右键等快捷入口调用,等效点击弹窗内「运行」按钮) */
15
+ run: () => void;
9
16
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
10
17
  message: (message: any) => any;
11
18
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
12
19
  onMessage?: ((message: any) => any) | undefined;
13
20
  }>, {
14
21
  layers: ILayer[];
22
+ currentCase: {
23
+ id?: string;
24
+ title?: string;
25
+ } | null;
15
26
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
16
27
  export default _default;
@@ -1,21 +1,34 @@
1
1
  /**
2
2
  * @File : script.ts
3
3
  * @Desc. : 脚本模拟器的设备字段配置与预设模板
4
+ * 严格对齐《socket-operating-api.md》(v3.5):
5
+ * - 每个步骤生成「信封 + 数据体」标准消息(envelope + payload)
6
+ * - envelope.type 固定值分发,msgType 记录该步骤的信封类型(缺省按模式推导)
7
+ * - 业务数据字段 key 即 payload 点路径(如 light.color / position.x),
8
+ * 生成消息时由 buildDevicePayload 展开为嵌套结构
4
9
  */
10
+ /** 画布模型 className → socket 协议 device_type(snake_case,见 socket-operating-api.md 6.0) */
11
+ export declare const toDeviceType: (className: string) => string;
5
12
  /** 字段配置 */
6
13
  export interface ScriptFieldConfig {
7
14
  key: string;
8
15
  label: string;
9
16
  /**
10
- * 字段类型。json:对象/数组类型业务字段(如 stationColor、layerStationStatus、laserSiteNumberArray),
11
- * 以 JSON 文本字符串形式编辑与存储,生成消息/预览时经 parseJsonFieldValues 解析为对象/数组
17
+ * 字段类型。key 为 payload 点路径(如 light.color / position.x),生成/预览时展开为嵌套对象。
18
+ * json:对象/数组类型业务字段(如 layer_visible、marking_sites),以 JSON 文本字符串形式编辑与存储,
19
+ * 生成消息/预览时经 buildDevicePayload 解析为对象/数组。
20
+ * device:设备下拉选择(持续运行步骤的「驱动设备」字段)
12
21
  */
13
- type: 'input' | 'select' | 'switch' | 'number' | 'color' | 'json';
22
+ type: 'input' | 'select' | 'switch' | 'number' | 'color' | 'json' | 'device';
14
23
  options?: {
15
24
  label: string;
16
25
  value: string | number;
17
26
  }[];
27
+ /** 是否必填:label 加红色 * 标记(无合理默认值、缺省会导致消息无效的字段) */
28
+ required?: boolean;
18
29
  default?: any;
30
+ /** 输入提示占位文本(json 等类型可按字段语义定制,如数组/对象示例) */
31
+ placeholder?: string;
19
32
  step?: number;
20
33
  min?: number;
21
34
  max?: number;
@@ -27,19 +40,32 @@ export interface ScriptStep {
27
40
  deviceId: string;
28
41
  delay: number;
29
42
  enabled: boolean;
43
+ /** 业务数据(payload),key 为点路径;生成消息时展开为嵌套结构 */
30
44
  params: Record<string, any>;
31
- /** 返回码(0 操作成功 / 400 客户端参数错误 / 500 服务端处理异常) */
32
- code: number;
33
- /** 返回消息说明(可选 code 自动带入后可修改) */
34
- msg: string;
35
- /** 消息体字段名:'data' 或 'payload' */
36
- payloadKey: 'data' | 'payload';
37
- /** 顶层 type 值(可自由配置,默认 'update') */
45
+ /**
46
+ * 用户显式配置过的字段 key 列表:
47
+ * 生成消息时仅发送这些字段,避免设备字段默认值(如 position.x=0)把模型瞬间移回原点,
48
+ * 与「持续运行」等高频位置驱动冲突造成抖动。undefined 表示兼容旧数据(全部发送)
49
+ */
50
+ configuredKeys?: string[];
51
+ /** 信封类型(envelope.type 固定值,见 socket-operating-api.md 2.2);缺失时按模式推导 */
38
52
  msgType: string;
39
- /** 自定义业务数据 JSON 文本(设备/资源选择「自定义」时启用,作为业务数据) */
53
+ /** 自定义业务数据 JSON 文本(设备/资源选择「自定义」时启用,作为完整消息体或 payload) */
40
54
  customData?: string;
41
- /** type 字段覆盖值:设置后业务数据中的 type 使用此值而非 deviceType */
42
- typeOverride?: string;
55
+ }
56
+ /**
57
+ * 单个方案的脚本数据(与 WsProxy 的 `WsProxyCaseConfig` 对称,按方案分组持久化/烧录)。
58
+ * 脚本的设备下拉来自所属方案的图层,故脚本天然绑定方案,不做跨方案共享。
59
+ */
60
+ export interface ScriptCaseData {
61
+ /** 绑定的方案 id(currentCase.id);空串表示未绑定方案(宿主未提供方案上下文时的兜底) */
62
+ caseId: string;
63
+ /** 方案名称(currentCase.title),用于文件可读性与列表展示;可缺省,缺省时回退 id */
64
+ caseName?: string;
65
+ /** 脚本步骤列表 */
66
+ steps: ScriptStep[];
67
+ /** 「循环脚本」开关(按方案保存,属该方案的运行配置) */
68
+ looping: boolean;
43
69
  }
44
70
  /** 脚本模板 */
45
71
  export interface ScriptTemplate {
@@ -54,61 +80,134 @@ export declare const deviceTypeOptions: {
54
80
  }[];
55
81
  /** 设备/资源下拉「自定义」选项的标识值(选中后编辑自定义业务数据 JSON) */
56
82
  export declare const CUSTOM_DEVICE_TYPE = "__custom__";
57
- /** 设备/资源下拉「全部复位」选项的标识值(选中后业务数据 type 预置 resetAll,经代理器触发画布全部复位) */
83
+ /** 设备/资源下拉「全部复位」选项的标识值(选中后消息为 scene_reset,画布全部复位) */
58
84
  export declare const RESET_ALL_TYPE = "__resetAll__";
59
- /** 「全部复位」业务数据的 type 预设值(与代理器全局操作类 ResetAll 规则的源类型值一致) */
60
- export declare const RESET_ALL_MSG_TYPE = "resetAll";
61
- /** 资源类型选项 */
85
+ /** 「全部复位」的信封类型(envelope.type:scene_reset) */
86
+ export declare const RESET_ALL_MSG_TYPE = "scene_reset";
87
+ /** 设备/资源下拉「持续运行」选项的标识值(选中后按设定频率持续发送设备高频消息,模拟生产环境持续运行) */
88
+ export declare const CONTINUOUS_TYPE = "__continuous__";
89
+ /** 资源类型选项(resource_type:workpiece / tool / auxiliary) */
62
90
  export declare const resourceTypeOptions: {
63
91
  label: string;
64
92
  value: string;
65
93
  }[];
66
- /** 通用状态字典:状态值/文本/颜色三要素,供「状态」下拉选择与状态灯颜色展示使用 */
94
+ /** 机器人夹具选项(current_fixture:三类资源 + none 空夹具,见 socket-operating-api.md 6.7) */
95
+ export declare const fixtureOptions: {
96
+ label: string;
97
+ value: string;
98
+ }[];
99
+ /** 通用状态字典:状态值/文本/颜色三要素(供状态灯颜色快速选择) */
67
100
  export interface CommonStatusOption {
68
101
  label: string;
69
102
  value: number;
70
103
  displayColor: string;
71
104
  }
72
105
  export declare const commonDict: CommonStatusOption[];
73
- /** 资源状态字典:资源增删专用,状态值/文本/颜色三要素 */
74
- export declare const resourceDict: CommonStatusOption[];
75
- /** 返回码字典:code / 说明,供「返回码」下拉与 msg 自动带入使用 */
76
- export interface CodeOption {
106
+ /** 资源操作类型选项(resource_command 的 payload.operation),对应 socket-operating-api.md 第 8 章 */
107
+ export declare const resourceOperationOptions: {
77
108
  label: string;
78
- value: number;
79
- }
80
- export declare const codeDict: CodeOption[];
81
- /** 默认消息体字段名 */
82
- export declare const defaultPayloadKey: 'data' | 'payload';
83
- /** 默认顶层 type 值 */
84
- export declare const defaultMsgType = "update";
85
- /** 顶层消息 type 预置选项(消息配置 type 下拉,filterable + allow-create 可自由输入其他值) */
86
- export declare const msgTypeOptions: string[];
87
- /** 默认返回码 */
88
- export declare const defaultCode = 0;
89
- /** 默认返回说明 */
90
- export declare const defaultMsg = "\u64CD\u4F5C\u6210\u529F";
109
+ value: string;
110
+ }[];
111
+ /** 各资源操作下展示的字段(按 key 排列):切换操作类型时面板据此显隐字段(见 resourceOperationFields 对应注释) */
112
+ export declare const resourceOperationFields: Record<string, string[]>;
113
+ /** 各资源操作必填字段(界面据此动态标记红色 *):与 resourceOperationFields 联用。
114
+ * 严格对齐文档:ResourceLocation 中仅 device_id 必填,layer / device_station 均为可选(见 socket-operating-api-backend.md 3.2),
115
+ * 故 add/transfer 仅标记 to_id(目标 device_id)为必填,to_type / to_device_station / to_device_layer 一律可选;
116
+ * transfer 的 from 整体可选;remove 的 resource_type 可选。 */
117
+ export declare const resourceOperationRequired: Record<string, string[]>;
118
+ /** 校验资源步骤缺失的必填字段(按当前 operation 对齐文档)。返回缺失字段 key 列表;非资源步骤 / 无缺失返回空数组 */
119
+ export declare function missingResourceFields(step: Pick<ScriptStep, 'deviceType' | 'params' | 'msgType'>): string[];
120
+ /** 消息信封类型预置选项(envelope.type,见 socket-operating-api.md 2.2)。
121
+ * 下拉框:左侧显示 type 值,右侧显示对应操作中文名;resource_command 置于首位。
122
+ * 末尾「自定义」为信封级自定义(编辑 envelope + payload 完整 JSON)。 */
123
+ export declare const CUSTOM_MSG_TYPE = "__custom__";
124
+ export declare const msgTypeOptions: {
125
+ value: string;
126
+ label: string;
127
+ }[];
128
+ /** 按设备/模式推导默认信封类型(envelope.type) */
129
+ export declare function defaultEnvelopeType(deviceType: string): string;
130
+ /**
131
+ * 解析步骤实际生效的信封类型(envelope.type):
132
+ * - 已显式设置且非旧协议遗留值('update')时采用 msgType
133
+ * - 否则按设备/模式推导(defaultEnvelopeType)
134
+ */
135
+ export declare const resolveEnvelopeType: (step: {
136
+ deviceType: string;
137
+ msgType: string;
138
+ }) => string;
139
+ /**
140
+ * 业务区形态:由信封类型(envelope.type)联动决定「设备选择 / 业务参数」需要显示的内容。
141
+ * - device → 目标设备选择 + 设备业务参数(device_command)
142
+ * - resource → 资源操作参数(to/from 设备,无目标设备)(resource_command)
143
+ * - custom → 无结构化表单,编辑自定义 JSON【alarm_push / runtime_status_push / device_init / 自定义步骤】
144
+ * - none → 无业务参数,仅提示【scene_reset / 全部复位】
145
+ * - continuous → 持续运行驱动参数(模拟器步骤物种,与协议信封类型正交)
146
+ */
147
+ export type PayloadMode = 'device' | 'resource' | 'custom' | 'none' | 'continuous';
148
+ /** 由信封类型(envelope.type)推导业务区形态;模拟器特殊步骤物种(自定义/持续/复位)优先按 deviceType 判断 */
149
+ export declare function payloadModeOf(step: {
150
+ deviceType: string;
151
+ msgType: string;
152
+ }): PayloadMode;
153
+ /** 解析自定义业务数据 JSON 文本:目标 JSON 对象;解析失败时返回包含错误提示的对象 */
154
+ export declare function parseCustomData(text: string | undefined): Record<string, any>;
155
+ /** 无结构化表单的信封类型(选择后编辑完整 envelope + payload JSON) */
156
+ export declare const CUSTOM_PAYLOAD_MSG_TYPES: string[];
157
+ /** 组装某信封类型的默认「envelope + payload」完整 JSON 文本:选择该信封类型时自动带入编辑(envelope 仅含 type,id/timestamp 发送时再生成) */
158
+ export declare function defaultEnvelopePayloadJson(type: string): string;
91
159
  /** 可作为资源容器的设备类型 */
92
160
  export declare const containerDeviceOptions: {
93
161
  label: string;
94
162
  value: string;
95
163
  }[];
96
- /** 各设备类型的字段配置 */
164
+ /** 各设备类型的字段配置(key 即 payload 点路径,与 socket 协议 payload 结构一致,见 socket-operating-api.md 第 6 章) */
97
165
  export declare const deviceFieldConfigs: Record<string, ScriptFieldConfig[]>;
166
+ /**
167
+ * 根据设备类型与(点路径)params 构建嵌套 payload。
168
+ * - 仅保留显式配置的字段(configuredKeys),避免默认 0 值复位设备
169
+ * - json 类型字段(layer_visible / marking_sites / layer_light_colors 等)由文本字符串解析为对象
170
+ * - 点路径(如 light.color / position.x)展开为嵌套对象
171
+ * - 兼容旧协议扁平键(x/lightColor/percent 等)映射为嵌套键,见 LEGACY_KEY_MAP
172
+ */
173
+ export declare function buildDevicePayload(deviceType: string, params: Record<string, any>, configuredKeys?: string[]): Record<string, any>;
174
+ /**
175
+ * 由脚本步骤生成完整协议消息(envelope + payload),严格对齐 socket-operating-api.md。
176
+ * payload 形态与 envelope.type 联动(与面板 payloadModeOf 一致):
177
+ * - device_command → 设备嵌套 payload(点路径 params 经 buildDevicePayload 展开)
178
+ * - resource_command → 资源操作 payload(add / transfer / remove)
179
+ * - device_init / alarm_push / runtime_status_push → 无结构化表单,取自定义 JSON 作为 payload/完整消息
180
+ * - scene_reset(含全部复位)→ 空 payload
181
+ * - 自定义步骤 → 完整消息体原样透出(含 envelope 时保留其 type,重生成 id/timestamp 避免被分发器按 id 去重丢弃)
182
+ */
183
+ export declare function buildMessage(step: ScriptStep): {
184
+ envelope: Record<string, any>;
185
+ payload: any;
186
+ };
98
187
  /**
99
188
  * 模板说明:
100
189
  * - 每个步骤的 deviceId 留空,由 loadTemplate 根据当前方案自动回填
101
190
  * - 单设备模板总时长 ≤ 3 秒
102
191
  * - 完整生产流程展示资源跨设备搬运全流程
103
- * - 状态值:0=待机,1=运行,2=报警(见 commonDict)
104
- * - x 值每步增量 ≤ 0.03,整体移动幅度小(轻微移动)
192
+ * - 状态灯颜色:待机 #999999 / 运行 #66DC7A / 报警 #E83B30(见 commonDict)
193
+ * - 位置字段使用点路径 position.x,每步增量 ≤ 0.03,整体移动幅度小(轻微移动)
105
194
  */
106
195
  export declare const scriptTemplates: ScriptTemplate[];
107
196
  /** 获取设备类型中文标签 */
108
197
  export declare function getDeviceLabel(deviceType: string): string;
198
+ /**
199
+ * 步骤显示名(缺必填等提示用):
200
+ * - 绑定了目标设备:`设备名 (device_id)`
201
+ * - 旧形态特殊物种(Resource / __custom__ / __resetAll__ 等):按 deviceType 取设备 label
202
+ * - 新形态步骤(deviceType 为空,物种由信封类型决定,如 resource_command 资源操作):回退信封类型 label,
203
+ * 避免出现「步骤「」」空名提示
204
+ */
205
+ export declare function stepLabel(step: {
206
+ deviceType: string;
207
+ deviceId: string;
208
+ msgType: string;
209
+ }): string;
109
210
  /** 深拷贝字段默认值:对象/数组类型默认值不可跨步骤共享引用 */
110
211
  export declare function cloneDefault(value: any): any;
111
- /** 将 payload 中 json 类型字段的字符串值解析为对象/数组(供消息生成与预览使用;字段 key 参考 deviceFieldConfigs) */
112
- export declare function parseJsonFieldValues(deviceType: string, payload: Record<string, any>): void;
113
- /** 为指定设备类型创建默认参数 */
212
+ /** 为指定设备类型创建默认参数(key 为点路径,与 deviceFieldConfigs 一致) */
114
213
  export declare function createDefaultParams(deviceType: string): Record<string, any>;
@@ -0,0 +1,92 @@
1
+ import { ScriptStep, ScriptCaseData } from './script';
2
+ /** 脚本文件路径(业务工程 public 目录下,与 cases.json 平级) */
3
+ export declare const MOCK_SOCKET_FILE_URL = "public/lingshu-smart/mockSocket.json";
4
+ /** 脚本烧录接口(开发服务器中间件,由 src/vite.ts 的 lingshuBurnCasesPlugin 提供) */
5
+ export declare const BURN_SCRIPTS_ENDPOINT = "/lingshu-smart/__burn-mock-socket";
6
+ /** 从文件加载脚本的结果 */
7
+ export type ScriptFileResult = {
8
+ status: 'ok';
9
+ configs: ScriptCaseData[];
10
+ repaired: number;
11
+ } | {
12
+ status: 'missing';
13
+ reason: string;
14
+ } | {
15
+ status: 'invalid';
16
+ reason: string;
17
+ } | {
18
+ status: 'unknown';
19
+ reason: string;
20
+ };
21
+ /** 烧录结果 */
22
+ export type BurnScriptsResult = {
23
+ ok: true;
24
+ } | {
25
+ ok: false;
26
+ reason: string;
27
+ };
28
+ /** 解析脚本数据的结果 */
29
+ export type ParseScriptsResult = {
30
+ ok: true;
31
+ configs: ScriptCaseData[];
32
+ repaired: number;
33
+ } | {
34
+ ok: false;
35
+ reason: string;
36
+ };
37
+ /**
38
+ * 校验单个脚本步骤的形状。
39
+ * 宽松策略(避免旧数据 / 手写 JSON 被误拒):仅 `deviceType` 强制为字符串,
40
+ * 其余字段缺省时容忍(由 normalizeScriptSteps 补默认值),存在时才校验类型。
41
+ * `msgType` 不做值域白名单(兼容历史 `'update'` 与空串推导)。
42
+ */
43
+ export declare function isScriptStep(value: unknown): value is ScriptStep;
44
+ /** 校验脚本步骤数组形状 */
45
+ export declare function isScriptStepArray(value: unknown): value is ScriptStep[];
46
+ /**
47
+ * 规范化脚本步骤:补全缺省字段,并为缺失 / 重复的 uid 重新生成(保留首个出现者)。
48
+ * 不拒绝任何已通过 isScriptStepArray 的数据,仅做修复。
49
+ * @returns steps 规范化后的新数组(不改动入参);repaired uid 被补全或重建的条数
50
+ */
51
+ export declare function normalizeScriptSteps(steps: ScriptStep[]): {
52
+ steps: ScriptStep[];
53
+ repaired: number;
54
+ };
55
+ /** 校验单个方案的脚本数据(steps 逐项校验) */
56
+ export declare function isScriptCaseData(value: unknown): value is ScriptCaseData;
57
+ /** 校验脚本配置数组形状 */
58
+ export declare function isScriptCaseDataArray(value: unknown): value is ScriptCaseData[];
59
+ /**
60
+ * 规范化脚本配置数组:补全各方案缺省字段(steps 内的 uid 一并修复)
61
+ * @returns configs 规范化后的新数组;repaired uid 被补全或重建的条数
62
+ */
63
+ export declare function normalizeScriptCases(configs: ScriptCaseData[]): {
64
+ configs: ScriptCaseData[];
65
+ repaired: number;
66
+ };
67
+ /** 解析脚本数据(对象形态直接判非法,仅接受按方案分组的数组) */
68
+ export declare function parseScriptCasesData(data: unknown): ParseScriptsResult;
69
+ /** 解析脚本文本(导入用):JSON 解析失败或结构非法时返回失败原因 */
70
+ export declare function parseScriptCasesJson(text: string): ParseScriptsResult;
71
+ /**
72
+ * 从业务工程 public 目录加载脚本文件(默认 public/lingshu-smart/mockSocket.json)。
73
+ * 先取 text 再解析:开发服务器对 public 下缺失路径会 fallback 返回 index.html(HTTP 200),
74
+ * 直接 res.json() 会抛 `Unexpected token '<'`,此处统一按「文件不存在」处理。
75
+ */
76
+ export declare function loadScriptCasesFromFile(fileUrl?: string): Promise<ScriptFileResult>;
77
+ /**
78
+ * 烧录脚本到 public/lingshu-smart/mockSocket.json(开发服务器写盘,需宿主已注册 lingshuBurnCasesPlugin)
79
+ * @param configs 全部方案的脚本数据(完整文件覆盖语义,与 cases.json 烧录一致)
80
+ */
81
+ export declare function burnScriptCases(configs: ScriptCaseData[]): Promise<BurnScriptsResult>;
82
+ /** 导出脚本为本地 JSON 文件(文件名默认 mockSocket_<时间戳>.json) */
83
+ export declare function exportScriptCases(configs: ScriptCaseData[], fileName?: string): void;
84
+ /**
85
+ * 单个方案的脚本内容 hash(仅 steps + looping,不含 caseId / caseName,
86
+ * 避免方案重命名被误判为「有未烧录改动」;必须先深拷贝,响应式 Proxy 直接 hash 会异常)
87
+ */
88
+ export declare function hashScriptCase(data: Pick<ScriptCaseData, 'steps' | 'looping'>): string;
89
+ /** 读取指定方案的「已同步基线」hash(无基线时返回空串) */
90
+ export declare function readBaselineHash(caseId: string): string;
91
+ /** 写入指定方案的「已同步基线」hash(文件加载 / 烧录 / 导入成功后调用;用户手动编辑不更新) */
92
+ export declare function writeBaselineHash(caseId: string, hash: string): void;
@@ -1,4 +1,4 @@
1
- import { ILayerOperating, IScene } from '../../../types';
1
+ import { IScene, SocketMessage } from '../../../types';
2
2
  import { WsProxyConfig, ProxyRule, DictFn } from './proxy';
3
3
  type __VLS_Props = {
4
4
  /** 是否自动应用注入的消息(父组件调用 expose 的 feedMessage 时) */
@@ -8,13 +8,13 @@ type __VLS_Props = {
8
8
  /** 场景信息:用于字段映射中 percentToPixel 换算(如 currentCase.scene)
9
9
  * 兼容旧用法:new 用法下由 currentCase.scene 派生,仅当 currentCase 缺失时回退此 prop */
10
10
  scene?: IScene | null;
11
- /** 当前方案 uuid:按方案自动匹配代理配置,未匹配则新建并绑定
12
- * 兼容旧用法:new 用法下由 currentCase.uuid 派生,仅当 currentCase 缺失时回退此 prop */
11
+ /** 当前方案 id:按方案自动匹配代理配置,未匹配则新建并绑定
12
+ * 兼容旧用法:new 用法下由 currentCase.id 派生,仅当 currentCase 缺失时回退此 prop */
13
13
  currentCaseId?: string;
14
- /** 当前方案(含 uuid/scene/title/layers):作为唯一权威来源,
14
+ /** 当前方案(含 id/scene/title/layers):作为唯一权威来源,
15
15
  * 内部派生 caseId 与 scene,并据此动态生成「画布模型类」列表 */
16
16
  currentCase?: {
17
- uuid?: string;
17
+ id?: string;
18
18
  title?: string;
19
19
  scene?: IScene | null;
20
20
  layers?: Array<{
@@ -37,18 +37,20 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
37
37
  isConnected: import('vue').Ref<boolean, boolean>;
38
38
  rules: import('vue').ComputedRef<ProxyRule[]>;
39
39
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
40
- operating: (data: ILayerOperating) => any;
41
40
  raw: (data: unknown) => any;
41
+ "socket-message": (message: SocketMessage<Record<string, unknown>>) => any;
42
+ "runtime-status": (data: Record<string, unknown>) => any;
42
43
  "status-change": (connected: boolean) => any;
43
44
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
44
- onOperating?: ((data: ILayerOperating) => any) | undefined;
45
45
  onRaw?: ((data: unknown) => any) | undefined;
46
+ "onSocket-message"?: ((message: SocketMessage<Record<string, unknown>>) => any) | undefined;
47
+ "onRuntime-status"?: ((data: Record<string, unknown>) => any) | undefined;
46
48
  "onStatus-change"?: ((connected: boolean) => any) | undefined;
47
49
  }>, {
48
50
  config: WsProxyConfig;
49
51
  scene: IScene | null;
50
52
  currentCase: {
51
- uuid?: string;
53
+ id?: string;
52
54
  title?: string;
53
55
  scene?: IScene | null;
54
56
  layers?: Array<{