@ray-js/robot-map 0.0.2-beta-3

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/README.md ADDED
@@ -0,0 +1,21 @@
1
+ English | [简体中文](./README-zh_CN.md)
2
+
3
+ # @ray-js/robot-map
4
+
5
+ [![latest](https://img.shields.io/npm/v/@ray-js/robot-map/latest.svg)](https://www.npmjs.com/package/@ray-js/robot-map) [![download](https://img.shields.io/npm/dt/@ray-js/robot-map.svg)](https://www.npmjs.com/package/@ray-js/robot-map)
6
+
7
+ > Robot map component
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ $ yarn add @ray-js/robot-map
13
+ // or
14
+ $ npm install @ray-js/robot-map
15
+ ```
16
+
17
+ ## Document
18
+
19
+ ```sh
20
+ $ npx serve node_modules/@ray-js/robot-map-sdk/dist-docs
21
+ ```
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { AppOptions } from '@ray-js/robot-map-sdk';
3
+ import { RobotMapProps } from './props';
4
+ declare const RobotMap: {
5
+ ({ map, path, roomProperties, forbiddenSweepZones, forbiddenMopZones, cleanZones, virtualWalls, spots, detectedObjects, customElements, onMapReady, config, runtime, ...callbacks }: RobotMapProps & AppOptions['events']): React.JSX.Element;
6
+ defaultProps: RobotMapProps;
7
+ displayName: string;
8
+ };
9
+ export default RobotMap;
@@ -0,0 +1,195 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ const _excluded = ["map", "path", "roomProperties", "forbiddenSweepZones", "forbiddenMopZones", "cleanZones", "virtualWalls", "spots", "detectedObjects", "customElements", "onMapReady", "config", "runtime"];
4
+ import "core-js/modules/esnext.iterator.constructor.js";
5
+ import "core-js/modules/esnext.iterator.for-each.js";
6
+ import "core-js/modules/esnext.iterator.map.js";
7
+ import "core-js/modules/esnext.iterator.reduce.js";
8
+ import "core-js/modules/web.dom-collections.iterator.js";
9
+ /* eslint-disable @typescript-eslint/no-empty-function */
10
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
11
+ import createInvoke from '@ray-js/webview-invoke/native';
12
+ import { createWebviewContext, WebView } from '@ray-js/ray';
13
+ import { MAP_API_METHODS, MAP_CALLBACK_METHODS } from '@ray-js/robot-map-sdk';
14
+ import { nanoid } from 'nanoid/non-secure';
15
+ import { robotMapDefaultProps } from './props';
16
+
17
+ // 回调名到事件名的映射
18
+ const CALLBACK_TO_EVENT_MAP = _objectSpread({
19
+ onInitialized: 'onInitialized'
20
+ }, MAP_CALLBACK_METHODS.reduce((acc, methodName) => {
21
+ acc[methodName] = methodName;
22
+ return acc;
23
+ }, {}));
24
+ const RobotMap = _ref => {
25
+ let {
26
+ map,
27
+ path,
28
+ roomProperties,
29
+ forbiddenSweepZones,
30
+ forbiddenMopZones,
31
+ cleanZones,
32
+ virtualWalls,
33
+ spots,
34
+ detectedObjects,
35
+ customElements,
36
+ onMapReady,
37
+ config = {},
38
+ runtime = {}
39
+ } = _ref,
40
+ callbacks = _objectWithoutProperties(_ref, _excluded);
41
+ const [mapApi, setMapApi] = useState(null);
42
+ const webviewId = useRef(nanoid()).current;
43
+ const webviewContext = useRef(null);
44
+ const invoke = useRef(null);
45
+ const callbacksRef = useRef(callbacks);
46
+ const triggersRef = useRef({
47
+ onReceiveMap: () => {},
48
+ onReceivePath: () => {},
49
+ onReceiveRoomProperties: () => {},
50
+ onReceiveForbiddenSweepZones: () => {},
51
+ onReceiveForbiddenMopZones: () => {},
52
+ onReceiveCleanZones: () => {},
53
+ onReceiveVirtualWalls: () => {},
54
+ onReceiveSpots: () => {},
55
+ onReceiveDetectedObjects: () => {},
56
+ onReceiveCustomElements: () => {},
57
+ onUpdateRuntime: () => {}
58
+ });
59
+ const handleMessage = useCallback(event => {
60
+ if (invoke.current) {
61
+ invoke.current.listener(event);
62
+ }
63
+ }, []);
64
+
65
+ // 事件分发函数 - 这个函数是稳定的,不会随渲染变化
66
+ const eventDispatcher = useCallback(function (eventName) {
67
+ const propName = CALLBACK_TO_EVENT_MAP[eventName];
68
+ if (propName && callbacksRef.current[propName]) {
69
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
70
+ args[_key - 1] = arguments[_key];
71
+ }
72
+ // 调用最新的prop回调
73
+ callbacksRef.current[propName](...args);
74
+ }
75
+ }, []);
76
+ useEffect(() => {
77
+ // 更新回调引用
78
+ callbacksRef.current = callbacks;
79
+ });
80
+ useEffect(() => {
81
+ webviewContext.current = createWebviewContext(webviewId);
82
+ Object.defineProperty(webviewContext.current, 'platform', {
83
+ value: 'mini',
84
+ writable: false
85
+ });
86
+ invoke.current = createInvoke(() => webviewContext.current);
87
+ invoke.current.define('onDocumentReady', () => {
88
+ invoke.current.bind('initApp')({
89
+ options: config,
90
+ runtime
91
+ });
92
+ });
93
+ triggersRef.current.onReceiveMap = invoke.current.bind('onReceiveMap');
94
+ triggersRef.current.onReceivePath = invoke.current.bind('onReceivePath');
95
+ triggersRef.current.onReceiveRoomProperties = invoke.current.bind('onReceiveRoomProperties');
96
+ triggersRef.current.onReceiveForbiddenSweepZones = invoke.current.bind('onReceiveForbiddenSweepZones');
97
+ triggersRef.current.onReceiveForbiddenMopZones = invoke.current.bind('onReceiveForbiddenMopZones');
98
+ triggersRef.current.onReceiveCleanZones = invoke.current.bind('onReceiveCleanZones');
99
+ triggersRef.current.onReceiveVirtualWalls = invoke.current.bind('onReceiveVirtualWalls');
100
+ triggersRef.current.onReceiveSpots = invoke.current.bind('onReceiveSpots');
101
+ triggersRef.current.onReceiveDetectedObjects = invoke.current.bind('onReceiveDetectedObjects');
102
+ triggersRef.current.onReceiveCustomElements = invoke.current.bind('onReceiveCustomElements');
103
+ triggersRef.current.onUpdateRuntime = invoke.current.bind('onUpdateRuntime');
104
+
105
+ // 为每个需要的事件定义分发函数
106
+ Object.keys(CALLBACK_TO_EVENT_MAP).forEach(eventName => {
107
+ invoke.current.define(eventName, function () {
108
+ if (eventName === 'onInitialized') {
109
+ const mapApi = MAP_API_METHODS.reduce((acc, methodName) => {
110
+ acc[methodName] = invoke.current.bind(methodName);
111
+ return acc;
112
+ }, {});
113
+ setMapApi(mapApi);
114
+ onMapReady === null || onMapReady === void 0 || onMapReady(mapApi);
115
+ }
116
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
117
+ args[_key2] = arguments[_key2];
118
+ }
119
+ eventDispatcher(eventName, ...args);
120
+ });
121
+ });
122
+ }, []);
123
+ useEffect(() => {
124
+ if (mapApi && map) {
125
+ triggersRef.current.onReceiveMap(map);
126
+ }
127
+ }, [map, mapApi]);
128
+ useEffect(() => {
129
+ if (mapApi && path) {
130
+ triggersRef.current.onReceivePath(path);
131
+ }
132
+ }, [path, mapApi]);
133
+ useEffect(() => {
134
+ if (mapApi && roomProperties) {
135
+ triggersRef.current.onReceiveRoomProperties(roomProperties);
136
+ }
137
+ }, [roomProperties, mapApi]);
138
+ useEffect(() => {
139
+ if (mapApi && forbiddenSweepZones) {
140
+ triggersRef.current.onReceiveForbiddenSweepZones(forbiddenSweepZones);
141
+ }
142
+ }, [forbiddenSweepZones, mapApi]);
143
+ useEffect(() => {
144
+ if (mapApi && forbiddenMopZones) {
145
+ triggersRef.current.onReceiveForbiddenMopZones(forbiddenMopZones);
146
+ }
147
+ }, [forbiddenMopZones, mapApi]);
148
+ useEffect(() => {
149
+ if (mapApi && cleanZones) {
150
+ triggersRef.current.onReceiveCleanZones(cleanZones);
151
+ }
152
+ }, [cleanZones, mapApi]);
153
+ useEffect(() => {
154
+ if (mapApi && virtualWalls) {
155
+ triggersRef.current.onReceiveVirtualWalls(virtualWalls);
156
+ }
157
+ }, [virtualWalls, mapApi]);
158
+ useEffect(() => {
159
+ if (mapApi && spots) {
160
+ triggersRef.current.onReceiveSpots(spots);
161
+ }
162
+ }, [spots, mapApi]);
163
+ useEffect(() => {
164
+ if (mapApi && detectedObjects) {
165
+ triggersRef.current.onReceiveDetectedObjects(detectedObjects);
166
+ }
167
+ }, [detectedObjects, mapApi]);
168
+ useEffect(() => {
169
+ if (mapApi && customElements) {
170
+ triggersRef.current.onReceiveCustomElements(customElements);
171
+ }
172
+ }, [customElements, mapApi]);
173
+ useEffect(() => {
174
+ if (mapApi && runtime) {
175
+ triggersRef.current.onUpdateRuntime(runtime);
176
+ }
177
+ }, [runtime, mapApi]);
178
+ useEffect(() => {
179
+ if (mapApi) {
180
+ setTimeout(() => {
181
+ mapApi.getCleanZones();
182
+ }, 2000);
183
+ }
184
+ }, [mapApi]);
185
+ return /*#__PURE__*/React.createElement(WebView, {
186
+ src: "webview://node_modules/@ray-js/robot-map-sdk/dist-app/index.html"
187
+ // src="http://127.0.0.1:3000"
188
+ ,
189
+ id: webviewId,
190
+ onMessage: handleMessage
191
+ });
192
+ };
193
+ RobotMap.defaultProps = robotMapDefaultProps;
194
+ RobotMap.displayName = 'RobotMap';
195
+ export default RobotMap;
@@ -0,0 +1,4 @@
1
+ export declare const tuya: {
2
+ backgroundColor: string;
3
+ navigationBarTitleText: string;
4
+ };
@@ -0,0 +1,4 @@
1
+ export const tuya = {
2
+ backgroundColor: '#f2f4f6',
3
+ navigationBarTitleText: 'Ray 跨端组件'
4
+ };
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default as RobotMap } from './RobotMap';
2
+ export * from '@ray-js/robot-map-sdk';
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default as RobotMap } from './RobotMap';
2
+ export * from '@ray-js/robot-map-sdk';
package/lib/props.d.ts ADDED
@@ -0,0 +1,309 @@
1
+ import { DeepPartialAppConfig, DeepPartialRuntimeConfig, MapApi, RoomProperty, ZoneParam, VirtualWallParam, DetectedObjectParam, CustomElementParam, MapState, PathState, Point, RoomData, SpotParam } from '@ray-js/robot-map-sdk';
2
+ /**
3
+ * 机器人地图组件属性接口
4
+ *
5
+ * 定义了机器人地图组件的所有属性,包括地图数据、配置选项、事件回调等。
6
+ * Robot map component props interface that defines all properties including map data, configuration options, event callbacks, etc.
7
+ */
8
+ export interface RobotMapProps {
9
+ /**
10
+ * @description.zh 地图数据
11
+ * @description.en Map data
12
+ * @description.zh 通常来源于p2p通道的数据,分为结构化协议和点阵协议两种协议格式。
13
+ * @description.en Usually from the p2p channel data, divided into two protocol formats: structured protocol and raster protocol.
14
+ */
15
+ map: string;
16
+ /**
17
+ * @description.zh 路径数据
18
+ * @description.en Path data
19
+ * @description.zh 通常来源于p2p通道的数据,包含机器人的历史轨迹和当前位置。
20
+ * @description.en Usually from the p2p channel data, containing the historical trajectory and current position of the robot.
21
+ */
22
+ path?: string;
23
+ /**
24
+ * @description.zh 房间属性
25
+ * @description.en Room properties
26
+ * @description.zh 房间的属性信息数组,包含房间ID、名称、清扫状态等信息。
27
+ * @description.en Array of room property information including room ID, name, cleaning status, etc.
28
+ */
29
+ roomProperties?: RoomProperty[];
30
+ /**
31
+ * @description.zh 禁扫区域
32
+ * @description.en Forbidden sweep zones
33
+ * @description.zh 定义机器人不允许清扫的区域,机器人在这些区域内不会进行清扫作业。
34
+ * @description.en Defines areas where the robot is not allowed to sweep, the robot will not perform cleaning operations in these areas.
35
+ */
36
+ forbiddenSweepZones?: ZoneParam[];
37
+ /**
38
+ * @description.zh 禁拖区域
39
+ * @description.en Forbidden mop zones
40
+ * @description.zh 定义机器人不允许拖地的区域,机器人在这些区域内不会进行拖地作业。
41
+ * @description.en Defines areas where the robot is not allowed to mop, the robot will not perform mopping operations in these areas.
42
+ */
43
+ forbiddenMopZones?: ZoneParam[];
44
+ /**
45
+ * @description.zh 清扫区域
46
+ * @description.en Clean zones
47
+ * @description.zh 定义机器人清扫的区域,机器人在这些区域内进行清扫作业。
48
+ * @description.en Defines areas where the robot performs cleaning operations.
49
+ */
50
+ cleanZones?: ZoneParam[];
51
+ /**
52
+ * @description.zh 虚拟墙
53
+ * @description.en Virtual walls
54
+ * @description.zh 虚拟障碍物,机器人将其视为实体墙壁,不会穿越这些区域。
55
+ * @description.en Virtual obstacles that the robot treats as physical walls and will not cross these areas.
56
+ */
57
+ virtualWalls?: VirtualWallParam[];
58
+ /**
59
+ * @description.zh 定点清扫点
60
+ * @description.en Spot clean points
61
+ * @description.zh 定点清扫点,机器人将在这些点进行清扫作业。
62
+ * @description.en Spot clean points, the robot will perform cleaning operations at these points.
63
+ */
64
+ spots?: SpotParam[];
65
+ /**
66
+ * @description.zh 检测对象
67
+ * @description.en Detected objects
68
+ * @description.zh 机器人检测到的物体信息,如家具、障碍物等,用图标的方式呈现。
69
+ * @description.en Information about objects detected by the robot, such as furniture, obstacles, etc. presented in icon form.
70
+ */
71
+ detectedObjects?: DetectedObjectParam[];
72
+ /**
73
+ * @description.zh 自定义元素
74
+ * @description.en Custom elements
75
+ * @description.zh 用户自定义的地图元素,支持图片、GIF和HTML三种格式。
76
+ * @description.en User-defined map elements, which can be images, GIFs, and HTML.
77
+ */
78
+ customElements?: CustomElementParam[];
79
+ /**
80
+ * @description.zh 配置项
81
+ * @description.en Configuration options
82
+ * @description.zh 地图组件的配置选项,用于定义视觉样式、素材资源和交互行为等一次性的配置
83
+ * @description.en Configuration options for the map component to customize map display and behavior.
84
+ */
85
+ config?: DeepPartialAppConfig;
86
+ /**
87
+ * @description.zh 运行时
88
+ * @description.en Runtime
89
+ * @description.zh 控制地图在运行时的各种行为状态
90
+ * @description.en Control the various behavior states of the map at runtime
91
+ */
92
+ runtime?: DeepPartialRuntimeConfig;
93
+ /**
94
+ * @description.zh 地图初始化完成,API准备就绪的回调
95
+ * @description.en Callback when the map is initialized and the API is ready
96
+ * @description.zh 当地图组件初始化完成并且所有API功能可用时触发的回调函数。
97
+ * @description.en Callback function triggered when the map component is initialized and all API functions are available.
98
+ * @param mapApi - 可供使用的地图 API 函数对象 / Available map API functions object
99
+ */
100
+ onMapReady?: (mapApi: MapApi) => void;
101
+ /**
102
+ * @description.zh 地图首次绘制完成回调
103
+ * @description.en Callback when the map is first drawn
104
+ * @description.zh 当地图首次加载并绘制完成后触发,通常用于移除Loading状态。与 onMapDrawed 不同,此回调只在首次绘制时触发一次。
105
+ * @description.en Triggered when the map is first loaded and drawn, usually used to remove the loading state. Unlike onMapDrawed, this callback is only triggered once on the first draw.
106
+ * @param.zh mapState - 地图状态信息,包含地图ID、原点、尺寸等信息
107
+ * @param.en mapState - Map state information including map ID, origin, dimensions, etc.
108
+ */
109
+ onMapFirstDrawed?: (mapState: MapState) => void;
110
+ /**
111
+ * @description.zh 地图绘制完成回调
112
+ * @description.en Callback when the map is drawn
113
+ * @description.zh 当地图数据解析并绘制完成后触发。
114
+ * @description.en Triggered when map data is parsed and drawn.
115
+ * @param.zh mapState - 地图状态信息,包含地图ID、原点、尺寸等信息
116
+ * @param.en mapState - Map state information including map ID, origin, dimensions, etc.
117
+ */
118
+ onMapDrawed?: (mapState: MapState) => void;
119
+ /**
120
+ * @description.zh 路径绘制完成回调
121
+ * @description.en Callback when the path is drawn
122
+ * @description.zh 当机器人路径数据绘制完成后触发。
123
+ * @description.en Triggered when robot path data is drawn.
124
+ * @param.zh pathState - 路径状态信息,包含路径ID、类型、机器人位置等
125
+ * @param.en pathState - Path state information including path ID, type, robot position, etc.
126
+ */
127
+ onPathDrawed?: (pathState: PathState) => void;
128
+ /**
129
+ * @description.zh 房间信息绘制完成回调
130
+ * @description.en Callback when room properties are drawn
131
+ * @description.zh 当房间属性信息绘制完成后触发。
132
+ * @description.en Triggered when room property information is drawn.
133
+ * @param.zh rooms - 房间属性信息数组
134
+ * @param.en rooms - Array of room property information
135
+ */
136
+ onRoomPropertiesDrawed?: (rooms: RoomProperty[]) => void;
137
+ /**
138
+ * @description.zh 点击房间回调
139
+ * @description.en Callback when clicking on a room
140
+ * @description.zh 当用户点击地图上的房间区域时触发。
141
+ * @description.en Triggered when user clicks on a room area on the map.
142
+ * @param.zh room - 被点击的房间信息
143
+ * @param.en room - Clicked room information
144
+ */
145
+ onClickRoom?: (room: Partial<RoomData>) => void;
146
+ /**
147
+ * @description.zh 点击房间信息回调
148
+ * @description.en Callback when clicking on room properties
149
+ * @description.zh 当用户点击房间的属性信息图标时触发。
150
+ * @description.en Triggered when user clicks on the room property information icon.
151
+ * @param.zh room - 被点击的房间信息
152
+ * @param.en room - Clicked room information
153
+ */
154
+ onClickRoomProperties?: (room: Partial<RoomData>) => void;
155
+ /**
156
+ * @description.zh 点击禁扫区域删除按钮的回调
157
+ * @description.en Callback when clicking the delete button of forbidden sweep zone
158
+ * @description.zh 当用户点击禁扫区域删除按钮时触发。
159
+ * @description.en Triggered when user clicks the delete button of forbidden sweep zone.
160
+ * @param.zh id - 被删除的禁扫区域ID
161
+ * @param.en id - ID of the deleted forbidden sweep zone
162
+ */
163
+ onRemoveForbiddenSweepZone?: (id: string) => void;
164
+ /**
165
+ * @description.zh 点击禁拖区域删除按钮的回调
166
+ * @description.en Callback when clicking the delete button of forbidden mop zone
167
+ * @description.zh 当用户点击禁拖区域删除按钮时触发。
168
+ * @description.en Triggered when user clicks the delete button of forbidden mop zone.
169
+ * @param.zh id - 被删除的禁拖区域ID
170
+ * @param.en id - ID of the deleted forbidden mop zone
171
+ */
172
+ onRemoveForbiddenMopZone?: (id: string) => void;
173
+ /**
174
+ * @description.zh 点击清扫区域删除按钮的回调
175
+ * @description.en Callback when clicking the delete button of clean zone
176
+ * @description.zh 当用户点击清扫区域删除按钮时触发。
177
+ * @description.en Triggered when user clicks the delete button of clean zone.
178
+ * @param.zh id - 被删除的清扫区域ID
179
+ * @param.en id - ID of the deleted clean zone
180
+ */
181
+ onRemoveCleanZone?: (id: string) => void;
182
+ /**
183
+ * @description.zh 点击虚拟墙删除按钮的回调
184
+ * @description.en Callback when clicking the delete button of virtual wall
185
+ * @description.zh 当用户点击虚拟墙删除按钮时触发。
186
+ * @description.en Triggered when user clicks the delete button of virtual wall.
187
+ * @param.zh id - 被删除的虚拟墙ID
188
+ * @param.en id - ID of the deleted virtual wall
189
+ */
190
+ onRemoveVirtualWall?: (id: string) => void;
191
+ /**
192
+ * @description.zh 更新禁扫区域的回调
193
+ * @description.en Callback when updating forbidden sweep zone
194
+ * @description.zh 当用户操作禁扫区域(如拖拽、缩放)后触发。
195
+ * @description.en Triggered when user operates forbidden sweep zone (such as dragging, scaling).
196
+ * @param.zh zone - 更新后的禁扫区域数据
197
+ * @param.en zone - Updated forbidden sweep zone data
198
+ */
199
+ onUpdateForbiddenSweepZone?: (zone: ZoneParam) => void;
200
+ /**
201
+ * @description.zh 更新禁拖区域的回调
202
+ * @description.en Callback when updating forbidden mop zone
203
+ * @description.zh 当用户操作禁拖区域(如拖拽、缩放)后触发。
204
+ * @description.en Triggered when user operates forbidden mop zone (such as dragging, scaling).
205
+ * @param.zh zone - 更新后的禁拖区域数据
206
+ * @param.en zone - Updated forbidden mop zone data
207
+ */
208
+ onUpdateForbiddenMopZone?: (zone: ZoneParam) => void;
209
+ /**
210
+ * @description.zh 更新清扫区域的回调
211
+ * @description.en Callback when updating clean zone
212
+ * @description.zh 当用户操作清扫区域(如拖拽、缩放)后触发。
213
+ * @description.en Triggered when user operates clean zone (such as dragging, scaling).
214
+ * @param.zh zone - 更新后的清扫区域数据
215
+ * @param.en zone - Updated clean zone data
216
+ */
217
+ onUpdateCleanZone?: (zone: ZoneParam) => void;
218
+ /**
219
+ * @description.zh 更新虚拟墙的回调
220
+ * @description.en Callback when updating virtual wall
221
+ * @description.zh 当用户操作虚拟墙(如拖拽、旋转)后触发。
222
+ * @description.en Triggered when user operates virtual wall (such as dragging, rotating).
223
+ * @param.zh wall - 更新后的虚拟墙数据
224
+ * @param.en wall - Updated virtual wall data
225
+ */
226
+ onUpdateVirtualWall?: (wall: VirtualWallParam) => void;
227
+ /**
228
+ * @description.zh 更新定点清扫的回调
229
+ * @description.en Callback when updating spot clean
230
+ * @description.zh 当用户操作定点清扫位置后触发。
231
+ * @description.en Triggered when user operates spot clean position.
232
+ * @param.zh spot - 更新后的定点清扫数据
233
+ * @param.en spot - Updated spot clean data
234
+ */
235
+ onUpdateSpot?: (spot: SpotParam) => void;
236
+ /**
237
+ * @description.zh 点击禁扫区域回调
238
+ * @description.en Callback when clicking forbidden sweep zone
239
+ * @description.zh 当用户点击禁扫区域时触发。
240
+ * @description.en Triggered when user clicks forbidden sweep zone.
241
+ * @param.zh zone - 被点击的禁扫区域数据
242
+ * @param.en zone - Clicked forbidden sweep zone data
243
+ */
244
+ onClickForbiddenSweepZone?: (zone: ZoneParam) => void;
245
+ /**
246
+ * @description.zh 点击禁拖区域回调
247
+ * @description.en Callback when clicking forbidden mop zone
248
+ * @description.zh 当用户点击禁拖区域时触发。
249
+ * @description.en Triggered when user clicks forbidden mop zone.
250
+ * @param.zh zone - 被点击的禁拖区域数据
251
+ * @param.en zone - Clicked forbidden mop zone data
252
+ */
253
+ onClickForbiddenMopZone?: (zone: ZoneParam) => void;
254
+ /**
255
+ * @description.zh 点击清扫区域回调
256
+ * @description.en Callback when clicking clean zone
257
+ * @description.zh 当用户点击清扫区域时触发。
258
+ * @description.en Triggered when user clicks clean zone.
259
+ * @param.zh zone - 被点击的清扫区域数据
260
+ * @param.en zone - Clicked clean zone data
261
+ */
262
+ onClickCleanZone?: (zone: ZoneParam) => void;
263
+ /**
264
+ * @description.zh 点击虚拟墙回调
265
+ * @description.en Callback when clicking virtual wall
266
+ * @description.zh 当用户点击虚拟墙时触发。
267
+ * @description.en Triggered when user clicks virtual wall.
268
+ * @param.zh wall - 被点击的虚拟墙数据
269
+ * @param.en wall - Clicked virtual wall data
270
+ */
271
+ onClickVirtualWall?: (wall: VirtualWallParam) => void;
272
+ /**
273
+ * @description.zh 点击定点清扫回调
274
+ * @description.en Callback when clicking spot clean
275
+ * @description.zh 当用户点击定点清扫点时触发。
276
+ * @description.en Triggered when user clicks spot clean point.
277
+ * @param.zh spot - 被点击的定点清扫数据
278
+ * @param.en spot - Clicked spot clean data
279
+ */
280
+ onClickSpot?: (spot: SpotParam) => void;
281
+ /**
282
+ * @description.zh 点击检测物体回调
283
+ * @description.en Callback when clicking detected object
284
+ * @description.zh 当用户点击地图上的检测物体时触发。
285
+ * @description.en Triggered when user clicks detected object on the map.
286
+ * @param.zh object - 被点击的检测物体数据
287
+ * @param.en object - Clicked detected object data
288
+ */
289
+ onClickDetectedObject?: (object: DetectedObjectParam) => void;
290
+ /**
291
+ * @description.zh 点击自定义元素回调
292
+ * @description.en Callback when clicking custom element
293
+ * @description.zh 当用户点击自定义元素时触发。
294
+ * @description.en Triggered when user clicks custom element.
295
+ * @param.zh element - 被点击的自定义元素数据
296
+ * @param.en element - Clicked custom element data
297
+ */
298
+ onClickCustomElement?: (element: CustomElementParam) => void;
299
+ /**
300
+ * @description.zh 更新分割线回调
301
+ * @description.en Callback when updating divider
302
+ * @description.zh 当用户操作分割线(如拖拽端点、移动整条线)后触发。
303
+ * @description.en Triggered when user operates divider (such as dragging endpoints, moving the entire line).
304
+ * @param.zh divider - 更新后的分割线数据
305
+ * @param.en divider - Updated divider data
306
+ */
307
+ onUpdateDivider?: (divider: Point[]) => void;
308
+ }
309
+ export declare const robotMapDefaultProps: RobotMapProps;
package/lib/props.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 机器人地图组件属性接口
3
+ *
4
+ * 定义了机器人地图组件的所有属性,包括地图数据、配置选项、事件回调等。
5
+ * Robot map component props interface that defines all properties including map data, configuration options, event callbacks, etc.
6
+ */
7
+
8
+ export const robotMapDefaultProps = {
9
+ map: ''
10
+ };
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@ray-js/robot-map",
3
+ "version": "0.0.2-beta-3",
4
+ "description": "机器人地图组件",
5
+ "main": "lib/index",
6
+ "files": [
7
+ "lib"
8
+ ],
9
+ "license": "MIT",
10
+ "types": "lib/index.d.ts",
11
+ "maintainers": [
12
+ "tuya_npm",
13
+ {
14
+ "name": "tuyafe",
15
+ "email": "tuyafe@tuya.com"
16
+ }
17
+ ],
18
+ "scripts": {
19
+ "lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
20
+ "lint:style": "stylelint \"src/**/*.less\" --fix",
21
+ "build": "ray build --type=component",
22
+ "dev": "ray start --type=component",
23
+ "build:tuya": "ray build -t tuya ./example",
24
+ "build:web": "ray build ./example --target=web",
25
+ "start:tuya": "ray start -t tuya ./example",
26
+ "start:web": "ray start ./example -t web",
27
+ "prepublishOnly": "yarn build",
28
+ "release-it": "standard-version",
29
+ "copy-sdk": "node scripts/copy-sdk.js"
30
+ },
31
+ "peerDependencies": {
32
+ "@ray-js/ray": "^1.7.39"
33
+ },
34
+ "dependencies": {
35
+ "@ray-js/robot-map-sdk": "0.0.2",
36
+ "clsx": "^1.2.1",
37
+ "nanoid": "^5.1.6"
38
+ },
39
+ "devDependencies": {
40
+ "@commitlint/cli": "^7.2.1",
41
+ "@commitlint/config-conventional": "^9.0.1",
42
+ "@ray-js/cli": "^1.7.39",
43
+ "@ray-js/panel-sdk": "^1.13.10",
44
+ "@ray-js/ray": "^1.7.39",
45
+ "@vant/stylelint-config": "^1.4.2",
46
+ "core-js": "^3.19.1",
47
+ "eslint-config-tuya-panel": "^0.4.2",
48
+ "fs-extra": "^11.3.0",
49
+ "husky": "^1.2.0",
50
+ "lint-staged": "^10.2.11",
51
+ "standard-version": "9.3.2",
52
+ "stylelint": "^13.0.0"
53
+ },
54
+ "husky": {
55
+ "hooks": {
56
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS --config commitlint.config.js",
57
+ "pre-commit": "lint-staged"
58
+ }
59
+ },
60
+ "lint-staged": {
61
+ "*.{ts,tsx,js,jsx}": [
62
+ "eslint --fix",
63
+ "git add"
64
+ ],
65
+ "*.{json,md,yml,yaml}": [
66
+ "prettier --write",
67
+ "git add"
68
+ ]
69
+ }
70
+ }