@ray-js/api 1.7.69 → 1.7.71

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 (154) hide show
  1. package/@types/AIKit.d.ts +5509 -610
  2. package/@types/AIStreamKit.d.ts +2641 -0
  3. package/@types/AVideoKit.d.ts +1827 -0
  4. package/@types/BaseKit.d.ts +8682 -1893
  5. package/@types/BizKit.d.ts +6639 -1038
  6. package/@types/CategoryCommonBizKit.d.ts +1459 -0
  7. package/@types/CommunityKit.d.ts +154 -0
  8. package/@types/DeviceKit.d.ts +18475 -5662
  9. package/@types/GroupCITestKit.d.ts +651 -0
  10. package/@types/HealthKit.d.ts +2290 -357
  11. package/@types/HomeKit.d.ts +4068 -182
  12. package/@types/IPCKit.d.ts +4327 -1227
  13. package/@types/LightKit.d.ts +125 -0
  14. package/@types/MapKit.d.ts +1560 -204
  15. package/@types/MediaKit.d.ts +136 -16
  16. package/@types/MediaPlayerKit.d.ts +47 -0
  17. package/@types/MiniKit.d.ts +2976 -628
  18. package/@types/OutdoorKit.d.ts +1337 -24
  19. package/@types/P2PKit.d.ts +622 -103
  20. package/@types/PayKit.d.ts +115 -0
  21. package/@types/PlayNetKit.d.ts +3454 -1309
  22. package/@types/SweeperKit.d.ts +154 -0
  23. package/@types/ThirdAuthKit.d.ts +324 -0
  24. package/@types/ThirdPartyDeviceKit.d.ts +410 -0
  25. package/@types/WearKit.d.ts +10177 -375
  26. package/@types/gateway.d.ts +349 -61
  27. package/@types/health.d.ts +486 -304
  28. package/lib/AIKit-1.6.0.d.ts +265 -41
  29. package/lib/AIKit-1.6.0.js +374 -120
  30. package/lib/BaseKit-3.17.7.d.ts +704 -0
  31. package/lib/BaseKit-3.17.7.js +720 -1
  32. package/lib/BizKit-4.10.4.d.ts +336 -0
  33. package/lib/BizKit-4.10.4.js +342 -5
  34. package/lib/DeviceKit-4.13.1.d.ts +996 -0
  35. package/lib/DeviceKit-4.13.1.js +1247 -249
  36. package/lib/HealthKit-6.5.0.d.ts +210 -44
  37. package/lib/HealthKit-6.5.0.js +295 -128
  38. package/lib/HomeKit-3.1.4.d.ts +20 -6
  39. package/lib/HomeKit-3.1.4.js +29 -14
  40. package/lib/IPCKit-6.4.5.d.ts +375 -77
  41. package/lib/IPCKit-6.4.5.js +525 -228
  42. package/lib/MapKit-3.4.13.d.ts +70 -16
  43. package/lib/MapKit-3.4.13.js +98 -47
  44. package/lib/MediaKit-3.4.1.d.ts +5 -3
  45. package/lib/MediaKit-3.4.1.js +7 -6
  46. package/lib/MiniKit-3.14.1.d.ts +300 -0
  47. package/lib/MiniKit-3.14.1.js +302 -0
  48. package/lib/OutdoorKit-1.0.4.d.ts +55 -13
  49. package/lib/OutdoorKit-1.0.4.js +78 -35
  50. package/lib/P2PKit-2.0.3.d.ts +125 -27
  51. package/lib/P2PKit-2.0.3.js +175 -78
  52. package/lib/PlayNetKit-1.3.30.d.ts +290 -60
  53. package/lib/PlayNetKit-1.3.30.js +407 -176
  54. package/lib/WearKit-1.1.6.d.ts +125 -27
  55. package/lib/WearKit-1.1.6.js +176 -77
  56. package/lib/all-kits.d.ts +10 -10
  57. package/lib/all-kits.js +10 -10
  58. package/lib/cloud/core.d.ts +31 -1
  59. package/lib/cloud/core.js +31 -1
  60. package/lib/cloud/device.d.ts +155 -24
  61. package/lib/cloud/device.js +153 -22
  62. package/lib/cloud/gateway.d.ts +254 -0
  63. package/lib/cloud/gateway.js +269 -9
  64. package/lib/cloud/health.d.ts +1 -0
  65. package/lib/cloud/health.js +121 -0
  66. package/lib/cloud/interface.d.ts +222 -44
  67. package/lib/cloud/interface.js +15 -2
  68. package/lib/cloud/laser-clean/deleteCleaningRecord/index.d.ts +27 -0
  69. package/lib/cloud/laser-clean/deleteCleaningRecord/index.js +28 -0
  70. package/lib/cloud/laser-clean/deleteCleaningRecord/type.d.ts +7 -0
  71. package/lib/cloud/laser-clean/deleteCleaningRecord/type.js +1 -0
  72. package/lib/cloud/laser-clean/deleteGyroCleanRecord/index.d.ts +27 -0
  73. package/lib/cloud/laser-clean/deleteGyroCleanRecord/index.js +28 -0
  74. package/lib/cloud/laser-clean/deleteGyroCleanRecord/type.d.ts +7 -0
  75. package/lib/cloud/laser-clean/deleteGyroCleanRecord/type.js +1 -0
  76. package/lib/cloud/laser-clean/deleteMultipleMapFiles/index.d.ts +27 -0
  77. package/lib/cloud/laser-clean/deleteMultipleMapFiles/index.js +28 -0
  78. package/lib/cloud/laser-clean/deleteMultipleMapFiles/type.d.ts +7 -0
  79. package/lib/cloud/laser-clean/deleteMultipleMapFiles/type.js +1 -0
  80. package/lib/cloud/laser-clean/getCleaningRecords/index.d.ts +30 -0
  81. package/lib/cloud/laser-clean/getCleaningRecords/index.js +31 -0
  82. package/lib/cloud/laser-clean/getCleaningRecords/type.d.ts +39 -0
  83. package/lib/cloud/laser-clean/getCleaningRecords/type.js +1 -0
  84. package/lib/cloud/laser-clean/getGyroCleanRecordDetail/index.d.ts +29 -0
  85. package/lib/cloud/laser-clean/getGyroCleanRecordDetail/index.js +30 -0
  86. package/lib/cloud/laser-clean/getGyroCleanRecordDetail/type.d.ts +30 -0
  87. package/lib/cloud/laser-clean/getGyroCleanRecordDetail/type.js +1 -0
  88. package/lib/cloud/laser-clean/getGyroCleanRecords/index.d.ts +29 -0
  89. package/lib/cloud/laser-clean/getGyroCleanRecords/index.js +30 -0
  90. package/lib/cloud/laser-clean/getGyroCleanRecords/type.d.ts +35 -0
  91. package/lib/cloud/laser-clean/getGyroCleanRecords/type.js +1 -0
  92. package/lib/cloud/laser-clean/getGyroLatestCleanMap/index.d.ts +28 -0
  93. package/lib/cloud/laser-clean/getGyroLatestCleanMap/index.js +29 -0
  94. package/lib/cloud/laser-clean/getGyroLatestCleanMap/type.d.ts +28 -0
  95. package/lib/cloud/laser-clean/getGyroLatestCleanMap/type.js +1 -0
  96. package/lib/cloud/laser-clean/getMultipleMapFiles/index.d.ts +24 -0
  97. package/lib/cloud/laser-clean/getMultipleMapFiles/index.js +25 -0
  98. package/lib/cloud/laser-clean/getMultipleMapFiles/type.d.ts +29 -0
  99. package/lib/cloud/laser-clean/getMultipleMapFiles/type.js +1 -0
  100. package/lib/cloud/laser-clean/getSweeperStorageConfig/index.d.ts +24 -0
  101. package/lib/cloud/laser-clean/getSweeperStorageConfig/index.js +25 -0
  102. package/lib/cloud/laser-clean/getSweeperStorageConfig/type.d.ts +26 -0
  103. package/lib/cloud/laser-clean/getSweeperStorageConfig/type.js +1 -0
  104. package/lib/cloud/laser-clean/getVoiceList/index.d.ts +28 -0
  105. package/lib/cloud/laser-clean/getVoiceList/index.js +29 -0
  106. package/lib/cloud/laser-clean/getVoiceList/type.d.ts +48 -0
  107. package/lib/cloud/laser-clean/getVoiceList/type.js +1 -0
  108. package/lib/cloud/laser-clean/index.d.ts +1 -1
  109. package/lib/cloud/laser-clean/index.js +1 -1
  110. package/lib/cloud/laser-clean/map.d.ts +5 -7
  111. package/lib/cloud/laser-clean/map.js +5 -9
  112. package/lib/cloud/laser-clean/record.d.ts +5 -6
  113. package/lib/cloud/laser-clean/record.js +5 -7
  114. package/lib/cloud/laser-clean/renameHistoryMap/index.d.ts +28 -0
  115. package/lib/cloud/laser-clean/renameHistoryMap/index.js +29 -0
  116. package/lib/cloud/laser-clean/renameHistoryMap/type.d.ts +9 -0
  117. package/lib/cloud/laser-clean/renameHistoryMap/type.js +1 -0
  118. package/lib/cloud/laser-clean/voice.d.ts +1 -3
  119. package/lib/cloud/laser-clean/voice.js +1 -4
  120. package/lib/cloud/linkage.d.ts +271 -53
  121. package/lib/cloud/linkage.js +256 -51
  122. package/lib/cloud/remoteGroup.d.ts +37 -0
  123. package/lib/cloud/remoteGroup.js +37 -0
  124. package/lib/cloud/timer.d.ts +104 -26
  125. package/lib/cloud/timer.js +104 -26
  126. package/lib/getApp/index.thing.d.ts +47 -1
  127. package/lib/getApp/index.thing.js +40 -2
  128. package/lib/getBoundingClientRect/index.thing.d.ts +101 -1
  129. package/lib/getBoundingClientRect/index.thing.js +59 -0
  130. package/lib/getCurrentPages/index.thing.d.ts +40 -15
  131. package/lib/getCurrentPages/index.thing.js +36 -15
  132. package/lib/getCustomConfig/index.d.ts +5 -2
  133. package/lib/getCustomConfig/index.thing.d.ts +68 -2
  134. package/lib/getCustomConfig/index.thing.js +62 -0
  135. package/lib/getCustomConfig/index.wechat.d.ts +5 -2
  136. package/lib/getCustomConfig/type.d.ts +26 -15
  137. package/lib/getElementById/index.thing.d.ts +42 -1
  138. package/lib/getElementById/index.thing.js +40 -0
  139. package/lib/index.d.ts +3 -0
  140. package/lib/index.js +4 -2
  141. package/lib/nativeRouters/common.d.ts +8 -0
  142. package/lib/nativeRouters/device.d.ts +137 -5
  143. package/lib/nativeRouters/device.js +138 -6
  144. package/lib/nativeRouters/gw.d.ts +58 -8
  145. package/lib/nativeRouters/gw.js +57 -8
  146. package/lib/nativeRouters/outdoors.d.ts +16 -3
  147. package/lib/nativeRouters/outdoors.js +16 -3
  148. package/lib/nativeRouters/remoteGroup.d.ts +23 -0
  149. package/lib/nativeRouters/remoteGroup.js +23 -0
  150. package/lib/nativeRouters/root.d.ts +19 -0
  151. package/lib/nativeRouters/root.js +17 -0
  152. package/lib/openGroupCreate/index.d.ts +45 -0
  153. package/lib/openGroupCreate/index.js +32 -0
  154. package/package.json +5 -5
