@ray-js/robot-data-stream 0.0.17-beta.8 → 0.1.0-beta.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.
- package/README.md +23 -1
- package/lib/api/index.d.ts +1 -0
- package/lib/api/p2pApi.d.ts +30 -7
- package/lib/api/p2pApi.js +59 -23
- package/lib/api/sweeperP2p.d.ts +18 -1
- package/lib/api/sweeperP2p.js +177 -25
- package/lib/index.d.ts +15 -9
- package/lib/index.js +60 -3
- package/lib/mqtt/createCommonOptions.d.ts +2 -20
- package/lib/mqtt/createCommonOptions.js +17 -5
- package/lib/mqtt/cruise.d.ts +2 -0
- package/lib/mqtt/cruise.js +9 -0
- package/lib/mqtt/defineRobotCommand.d.ts +52 -0
- package/lib/mqtt/defineRobotCommand.js +71 -0
- package/lib/mqtt/hooks/useStructuredMessage.d.ts +5 -1
- package/lib/mqtt/hooks/useStructuredMessage.js +22 -10
- package/lib/mqtt/index.d.ts +8 -1
- package/lib/mqtt/index.js +12 -1
- package/lib/mqtt/promise.d.ts +21 -6
- package/lib/mqtt/promise.js +47 -12
- package/lib/mqtt/spotPolygons.d.ts +7 -0
- package/lib/mqtt/spotPolygons.js +18 -0
- package/lib/mqtt/type/protocols/carpetProtocol.d.ts +2 -0
- package/lib/mqtt/type/protocols/cruiseProtocol.d.ts +6 -3
- package/lib/mqtt/type/protocols/index.d.ts +3 -0
- package/lib/mqtt/type/protocols/index.js +4 -1
- package/lib/mqtt/type/protocols/spotPolygonsProtocol.d.ts +21 -0
- package/lib/mqtt/type/protocols/spotPolygonsProtocol.js +1 -0
- package/lib/mqtt/type/protocols/thresholdProtocol.d.ts +22 -0
- package/lib/mqtt/type/protocols/thresholdProtocol.js +1 -0
- package/lib/mqtt/type/requestType.d.ts +8 -0
- package/lib/mqtt/type/requestType.js +14 -0
- package/lib/mqtt/useCarpet.js +12 -4
- package/lib/mqtt/useCarpetClean.js +6 -2
- package/lib/mqtt/useCruise.js +4 -1
- package/lib/mqtt/useCustomCommand.d.ts +39 -0
- package/lib/mqtt/useCustomCommand.js +45 -0
- package/lib/mqtt/useDeviceModel.js +3 -1
- package/lib/mqtt/useFurnitureModel.js +3 -1
- package/lib/mqtt/useHistoryMap.js +9 -3
- package/lib/mqtt/usePartDivision.js +3 -1
- package/lib/mqtt/usePartMerge.js +3 -1
- package/lib/mqtt/usePassword.js +6 -2
- package/lib/mqtt/usePurifierSchedule.js +3 -1
- package/lib/mqtt/useQuiteHours.js +3 -1
- package/lib/mqtt/useResetMap.js +3 -1
- package/lib/mqtt/useRoomProperty.js +3 -1
- package/lib/mqtt/useSchedule.js +3 -1
- package/lib/mqtt/useSelectRoomClean.js +3 -1
- package/lib/mqtt/useSpotClean.js +3 -1
- package/lib/mqtt/useSpotPolygons.d.ts +9 -0
- package/lib/mqtt/useSpotPolygons.js +50 -0
- package/lib/mqtt/useThreshold.d.ts +10 -0
- package/lib/mqtt/useThreshold.js +90 -0
- package/lib/mqtt/useVirtualArea.js +3 -1
- package/lib/mqtt/useVirtualWall.js +3 -1
- package/lib/mqtt/useVoice.js +3 -1
- package/lib/mqtt/useWifiMap.js +3 -1
- package/lib/mqtt/useZoneClean.js +3 -1
- package/lib/utils/index.d.ts +7 -7
- package/package.json +5 -1
|
@@ -96,7 +96,9 @@ export const useVirtualArea = () => {
|
|
|
96
96
|
num: data.length,
|
|
97
97
|
modes: modes,
|
|
98
98
|
names: names
|
|
99
|
-
}, resolve, error => reject(handleMqttError(error, 'Failed to set virtual area')),
|
|
99
|
+
}, resolve, error => reject(handleMqttError(error, 'Failed to set virtual area')), {
|
|
100
|
+
responseType: VirtualAreaEnum.query
|
|
101
|
+
} // 响应类型是 query,不是 set
|
|
100
102
|
);
|
|
101
103
|
return;
|
|
102
104
|
}
|
|
@@ -77,7 +77,9 @@ export const useVirtualWall = () => {
|
|
|
77
77
|
points: data.map(points => pointsToString(points, origin)),
|
|
78
78
|
num: data.length,
|
|
79
79
|
mode: new Array(data.length).fill('0')
|
|
80
|
-
}, resolve, error => reject(handleMqttError(error, 'Failed to set virtual wall')),
|
|
80
|
+
}, resolve, error => reject(handleMqttError(error, 'Failed to set virtual wall')), {
|
|
81
|
+
responseType: VirtualWallEnum.query
|
|
82
|
+
} // 响应类型是 query,不是 set
|
|
81
83
|
);
|
|
82
84
|
return;
|
|
83
85
|
}
|
package/lib/mqtt/useVoice.js
CHANGED
|
@@ -71,7 +71,9 @@ export const useVoice = () => {
|
|
|
71
71
|
const sendData = _objectSpread(_objectSpread({}, message), {}, {
|
|
72
72
|
urlLen: message.url.length
|
|
73
73
|
});
|
|
74
|
-
sendStructuredMessage(VoiceLanguageEnum.set, sendData, resolve, error => reject(handleMqttError(error, 'Failed to set voice')),
|
|
74
|
+
sendStructuredMessage(VoiceLanguageEnum.set, sendData, resolve, error => reject(handleMqttError(error, 'Failed to set voice')), {
|
|
75
|
+
responseType: VoiceLanguageEnum.query
|
|
76
|
+
});
|
|
75
77
|
return;
|
|
76
78
|
}
|
|
77
79
|
|
package/lib/mqtt/useWifiMap.js
CHANGED
|
@@ -41,7 +41,9 @@ export const useWifiMap = () => {
|
|
|
41
41
|
taskId: data.taskId || String(Date.now()),
|
|
42
42
|
switch: (_data$switch = data.switch) !== null && _data$switch !== void 0 ? _data$switch : true
|
|
43
43
|
};
|
|
44
|
-
sendStructuredMessage(WifiMapEnum.set, wifiMapData, resolve, error => reject(handleMqttError(error, 'Failed to set WiFi map')),
|
|
44
|
+
sendStructuredMessage(WifiMapEnum.set, wifiMapData, resolve, error => reject(handleMqttError(error, 'Failed to set WiFi map')), {
|
|
45
|
+
responseType: WifiMapEnum.rst
|
|
46
|
+
} // 响应类型是 rst,不是 set
|
|
45
47
|
);
|
|
46
48
|
} catch (error) {
|
|
47
49
|
reject(handleMqttError(error, 'Failed to set WiFi map'));
|
package/lib/mqtt/useZoneClean.js
CHANGED
|
@@ -131,7 +131,9 @@ export const useZoneClean = () => {
|
|
|
131
131
|
polygons
|
|
132
132
|
}, commonFields), {}, {
|
|
133
133
|
names
|
|
134
|
-
}), resolve, error => reject(handleMqttError(error, 'Failed to set zone clean')),
|
|
134
|
+
}), resolve, error => reject(handleMqttError(error, 'Failed to set zone clean')), {
|
|
135
|
+
responseType: ZoneCleanEnum.query
|
|
136
|
+
});
|
|
135
137
|
return;
|
|
136
138
|
}
|
|
137
139
|
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -6,27 +6,27 @@ export declare const emitter: import("mitt").Emitter<Record<import("mitt").Event
|
|
|
6
6
|
export declare const pointsToString: (points: Point[], origin?: Point) => string;
|
|
7
7
|
export declare const isJSONString: (str: any) => boolean;
|
|
8
8
|
export declare const parseJSON: (str: any) => any;
|
|
9
|
-
export declare const logger: (type:
|
|
10
|
-
[key: string]: any;
|
|
9
|
+
export declare const logger: (type: "warn" | "error" | "info", params: {
|
|
11
10
|
msg: string;
|
|
12
|
-
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}, onLogger?: (type: "warn" | "error" | "info", v: string) => void) => void;
|
|
13
13
|
/**
|
|
14
14
|
* 创建绑定了 onLogger 的 logger 函数
|
|
15
15
|
* @param onLogger - 可选的日志回调函数
|
|
16
16
|
* @returns 返回一个简化的 logger 函数
|
|
17
17
|
*/
|
|
18
|
-
export declare const createLogger: (onLogger?: (
|
|
18
|
+
export declare const createLogger: (onLogger?: (type: "warn" | "error" | "info", v: string) => void) => {
|
|
19
19
|
info: (params: {
|
|
20
|
-
[key: string]: any;
|
|
21
20
|
msg: string;
|
|
21
|
+
[key: string]: any;
|
|
22
22
|
}) => void;
|
|
23
23
|
warn: (params: {
|
|
24
|
-
[key: string]: any;
|
|
25
24
|
msg: string;
|
|
25
|
+
[key: string]: any;
|
|
26
26
|
}) => void;
|
|
27
27
|
error: (params: {
|
|
28
|
-
[key: string]: any;
|
|
29
28
|
msg: string;
|
|
29
|
+
[key: string]: any;
|
|
30
30
|
}) => void;
|
|
31
31
|
};
|
|
32
32
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/robot-data-stream",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
4
|
"description": "扫地机P2P数据流标准化组件",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
19
|
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
|
|
20
|
+
"test": "vitest --run",
|
|
21
|
+
"typecheck": "tsc -p tsconfig.typecheck.json",
|
|
20
22
|
"build": "patch-package && ray build --type=component",
|
|
21
23
|
"watch": "ray start --type=component --output ./example/src/lib",
|
|
22
24
|
"build:tuya": "ray build ./example",
|
|
@@ -63,6 +65,8 @@
|
|
|
63
65
|
"patch-package": "^8.0.0",
|
|
64
66
|
"prettier": "^3.8.0",
|
|
65
67
|
"standard-version": "9.3.2",
|
|
68
|
+
"typescript": "^5.0.0",
|
|
69
|
+
"vitest": "^2.1.4",
|
|
66
70
|
"vitepress": "^1.6.4"
|
|
67
71
|
},
|
|
68
72
|
"husky": {
|