@tarojs/taro-h5 3.5.0-canary.1 → 3.5.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 (411) hide show
  1. package/dist/api/ad/index.d.ts +6 -0
  2. package/dist/api/ad/index.js +1 -1
  3. package/dist/api/ai/facial.d.ts +9 -0
  4. package/dist/api/ai/facial.js +1 -1
  5. package/dist/api/ai/index.d.ts +2 -0
  6. package/dist/api/ai/visual.d.ts +6 -0
  7. package/dist/api/ai/visual.js +3 -1
  8. package/dist/api/alipay/index.d.ts +3 -0
  9. package/dist/api/alipay/index.js +1 -1
  10. package/dist/api/base/crypto.d.ts +3 -0
  11. package/dist/api/base/crypto.js +1 -1
  12. package/dist/api/base/debug.d.ts +9 -0
  13. package/dist/api/base/debug.js +1 -1
  14. package/dist/api/base/index.d.ts +12 -0
  15. package/dist/api/base/index.js +5 -5
  16. package/dist/api/base/performance.d.ts +6 -0
  17. package/dist/api/base/performance.js +1 -1
  18. package/dist/api/base/system.d.ts +27 -0
  19. package/dist/api/base/system.js +191 -0
  20. package/dist/api/base/update.d.ts +6 -0
  21. package/dist/api/base/update.js +1 -1
  22. package/dist/api/base/weapp/app-event.d.ts +41 -0
  23. package/dist/api/base/weapp/app-event.js +56 -5
  24. package/dist/api/base/weapp/life-cycle.d.ts +6 -0
  25. package/dist/api/base/weapp/life-cycle.js +1 -1
  26. package/dist/api/canvas/CanvasContext.d.ts +104 -0
  27. package/dist/api/canvas/CanvasContext.js +27 -16
  28. package/dist/api/canvas/canvasGetImageData.d.ts +5 -0
  29. package/dist/api/canvas/canvasGetImageData.js +2 -2
  30. package/dist/api/canvas/canvasPutImageData.d.ts +6 -0
  31. package/dist/api/canvas/canvasPutImageData.js +2 -2
  32. package/dist/api/canvas/canvasToTempFilePath.d.ts +6 -0
  33. package/dist/api/canvas/canvasToTempFilePath.js +2 -2
  34. package/dist/api/canvas/createCanvasContext.d.ts +5 -0
  35. package/dist/api/canvas/createCanvasContext.js +1 -1
  36. package/dist/api/canvas/index.d.ts +12 -0
  37. package/dist/api/canvas/index.js +6 -2
  38. package/dist/api/cloud/index.d.ts +31 -0
  39. package/dist/api/cloud/index.js +1 -1
  40. package/dist/api/data-analysis/index.d.ts +12 -0
  41. package/dist/api/data-analysis/index.js +1 -1
  42. package/dist/api/device/accelerometer.d.ts +17 -0
  43. package/dist/api/device/accelerometer.js +10 -18
  44. package/dist/api/device/accessibility.d.ts +3 -0
  45. package/dist/api/device/accessibility.js +1 -1
  46. package/dist/api/device/battery.d.ts +5 -0
  47. package/dist/api/device/battery.js +28 -2
  48. package/dist/api/device/bluetooth-ble.d.ts +48 -0
  49. package/dist/api/device/bluetooth-ble.js +1 -1
  50. package/dist/api/device/bluetooth-peripheral.d.ts +9 -0
  51. package/dist/api/device/bluetooth-peripheral.js +1 -1
  52. package/dist/api/device/bluetooth.d.ts +39 -0
  53. package/dist/api/device/bluetooth.js +1 -1
  54. package/dist/api/device/calendar.d.ts +6 -0
  55. package/dist/api/device/calendar.js +1 -1
  56. package/dist/api/device/clipboard.d.ts +15 -0
  57. package/dist/api/device/clipboard.js +15 -6
  58. package/dist/api/device/compass.d.ts +17 -0
  59. package/dist/api/device/compass.js +33 -19
  60. package/dist/api/device/contact.d.ts +6 -0
  61. package/dist/api/device/contact.js +1 -1
  62. package/dist/api/device/crypto.d.ts +3 -0
  63. package/dist/api/device/crypto.js +1 -1
  64. package/dist/api/device/gyroscope.d.ts +12 -0
  65. package/dist/api/device/gyroscope.js +1 -1
  66. package/dist/api/device/iBeacon.d.ts +21 -0
  67. package/dist/api/device/iBeacon.js +1 -1
  68. package/dist/api/device/index.d.ts +23 -0
  69. package/dist/api/device/index.js +1 -0
  70. package/dist/api/device/keyboard.d.ts +12 -0
  71. package/dist/api/device/keyboard.js +1 -1
  72. package/dist/api/device/memory.d.ts +6 -0
  73. package/dist/api/device/memory.js +1 -1
  74. package/dist/api/device/motion.d.ts +17 -0
  75. package/dist/api/device/motion.js +9 -18
  76. package/dist/api/device/network.d.ts +20 -0
  77. package/dist/api/device/network.js +87 -0
  78. package/dist/api/device/nfc.d.ts +21 -0
  79. package/dist/api/device/nfc.js +1 -1
  80. package/dist/api/device/phone.d.ts +2 -0
  81. package/dist/api/device/phone.js +2 -2
  82. package/dist/api/device/scan.d.ts +3 -0
  83. package/dist/api/device/scan.js +9 -5
  84. package/dist/api/device/screen.d.ts +18 -0
  85. package/dist/api/device/screen.js +1 -1
  86. package/dist/api/device/vibrate.d.ts +9 -0
  87. package/dist/api/device/vibrate.js +6 -8
  88. package/dist/api/device/wifi.d.ts +33 -0
  89. package/dist/api/device/wifi.js +2 -1
  90. package/dist/api/ext/index.d.ts +6 -0
  91. package/dist/api/ext/index.js +1 -1
  92. package/dist/api/files/index.d.ts +24 -0
  93. package/dist/api/files/index.js +1 -1
  94. package/dist/api/framework/index.d.ts +4 -0
  95. package/dist/api/index.d.ts +24 -0
  96. package/dist/api/index.js +2 -2
  97. package/dist/api/location/chooseLocation.d.ts +6 -0
  98. package/dist/api/location/chooseLocation.js +22 -8
  99. package/dist/api/location/getLocation.d.ts +2 -0
  100. package/dist/api/location/getLocation.js +64 -0
  101. package/dist/api/location/index.d.ts +32 -0
  102. package/dist/api/location/index.js +8 -4
  103. package/dist/api/media/EditorContext.d.ts +42 -0
  104. package/dist/api/media/EditorContext.js +2 -1
  105. package/dist/api/media/audio/InnerAudioContext.d.ts +58 -0
  106. package/dist/api/media/audio/InnerAudioContext.js +3 -3
  107. package/dist/api/media/audio/index.d.ts +29 -0
  108. package/dist/api/media/audio/index.js +1 -1
  109. package/dist/api/media/background-audio/BackgroundAudioManager.d.ts +71 -0
  110. package/dist/api/media/background-audio/BackgroundAudioManager.js +2 -2
  111. package/dist/api/media/background-audio/index.d.ts +29 -0
  112. package/dist/api/media/background-audio/index.js +1 -1
  113. package/dist/api/media/camera.d.ts +3 -0
  114. package/dist/api/media/camera.js +1 -1
  115. package/dist/api/media/image/chooseImage.d.ts +5 -0
  116. package/dist/api/media/image/chooseImage.js +14 -3
  117. package/dist/api/media/image/getImageInfo.d.ts +5 -0
  118. package/dist/api/media/image/getImageInfo.js +18 -3
  119. package/dist/api/media/image/index.d.ts +15 -0
  120. package/dist/api/media/image/index.js +2 -2
  121. package/dist/api/media/image/previewImage.d.ts +8 -0
  122. package/dist/api/media/image/previewImage.js +14 -5
  123. package/dist/api/media/index.d.ts +12 -0
  124. package/dist/api/media/live.d.ts +6 -0
  125. package/dist/api/media/live.js +1 -1
  126. package/dist/api/media/map.d.ts +3 -0
  127. package/dist/api/media/map.js +1 -1
  128. package/dist/api/media/media-recorder.d.ts +3 -0
  129. package/dist/api/media/media-recorder.js +1 -1
  130. package/dist/api/media/recorder.d.ts +9 -0
  131. package/dist/api/media/recorder.js +1 -1
  132. package/dist/api/media/video/index.d.ts +24 -0
  133. package/dist/api/media/video/index.js +2 -2
  134. package/dist/api/media/video-decoder.d.ts +3 -0
  135. package/dist/api/media/video-decoder.js +1 -1
  136. package/dist/api/media/video-processing.d.ts +3 -0
  137. package/dist/api/media/video-processing.js +1 -1
  138. package/dist/api/media/voip.d.ts +42 -0
  139. package/dist/api/media/voip.js +1 -1
  140. package/dist/api/navigate/index.d.ts +12 -0
  141. package/dist/api/navigate/index.js +1 -1
  142. package/dist/api/network/download.d.ts +6 -0
  143. package/dist/api/network/download.js +2 -1
  144. package/dist/api/network/index.d.ts +7 -0
  145. package/dist/api/network/mdns.d.ts +30 -0
  146. package/dist/api/network/mdns.js +1 -1
  147. package/dist/api/network/request/index.d.ts +4 -0
  148. package/dist/api/network/request/index.js +6 -2
  149. package/dist/api/network/tcp.d.ts +3 -0
  150. package/dist/api/network/tcp.js +1 -1
  151. package/dist/api/network/udp.d.ts +3 -0
  152. package/dist/api/network/udp.js +1 -1
  153. package/dist/api/network/upload.d.ts +5 -0
  154. package/dist/api/network/upload.js +4 -8
  155. package/{src/api/network/utils.ts → dist/api/network/utils.d.ts} +44 -71
  156. package/dist/api/network/utils.js +1 -0
  157. package/dist/api/network/websocket/index.d.ts +7 -0
  158. package/dist/api/network/websocket/index.js +2 -2
  159. package/dist/api/network/websocket/socketTask.d.ts +25 -0
  160. package/dist/api/open-api/account.d.ts +3 -0
  161. package/dist/api/open-api/account.js +1 -1
  162. package/dist/api/open-api/address.d.ts +3 -0
  163. package/dist/api/open-api/address.js +1 -1
  164. package/dist/api/open-api/authorize.d.ts +6 -0
  165. package/dist/api/open-api/authorize.js +1 -1
  166. package/dist/api/open-api/card.d.ts +6 -0
  167. package/dist/api/open-api/card.js +1 -1
  168. package/dist/api/open-api/channels-live.d.ts +18 -0
  169. package/dist/api/open-api/channels-live.js +1 -1
  170. package/dist/api/open-api/customer-service.d.ts +3 -0
  171. package/dist/api/open-api/customer-service.js +1 -1
  172. package/dist/api/open-api/facial.d.ts +12 -0
  173. package/dist/api/open-api/facial.js +1 -1
  174. package/dist/api/open-api/favorites.d.ts +6 -0
  175. package/dist/api/open-api/favorites.js +1 -1
  176. package/dist/api/open-api/group.d.ts +3 -0
  177. package/dist/api/open-api/group.js +1 -1
  178. package/dist/api/open-api/index.d.ts +18 -0
  179. package/dist/api/open-api/invoice.d.ts +6 -0
  180. package/dist/api/open-api/invoice.js +1 -1
  181. package/dist/api/open-api/license-plate.d.ts +3 -0
  182. package/dist/api/open-api/license-plate.js +1 -1
  183. package/dist/api/open-api/login.d.ts +9 -0
  184. package/dist/api/open-api/login.js +1 -1
  185. package/dist/api/open-api/red-package.d.ts +3 -0
  186. package/dist/api/open-api/red-package.js +1 -1
  187. package/dist/api/open-api/settings.d.ts +6 -0
  188. package/dist/api/open-api/settings.js +1 -1
  189. package/dist/api/open-api/soter.d.ts +9 -0
  190. package/dist/api/open-api/soter.js +1 -1
  191. package/dist/api/open-api/subscribe-message.d.ts +3 -0
  192. package/dist/api/open-api/subscribe-message.js +1 -1
  193. package/dist/api/open-api/user-info.d.ts +6 -0
  194. package/dist/api/open-api/user-info.js +1 -1
  195. package/dist/api/open-api/werun.d.ts +6 -0
  196. package/dist/api/open-api/werun.js +1 -1
  197. package/dist/api/payment/index.d.ts +6 -0
  198. package/dist/api/payment/index.js +1 -1
  199. package/dist/api/route/index.d.ts +1 -0
  200. package/dist/api/route/index.js +1 -1
  201. package/dist/api/share/index.d.ts +30 -0
  202. package/dist/api/share/index.js +1 -1
  203. package/dist/api/storage/background-fetch.d.ts +12 -0
  204. package/dist/api/storage/background-fetch.js +1 -1
  205. package/dist/api/storage/index.d.ts +18 -0
  206. package/dist/api/storage/index.js +2 -2
  207. package/dist/api/swan/index.d.ts +63 -0
  208. package/dist/api/swan/index.js +1 -1
  209. package/dist/api/taro.d.ts +12 -0
  210. package/dist/api/taro.js +4 -5
  211. package/dist/api/ui/animation/index.d.ts +2 -0
  212. package/dist/api/ui/background.d.ts +6 -0
  213. package/dist/api/ui/background.js +1 -1
  214. package/dist/api/ui/custom-component.d.ts +1 -0
  215. package/dist/api/ui/fonts.d.ts +2 -0
  216. package/dist/api/ui/fonts.js +59 -2
  217. package/dist/api/ui/index.d.ts +12 -0
  218. package/dist/api/ui/index.js +1 -1
  219. package/dist/api/ui/interaction/actionSheet.d.ts +61 -0
  220. package/dist/api/ui/interaction/actionSheet.js +4 -13
  221. package/dist/api/ui/interaction/index.d.ts +14 -0
  222. package/dist/api/ui/interaction/index.js +22 -13
  223. package/dist/api/ui/interaction/modal.d.ts +69 -0
  224. package/dist/api/ui/interaction/modal.js +8 -28
  225. package/dist/api/ui/interaction/toast.d.ts +85 -0
  226. package/dist/api/ui/interaction/toast.js +15 -41
  227. package/dist/api/ui/menu.d.ts +3 -0
  228. package/dist/api/ui/menu.js +1 -1
  229. package/dist/api/ui/navigation-bar/index.d.ts +15 -0
  230. package/dist/api/ui/navigation-bar/index.js +4 -5
  231. package/dist/api/ui/pull-down-refresh.d.ts +9 -0
  232. package/dist/api/ui/pull-down-refresh.js +1 -1
  233. package/dist/api/ui/scroll/index.d.ts +5 -0
  234. package/dist/api/ui/scroll/index.js +2 -2
  235. package/dist/api/ui/sticky.d.ts +3 -0
  236. package/dist/api/ui/sticky.js +1 -1
  237. package/dist/api/ui/tab-bar.d.ts +34 -0
  238. package/dist/api/ui/tab-bar.js +2 -2
  239. package/dist/api/ui/window.d.ts +15 -0
  240. package/dist/api/ui/window.js +2 -2
  241. package/dist/api/worker/index.d.ts +3 -0
  242. package/dist/api/worker/index.js +1 -1
  243. package/dist/api/wxml/index.d.ts +5 -0
  244. package/dist/api/wxml/index.js +1 -1
  245. package/dist/api/wxml/nodesRef.d.ts +13 -0
  246. package/dist/api/wxml/selectorQuery.d.ts +24 -0
  247. package/dist/api/wxml/selectorQuery.js +2 -2
  248. package/dist/index.cjs.d.ts +1373 -0
  249. package/dist/index.cjs.js +5021 -8380
  250. package/dist/index.cjs.js.map +1 -0
  251. package/dist/index.d.ts +4 -0
  252. package/dist/index.esm.d.ts +1373 -0
  253. package/dist/index.esm.js +5194 -0
  254. package/dist/index.esm.js.map +1 -0
  255. package/dist/taroApis.d.ts +1364 -0
  256. package/dist/taroApis.js +2 -1
  257. package/dist/taroApis.js.map +1 -0
  258. package/dist/utils/animation.d.ts +6 -0
  259. package/dist/utils/animation.js +14 -0
  260. package/dist/utils/handler.d.ts +48 -0
  261. package/dist/{api/utils → utils}/handler.js +0 -0
  262. package/dist/utils/index.d.ts +39 -0
  263. package/dist/{api/utils → utils}/index.js +36 -53
  264. package/dist/utils/lodash.d.ts +2 -0
  265. package/dist/utils/lodash.js +29 -0
  266. package/dist/utils/valid.d.ts +2 -0
  267. package/dist/utils/valid.js +7 -0
  268. package/package.json +21 -20
  269. package/{src/types → types}/api.d.ts +1 -1
  270. package/types/define.d.ts +2 -0
  271. package/types/index.d.ts +33 -0
  272. package/types/overlay.d.ts +9 -0
  273. package/LICENSE +0 -21
  274. package/dist/api/base/system/index.js +0 -2
  275. package/dist/api/base/system/info.js +0 -57
  276. package/dist/api/base/system/network.js +0 -63
  277. package/dist/types/type.js +0 -2
  278. package/src/api/ad/index.ts +0 -5
  279. package/src/api/ai/facial.ts +0 -6
  280. package/src/api/ai/index.ts +0 -2
  281. package/src/api/ai/visual.ts +0 -4
  282. package/src/api/alipay/index.ts +0 -4
  283. package/src/api/base/crypto.ts +0 -4
  284. package/src/api/base/debug.ts +0 -5
  285. package/src/api/base/index.ts +0 -23
  286. package/src/api/base/performance.ts +0 -5
  287. package/src/api/base/system/index.ts +0 -2
  288. package/src/api/base/system/info.ts +0 -64
  289. package/src/api/base/system/network.ts +0 -70
  290. package/src/api/base/update.ts +0 -5
  291. package/src/api/base/weapp/app-event.ts +0 -19
  292. package/src/api/base/weapp/life-cycle.ts +0 -5
  293. package/src/api/canvas/CanvasContext.ts +0 -233
  294. package/src/api/canvas/canvasGetImageData.ts +0 -27
  295. package/src/api/canvas/canvasPutImageData.ts +0 -24
  296. package/src/api/canvas/canvasToTempFilePath.ts +0 -24
  297. package/src/api/canvas/createCanvasContext.ts +0 -18
  298. package/src/api/canvas/index.ts +0 -10
  299. package/src/api/cloud/index.ts +0 -31
  300. package/src/api/data-analysis/index.ts +0 -6
  301. package/src/api/device/accelerometer.ts +0 -87
  302. package/src/api/device/accessibility.ts +0 -4
  303. package/src/api/device/battery.ts +0 -5
  304. package/src/api/device/bluetooth-ble.ts +0 -19
  305. package/src/api/device/bluetooth-peripheral.ts +0 -6
  306. package/src/api/device/bluetooth.ts +0 -16
  307. package/src/api/device/calendar.ts +0 -5
  308. package/src/api/device/clipboard.ts +0 -67
  309. package/src/api/device/compass.ts +0 -67
  310. package/src/api/device/contact.ts +0 -5
  311. package/src/api/device/crypto.ts +0 -4
  312. package/src/api/device/gyroscope.ts +0 -7
  313. package/src/api/device/iBeacon.ts +0 -10
  314. package/src/api/device/index.ts +0 -22
  315. package/src/api/device/keyboard.ts +0 -7
  316. package/src/api/device/memory.ts +0 -5
  317. package/src/api/device/motion.ts +0 -85
  318. package/src/api/device/nfc.ts +0 -10
  319. package/src/api/device/phone.ts +0 -30
  320. package/src/api/device/scan.ts +0 -7
  321. package/src/api/device/screen.ts +0 -9
  322. package/src/api/device/vibrate.ts +0 -36
  323. package/src/api/device/wifi.ts +0 -13
  324. package/src/api/ext/index.ts +0 -5
  325. package/src/api/files/index.ts +0 -11
  326. package/src/api/framework/index.ts +0 -10
  327. package/src/api/index.ts +0 -25
  328. package/src/api/location/chooseLocation.ts +0 -106
  329. package/src/api/location/index.ts +0 -19
  330. package/src/api/location/style.css +0 -79
  331. package/src/api/media/EditorContext.ts +0 -29
  332. package/src/api/media/audio/InnerAudioContext.ts +0 -98
  333. package/src/api/media/audio/index.ts +0 -20
  334. package/src/api/media/background-audio/BackgroundAudioManager.ts +0 -103
  335. package/src/api/media/background-audio/index.ts +0 -17
  336. package/src/api/media/camera.ts +0 -4
  337. package/src/api/media/image/chooseImage.ts +0 -78
  338. package/src/api/media/image/getImageInfo.ts +0 -35
  339. package/src/api/media/image/index.ts +0 -13
  340. package/src/api/media/image/previewImage.ts +0 -80
  341. package/src/api/media/index.ts +0 -12
  342. package/src/api/media/live.ts +0 -5
  343. package/src/api/media/map.ts +0 -4
  344. package/src/api/media/media-recorder.ts +0 -4
  345. package/src/api/media/recorder.ts +0 -6
  346. package/src/api/media/video/index.ts +0 -82
  347. package/src/api/media/video-decoder.ts +0 -4
  348. package/src/api/media/video-processing.ts +0 -4
  349. package/src/api/media/voip.ts +0 -17
  350. package/src/api/navigate/index.ts +0 -7
  351. package/src/api/network/download.ts +0 -140
  352. package/src/api/network/index.ts +0 -7
  353. package/src/api/network/mdns.ts +0 -13
  354. package/src/api/network/request/index.ts +0 -130
  355. package/src/api/network/tcp.ts +0 -4
  356. package/src/api/network/udp.ts +0 -4
  357. package/src/api/network/upload.ts +0 -174
  358. package/src/api/network/websocket/index.ts +0 -88
  359. package/src/api/network/websocket/socketTask.ts +0 -89
  360. package/src/api/open-api/account.ts +0 -4
  361. package/src/api/open-api/address.ts +0 -4
  362. package/src/api/open-api/authorize.ts +0 -5
  363. package/src/api/open-api/card.ts +0 -5
  364. package/src/api/open-api/channels-live.ts +0 -9
  365. package/src/api/open-api/customer-service.ts +0 -4
  366. package/src/api/open-api/facial.ts +0 -7
  367. package/src/api/open-api/favorites.ts +0 -5
  368. package/src/api/open-api/group.ts +0 -4
  369. package/src/api/open-api/index.ts +0 -18
  370. package/src/api/open-api/invoice.ts +0 -5
  371. package/src/api/open-api/license-plate.ts +0 -4
  372. package/src/api/open-api/login.ts +0 -6
  373. package/src/api/open-api/red-package.ts +0 -4
  374. package/src/api/open-api/settings.ts +0 -5
  375. package/src/api/open-api/soter.ts +0 -6
  376. package/src/api/open-api/subscribe-message.ts +0 -4
  377. package/src/api/open-api/user-info.ts +0 -5
  378. package/src/api/open-api/werun.ts +0 -5
  379. package/src/api/payment/index.ts +0 -5
  380. package/src/api/route/index.ts +0 -10
  381. package/src/api/share/index.ts +0 -13
  382. package/src/api/storage/background-fetch.ts +0 -7
  383. package/src/api/storage/index.ts +0 -181
  384. package/src/api/swan/index.ts +0 -31
  385. package/src/api/taro.ts +0 -89
  386. package/src/api/ui/animation/index.ts +0 -356
  387. package/src/api/ui/background.ts +0 -5
  388. package/src/api/ui/custom-component.ts +0 -4
  389. package/src/api/ui/fonts.ts +0 -4
  390. package/src/api/ui/index.ts +0 -12
  391. package/src/api/ui/interaction/actionSheet.ts +0 -212
  392. package/src/api/ui/interaction/index.ts +0 -301
  393. package/src/api/ui/interaction/modal.ts +0 -237
  394. package/src/api/ui/interaction/toast.ts +0 -220
  395. package/src/api/ui/menu.ts +0 -4
  396. package/src/api/ui/navigation-bar/index.ts +0 -52
  397. package/src/api/ui/pull-down-refresh.ts +0 -27
  398. package/src/api/ui/scroll/index.ts +0 -85
  399. package/src/api/ui/sticky.ts +0 -4
  400. package/src/api/ui/tab-bar.ts +0 -326
  401. package/src/api/ui/window.ts +0 -37
  402. package/src/api/utils/handler.ts +0 -105
  403. package/src/api/utils/index.ts +0 -190
  404. package/src/api/worker/index.ts +0 -4
  405. package/src/api/wxml/index.ts +0 -9
  406. package/src/api/wxml/nodesRef.ts +0 -56
  407. package/src/api/wxml/selectorQuery.ts +0 -219
  408. package/src/index.ts +0 -6
  409. package/src/types/define.d.ts +0 -2
  410. package/src/types/index.d.ts +0 -3
  411. package/src/types/type.ts +0 -32
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  const TextBaseLineMap = {
2
11
  top: 'top',
3
12
  bottom: 'bottom',
@@ -81,24 +90,26 @@ export class CanvasContext {
81
90
  * 将之前在绘图上下文中的描述(路径、变形、样式)画到 canvas 中。
82
91
  * @todo 每次 draw 都会读取 width 和 height
83
92
  */
84
- async draw(reserve, callback) {
85
- try {
86
- if (!reserve) {
87
- this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
93
+ draw(reserve, callback) {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ try {
96
+ if (!reserve) {
97
+ this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
98
+ }
99
+ // 部分 action 是异步的
100
+ for (const { func, args } of this.actions) {
101
+ yield func.apply(this.ctx, args);
102
+ }
103
+ this.emptyActions();
104
+ callback && callback();
88
105
  }
89
- // 部分 action 是异步的
90
- for (const { func, args } of this.actions) {
91
- await func.apply(this.ctx, args);
106
+ catch (e) {
107
+ /* eslint-disable no-throw-literal */
108
+ throw {
109
+ errMsg: e.message
110
+ };
92
111
  }
93
- this.emptyActions();
94
- callback && callback();
95
- }
96
- catch (e) {
97
- /* eslint-disable no-throw-literal */
98
- throw {
99
- errMsg: e.message
100
- };
101
- }
112
+ });
102
113
  }
103
114
  drawImage(imageResource, ...extra) {
104
115
  this.enqueueActions(() => {
@@ -0,0 +1,5 @@
1
+ import Taro from '@tarojs/api';
2
+ /**
3
+ * 获取 canvas 区域隐含的像素数据。
4
+ */
5
+ export declare const canvasGetImageData: typeof Taro.canvasGetImageData;
@@ -1,5 +1,5 @@
1
- import { MethodHandler } from '../utils/handler';
2
- import { findDOM } from '../utils';
1
+ import { findDOM } from '../../utils';
2
+ import { MethodHandler } from '../../utils/handler';
3
3
  /**
4
4
  * 获取 canvas 区域隐含的像素数据。
5
5
  */
@@ -0,0 +1,6 @@
1
+ import Taro from '@tarojs/api';
2
+ /**
3
+ * 将像素数据绘制到画布。在自定义组件下,第二个参数传入自定义组件实例 this,以操作组件内 <canvas> 组件
4
+ * @todo 暂未支持尺寸相关功能
5
+ */
6
+ export declare const canvasPutImageData: typeof Taro.canvasPutImageData;
@@ -1,5 +1,5 @@
1
- import { MethodHandler } from '../utils/handler';
2
- import { findDOM } from '../utils';
1
+ import { findDOM } from '../../utils';
2
+ import { MethodHandler } from '../../utils/handler';
3
3
  /**
4
4
  * 将像素数据绘制到画布。在自定义组件下,第二个参数传入自定义组件实例 this,以操作组件内 <canvas> 组件
5
5
  * @todo 暂未支持尺寸相关功能
@@ -0,0 +1,6 @@
1
+ import Taro from '@tarojs/api';
2
+ /**
3
+ * 把当前画布指定区域的内容导出生成指定大小的图片。在 draw() 回调里调用该方法才能保证图片导出成功。
4
+ * @todo 暂未支持尺寸相关功能
5
+ */
6
+ export declare const canvasToTempFilePath: typeof Taro.canvasToTempFilePath;
@@ -1,5 +1,5 @@
1
- import { findDOM } from '../utils';
2
- import { MethodHandler } from '../utils/handler';
1
+ import { findDOM } from '../../utils';
2
+ import { MethodHandler } from '../../utils/handler';
3
3
  /**
4
4
  * 把当前画布指定区域的内容导出生成指定大小的图片。在 draw() 回调里调用该方法才能保证图片导出成功。
5
5
  * @todo 暂未支持尺寸相关功能
@@ -0,0 +1,5 @@
1
+ import Taro from '@tarojs/api';
2
+ /**
3
+ * 创建 canvas 的绘图上下文 CanvasContext 对象
4
+ */
5
+ export declare const createCanvasContext: typeof Taro.createCanvasContext;
@@ -1,4 +1,4 @@
1
- import { findDOM } from '../utils';
1
+ import { findDOM } from '../../utils';
2
2
  import { CanvasContext } from './CanvasContext';
3
3
  /**
4
4
  * 创建 canvas 的绘图上下文 CanvasContext 对象
@@ -0,0 +1,12 @@
1
+ /** 创建离屏 canvas 实例 */
2
+ export declare const createOffscreenCanvas: () => Promise<{
3
+ errMsg: string;
4
+ }>;
5
+ /** 创建 canvas 的绘图上下文 CanvasContext 对象 */
6
+ export * from './createCanvasContext';
7
+ /** 把当前画布指定区域的内容导出生成指定大小的图片 */
8
+ export * from './canvasToTempFilePath';
9
+ /** 将像素数据绘制到画布 */
10
+ export * from './canvasPutImageData';
11
+ /** 获取 canvas 区域隐含的像素数据 */
12
+ export * from './canvasGetImageData';
@@ -1,8 +1,12 @@
1
- import { temporarilyNotSupport } from '../utils';
1
+ import { temporarilyNotSupport } from '../../utils';
2
2
  // 画布
3
+ /** 创建离屏 canvas 实例 */
3
4
  export const createOffscreenCanvas = temporarilyNotSupport('createOffscreenCanvas');
5
+ /** 创建 canvas 的绘图上下文 CanvasContext 对象 */
4
6
  export * from './createCanvasContext';
7
+ /** 把当前画布指定区域的内容导出生成指定大小的图片 */
5
8
  export * from './canvasToTempFilePath';
9
+ /** 将像素数据绘制到画布 */
6
10
  export * from './canvasPutImageData';
11
+ /** 获取 canvas 区域隐含的像素数据 */
7
12
  export * from './canvasGetImageData';
8
- export const drawCanvas = temporarilyNotSupport('drawCanvas');
@@ -0,0 +1,31 @@
1
+ import Taro from '@tarojs/api';
2
+ export declare class cloud implements Taro.cloud {
3
+ Cloud: new (options: Taro.cloud.IOptions) => Taro.Cloud;
4
+ init: () => Promise<{
5
+ errMsg: string;
6
+ }>;
7
+ CloudID: () => Promise<{
8
+ errMsg: string;
9
+ }>;
10
+ callFunction: () => Promise<{
11
+ errMsg: string;
12
+ }>;
13
+ uploadFile: () => Promise<{
14
+ errMsg: string;
15
+ }>;
16
+ downloadFile: () => Promise<{
17
+ errMsg: string;
18
+ }>;
19
+ getTempFileURL: () => Promise<{
20
+ errMsg: string;
21
+ }>;
22
+ deleteFile: () => Promise<{
23
+ errMsg: string;
24
+ }>;
25
+ database: () => Promise<{
26
+ errMsg: string;
27
+ }>;
28
+ callContainer: () => Promise<{
29
+ errMsg: string;
30
+ }>;
31
+ }
@@ -1,4 +1,4 @@
1
- import { temporarilyNotSupport } from '../utils';
1
+ import { temporarilyNotSupport } from '../../utils';
2
2
  export class cloud {
3
3
  constructor() {
4
4
  this.init = temporarilyNotSupport('cloud.init');
@@ -0,0 +1,12 @@
1
+ export declare const reportMonitor: () => Promise<{
2
+ errMsg: string;
3
+ }>;
4
+ export declare const reportAnalytics: () => Promise<{
5
+ errMsg: string;
6
+ }>;
7
+ export declare const reportEvent: () => Promise<{
8
+ errMsg: string;
9
+ }>;
10
+ export declare const getExptInfoSync: () => Promise<{
11
+ errMsg: string;
12
+ }>;
@@ -1,4 +1,4 @@
1
- import { temporarilyNotSupport } from '../utils';
1
+ import { temporarilyNotSupport } from '../../utils';
2
2
  export const reportMonitor = temporarilyNotSupport('reportMonitor');
3
3
  export const reportAnalytics = temporarilyNotSupport('reportAnalytics');
4
4
  export const reportEvent = temporarilyNotSupport('reportEvent');
@@ -0,0 +1,17 @@
1
+ import Taro from '@tarojs/api';
2
+ /**
3
+ * 停止监听加速度数据。
4
+ */
5
+ export declare const stopAccelerometer: typeof Taro.stopAccelerometer;
6
+ /**
7
+ * 开始监听加速度数据。
8
+ */
9
+ export declare const startAccelerometer: typeof Taro.startAccelerometer;
10
+ /**
11
+ * 监听加速度数据事件。频率根据 Taro.startAccelerometer() 的 interval 参数。可使用 Taro.stopAccelerometer() 停止监听。
12
+ */
13
+ export declare const onAccelerometerChange: typeof Taro.onAccelerometerChange;
14
+ /**
15
+ * 取消监听加速度数据事件,参数为空,则取消所有的事件监听
16
+ */
17
+ export declare const offAccelerometerChange: typeof Taro.offAccelerometerChange;
@@ -1,4 +1,5 @@
1
- import { CallbackManager, MethodHandler } from '../utils/handler';
1
+ import { throttle } from '../../utils';
2
+ import { CallbackManager, MethodHandler } from '../../utils/handler';
2
3
  const callbackManager = new CallbackManager();
3
4
  let devicemotionListener;
4
5
  /**
@@ -30,22 +31,6 @@ const INTERVAL_MAP = {
30
31
  frequency: 5
31
32
  }
32
33
  };
33
- const getDevicemotionListener = interval => {
34
- let lock;
35
- let timer;
36
- return evt => {
37
- if (lock)
38
- return;
39
- lock = true;
40
- timer && clearTimeout(timer);
41
- callbackManager.trigger({
42
- x: evt.acceleration.x || 0,
43
- y: evt.acceleration.y || 0,
44
- z: evt.acceleration.z || 0
45
- });
46
- timer = setTimeout(() => { lock = false; }, interval);
47
- };
48
- };
49
34
  /**
50
35
  * 开始监听加速度数据。
51
36
  */
@@ -57,7 +42,14 @@ export const startAccelerometer = ({ interval = 'normal', success, fail, complet
57
42
  if (devicemotionListener) {
58
43
  stopAccelerometer();
59
44
  }
60
- devicemotionListener = getDevicemotionListener(intervalObj.interval);
45
+ devicemotionListener = throttle((evt) => {
46
+ var _a, _b, _c;
47
+ callbackManager.trigger({
48
+ x: ((_a = evt.acceleration) === null || _a === void 0 ? void 0 : _a.x) || 0,
49
+ y: ((_b = evt.acceleration) === null || _b === void 0 ? void 0 : _b.y) || 0,
50
+ z: ((_c = evt.acceleration) === null || _c === void 0 ? void 0 : _c.z) || 0
51
+ });
52
+ }, intervalObj.interval);
61
53
  window.addEventListener('devicemotion', devicemotionListener, true);
62
54
  }
63
55
  else {
@@ -0,0 +1,3 @@
1
+ export declare const checkIsOpenAccessibility: () => Promise<{
2
+ errMsg: string;
3
+ }>;
@@ -1,3 +1,3 @@
1
- import { temporarilyNotSupport } from '../utils';
1
+ import { temporarilyNotSupport } from '../../utils';
2
2
  // 无障碍
3
3
  export const checkIsOpenAccessibility = temporarilyNotSupport('checkIsOpenAccessibility');
@@ -0,0 +1,5 @@
1
+ import Taro from '@tarojs/api';
2
+ export declare const getBatteryInfoSync: () => Promise<{
3
+ errMsg: string;
4
+ }>;
5
+ export declare const getBatteryInfo: typeof Taro.getBatteryInfo;
@@ -1,4 +1,30 @@
1
- import { temporarilyNotSupport } from '../utils';
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { temporarilyNotSupport } from '../../utils';
11
+ import { MethodHandler } from '../../utils/handler';
2
12
  // 电量
3
13
  export const getBatteryInfoSync = temporarilyNotSupport('getBatteryInfoSync');
4
- export const getBatteryInfo = temporarilyNotSupport('getBatteryInfo');
14
+ export const getBatteryInfo = ({ success, fail, complete } = {}) => __awaiter(void 0, void 0, void 0, function* () {
15
+ var _a;
16
+ const handle = new MethodHandler({ name: 'getBatteryInfo', success, fail, complete });
17
+ try {
18
+ // @ts-ignore
19
+ const battery = yield ((_a = navigator.getBattery) === null || _a === void 0 ? void 0 : _a.call(navigator));
20
+ return handle.success({
21
+ isCharging: battery.charging,
22
+ level: Number(battery.level || 0) * 100
23
+ });
24
+ }
25
+ catch (error) {
26
+ return handle.fail({
27
+ errMsg: (error === null || error === void 0 ? void 0 : error.message) || error
28
+ });
29
+ }
30
+ });
@@ -0,0 +1,48 @@
1
+ export declare const writeBLECharacteristicValue: () => Promise<{
2
+ errMsg: string;
3
+ }>;
4
+ export declare const setBLEMTU: () => Promise<{
5
+ errMsg: string;
6
+ }>;
7
+ export declare const readBLECharacteristicValue: () => Promise<{
8
+ errMsg: string;
9
+ }>;
10
+ export declare const onBLEMTUChange: () => Promise<{
11
+ errMsg: string;
12
+ }>;
13
+ export declare const onBLEConnectionStateChange: () => Promise<{
14
+ errMsg: string;
15
+ }>;
16
+ export declare const onBLECharacteristicValueChange: () => Promise<{
17
+ errMsg: string;
18
+ }>;
19
+ export declare const offBLEMTUChange: () => Promise<{
20
+ errMsg: string;
21
+ }>;
22
+ export declare const offBLEConnectionStateChange: () => Promise<{
23
+ errMsg: string;
24
+ }>;
25
+ export declare const offBLECharacteristicValueChange: () => Promise<{
26
+ errMsg: string;
27
+ }>;
28
+ export declare const notifyBLECharacteristicValueChange: () => Promise<{
29
+ errMsg: string;
30
+ }>;
31
+ export declare const getBLEMTU: () => Promise<{
32
+ errMsg: string;
33
+ }>;
34
+ export declare const getBLEDeviceServices: () => Promise<{
35
+ errMsg: string;
36
+ }>;
37
+ export declare const getBLEDeviceRSSI: () => Promise<{
38
+ errMsg: string;
39
+ }>;
40
+ export declare const getBLEDeviceCharacteristics: () => Promise<{
41
+ errMsg: string;
42
+ }>;
43
+ export declare const createBLEConnection: () => Promise<{
44
+ errMsg: string;
45
+ }>;
46
+ export declare const closeBLEConnection: () => Promise<{
47
+ errMsg: string;
48
+ }>;
@@ -1,4 +1,4 @@
1
- import { temporarilyNotSupport } from '../utils';
1
+ import { temporarilyNotSupport } from '../../utils';
2
2
  // 蓝牙-低功耗中心设备
3
3
  export const writeBLECharacteristicValue = temporarilyNotSupport('writeBLECharacteristicValue');
4
4
  export const setBLEMTU = temporarilyNotSupport('setBLEMTU');
@@ -0,0 +1,9 @@
1
+ export declare const onBLEPeripheralConnectionStateChanged: () => Promise<{
2
+ errMsg: string;
3
+ }>;
4
+ export declare const offBLEPeripheralConnectionStateChanged: () => Promise<{
5
+ errMsg: string;
6
+ }>;
7
+ export declare const createBLEPeripheralServer: () => Promise<{
8
+ errMsg: string;
9
+ }>;
@@ -1,4 +1,4 @@
1
- import { temporarilyNotSupport } from '../utils';
1
+ import { temporarilyNotSupport } from '../../utils';
2
2
  // 蓝牙-低功耗外围设备
3
3
  export const onBLEPeripheralConnectionStateChanged = temporarilyNotSupport('onBLEPeripheralConnectionStateChanged');
4
4
  export const offBLEPeripheralConnectionStateChanged = temporarilyNotSupport('offBLEPeripheralConnectionStateChanged');
@@ -0,0 +1,39 @@
1
+ export declare const stopBluetoothDevicesDiscovery: () => Promise<{
2
+ errMsg: string;
3
+ }>;
4
+ export declare const startBluetoothDevicesDiscovery: () => Promise<{
5
+ errMsg: string;
6
+ }>;
7
+ export declare const openBluetoothAdapter: () => Promise<{
8
+ errMsg: string;
9
+ }>;
10
+ export declare const onBluetoothDeviceFound: () => Promise<{
11
+ errMsg: string;
12
+ }>;
13
+ export declare const onBluetoothAdapterStateChange: () => Promise<{
14
+ errMsg: string;
15
+ }>;
16
+ export declare const offBluetoothDeviceFound: () => Promise<{
17
+ errMsg: string;
18
+ }>;
19
+ export declare const offBluetoothAdapterStateChange: () => Promise<{
20
+ errMsg: string;
21
+ }>;
22
+ export declare const makeBluetoothPair: () => Promise<{
23
+ errMsg: string;
24
+ }>;
25
+ export declare const isBluetoothDevicePaired: () => Promise<{
26
+ errMsg: string;
27
+ }>;
28
+ export declare const getConnectedBluetoothDevices: () => Promise<{
29
+ errMsg: string;
30
+ }>;
31
+ export declare const getBluetoothDevices: () => Promise<{
32
+ errMsg: string;
33
+ }>;
34
+ export declare const getBluetoothAdapterState: () => Promise<{
35
+ errMsg: string;
36
+ }>;
37
+ export declare const closeBluetoothAdapter: () => Promise<{
38
+ errMsg: string;
39
+ }>;
@@ -1,4 +1,4 @@
1
- import { temporarilyNotSupport } from '../utils';
1
+ import { temporarilyNotSupport } from '../../utils';
2
2
  // 蓝牙-通用
3
3
  export const stopBluetoothDevicesDiscovery = temporarilyNotSupport('stopBluetoothDevicesDiscovery');
4
4
  export const startBluetoothDevicesDiscovery = temporarilyNotSupport('startBluetoothDevicesDiscovery');
@@ -0,0 +1,6 @@
1
+ export declare const addPhoneRepeatCalendar: () => Promise<{
2
+ errMsg: string;
3
+ }>;
4
+ export declare const addPhoneCalendar: () => Promise<{
5
+ errMsg: string;
6
+ }>;
@@ -1,4 +1,4 @@
1
- import { temporarilyNotSupport } from '../utils';
1
+ import { temporarilyNotSupport } from '../../utils';
2
2
  // 日历
3
3
  export const addPhoneRepeatCalendar = temporarilyNotSupport('addPhoneRepeatCalendar');
4
4
  export const addPhoneCalendar = temporarilyNotSupport('addPhoneCalendar');
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 剪贴板部分的api参考了Chameleon项目的实现:
3
+ *
4
+ * setClipboardData: https://github.com/chameleon-team/chameleon-api/tree/master/src/interfaces/setClipBoardData
5
+ * getClipboardData: https://github.com/chameleon-team/chameleon-api/tree/master/src/interfaces/getClipBoardData
6
+ */
7
+ import Taro from '@tarojs/api';
8
+ /**
9
+ * 设置系统剪贴板的内容
10
+ */
11
+ export declare const setClipboardData: typeof Taro.setClipboardData;
12
+ /**
13
+ * 获取系统剪贴板的内容
14
+ */
15
+ export declare const getClipboardData: typeof Taro.getClipboardData;
@@ -4,8 +4,17 @@
4
4
  * setClipboardData: https://github.com/chameleon-team/chameleon-api/tree/master/src/interfaces/setClipBoardData
5
5
  * getClipboardData: https://github.com/chameleon-team/chameleon-api/tree/master/src/interfaces/getClipBoardData
6
6
  */
7
- import { setStorage, setStorageSync, getStorageSync } from '../storage/index';
8
- import { MethodHandler } from '../utils/handler';
7
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
+ return new (P || (P = Promise))(function (resolve, reject) {
10
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
14
+ });
15
+ };
16
+ import { MethodHandler } from '../../utils/handler';
17
+ import { getStorageSync, setStorage, setStorageSync } from '../storage/index';
9
18
  const CLIPBOARD_STORAGE_NAME = 'taro_clipboard';
10
19
  document.addEventListener('copy', () => {
11
20
  var _a;
@@ -19,7 +28,7 @@ document.addEventListener('copy', () => {
19
28
  /**
20
29
  * 设置系统剪贴板的内容
21
30
  */
22
- export const setClipboardData = async ({ data, success, fail, complete }) => {
31
+ export const setClipboardData = ({ data, success, fail, complete }) => __awaiter(void 0, void 0, void 0, function* () {
23
32
  const handle = new MethodHandler({ name: 'setClipboardData', success, fail, complete });
24
33
  try {
25
34
  setStorageSync(CLIPBOARD_STORAGE_NAME, data);
@@ -49,11 +58,11 @@ export const setClipboardData = async ({ data, success, fail, complete }) => {
49
58
  catch (e) {
50
59
  return handle.fail({ errMsg: e.message });
51
60
  }
52
- };
61
+ });
53
62
  /**
54
63
  * 获取系统剪贴板的内容
55
64
  */
56
- export const getClipboardData = async ({ success, fail, complete } = {}) => {
65
+ export const getClipboardData = ({ success, fail, complete } = {}) => __awaiter(void 0, void 0, void 0, function* () {
57
66
  const handle = new MethodHandler({ name: 'getClipboardData', success, fail, complete });
58
67
  try {
59
68
  const data = getStorageSync(CLIPBOARD_STORAGE_NAME);
@@ -62,4 +71,4 @@ export const getClipboardData = async ({ success, fail, complete } = {}) => {
62
71
  catch (e) {
63
72
  return handle.fail({ errMsg: e.message });
64
73
  }
65
- };
74
+ });
@@ -0,0 +1,17 @@
1
+ import Taro from '@tarojs/api';
2
+ /**
3
+ * 停止监听罗盘数据
4
+ */
5
+ export declare const stopCompass: typeof Taro.stopCompass;
6
+ /**
7
+ * 开始监听罗盘数据
8
+ */
9
+ export declare const startCompass: typeof Taro.startCompass;
10
+ /**
11
+ * 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 wx.stopCompass 停止监听。
12
+ */
13
+ export declare const onCompassChange: typeof Taro.onCompassChange;
14
+ /**
15
+ * 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。
16
+ */
17
+ export declare const offCompassChange: typeof Taro.offCompassChange;
@@ -1,45 +1,59 @@
1
- import { CallbackManager, MethodHandler } from '../utils/handler';
1
+ import { throttle } from '../../utils';
2
+ import { CallbackManager, MethodHandler } from '../../utils/handler';
3
+ import { getDeviceInfo } from '../base/system';
2
4
  const callbackManager = new CallbackManager();
3
5
  let compassListener;
6
+ /**
7
+ * Note: 按系统类型获取对应绝对 orientation 事件名,因为安卓系统中直接监听 deviceorientation 事件得到的不是绝对 orientation
8
+ */
9
+ const deviceorientationEventName = ['absolutedeviceorientation', 'deviceorientationabsolute', 'deviceorientation'].find(item => {
10
+ if ('on' + item in window) {
11
+ return item;
12
+ }
13
+ }) || '';
4
14
  /**
5
15
  * 停止监听罗盘数据
6
16
  */
7
17
  export const stopCompass = ({ success, fail, complete } = {}) => {
8
18
  const handle = new MethodHandler({ name: 'stopCompass', success, fail, complete });
9
19
  try {
10
- window.removeEventListener('deviceorientation', compassListener, true);
20
+ window.removeEventListener(deviceorientationEventName, compassListener, true);
11
21
  return handle.success();
12
22
  }
13
23
  catch (e) {
14
24
  return handle.fail({ errMsg: e.message });
15
25
  }
16
26
  };
17
- const getDeviceOrientationListener = interval => {
18
- let lock;
19
- let timer;
20
- return evt => {
21
- if (lock)
22
- return;
23
- lock = true;
24
- timer && clearTimeout(timer);
25
- callbackManager.trigger({
26
- direction: 360 - evt.alpha
27
- });
28
- timer = setTimeout(() => { lock = false; }, interval);
29
- };
30
- };
27
+ let CompassChangeTrigger = false;
31
28
  /**
32
29
  * 开始监听罗盘数据
33
30
  */
34
31
  export const startCompass = ({ success, fail, complete } = {}) => {
35
32
  const handle = new MethodHandler({ name: 'startCompass', success, fail, complete });
36
33
  try {
37
- if (window.DeviceOrientationEvent) {
34
+ if (deviceorientationEventName !== '') {
38
35
  if (compassListener) {
39
36
  stopCompass();
40
37
  }
41
- compassListener = getDeviceOrientationListener(200);
42
- window.addEventListener('deviceorientation', compassListener, true);
38
+ compassListener = throttle((evt) => {
39
+ const isAndroid = getDeviceInfo().system === 'AndroidOS';
40
+ if (isAndroid && !evt.absolute && !CompassChangeTrigger) {
41
+ CompassChangeTrigger = true;
42
+ console.warn('Warning: In \'onCompassChange\', your browser is not supported to get the orientation relative to the earth, the orientation data will be related to the initial orientation of the device .');
43
+ }
44
+ const alpha = evt.alpha || 0;
45
+ /**
46
+ * 由于平台差异,accuracy 在 iOS/Android 的值不同。
47
+ * - iOS:accuracy 是一个 number 类型的值,表示相对于磁北极的偏差。0 表示设备指向磁北,90 表示指向东,180 表示指向南,依此类推。
48
+ * - Android:accuracy 是一个 string 类型的枚举值。
49
+ */
50
+ const accuracy = isAndroid ? evt.absolute ? 'high' : 'medium' : alpha;
51
+ callbackManager.trigger({
52
+ direction: 360 - alpha,
53
+ accuracy: accuracy
54
+ });
55
+ }, 5000);
56
+ window.addEventListener(deviceorientationEventName, compassListener, true);
43
57
  }
44
58
  else {
45
59
  throw new Error('compass is not supported');
@@ -0,0 +1,6 @@
1
+ export declare const chooseContact: () => Promise<{
2
+ errMsg: string;
3
+ }>;
4
+ export declare const addPhoneContact: () => Promise<{
5
+ errMsg: string;
6
+ }>;
@@ -1,4 +1,4 @@
1
- import { temporarilyNotSupport } from '../utils';
1
+ import { temporarilyNotSupport } from '../../utils';
2
2
  // 联系人
3
3
  export const chooseContact = temporarilyNotSupport('chooseContact');
4
4
  export const addPhoneContact = temporarilyNotSupport('addPhoneContact');
@@ -0,0 +1,3 @@
1
+ export declare const getRandomValues: () => Promise<{
2
+ errMsg: string;
3
+ }>;