@@ -178,6 +178,23 @@ const getLastTimerPeriod = params => {
178
178
 
179
179
  /**
180
180
  * 获取天文定时列表
181
+ *
182
+ * @public
183
+ * @since @ray-js/ray 1.5.2
184
+ * @param params - 请求参数
185
+ * @returns 天文定时列表数组
186
+ * @example 基础用法
187
+ * ```ts
188
+ * import { getAstronomicalList } from '@ray-js/ray';
189
+ *
190
+ * getAstronomicalList({
191
+ * bizId: 'vdevo160456552237748',
192
+ * }).then((response) => {
193
+ * console.log('天文定时列表:', response);
194
+ * }).catch((err) => {
195
+ * console.error(err);
196
+ * });
197
+ * ```
181
198
  */
182
199
  const getAstronomicalList = params => {
183
200
  return requestCloud({
@@ -189,17 +206,32 @@ const getAstronomicalList = params => {
189
206
 
190
207
  /**
191
208
  * 添加天文定时
192
- * @param {string} bizId 设备 ID 或群组 ID
193
- * @param {number} bizType 0:设备; 1:设备群组
194
- * @param {string} loops 周期
195
- * @param {any} dps dp 点,json 格式
196
- * @param {number} astronomicalType 天文类型, 0:日出; 1:日落
197
- * @param {string} timezone 时区
198
- * @param {string} date 日期 yyyyMMdd
199
- * @param {string} time 偏移时间,“HH:mm” 24 进制
200
- * @param {number} offsetType 偏移类型,-1 : 向前; 0 正常; 1 : 向后
201
- * @param {number} lat 纬度
202
- * @param {number} lon 经度
209
+ *
210
+ * @public
211
+ * @since @ray-js/ray 1.5.2
212
+ * @param params - 请求参数
213
+ * @returns 新添加天文定时的 ID
214
+ * @example 基础用法
215
+ * ```ts
216
+ * import { addAstronomical } from '@ray-js/ray';
217
+ *
218
+ * addAstronomical({
219
+ * astronomicalType: 1,
220
+ * bizId: 'vdevo160456552237748',
221
+ * bizType: 0,
222
+ * dps: { 1: true },
223
+ * lat: 30.300694,
224
+ * lon: 120.068634,
225
+ * loops: '1111111',
226
+ * offsetType: -1,
227
+ * time: '00:04',
228
+ * timezone: '+08:00',
229
+ * }).then((response) => {
230
+ * console.log('新增天文定时 ID:', response);
231
+ * }).catch((err) => {
232
+ * console.error(err);
233
+ * });
234
+ * ```
203
235
  */
204
236
  const addAstronomical = params => {
205
237
  return requestCloud({
@@ -211,17 +243,33 @@ const addAstronomical = params => {
211
243
 
212
244
  /**
213
245
  * 修改天文定时
214
- * @param {string} bizId 设备 ID 或群组 ID
215
- * @param {number} bizType 0:设备; 1:设备群组
216
- * @param {string} loops 周期
217
- * @param {any} dps dp 点,json 格式
218
- * @param {number} astronomicalType 天文类型, 0:日出; 1:日落
219
- * @param {string} timezone 时区
220
- * @param {string} date 日期 yyyyMMdd
221
- * @param {string} time 偏移时间,“HH:mm” 24 进制
222
- * @param {number} offsetType 偏移类型,-1 : 向前; 0 正常; 1 : 向后
223
- * @param {number} lat 纬度
224
- * @param {number} lon 经度
246
+ *
247
+ * @public
248
+ * @since @ray-js/ray 1.5.2
249
+ * @param params - 请求参数
250
+ * @returns 是否成功修改天文定时
251
+ * @example 基础用法
252
+ * ```ts
253
+ * import { updateAstronomical } from '@ray-js/ray';
254
+ *
255
+ * updateAstronomical({
256
+ * id: 8642566,
257
+ * astronomicalType: 1,
258
+ * bizId: 'vdevo160456552237748',
259
+ * bizType: 0,
260
+ * dps: { 1: true },
261
+ * lat: 30.300694,
262
+ * lon: 120.068634,
263
+ * loops: '1111111',
264
+ * offsetType: -1,
265
+ * time: '00:04',
266
+ * timezone: '+08:00',
267
+ * }).then((response) => {
268
+ * console.log('修改结果:', response);
269
+ * }).catch((err) => {
270
+ * console.error(err);
271
+ * });
272
+ * ```
225
273
  */
226
274
  const updateAstronomical = params => {
227
275
  return requestCloud({
@@ -232,9 +280,25 @@ const updateAstronomical = params => {
232
280
  };
233
281
 
234
282
  /**
235
- * 修改天文定时使能
236
- * @param {string} id 定时任务id
237
- * @param {number} status 0:关闭;1开启
283
+ * 修改天文定时使能状态
284
+ *
285
+ * @public
286
+ * @since @ray-js/ray 1.5.2
287
+ * @param params - 请求参数
288
+ * @returns 是否成功修改状态
289
+ * @example 基础用法
290
+ * ```ts
291
+ * import { updateAstronomicalStatus } from '@ray-js/ray';
292
+ *
293
+ * updateAstronomicalStatus({
294
+ * id: '8642566',
295
+ * status: 0,
296
+ * }).then((response) => {
297
+ * console.log('修改状态结果:', response);
298
+ * }).catch((err) => {
299
+ * console.error(err);
300
+ * });
301
+ * ```
238
302
  */
239
303
  const updateAstronomicalStatus = params => {
240
304
  return requestCloud({
@@ -246,7 +310,21 @@ const updateAstronomicalStatus = params => {
246
310
 
247
311
  /**
248
312
  * 删除天文定时
249
- * @param {string} id 定时任务 id
313
+ *
314
+ * @public
315
+ * @since @ray-js/ray 1.5.2
316
+ * @param params - 请求参数
317
+ * @returns 是否成功删除天文定时
318
+ * @example 基础用法
319
+ * ```ts
320
+ * import { removeAstronomical } from '@ray-js/ray';
321
+ *
322
+ * removeAstronomical({ id: '8642566' }).then((response) => {
323
+ * console.log('删除结果:', response);
324
+ * }).catch((err) => {
325
+ * console.error(err);
326
+ * });
327
+ * ```
250
328
  */
251
329
  const removeAstronomical = params => {
252
330
  return requestCloud({
@@ -1 +1,47 @@
1
- export default function (): any;
1
+ interface AppInstance {
2
+ /** 获取应用全局数据 */
3
+ getData: () => Record<string, unknown>;
4
+ /** 设置应用全局数据 */
5
+ setData: (data: Record<string, unknown>) => void;
6
+ /** 开发者自定义的属性和方法 */
7
+ [key: string]: any;
8
+ }
9
+ /**
10
+ * 获取应用唯一 App 实例,实例对象为 `src/App.tsx`
11
+ *
12
+ * @public
13
+ * @since @ray-js/ray 0.5.10
14
+ * @returns App 实例对象
15
+ * @example 读写全局数据
16
+ * ```tsx
17
+ * import React from 'react';
18
+ * import { View, Button, getApp } from '@ray-js/ray';
19
+ *
20
+ * export default function Demo() {
21
+ * const app = getApp();
22
+ *
23
+ * const handleGetGlobalData = () => {
24
+ * const globalData = app.getData();
25
+ * console.log('globalData:', globalData);
26
+ * };
27
+ *
28
+ * return (
29
+ * <View style={{ padding: 20 }}>
30
+ * <Button onClick={handleGetGlobalData}>
31
+ * 获取全局数据
32
+ * </Button>
33
+ * <Button
34
+ * style={{ marginTop: 10 }}
35
+ * onClick={() => {
36
+ * app.setData({ theme: 'dark' });
37
+ * }}
38
+ * >
39
+ * 修改全局数据
40
+ * </Button>
41
+ * </View>
42
+ * );
43
+ * }
44
+ * ```
45
+ */
46
+ export default function getApp(): AppInstance;
47
+ export {};
@@ -1,3 +1,41 @@
1
- export default function () {
2
- return getApp();
1
+ const _getApp = getApp;
2
+ /**
3
+ * 获取应用唯一 App 实例,实例对象为 `src/App.tsx`
4
+ *
5
+ * @public
6
+ * @since @ray-js/ray 0.5.10
7
+ * @returns App 实例对象
8
+ * @example 读写全局数据
9
+ * ```tsx
10
+ * import React from 'react';
11
+ * import { View, Button, getApp } from '@ray-js/ray';
12
+ *
13
+ * export default function Demo() {
14
+ * const app = getApp();
15
+ *
16
+ * const handleGetGlobalData = () => {
17
+ * const globalData = app.getData();
18
+ * console.log('globalData:', globalData);
19
+ * };
20
+ *
21
+ * return (
22
+ * <View style={{ padding: 20 }}>
23
+ * <Button onClick={handleGetGlobalData}>
24
+ * 获取全局数据
25
+ * </Button>
26
+ * <Button
27
+ * style={{ marginTop: 10 }}
28
+ * onClick={() => {
29
+ * app.setData({ theme: 'dark' });
30
+ * }}
31
+ * >
32
+ * 修改全局数据
33
+ * </Button>
34
+ * </View>
35
+ * );
36
+ * }
37
+ * ```
38
+ */
39
+ export default function getApp() {
40
+ return _getApp();
3
41
  }
@@ -1,9 +1,109 @@
1
+ /** 节点布局信息,由 boundingClientRect 回调返回 */
2
+ export interface BoundingClientRectResult {
3
+ /** 节点 id */
4
+ id: string;
5
+ /** 节点 dataset */
6
+ dataset: Record<string, unknown>;
7
+ /** 左边界坐标 */
8
+ left: number;
9
+ /** 右边界坐标 */
10
+ right: number;
11
+ /** 上边界坐标 */
12
+ top: number;
13
+ /** 下边界坐标 */
14
+ bottom: number;
15
+ /** 节点宽度 */
16
+ width: number;
17
+ /** 节点高度 */
18
+ height: number;
19
+ }
20
+ /** 节点滚动位置信息,由 scrollOffset 回调返回 */
21
+ export interface ScrollOffsetResult {
22
+ /** 节点 id */
23
+ id: string;
24
+ /** 节点 dataset */
25
+ dataset: Record<string, unknown>;
26
+ /** 横向滚动位置 */
27
+ scrollLeft: number;
28
+ /** 纵向滚动位置 */
29
+ scrollTop: number;
30
+ }
31
+ /** SelectorQuery 查询链,支持 exec 执行 */
32
+ export interface SelectorQueryChain {
33
+ /** 执行查询 */
34
+ exec(callback?: (results: unknown[]) => void): void;
35
+ }
36
+ /** 节点引用对象,通过 ty.createSelectorQuery().select() 获取 */
37
+ export interface NodesRef {
38
+ /** 获取节点布局位置(left, right, top, bottom, width, height) */
39
+ boundingClientRect(callback?: (result: BoundingClientRectResult) => void): SelectorQueryChain;
40
+ /** 获取节点滚动位置(scrollLeft, scrollTop) */
41
+ scrollOffset(callback?: (result: ScrollOffsetResult) => void): SelectorQueryChain;
42
+ /** 获取节点指定字段信息 */
43
+ fields(fields: Record<string, boolean>, callback?: (result: Record<string, unknown>) => void): SelectorQueryChain;
44
+ }
45
+ /** 节点坐标信息 */
1
46
  export interface Rect {
47
+ /** 节点右边界坐标 */
2
48
  right: number;
49
+ /** 节点左边界坐标 */
3
50
  left: number;
51
+ /** 节点上边界坐标 */
4
52
  top: number;
53
+ /** 节点下边界坐标 */
5
54
  bottom: number;
55
+ /** 节点宽度 */
6
56
  width: number;
57
+ /** 节点高度 */
7
58
  height: number;
8
59
  }
9
- export default function getBoundingClientRect(ref: WechatMiniprogram.NodesRef): Promise<Rect | null>;
60
+ /**
61
+ * 获取节点的坐标信息
62
+ *
63
+ * @public
64
+ * @since @ray-js/ray 0.5.10
65
+ * @param ref - 通过 getElementById 获取的节点引用
66
+ * @returns 包含节点坐标和尺寸信息的 Rect 对象,节点不存在时返回 null
67
+ * @example 基础用法
68
+ * ```tsx
69
+ * import React, { useState } from 'react';
70
+ * import { View, Button, Text, getBoundingClientRect, getElementById } from '@ray-js/ray';
71
+ *
72
+ * export default function Demo() {
73
+ * const [info, setInfo] = useState('');
74
+ *
75
+ * const handleGetRect = async () => {
76
+ * const element = await getElementById('targetBox');
77
+ * if (element) {
78
+ * const rect = await getBoundingClientRect(element);
79
+ * if (rect) {
80
+ * setInfo(`宽:${rect.width} 高:${rect.height} 左:${rect.left} 上:${rect.top}`);
81
+ * }
82
+ * }
83
+ * };
84
+ *
85
+ * return (
86
+ * <View style={{ padding: 20 }}>
87
+ * <View
88
+ * id="targetBox"
89
+ * style={{
90
+ * width: 200,
91
+ * height: 100,
92
+ * backgroundColor: '#1890ff',
93
+ * display: 'flex',
94
+ * alignItems: 'center',
95
+ * justifyContent: 'center',
96
+ * }}
97
+ * >
98
+ * <Text style={{ color: '#fff' }}>目标区域</Text>
99
+ * </View>
100
+ * <Button style={{ marginTop: 10 }} onClick={handleGetRect}>
101
+ * 获取坐标信息
102
+ * </Button>
103
+ * {info && <Text style={{ marginTop: 10 }}>{info}</Text>}
104
+ * </View>
105
+ * );
106
+ * }
107
+ * ```
108
+ */
109
+ export default function getBoundingClientRect(ref: NodesRef): Promise<Rect | null>;
@@ -1,4 +1,63 @@
1
1
  import "core-js/modules/es.regexp.exec.js";
2
+ /** 节点布局信息,由 boundingClientRect 回调返回 */
3
+
4
+ /** 节点滚动位置信息,由 scrollOffset 回调返回 */
5
+
6
+ /** SelectorQuery 查询链,支持 exec 执行 */
7
+
8
+ /** 节点引用对象,通过 ty.createSelectorQuery().select() 获取 */
9
+
10
+ /** 节点坐标信息 */
11
+
12
+ /**
13
+ * 获取节点的坐标信息
14
+ *
15
+ * @public
16
+ * @since @ray-js/ray 0.5.10
17
+ * @param ref - 通过 getElementById 获取的节点引用
18
+ * @returns 包含节点坐标和尺寸信息的 Rect 对象,节点不存在时返回 null
19
+ * @example 基础用法
20
+ * ```tsx
21
+ * import React, { useState } from 'react';
22
+ * import { View, Button, Text, getBoundingClientRect, getElementById } from '@ray-js/ray';
23
+ *
24
+ * export default function Demo() {
25
+ * const [info, setInfo] = useState('');
26
+ *
27
+ * const handleGetRect = async () => {
28
+ * const element = await getElementById('targetBox');
29
+ * if (element) {
30
+ * const rect = await getBoundingClientRect(element);
31
+ * if (rect) {
32
+ * setInfo(`宽:${rect.width} 高:${rect.height} 左:${rect.left} 上:${rect.top}`);
33
+ * }
34
+ * }
35
+ * };
36
+ *
37
+ * return (
38
+ * <View style={{ padding: 20 }}>
39
+ * <View
40
+ * id="targetBox"
41
+ * style={{
42
+ * width: 200,
43
+ * height: 100,
44
+ * backgroundColor: '#1890ff',
45
+ * display: 'flex',
46
+ * alignItems: 'center',
47
+ * justifyContent: 'center',
48
+ * }}
49
+ * >
50
+ * <Text style={{ color: '#fff' }}>目标区域</Text>
51
+ * </View>
52
+ * <Button style={{ marginTop: 10 }} onClick={handleGetRect}>
53
+ * 获取坐标信息
54
+ * </Button>
55
+ * {info && <Text style={{ marginTop: 10 }}>{info}</Text>}
56
+ * </View>
57
+ * );
58
+ * }
59
+ * ```
60
+ */
2
61
  export default function getBoundingClientRect(ref) {
3
62
  return new Promise(resolve => {
4
63
  ref.boundingClientRect(rect => {
@@ -1,21 +1,46 @@
1
- interface PageInstance {
1
+ /** 页面实例对象 */
2
+ export interface PageInstance {
3
+ /** 页面唯一标识 */
4
+ pageId: string;
5
+ /** 页面路径 */
2
6
  route: string;
7
+ /** 页面参数对象(跳转时传递的 query 参数) */
8
+ options?: Record<string, unknown>;
9
+ /** 页面数据对象 */
10
+ data?: Record<string, unknown>;
3
11
  [key: string]: any;
4
12
  }
5
13
  /**
6
- * getCurrentPages(): PageObject[]获取当前页面栈。数组中第一个元素为首页,最后一个元素为当前页面。
7
- * 注意事项
14
+ * 获取当前页面栈。返回一个数组,数组中的元素为页面栈中的页面对象,数组第一个元素为首页,最后一个元素为当前页面。
15
+ *
16
+ * @public
17
+ * @since @ray-js/ray 0.2.0
18
+ * @returns 页面栈数组,每个元素为 PageInstance 对象
19
+ * @remarks
8
20
  * 1. 不要尝试修改页面栈,会导致路由以及页面状态错误。
9
- * 2. 不要在 App.onLaunch 的时候调用 getCurrentPages(),此时 page 还没有生成。
10
- * @example
11
- * // page/index.js
12
- * Page({
13
- * onLoad() {
14
- * const pageInsts = getCurrentPages();
15
- * const currentPagePath = pageInsts[pageInsts.length - 1].route;
16
- * consoe.log('currentPagePath ===> ', currentPagePath);
17
- * },
18
- * });
21
+ * 2. 不要在 App.onLaunch 的时候调用 getCurrentPages(),此时 page 还没有生成。
22
+ * @example 基础用法
23
+ * ```tsx
24
+ * import React from 'react';
25
+ * import { View, Button, getCurrentPages } from '@ray-js/ray';
26
+ *
27
+ * export default function Home() {
28
+ * const handleGetPages = () => {
29
+ * const pages = getCurrentPages();
30
+ * console.log('当前页面栈长度:', pages.length);
31
+ * console.log('当前页面:', pages[pages.length - 1]);
32
+ *
33
+ * pages.forEach((page, index) => {
34
+ * console.log(`页面 ${index}:`, page.route);
35
+ * });
36
+ * };
37
+ *
38
+ * return (
39
+ * <View style={{ padding: 20 }}>
40
+ * <Button onClick={handleGetPages}>获取页面栈</Button>
41
+ * </View>
42
+ * );
43
+ * }
44
+ * ```
19
45
  */
20
- export default function (): PageInstance[];
21
- export {};
46
+ export default function getCurrentPages(): PageInstance[];
@@ -1,20 +1,41 @@
1
+ /** 页面实例对象 */
2
+
3
+ const _getCurrentPages = getCurrentPages;
4
+
1
5
  /**
2
- * getCurrentPages(): PageObject[]获取当前页面栈。数组中第一个元素为首页,最后一个元素为当前页面。
3
- * 注意事项
6
+ * 获取当前页面栈。返回一个数组,数组中的元素为页面栈中的页面对象,数组第一个元素为首页,最后一个元素为当前页面。
7
+ *
8
+ * @public
9
+ * @since @ray-js/ray 0.2.0
10
+ * @returns 页面栈数组,每个元素为 PageInstance 对象
11
+ * @remarks
4
12
  * 1. 不要尝试修改页面栈,会导致路由以及页面状态错误。
5
- * 2. 不要在 App.onLaunch 的时候调用 getCurrentPages(),此时 page 还没有生成。
6
- * @example
7
- * // page/index.js
8
- * Page({
9
- * onLoad() {
10
- * const pageInsts = getCurrentPages();
11
- * const currentPagePath = pageInsts[pageInsts.length - 1].route;
12
- * consoe.log('currentPagePath ===> ', currentPagePath);
13
- * },
14
- * });
13
+ * 2. 不要在 App.onLaunch 的时候调用 getCurrentPages(),此时 page 还没有生成。
14
+ * @example 基础用法
15
+ * ```tsx
16
+ * import React from 'react';
17
+ * import { View, Button, getCurrentPages } from '@ray-js/ray';
18
+ *
19
+ * export default function Home() {
20
+ * const handleGetPages = () => {
21
+ * const pages = getCurrentPages();
22
+ * console.log('当前页面栈长度:', pages.length);
23
+ * console.log('当前页面:', pages[pages.length - 1]);
24
+ *
25
+ * pages.forEach((page, index) => {
26
+ * console.log(`页面 ${index}:`, page.route);
27
+ * });
28
+ * };
29
+ *
30
+ * return (
31
+ * <View style={{ padding: 20 }}>
32
+ * <Button onClick={handleGetPages}>获取页面栈</Button>
33
+ * </View>
34
+ * );
35
+ * }
36
+ * ```
15
37
  */
16
-
17
- export default function () {
38
+ export default function getCurrentPages() {
18
39
  // @ts-ignore
19
- return getCurrentPages();
40
+ return _getCurrentPages();
20
41
  }
@@ -1,3 +1,6 @@
1
- import type { TGetCustomConfig } from './type';
2
- declare const getCustomConfig: TGetCustomConfig;
1
+ import type { GetCustomConfigParams } from './type';
2
+ declare const getCustomConfig: {
3
+ (params: GetCustomConfigParams): void;
4
+ (): Promise<Record<string, unknown>>;
5
+ };
3
6
  export default getCustomConfig;
@@ -1,3 +1,69 @@
1
- import type { TGetCustomConfig } from './type';
2
- declare const getCustomConfig: TGetCustomConfig;
1
+ import type { CustomConfigValue, GetCustomConfigParams } from './type';
2
+ interface GetCustomConfig {
3
+ (options: GetCustomConfigParams): void;
4
+ (): Promise<Record<string, CustomConfigValue>>;
5
+ }
6
+ /**
7
+ * 获取小程序自定义配置信息。此接口用于获取在开发者后台配置的自定义业务配置,支持多种数据类型(链接、布尔值、数字、字符串)。
8
+ *
9
+ * 自定义配置支持模板配置和实例配置的分层管理,实例配置优先于模板配置。配置修改后会自动同步到云端,小程序可以通过此接口获取最新的配置信息。
10
+ *
11
+ * @public
12
+ * @since 基础库 2.0.0
13
+ * @since @ray-js/ray 1.7.29
14
+ * @param options - 参数对象,包含 success / fail / complete 回调;不传时返回 Promise
15
+ * @returns 不传回调时返回 Promise,resolve 值为自定义配置键值对对象
16
+ * @error {7} API Internal processing failed
17
+ * @example 回调方式
18
+ * ```tsx
19
+ * import React from 'react';
20
+ * import { View, Button, Text, getCustomConfig } from '@ray-js/ray';
21
+ *
22
+ * export default function Demo() {
23
+ * const handleGetConfig = () => {
24
+ * getCustomConfig({
25
+ * success(config) {
26
+ * console.log('自定义配置:', config);
27
+ * },
28
+ * fail(err) {
29
+ * console.error('获取失败:', err.errorMsg);
30
+ * },
31
+ * });
32
+ * };
33
+ *
34
+ * return (
35
+ * <View style={{ padding: 20 }}>
36
+ * <Button onClick={handleGetConfig}>获取自定义配置(回调)</Button>
37
+ * </View>
38
+ * );
39
+ * }
40
+ * ```
41
+ * @example Promise 方式
42
+ * ```tsx
43
+ * import React, { useState } from 'react';
44
+ * import { View, Button, Text, getCustomConfig } from '@ray-js/ray';
45
+ *
46
+ * export default function Demo() {
47
+ * const [config, setConfig] = useState('');
48
+ *
49
+ * const handleGetConfig = async () => {
50
+ * try {
51
+ * const result = await getCustomConfig();
52
+ * setConfig(JSON.stringify(result));
53
+ * console.log('自定义配置:', result);
54
+ * } catch (err) {
55
+ * console.error('获取失败:', err);
56
+ * }
57
+ * };
58
+ *
59
+ * return (
60
+ * <View style={{ padding: 20 }}>
61
+ * <Button onClick={handleGetConfig}>获取自定义配置(Promise)</Button>
62
+ * {config && <Text style={{ marginTop: 10 }}>{config}</Text>}
63
+ * </View>
64
+ * );
65
+ * }
66
+ * ```
67
+ */
68
+ declare const getCustomConfig: GetCustomConfig;
3
69
  export default getCustomConfig;